- Timestamp:
- Sep 4, 2018, 1:59:07 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LMDZ6/trunk/libf/phylmd/carbon_cycle_mod.F90
r3384 r3385 1 1 MODULE carbon_cycle_mod 2 3 !=======================================================================4 !5 ! Authors: Patricia Cadule and Laurent Fairhead6 ! base sur un travail anterieur mene par Patricia Cadule et Josefine7 ! Ghattas8 ! -------9 !10 ! Purpose and description:11 ! -----------------------12 2 ! Controle module for the carbon CO2 tracers : 13 3 ! - Identification … … 16 6 ! - Calculate new carbon flux for sending to coupled models (PISCES and ORCHIDEE) 17 7 ! 18 ! Module permettant de mettre a jour les champs (puits et sources) pour le transport de CO2 en 19 ! online (IPSL-CM et LMDZOR) et offline (lecture de carte) 20 ! 21 ! Le cas online/offline est defini par le flag carbon_cycle_cpl (y/n) 22 ! Le transport du traceur CO2 est defini par le flag carbon_cycle_tr (y/n) 23 ! la provenance des champs (termes de puits) est denini par le flag level_coupling_esm 24 25 ! level_coupling_esm : level of coupling of the biogeochemical fields between 26 ! LMDZ, ORCHIDEE and NEMO 27 ! Definitions of level_coupling_esm in physiq.def 28 ! level_coupling_esm = 0 ! No field exchange between LMDZ and ORCHIDEE models 29 ! ! No field exchange between LMDZ and NEMO 30 ! level_coupling_esm = 1 ! Field exchange between LMDZ and ORCHIDEE models 31 ! ! No field exchange between LMDZ and NEMO models 32 ! level_coupling_esm = 2 ! No field exchange between LMDZ and ORCHIDEE models 33 ! ! Field exchange between LMDZ and NEMO models 34 ! level_coupling_esm = 3 ! Field exchange between LMDZ and ORCHIDEE models 35 ! ! Field exchange between LMDZ and NEMO models 36 ! 37 ! si carbon_cycle_cpl=y alors les termes de puits et sources sont mis a jour 38 ! en focntion de la valeur de level_coupling_esm 39 ! dans tous les cas (si carbon_cycle_cpl=y) les valeurs des emissions anthropiques de CO2 (fossil 40 ! fuel+cement) sont lues, 41 ! - soit via des cartes 2D mensuelles (fichiers netcdf contenant 12 valeurs par 42 ! annee): fCO2_fco2fos 43 ! - soit via des fichier txt contenant une valeur globale mensuelle/annuelle: fCO2_fco2fos_1D 44 ! 45 ! Ce module permet de transport des champs de carbone dans LMDz 46 47 ! Declaration des differents champs 48 ! LAND: fCO2_nep, fCO2_fLuc, fCO2_fFire, 49 ! OCEAN: fCO2_fgco2 50 ! FOS:fCO2_fco2fos 8 ! Author : Josefine GHATTAS, Patricia CADULE 51 9 52 10 IMPLICIT NONE … … 60 18 LOGICAL, PUBLIC :: carbon_cycle_cpl ! Coupling of CO2 fluxes between LMDZ/ORCHIDEE and LMDZ/OCEAN(PISCES) 61 19 !$OMP THREADPRIVATE(carbon_cycle_cpl) 62 INTEGER, SAVE, PUBLIC :: level_coupling_esm 20 INTEGER, SAVE, PUBLIC :: level_coupling_esm ! Level of coupling for the ESM - 0, 1, 2, 3 63 21 !$OMP THREADPRIVATE(level_coupling_esm) 64 22 … … 71 29 !$OMP THREADPRIVATE(RCO2_inter) 72 30 73 ! Scalar values when no transport, from physiq.def 74 REAL :: fCO2_fco2fos_1D_omp 75 !$OMP THREADPRIVATE(fCO2_fco2fos_1D_omp) 76 REAL :: fCO2_fco2fos_1D ! carbon_cycle_fco2fos dans physiq.def 77 !$OMP THREADPRIVATE(fCO2_fco2fos_1D) 31 ! Scalare values when no transport, from physiq.def 32 REAL :: fos_fuel_s_omp 33 REAL :: fos_fuel_s ! carbon_cycle_fos_fuel dans physiq.def 34 !$OMP THREADPRIVATE(fos_fuel_s) 78 35 REAL :: emis_land_s ! not yet implemented 79 36 !$OMP THREADPRIVATE(emis_land_s) … … 82 39 !$OMP THREADPRIVATE(airetot) 83 40 84 INTEGER :: ntr_co2 ! Number of fields concerning the carbon cycle41 INTEGER :: ntr_co2 ! Number of tracers concerning the carbon cycle 85 42 !$OMP THREADPRIVATE(ntr_co2) 86 43 87 ! fCO2_fgco2 : carbon flux from ocean cumulated between 2 ATM-OCN coupling timestep [gC/m2/Dt]. 88 ! fCO2_fgco2 : flux de carbone venant de l ocean. Ce flux est cumule entre 89 ! deux pas de temps du couplage ATM-OCN [gC/m2/Dt]. 90 ! Allocation and initalization done in cpl_mod 91 92 ! OCEAN 93 ! fkux echange a la frequence de couplage entre NEMO et LMDZ 94 REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fCO2_fgco2 95 !$OMP THREADPRIVATE(fCO2_fgco2) 96 97 ! LAND 98 REAL, DIMENSION(:), ALLOCATABLE :: fCO2_nbp ! carbon flux from land at each time step [kgC/m2/s] 99 !$OMP THREADPRIVATE(fCO2_nbp) 100 REAL, DIMENSION(:), ALLOCATABLE :: fCO2_nep ! carbon flux from land at each time step [kgC/m2/s] 101 !$OMP THREADPRIVATE(fCO2_nep) 102 REAL, DIMENSION(:), ALLOCATABLE :: fCO2_fLuc ! Emission from land use change [gC/m2/s] 103 !$OMP THREADPRIVATE(fCO2_fLuc) 104 REAL, DIMENSION(:), ALLOCATABLE :: fCO2_fFire 105 !$OMP THREADPRIVATE(fCO2_fFire) 106 107 ! SOURCES: FOSSIL FUEL emissions 108 REAL, DIMENSION(:), ALLOCATABLE :: fCO2_fco2fos 109 !$OMP THREADPRIVATE(fCO2_fco2fos) 44 ! fco2_ocn_day : flux CO2 from ocean for 1 day (cumulated) [gC/m2/d]. Allocation and initalization done in cpl_mod 45 REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_ocn_day 46 !$OMP THREADPRIVATE(fco2_ocn_day) 47 48 REAL, DIMENSION(:), ALLOCATABLE :: fco2_land_day ! flux CO2 from land for 1 day (cumulated) [gC/m2/d] 49 !$OMP THREADPRIVATE(fco2_land_day) 50 REAL, DIMENSION(:), ALLOCATABLE :: fco2_lu_day ! Emission from land use change for 1 day (cumulated) [gC/m2/d] 51 !$OMP THREADPRIVATE(fco2_lu_day) 110 52 111 53 REAL, DIMENSION(:,:), ALLOCATABLE :: dtr_add ! Tracer concentration to be injected 112 54 !$OMP THREADPRIVATE(dtr_add) 113 REAL, DIMENSION(:), ALLOCATABLE :: dtr_add_sum ! Tracer concentration to be injected 114 !$OMP THREADPRIVATE(dtr_add_sum) 115 116 ! Following 4 fields will be allocated and initialized in surf_land_orchidee 117 REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fCO2_nbp_inst ! flux CO2 from land at one time step 118 !$OMP THREADPRIVATE(fCO2_nbp_inst) 119 REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fCO2_nep_inst ! flux CO2 from land at one time step 120 !$OMP THREADPRIVATE(fCO2_nep_inst) 121 REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fCO2_fLuc_inst ! Emission from land use change at one time step 122 !$OMP THREADPRIVATE(fCO2_fLuc_inst) 123 REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fCO2_fFire_inst ! flux CO2 from land at one time step 124 !$OMP THREADPRIVATE(fCO2_fFire_inst) 125 126 ! Calculated co2 field to be send to the ocean model (NEMO) via the coupler and to the land surface model (ORCHIDEE) 55 56 ! Following 2 fields will be allocated and initialized in surf_land_orchidee 57 REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_land_inst ! flux CO2 from land at one time step 58 !$OMP THREADPRIVATE(fco2_land_inst) 59 REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_lu_inst ! Emission from land use change at one time step 60 !$OMP THREADPRIVATE(fco2_lu_inst) 61 62 ! Calculated co2 field to be send to the ocean via the coupler and to ORCHIDEE 127 63 REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: co2_send ! Field allocated in phyetat0 128 64 !$OMP THREADPRIVATE(co2_send) 129 65 130 66 131 TYPE, PUBLIC :: co2_ fields_type132 CHARACTER(len = 20) :: name ! Fields67 TYPE, PUBLIC :: co2_trac_type 68 CHARACTER(len = 8) :: name ! Tracer name in tracer.def 133 69 INTEGER :: id ! Index in total tracer list, tr_seri 134 70 CHARACTER(len=30) :: file ! File name … … 138 74 INTEGER :: readstep ! Actual time step to read in file 139 75 LOGICAL :: updatenow ! True if this tracer should be updated this time step 140 END TYPE co2_fields_type141 INTEGER,PARAMETER :: maxco2fields=5 ! Maximum number of different CO2 fluxes142 TYPE(co2_fields_type), DIMENSION(maxco2fields) :: co2fields143 !$OMP THREADPRIVATE(co2fields)144 145 146 TYPE, PUBLIC :: co2_trac_type147 CHARACTER(len = 8) :: name ! Tracer name in tracer.def148 INTEGER :: id ! Index in total tracer list, tr_seri149 CHARACTER(len=30) :: file ! File name150 LOGICAL :: cpl ! True if this tracers is coupled from ORCHIDEE or PISCES.151 ! False if read from file.152 INTEGER :: updatefreq ! Frequence to inject in second153 INTEGER :: readstep ! Actual time step to read in file154 LOGICAL :: updatenow ! True if this tracer should be updated this time step155 76 END TYPE co2_trac_type 156 77 INTEGER,PARAMETER :: maxco2trac=5 ! Maximum number of different CO2 fluxes 157 78 TYPE(co2_trac_type), DIMENSION(maxco2trac) :: co2trac 158 159 160 79 161 80 CONTAINS … … 176 95 USE phys_cal_mod, ONLY : mth_len 177 96 USE print_control_mod, ONLY: lunout 178 USE infocfields_mod179 97 180 98 IMPLICIT NONE … … 200 118 IF (.NOT. carbon_cycle_tr) THEN 201 119 !$OMP MASTER 202 f CO2_fco2fos_1D_omp = 0.203 CALL getin ('carbon_cycle_f co2fos_1D',fCO2_fco2fos_1D_omp)120 fos_fuel_s_omp = 0. 121 CALL getin ('carbon_cycle_fos_fuel',fos_fuel_s_omp) 204 122 !$OMP END MASTER 205 123 !$OMP BARRIER 206 fCO2_fco2fos_1D=fCO2_fco2fos_1D_omp 207 CALL bcast(fCO2_fco2fos_1D) 208 WRITE(lunout,*) 'carbon_cycle_fco2fos_1D = ', fCO2_fco2fos_1D 124 fos_fuel_s=fos_fuel_s_omp 125 WRITE(lunout,*) 'carbon_cycle_fos_fuel = ', fos_fuel_s 209 126 END IF 210 127 … … 238 155 239 156 240 ! 2) Search for carbon fields and set default values157 ! 2) Search for carbon tracers and set default values 241 158 ! --------------------------------------------------- 242 159 itc=0 243 DO it=1,nbcf_in ! bien remplir le fichier pour avoir un champ fos et un champs ocean 244 245 !fCO2_nbp, fCO2_nep, fCO2_fLuc, fCO2_fFire, fCO2_fco2fos, fCO2_fgco2 246 247 SELECT CASE(cfname_in(it)) 248 !SELECT CASE(co2fields(it)%name) 249 CASE("fCO2_fgco2") 250 itc = itc + 1 251 co2fields(it)%name=TRIM(cfname_in(it)) 252 co2fields(it)%id=it 253 co2fields(it)%file='flx_fgco2_ocean.nc' 254 IF (carbon_cycle_cpl .AND. (type_ocean=='couple') .AND. (level_coupling_esm.GE.2)) THEN 255 WRITE(lunout,*) 'carbon_cycle_mod (ESM) --- fCO2_fgco2' 256 co2fields(it)%cpl=.TRUE. 257 ! >> PC 258 ! on va injecter a tous les pas de temps de couplage (2700x2) 259 ! recuperer proprement la frequence de couplage 260 ! << PC 261 !!!! METTRE la vraie frequence de couplage !!! PAS en dur 262 co2fields(it)%updatefreq = 5400 ! OASIS/NEMO-PISCES 263 ! << PC 264 ELSE IF (carbon_cycle_cpl .AND. (level_coupling_esm.LE.2)) THEN 265 co2fields(it)%cpl=.FALSE. 266 co2fields(it)%updatefreq = 86400*mth_len ! Once a month 267 END IF 268 CASE("fCO2_nbp") 269 itc = itc + 1 270 co2fields(it)%name=TRIM(cfname_in(it)) 271 co2fields(it)%id=it 272 co2fields(it)%file='flx_nbp_land.nc' 273 IF (carbon_cycle_cpl .AND. ((level_coupling_esm.EQ.1) .OR. level_coupling_esm.EQ.3)) THEN 274 WRITE(lunout,*) 'carbon_cycle_mod (ESM) --- fCO2_nbp' 275 co2fields(it)%cpl=.TRUE. 276 co2fields(it)%updatefreq = INT(pdtphys) ! Each timestep as the coupling with ORCHIDEE 277 ELSE IF (carbon_cycle_cpl .AND. ((level_coupling_esm.EQ.0) .OR. level_coupling_esm.EQ.2)) THEN 278 co2fields(it)%cpl=.FALSE. 279 ! co2fields(itc)%updatefreq = 10800 ! 10800sec = 3H 280 co2fields(it)%updatefreq = 86400*mth_len ! Once a month 281 END IF 282 !!!! Si le test est ok pour nbp dupliquer sur les autres champs LAND 283 CASE("fCO2_nep") 284 itc = itc + 1 285 co2fields(it)%name=TRIM(cfname_in(it)) 286 co2fields(it)%id=it 287 co2fields(it)%file='flx_nep_land.nc' 160 DO it=1,nbtr 161 !! iiq=niadv(it+2) ! jyg 162 iiq=niadv(it+nqo) ! jyg 163 164 SELECT CASE(tname(iiq)) 165 CASE("fCO2_ocn") 166 itc = itc + 1 167 co2trac(itc)%name='fCO2_ocn' 168 co2trac(itc)%id=it 169 co2trac(itc)%file='fl_co2_ocean.nc' 170 IF (carbon_cycle_cpl .AND. type_ocean=='couple') THEN 171 co2trac(itc)%cpl=.TRUE. 172 co2trac(itc)%updatefreq = 86400 ! Once a day as the coupling with OASIS/PISCES 173 ELSE 174 co2trac(itc)%cpl=.FALSE. 175 co2trac(itc)%updatefreq = 86400*mth_len ! Once a month 176 END IF 177 CASE("fCO2_land") 178 itc = itc + 1 179 co2trac(itc)%name='fCO2_land' 180 co2trac(itc)%id=it 181 co2trac(itc)%file='fl_co2_land.nc' 288 182 IF (carbon_cycle_cpl .AND. ok_veget) THEN 289 WRITE(lunout,*) 'carbon_cycle_mod (ESM) --- fCO2_nep' 290 co2fields(it)%cpl=.TRUE. 291 co2fields(it)%updatefreq = INT(pdtphys) ! Each timestep as the coupling with ORCHIDEE 292 ELSE 293 co2fields(it)%cpl=.FALSE. 294 ! co2fields(itc)%updatefreq = 10800 ! 10800sec = 3H 295 co2fields(it)%updatefreq = 86400*mth_len ! Once a month 296 END IF 297 CASE("fCO2_fLuc") 298 itc = itc + 1 299 co2fields(it)%name=TRIM(cfname_in(it)) 300 co2fields(it)%id=it 301 co2fields(it)%file='flx_fLuc_land.nc' 183 co2trac(itc)%cpl=.TRUE. 184 co2trac(itc)%updatefreq = INT(pdtphys) ! Each timestep as the coupling with ORCHIDEE 185 ELSE 186 co2trac(itc)%cpl=.FALSE. 187 ! co2trac(itc)%updatefreq = 10800 ! 10800sec = 3H 188 co2trac(itc)%updatefreq = 86400*mth_len ! Once a month 189 END IF 190 CASE("fCO2_land_use") 191 itc = itc + 1 192 co2trac(itc)%name='fCO2_land_use' 193 co2trac(itc)%id=it 194 co2trac(itc)%file='fl_co2_land_use.nc' 302 195 IF (carbon_cycle_cpl .AND. ok_veget) THEN 303 WRITE(lunout,*) 'carbon_cycle_mod (ESM) --- fCO2_nbp' 304 co2fields(it)%cpl=.TRUE. 305 co2fields(it)%updatefreq = INT(pdtphys) ! Each timestep as the coupling with ORCHIDEE 306 ELSE 307 co2fields(it)%cpl=.FALSE. 308 co2fields(it)%updatefreq = 10800 ! 10800sec = 3H 309 END IF 310 CASE("fCO2_fco2fos") 311 itc = itc + 1 312 !co2fields(it)%name='fCO2_fco2fos' 313 co2fields(it)%name=TRIM(cfname_in(it)) 314 co2fields(it)%id=it 315 co2fields(it)%file='fco2fos.nc' 316 ! >> PC 317 IF ( carbon_cycle_cpl .AND. carbon_cycle_tr) THEN 318 WRITE(lunout,*) 'carbon_cycle_mod (ESM) --- fCO2_fco2fos' 319 co2fields(it)%cpl=.TRUE. 320 co2fields(it)%updatefreq = 86400*mth_len ! Once a month 321 ELSE IF ( carbon_cycle_cpl .AND. (.NOT. carbon_cycle_tr)) THEN 322 co2fields(it)%cpl=.TRUE. 323 co2fields(it)%updatefreq = 86400*mth_len ! Once a month 324 WRITE(*,*) "lecture du champs scalaire" 325 END IF 326 ! << PC 327 CASE("fCO2_fFire") 328 itc = itc + 1 329 co2fields(it)%name=TRIM(cfname_in(it)) 330 co2fields(it)%id=it 331 co2fields(it)%file='flx_fFire_land.nc' 332 co2fields(it)%cpl=.FALSE. ! This tracer always read from file 333 co2fields(it)%updatefreq = 86400*mth_len ! Once a month 196 co2trac(it)%cpl=.TRUE. 197 co2trac(itc)%updatefreq = INT(pdtphys) ! Each timestep as the coupling with ORCHIDEE 198 ELSE 199 co2trac(itc)%cpl=.FALSE. 200 co2trac(itc)%updatefreq = 10800 ! 10800sec = 3H 201 END IF 202 CASE("fCO2_fos_fuel") 203 itc = itc + 1 204 co2trac(itc)%name='fCO2_fos_fuel' 205 co2trac(itc)%id=it 206 co2trac(itc)%file='fossil_fuel.nc' 207 co2trac(itc)%cpl=.FALSE. ! This tracer always read from file 208 ! co2trac(itc)%updatefreq = 86400 ! 86400sec = 24H Cadule case 209 co2trac(itc)%updatefreq = 86400*mth_len ! Once a month 210 CASE("fCO2_bbg") 211 itc = itc + 1 212 co2trac(itc)%name='fCO2_bbg' 213 co2trac(itc)%id=it 214 co2trac(itc)%file='fl_co2_bbg.nc' 215 co2trac(itc)%cpl=.FALSE. ! This tracer always read from file 216 co2trac(itc)%updatefreq = 86400*mth_len ! Once a month 334 217 CASE("fCO2") 335 218 ! fCO2 : One tracer transporting the total CO2 flux 336 219 itc = itc + 1 337 co2 fields(it)%name='fCO2'338 co2 fields(it)%id=it339 co2 fields(it)%file='flx_fCO2.nc'220 co2trac(itc)%name='fCO2' 221 co2trac(itc)%id=it 222 co2trac(itc)%file='fl_co2.nc' 340 223 IF (carbon_cycle_cpl) THEN 341 WRITE(lunout,*) 'carbon_cycle_mod (ESM) --- fCO2' 342 co2fields(it)%cpl=.TRUE. 343 ELSE 344 co2fields(it)%cpl=.FALSE. 345 END IF 346 co2fields(it)%updatefreq = 86400*mth_len 224 co2trac(itc)%cpl=.TRUE. 225 ELSE 226 co2trac(itc)%cpl=.FALSE. 227 END IF 228 co2trac(itc)%updatefreq = 86400 347 229 ! DOES THIS WORK ???? Problematic due to implementation of the coupled fluxes... 348 230 CALL abort_physic('carbon_cycle_init','transport of total CO2 has to be implemented and tested',1) … … 350 232 END DO 351 233 352 ! CO2 tracer 353 354 IF ( carbon_cycle_cpl .AND. carbon_cycle_tr) THEN 355 itc=0 356 357 DO it=1,nbtr 358 iiq=niadv(it+nqo) 359 360 SELECT CASE(tname(iiq)) 361 CASE("fCO2") 362 itc = itc + 1 363 co2fields(it)%name='fCO2' 364 IF (carbon_cycle_cpl .AND. type_ocean=='couple') THEN 365 co2fields(it)%cpl=.TRUE. 366 END IF 367 END SELECT 368 END DO 369 END IF 370 371 !!!!! BIEN FAIRE LA DIFFERENCE ENTRE tracer.def et coupling_fields.def 372 ! cela conditionne la valeur de ntr_co2 373 ! ntr_co2 = itc 374 375 ntr_co2=0 376 IF (carbon_cycle_tr .AND. (nbcf .GT. 0)) ntr_co2=1 377 234 ! Total number of carbon CO2 tracers 235 ntr_co2 = itc 236 378 237 ! Definition of control varaiables for the tracers 379 238 DO it=1,ntr_co2 … … 390 249 ! --------------------- 391 250 ! Allocate vector for storing fluxes to inject 392 !fCO2_nbp, fCO2_nep, fCO2_fLuc, fCO2_fFire, fCO2_fco2fos, fCO2_fgco2 393 ALLOCATE(dtr_add(klon,maxco2fields), stat=ierr) 251 ALLOCATE(dtr_add(klon,maxco2trac), stat=ierr) 394 252 IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation 11',1) 395 396 ALLOCATE(dtr_add_sum(klon), stat=ierr) 397 IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation 12',1) 398 399 253 400 254 ! Allocate variables for cumulating fluxes from ORCHIDEE 401 ! IF (RCO2_inter) THEN 402 !IF ((.NOT. carbon_cycle_tr) .AND. carbon_cycle_cpl) THEN 403 IF (carbon_cycle_tr .OR. carbon_cycle_cpl) THEN 404 405 ALLOCATE(fCO2_nbp(klon), stat=ierr) 255 IF (RCO2_inter) THEN 256 IF (.NOT. carbon_cycle_tr .AND. carbon_cycle_cpl) THEN 257 ALLOCATE(fco2_land_day(klon), stat=ierr) 406 258 IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation 2',1) 407 fCO2_nbp(1:klon) = 0. 408 409 ALLOCATE(fCO2_nep(klon), stat=ierr) 410 IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation 2',1) 411 fCO2_nep(1:klon) = 0. 259 fco2_land_day(1:klon) = 0. 412 260 413 ALLOCATE(f CO2_fLuc(klon), stat=ierr)261 ALLOCATE(fco2_lu_day(klon), stat=ierr) 414 262 IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation 3',1) 415 fCO2_fLuc(1:klon) = 0. 416 417 ALLOCATE(fCO2_fFire(klon), stat=ierr) 418 IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation 2',1) 419 fCO2_fFire(1:klon) = 0. 420 421 END IF 422 ! END IF 263 fco2_lu_day(1:klon) = 0. 264 END IF 265 END IF 423 266 424 267 … … 441 284 END DO 442 285 443 444 IF (ntr_co2==0 .AND. carbon_cycle_tr) THEN 286 IF (ntr_co2==0) THEN 445 287 ! No carbon tracers found in tracer.def. It is not possible to do carbon cycle 446 ! >> PC 447 WRITE(lunout,*) 'No carbon tracers found in tracer.def. Not ok with carbon_cycle_tr and/or carbon_cycle_cpl' 448 ! << PC 288 WRITE(lunout,*) 'No carbon tracers found in tracer.def. Not ok with carbon_cycle_tr and/or carbon_cycle_cp' 449 289 CALL abort_physic('carbon_cycle_init', 'No carbon tracers found in tracer.def',1) 450 290 END IF … … 474 314 USE print_control_mod, ONLY: lunout 475 315 USE geometry_mod, ONLY : cell_area 476 USE infocfields_mod477 478 ! >> PC479 ! ne pas le mettre en argument de la subrourine480 ! USE time_phylmdz_mod, ONLY: pdtphys481 ! << PC482 316 483 317 IMPLICIT NONE … … 494 328 495 329 ! Local variables 496 INTEGER :: it,itc 497 ! >> PC 498 LOGICAL :: newyear ! indicates if a new month just started 499 ! << PC 330 INTEGER :: it 500 331 LOGICAL :: newmonth ! indicates if a new month just started 501 332 LOGICAL :: newday ! indicates if a new day just started 502 333 LOGICAL :: endday ! indicated if last time step in a day 503 334 504 ! >> PC 505 REAL, PARAMETER :: fact=1.0e06 * 28.97/44.011 ! transformation factor kg CO2/kg air => ppm 506 ! << PC 335 REAL, PARAMETER :: fact=1.E-15/2.12 ! transformation factor from gC/m2/day => ppm/m2/day 507 336 REAL, DIMENSION(klon) :: fco2_tmp 508 337 REAL :: sumtmp … … 513 342 ! ------------------------------------------------------------------------------------------------------- 514 343 515 ! >> PC 516 ! Mise a jour mensuelle des emissions fossiles 517 !newday = .FALSE.; endday = .FALSE.; newmonth = .FALSE. 518 newday = .FALSE.; endday = .FALSE.; newmonth = .FALSE. ; newyear = .FALSE. 344 newday = .FALSE.; endday = .FALSE.; newmonth = .FALSE. 519 345 520 346 IF (MOD(nstep,INT(86400./pdtphys))==1) newday=.TRUE. 521 347 IF (MOD(nstep,INT(86400./pdtphys))==0) endday=.TRUE. 522 348 IF (newday .AND. day_cur==1) newmonth=.TRUE. 523 ! mettre la duree de l annee au propre len_year ???524 IF (newday .AND. (MOD(nstep,INT(86400.*365/pdtphys))==1)) newyear=.TRUE.525 ! << PC526 349 527 350 ! 2) For each carbon tracer find out if it is time to inject (update) 528 351 ! -------------------------------------------------------------------- 529 !DO it = 1, nbcf_in+2 530 DO it = 1, nbcf_in 531 WRITE(lunout,*) 'nstep ',nstep 532 WRITE(lunout,*) 'co2fields(it)%updatefreq ',co2fields(it)%name,' ', co2fields(it)%updatefreq 533 WRITE(lunout,*) 'co2fields(it)%name ',co2fields(it)%name 534 WRITE(lunout,*) 'INT(pdtphys) ',INT(pdtphys) 535 WRITE(lunout,*) '(INT(co2fields(it)%updatefreq)/INT(pdtphys))', (INT(co2fields(it)%updatefreq)/INT(pdtphys)) 536 WRITE(lunout,*) 'MOD(nstep,(INT(co2fields(it)%updatefreq)/INT(pdtphys))) ',MOD(nstep,(INT(co2fields(it)%updatefreq)/INT(pdtphys))) 537 IF ( MOD(nstep,(INT(co2fields(it)%updatefreq)/INT(pdtphys))) == 0 ) THEN 538 co2fields(it)%updatenow = .TRUE. 352 DO it = 1, ntr_co2 353 IF ( MOD(nstep,INT(co2trac(it)%updatefreq/pdtphys)) == 1 ) THEN 354 co2trac(it)%updatenow = .TRUE. 539 355 ELSE 540 co2fields(it)%updatenow = .FALSE. 541 END IF 542 WRITE(lunout,*) 'co2fields(it)%updatenow ',co2fields(it)%updatenow 356 co2trac(it)%updatenow = .FALSE. 357 END IF 543 358 END DO 544 359 545 360 ! 3) Get tracer update 546 361 ! -------------------------------------- 547 ! >> PC 548 IF (newyear) THEN 549 co2fields(:)%readstep = 0 550 END IF 551 ! << PC 552 553 DO it = 1, nbcf_in 554 IF ( co2fields(it)%updatenow ) THEN 555 IF ( co2fields(it)%cpl ) THEN 362 DO it = 1, ntr_co2 363 IF ( co2trac(it)%updatenow ) THEN 364 IF ( co2trac(it)%cpl ) THEN 556 365 ! Get tracer from coupled model 557 SELECT CASE(TRIM(co2fields(it)%name)) 558 CASE('fCO2_nbp') ! from ORCHIDEE 559 dtr_add(:,it) = fCO2_nbp_inst(:)*pctsrf(:,is_ter)*((co2fields(it)%updatefreq)/INT(pdtphys))*fact ! [ppm/m2/s] 560 CASE('fCO2_nep') ! from ORCHIDEE 561 dtr_add(:,it) = fCO2_nep_inst(:)*pctsrf(:,is_ter)*((co2fields(it)%updatefreq)/INT(pdtphys))*fact ! [ppm/m2/s] 562 CASE('fCO2_fLuc') ! from ORCHIDEE 563 dtr_add(:,it) = fCO2_fLuc_inst(:) *pctsrf(:,is_ter)*((co2fields(it)%updatefreq)/INT(pdtphys))*fact ! [ppm/m2/s] 564 CASE('fCO2_fFire') ! from ORCHIDEE 565 dtr_add(:,it) = fCO2_fFire_inst(:)*pctsrf(:,is_ter)*((co2fields(it)%updatefreq)/INT(pdtphys))*fact ! [ppm/m2/s] 566 CASE('fCO2_fgco2') ! from PISCES 567 dtr_add(:,it) = fCO2_fgco2(:) *pctsrf(:,is_oce)*((co2fields(it)%updatefreq)/INT(pdtphys))*fact ! [ppm/m2/s] 568 ! >> PC 569 CASE("fCO2_fco2fos") 570 WRITE(lunout,*) 'carbon cycle --- fossil fuel emissions' 571 IF (newmonth) THEN 572 co2fields(it)%readstep = co2fields(it)%readstep + 1 573 ! ne pas faire la lecture du fichier a chaque pas de temps 574 CALL read_map2D(co2fields(it)%file,'CO2_em_anthro',co2fields(it)%readstep,.TRUE.,source(1:klon,co2fields(it)%id)) 575 dtr_add(:,it) = source(1:klon,co2fields(it)%id)*pctsrf(:,is_ter)*(co2fields(it)%updatefreq/INT(pdtphys))*fact ! [ppm/m2/s] 576 END IF 577 ! << PC 366 SELECT CASE(co2trac(it)%name) 367 CASE('fCO2_land') ! from ORCHIDEE 368 dtr_add(:,it) = fco2_land_inst(:)*pctsrf(:,is_ter)*fact ! [ppm/m2/day] 369 CASE('fCO2_land_use') ! from ORCHIDEE 370 dtr_add(:,it) = fco2_lu_inst(:) *pctsrf(:,is_ter)*fact ! [ppm/m2/day] 371 CASE('fCO2_ocn') ! from PISCES 372 dtr_add(:,it) = fco2_ocn_day(:) *pctsrf(:,is_oce)*fact ! [ppm/m2/day] 578 373 CASE DEFAULT 579 WRITE(lunout,*) 'Error with field ',co2fields(it)%name374 WRITE(lunout,*) 'Error with tracer ',co2trac(it)%name 580 375 CALL abort_physic('carbon_cycle', 'No coupling implemented for this tracer',1) 581 376 END SELECT 582 377 ELSE 583 378 ! Read tracer from file 584 co2fields(it)%readstep = co2fields(it)%readstep + 1 ! increment time step in file 585 ! Patricia CALL read_map2D(co2fields(it)%file,'fco2',co2fields(it)%readstep,.FALSE.,dtr_add(:,it)) 586 CALL read_map2D(co2fields(it)%file,'fco2',co2fields(it)%readstep,.TRUE.,dtr_add(:,it)) 587 588 ! >> PC 589 !! Converte from kgC/m2/h to kgC/m2/s 590 !dtr_add(:,it) = dtr_add(:,it)/3600 591 ! << PC 379 co2trac(it)%readstep = co2trac(it)%readstep + 1 ! increment time step in file 380 ! Patricia CALL read_map2D(co2trac(it)%file,'fco2',co2trac(it)%readstep,.FALSE.,dtr_add(:,it)) 381 CALL read_map2D(co2trac(it)%file,'fco2',co2trac(it)%readstep,.TRUE.,dtr_add(:,it)) 382 383 ! Converte from kgC/m2/h to kgC/m2/s 384 dtr_add(:,it) = dtr_add(:,it)/3600 592 385 ! Add individual treatment of values read from file 593 SELECT CASE(co2 fields(it)%name)594 CASE('fCO2_ nbp')386 SELECT CASE(co2trac(it)%name) 387 CASE('fCO2_land') 595 388 dtr_add(:,it) = dtr_add(:,it) *pctsrf(:,is_ter) 596 CASE('fCO2_ nep')389 CASE('fCO2_land_use') 597 390 dtr_add(:,it) = dtr_add(:,it) *pctsrf(:,is_ter) 598 CASE('fCO2_fLuc') 599 dtr_add(:,it) = dtr_add(:,it) *pctsrf(:,is_ter) 600 CASE('fCO2_fFire') 601 dtr_add(:,it) = dtr_add(:,it) *pctsrf(:,is_ter) 602 CASE('fCO2_fgco2') 391 CASE('fCO2_ocn') 603 392 dtr_add(:,it) = dtr_add(:,it) *pctsrf(:,is_oce) 604 CASE('fCO2_fco2fos')605 dtr_add(:,it) = dtr_add(:,it) *pctsrf(:,is_ter)606 393 ! Patricia : 607 394 ! CASE('fCO2_fos_fuel') 608 395 ! dtr_add(:,it) = dtr_add(:,it)/mth_len 609 ! co2 fields(it)%readstep = 0 ! Always read same value for fossil fuel(Cadule case)396 ! co2trac(it)%readstep = 0 ! Always read same value for fossil fuel(Cadule case) 610 397 END SELECT 611 398 END IF … … 617 404 ! ------------------------------------------------------------------ 618 405 IF (carbon_cycle_tr) THEN 619 620 dtr_add_sum(1:klon)=0.621 DO it=1,nbcf_in622 dtr_add_sum(1:klon)=dtr_add_sum(1:klon)+dtr_add(1:klon,it)623 END DO624 625 406 DO it = 1, ntr_co2 626 tr_seri(1:klon,1,co2trac(it)%id) = tr_seri(1:klon,1,co2trac(it)%id) + dtr_add_sum(1:klon) 407 IF (.FALSE.) THEN 408 tr_seri(1:klon,1,co2trac(it)%id) = tr_seri(1:klon,1,co2trac(it)%id) + dtr_add(1:klon,it) 409 source(1:klon,co2trac(it)%id) = 0. 410 ELSE 411 source(1:klon,co2trac(it)%id) = dtr_add(1:klon,it) 412 END IF 627 413 END DO 628 414 END IF … … 631 417 ! 5) Calculations for new CO2 value for the radiation scheme(instead of reading value from .def) 632 418 ! ---------------------------------------------------------------------------------------------- 633 !IF (RCO2_inter) THEN 634 ! >> PC 635 ! IF (.NOT. carbon_cycle_tr .AND. carbon_cycle_cpl) THEN 636 !! IF (newday) THEN ! Reset cumulative variables once a day 637 !! fCO2_nep(1:klon) = 0. 638 !! fCO2_fLuc(1:klon) = 0. 639 !! END IF 640 !! >> PC 641 ! fCO2_nep(1:klon) = fCO2_nep_inst(1:klon) ![gC/m2/s] 642 ! fCO2_fLuc(1:klon) = fCO2_fLuc_inst(1:klon) ![gC/m2/s] 643 ! END IF 644 !! << PC 645 646 ! >> PC 647 ! IF (endday) THEN 648 ! << PC 649 650 ! >> PC 651 ! modifier le test (carbon_cycle_tr) ligne 492 pour prendre en compte que les cas 652 ! ou carbon_cycle_cpl = 1 ou 2 .AND. carbon_cycle_tr=y 653 ! bien declarer la variable fco2_tmp (pour un seul traceur) 419 IF (RCO2_inter) THEN 420 ! Cumulate fluxes from ORCHIDEE at each timestep 421 IF (.NOT. carbon_cycle_tr .AND. carbon_cycle_cpl) THEN 422 IF (newday) THEN ! Reset cumulative variables once a day 423 fco2_land_day(1:klon) = 0. 424 fco2_lu_day(1:klon) = 0. 425 END IF 426 fco2_land_day(1:klon) = fco2_land_day(1:klon) + fco2_land_inst(1:klon) ![gC/m2/day] 427 fco2_lu_day(1:klon) = fco2_lu_day(1:klon) + fco2_lu_inst(1:klon) ![gC/m2/day] 428 END IF 429 430 ! At the end of a new day, calculate a mean scalare value of CO2 431 ! JG : Ici on utilise uniquement le traceur du premier couche du modele. Est-ce que c'est correcte ? 432 IF (endday) THEN 654 433 655 434 IF (carbon_cycle_tr) THEN 656 WRITE(lunout,*) 'fco2_tmp --- carbon_cycle_tr case'657 435 ! Sum all co2 tracers to get the total delta CO2 flux 658 436 fco2_tmp(:) = 0. … … 660 438 fco2_tmp(1:klon) = fco2_tmp(1:klon) + tr_seri(1:klon,1,co2trac(it)%id) 661 439 END DO 662 ! << PC 663 ELSE IF (carbon_cycle_cpl .AND. (.NOT. carbon_cycle_tr)) THEN ! no carbon_cycle_tr 664 WRITE(lunout,*) 'fco2_tmp --- carbon_cycle_cpl case' 440 441 ELSE IF (carbon_cycle_cpl) THEN ! no carbon_cycle_tr 665 442 ! Sum co2 fluxes comming from coupled models and parameter for fossil fuel 666 ! >> PC 667 !fco2_tmp(1:klon) = (fCO2_fco2fos*pctsrf(1:klon,is_ter) + (fCO2_fLuc(1:klon) + fCO2_nep(1:klon))*pctsrf(1:klon,is_ter) & 668 669 ! fco2_tmp(1:klon) = (fCO2_fco2fos(1:klon)*pctsrf(1:klon,is_ter) + fCO2_nbp(1:klon)*pctsrf(1:klon,is_ter) & 670 ! + fCO2_fgco2(1:klon)*pctsrf(1:klon,is_oce)) * fact 671 ! fCO2_fco2fos_1D 672 fco2_tmp(:) = 0. 673 fco2_tmp(:) = ( fCO2_fco2fos_1D + fCO2_nbp_inst(:)*pctsrf(:,is_ter) + fCO2_fgco2(:)*pctsrf(:,is_oce))/2.12 674 WRITE(lunout,*) 'fco2_tmp(:) ',fco2_tmp(:) 675 ! << PC 443 fco2_tmp(1:klon) = fos_fuel_s + ((fco2_lu_day(1:klon) + fco2_land_day(1:klon))*pctsrf(1:klon,is_ter) & 444 + fco2_ocn_day(:)*pctsrf(:,is_oce)) * fact 676 445 END IF 677 446 678 447 ! Calculate a global mean value of delta CO2 flux 679 fco2_tmp( :) = fco2_tmp(:) * cell_area(:)448 fco2_tmp(1:klon) = fco2_tmp(1:klon) * cell_area(1:klon) 680 449 CALL reduce_sum(SUM(fco2_tmp),sumtmp) 681 450 CALL bcast(sumtmp) 682 451 delta_co2_ppm = sumtmp/airetot 683 WRITE(lunout,*) 'delta_co2_ppm: ',delta_co2_ppm684 452 685 453 ! Add initial value for co2_ppm and delta value 686 WRITE(lunout,*)'carbon_cycle_mod --- co2_ppm0 ',co2_ppm0687 454 co2_ppm = co2_ppm0 + delta_co2_ppm 688 CALL bcast(co2_ppm) 689 WRITE(lunout,*)'carbon_cycle_mod --- co2_ppm ',co2_ppm 690 IF (RCO2_inter) THEN 455 691 456 ! Transformation of atmospheric CO2 concentration for the radiation code 692 457 RCO2 = co2_ppm * 1.0e-06 * 44.011/28.97 693 458 694 WRITE(lunout,*) 'RCO2 is now updated (in carbon_cycle_mod) ! RCO2 = ', RCO2 695 696 ! >> PC 697 ! END IF ! endday 698 ! << PC 699 700 END IF ! RCO2_inter 459 WRITE(lunout,*) 'RCO2 is now updated! RCO2 = ', RCO2 460 END IF ! endday 461 462 END IF ! RCO2_inter 701 463 702 464 703 465 ! 6) Calculate CO2 flux to send to ocean and land models : PISCES and ORCHIDEE 704 466 ! ---------------------------------------------------------------------------- 705 ! IF (carbon_cycle_cpl) THEN 706 ! 707 ! IF (carbon_cycle_tr) THEN 708 ! ! Sum all co2 tracers to get the total delta CO2 flux at first model layer 709 ! fco2_tmp(:) = 0. 710 ! DO it = 1, ntr_co2 711 ! fco2_tmp(1:klon) = fco2_tmp(1:klon) + tr_seri(1:klon,1,co2fields(it)%id) 712 ! END DO 713 ! co2_send(1:klon) = fco2_tmp(1:klon) + co2_ppm0 714 ! ELSE 715 ! ! Send a scalare value in 2D variable to ocean and land model (PISCES and ORCHIDEE) 716 ! co2_send(1:klon) = co2_ppm 717 ! END IF 718 ! 719 ! END IF 720 721 722 ! << PC 723 ! co2_ppm0 au premier pas de temps 724 ! prendre le co2 du restart 725 726 IF (carbon_cycle_cpl .AND. carbon_cycle_tr) THEN 727 ! Sum all co2 tracers to get the total delta CO2 flux at first model 728 ! layer 729 !fco2_tmp(:) = 0. 467 IF (carbon_cycle_cpl) THEN 468 469 IF (carbon_cycle_tr) THEN 470 ! Sum all co2 tracers to get the total delta CO2 flux at first model layer 471 fco2_tmp(:) = 0. 730 472 DO it = 1, ntr_co2 731 fco2_tmp(1:klon) = fco2_tmp(1:klon) + tr_seri(1:klon,1,co2 fields(it)%id)473 fco2_tmp(1:klon) = fco2_tmp(1:klon) + tr_seri(1:klon,1,co2trac(it)%id) 732 474 END DO 733 475 co2_send(1:klon) = fco2_tmp(1:klon) + co2_ppm0 734 ELSE IF (carbon_cycle_cpl .AND. (.NOT. carbon_cycle_tr)) THEN735 WRITE(lunout,*) 'carbon_cycle_mod --- co2_send(1:klon)', co2_send(1:klon)736 co2_send(1:klon) = co2_ppm737 476 ELSE 738 ! Send a scalare value in 2D variable to ocean and land model (PISCES 739 ! and ORCHIDEE) 477 ! Send a scalare value in 2D variable to ocean and land model (PISCES and ORCHIDEE) 740 478 co2_send(1:klon) = co2_ppm 741 479 END IF 742 480 743 481 END IF 744 482 745 483 END SUBROUTINE carbon_cycle
Note: See TracChangeset
for help on using the changeset viewer.