[3361] | 1 | MODULE tracco2i_mod |
---|
| 2 | ! |
---|
| 3 | ! This module does the work for the interactive CO2 tracers |
---|
| 4 | ! |
---|
| 5 | CONTAINS |
---|
| 6 | |
---|
| 7 | SUBROUTINE tracco2i(pdtphys, debutphy, & |
---|
| 8 | xlat, xlon, pphis, pphi, & |
---|
| 9 | t_seri, pplay, paprs, tr_seri, source) |
---|
| 10 | |
---|
| 11 | USE dimphy |
---|
[3435] | 12 | USE infotrac_phy |
---|
[3450] | 13 | USE geometry_mod, ONLY: cell_area |
---|
[3453] | 14 | USE carbon_cycle_mod, ONLY: id_CO2, nbcf_in, fields_in, cfname_in |
---|
| 15 | USE carbon_cycle_mod, ONLY: fco2_ocn_day, fco2_ff, fco2_bb, fco2_land, fco2_ocean |
---|
[3450] | 16 | USE carbon_cycle_mod, ONLY: carbon_cycle_tr, carbon_cycle_rad, RCO2_glo, RCO2_tot |
---|
[3361] | 17 | USE mod_grid_phy_lmdz |
---|
[3450] | 18 | USE mod_phys_lmdz_mpi_data, ONLY: is_mpi_root |
---|
[3361] | 19 | USE mod_phys_lmdz_para, ONLY: gather, bcast, scatter |
---|
| 20 | USE phys_cal_mod |
---|
[3450] | 21 | USE phys_state_var_mod, ONLY: pctsrf |
---|
| 22 | USE indice_sol_mod, ONLY: nbsrf, is_ter, is_lic, is_oce, is_sic |
---|
[3361] | 23 | |
---|
| 24 | IMPLICIT NONE |
---|
| 25 | |
---|
| 26 | INCLUDE "clesphys.h" |
---|
| 27 | INCLUDE "YOMCST.h" |
---|
| 28 | |
---|
| 29 | ! Input argument |
---|
| 30 | !--------------- |
---|
| 31 | REAL,INTENT(IN) :: pdtphys ! Pas d'integration pour la physique (seconde) |
---|
| 32 | LOGICAL,INTENT(IN) :: debutphy ! le flag de l'initialisation de la physique |
---|
| 33 | |
---|
| 34 | REAL,DIMENSION(klon),INTENT(IN) :: xlat ! latitudes pour chaque point |
---|
| 35 | REAL,DIMENSION(klon),INTENT(IN) :: xlon ! longitudes pour chaque point |
---|
| 36 | REAL,DIMENSION(klon),INTENT(IN) :: pphis ! geopotentiel du sol |
---|
| 37 | REAL,DIMENSION(klon,klev),INTENT(IN) :: pphi ! geopotentiel de chaque couche |
---|
| 38 | |
---|
| 39 | REAL,DIMENSION(klon,klev),INTENT(IN) :: t_seri ! Temperature |
---|
| 40 | REAL,DIMENSION(klon,klev),INTENT(IN) :: pplay ! pression pour le mileu de chaque couche (en Pa) |
---|
| 41 | REAL,DIMENSION(klon,klev+1),INTENT(IN) :: paprs ! pression pour chaque inter-couche (en Pa) |
---|
| 42 | REAL,DIMENSION(klon,nbtr),INTENT(INOUT):: source ! flux de traceur [U/m2/s] |
---|
| 43 | |
---|
| 44 | ! Output argument |
---|
| 45 | !---------------- |
---|
| 46 | REAL,DIMENSION(klon,klev,nbtr),INTENT(INOUT) :: tr_seri ! Concentration Traceur [U/kgA] |
---|
| 47 | |
---|
| 48 | ! Local variables |
---|
| 49 | !---------------- |
---|
| 50 | |
---|
[3421] | 51 | INTEGER :: it, k, i, nb |
---|
| 52 | REAL, DIMENSION(klon,klev) :: m_air ! mass of air in every grid box [kg] |
---|
[3361] | 53 | REAL, DIMENSION(klon_glo,klev) :: co2_glo ! variable temporaire sur la grille global |
---|
| 54 | REAL, DIMENSION(klon_glo,klev) :: m_air_glo ! variable temporaire sur la grille global |
---|
| 55 | |
---|
[3450] | 56 | INTEGER, SAVE :: mth_pre=0, day_pre=0 |
---|
| 57 | !$OMP THREADPRIVATE(mth_pre, day_pre) |
---|
[3361] | 58 | |
---|
| 59 | IF (is_mpi_root) THEN |
---|
| 60 | PRINT *,'in tracco2i: date from phys_cal_mod =',year_cur,'-',mth_cur,'-',day_cur,'-',hour |
---|
| 61 | ENDIF |
---|
| 62 | |
---|
| 63 | !--initialisation of CO2 field if not in restart file |
---|
| 64 | !--dirty way of doing, do it better later |
---|
| 65 | !--convert 280 ppm into kg CO2 / kg air |
---|
| 66 | IF (debutphy) THEN |
---|
| 67 | IF (MAXVAL(tr_seri(:,:,id_CO2)).LT.1.e-15) THEN |
---|
[3450] | 68 | !!tr_seri(:,:,id_CO2)=280.e-6/RMD*RMCO2 |
---|
| 69 | tr_seri(:,:,id_CO2)=400.e-6/RMD*RMCO2 !--initialised to 400 ppm for a test |
---|
[3361] | 70 | ENDIF |
---|
| 71 | ENDIF |
---|
| 72 | |
---|
[3421] | 73 | !--calculate mass of air in every grid box in kg air |
---|
[3361] | 74 | DO i=1, klon |
---|
| 75 | DO k=1, klev |
---|
| 76 | m_air(i,k)=(paprs(i,k)-paprs(i,k+1))/RG*cell_area(i) |
---|
| 77 | ENDDO |
---|
| 78 | ENDDO |
---|
| 79 | |
---|
| 80 | !--call CO2 emission routine |
---|
| 81 | !--co2bb is zero for now |
---|
[3421] | 82 | !--unit kg CO2 m-2 s-1 |
---|
| 83 | CALL co2_emissions(debutphy) |
---|
[3361] | 84 | |
---|
[3421] | 85 | !--retrieving land and ocean CO2 flux |
---|
[3453] | 86 | fco2_land(:)=0.0 |
---|
| 87 | fco2_ocean(:)=0.0 |
---|
[3421] | 88 | DO nb=1, nbcf_in |
---|
[3450] | 89 | !--fCO2_nep comes in unit of kg C m-2 s-1 |
---|
| 90 | !--converting to kg CO2 m-2 s-1 |
---|
[3453] | 91 | IF (cfname_in(nb) == "fCO2_nep" ) fco2_land(:)=fields_in(:,nb)*RMCO2/RMC*pctsrf(:,is_ter) |
---|
[3450] | 92 | !--fCO2_fgco2 comes in unit of mol C02 m-2 s-1 |
---|
| 93 | !--converting to kg CO2 m-2 s-1 + change sign |
---|
[3453] | 94 | IF (cfname_in(nb) == "fCO2_fgco2" ) fco2_ocean(:)=-1.*fco2_ocn_day(:)*RMCO2/1.e3*(pctsrf(:,is_oce)+pctsrf(:,is_sic)) |
---|
[3421] | 95 | ENDDO |
---|
| 96 | |
---|
[3453] | 97 | !--preparing the net anthropogenic flux at the surface for mixing layer |
---|
[3361] | 98 | !--unit kg CO2 / m2 / s |
---|
[3453] | 99 | source(:,id_CO2)=fco2_ff(:)+fco2_bb(:)+fco2_land(:)+fco2_ocean(:) |
---|
[3361] | 100 | |
---|
| 101 | !--computing global mean CO2 for radiation |
---|
[3450] | 102 | !--every timestep for now but enough every day |
---|
[3361] | 103 | ! IF (debutphy.OR.mth_cur.NE.mth_pre) THEN |
---|
[3450] | 104 | ! IF (debutphy.OR.day_cur.NE.day_pre) THEN |
---|
[3361] | 105 | CALL gather(tr_seri(:,:,id_CO2),co2_glo) |
---|
| 106 | CALL gather(m_air,m_air_glo) |
---|
| 107 | !$OMP MASTER |
---|
[3450] | 108 | !--compute a global mean CO2 value and print its value in ppm |
---|
[3361] | 109 | IF (is_mpi_root) THEN |
---|
[3450] | 110 | RCO2_tot=SUM(co2_glo*m_air_glo) !--unit kg CO2 |
---|
| 111 | RCO2_glo=RCO2_tot/SUM(m_air_glo) !--unit kg CO2 / kg air |
---|
| 112 | PRINT *,'tracco2i: global CO2 in ppm =', RCO2_glo*1.e6*RMD/RMCO2 |
---|
| 113 | PRINT *,'tracco2i: total CO2 in kg =', RCO2_tot |
---|
[3361] | 114 | ENDIF |
---|
| 115 | !$OMP END MASTER |
---|
| 116 | CALL bcast(RCO2_glo) |
---|
| 117 | mth_pre=mth_cur |
---|
[3450] | 118 | day_pre=day_cur |
---|
| 119 | !--if not carbon_cycle_tr, then we reinitialize the CO2 each day to its global mean value |
---|
| 120 | IF (.NOT.carbon_cycle_tr) THEN |
---|
| 121 | tr_seri(:,:,id_CO2)=RCO2_glo |
---|
| 122 | ENDIF |
---|
[3361] | 123 | ! ENDIF |
---|
| 124 | |
---|
| 125 | END SUBROUTINE tracco2i |
---|
| 126 | |
---|
[3421] | 127 | SUBROUTINE co2_emissions(debutphy) |
---|
[3361] | 128 | |
---|
| 129 | USE dimphy |
---|
[3435] | 130 | USE infotrac_phy |
---|
[3361] | 131 | USE geometry_mod, ONLY : cell_area |
---|
| 132 | USE mod_grid_phy_lmdz |
---|
[3366] | 133 | USE mod_phys_lmdz_mpi_data, ONLY: is_mpi_root |
---|
[3361] | 134 | USE mod_phys_lmdz_para, ONLY: gather, scatter |
---|
| 135 | USE phys_cal_mod |
---|
| 136 | |
---|
| 137 | USE netcdf95, ONLY: nf95_close, nf95_gw_var, nf95_inq_varid, nf95_open |
---|
| 138 | USE netcdf, ONLY: nf90_get_var, nf90_noerr, nf90_nowrite |
---|
| 139 | |
---|
[3421] | 140 | USE carbon_cycle_mod, ONLY : fco2_ff, fco2_bb |
---|
| 141 | |
---|
[3361] | 142 | IMPLICIT NONE |
---|
| 143 | |
---|
[3368] | 144 | INCLUDE "YOMCST.h" |
---|
[3361] | 145 | LOGICAL,INTENT(IN) :: debutphy |
---|
| 146 | |
---|
| 147 | ! For NetCDF: |
---|
[3366] | 148 | INTEGER ncid_in ! IDs for input files |
---|
| 149 | INTEGER varid, ncerr |
---|
[3361] | 150 | |
---|
| 151 | INTEGER :: n_glo, n_month |
---|
| 152 | REAL, POINTER:: vector(:), time(:) |
---|
[3366] | 153 | REAL,ALLOCATABLE :: flx_co2ff_glo(:,:) ! fossil-fuel CO2 |
---|
[3421] | 154 | REAL,ALLOCATABLE :: flx_co2bb_glo(:,:) ! biomass-burning CO2 |
---|
[3366] | 155 | REAL,ALLOCATABLE, SAVE :: flx_co2ff(:,:) ! fossil-fuel CO2 |
---|
| 156 | REAL,ALLOCATABLE, SAVE :: flx_co2bb(:,:) ! biomass-burning CO2 |
---|
[3421] | 157 | !$OMP THREADPRIVATE(flx_co2ff,flx_co2bb) |
---|
[3361] | 158 | |
---|
[3383] | 159 | !! may be controlled via the .def later on |
---|
| 160 | !! also co2bb for now comes from ORCHIDEE |
---|
| 161 | LOGICAL, PARAMETER :: readco2ff=.TRUE., readco2bb=.FALSE. |
---|
[3361] | 162 | |
---|
[3531] | 163 | CHARACTER (len = 20) :: modname = 'tracco2i.co2_emissions' |
---|
| 164 | CHARACTER (len = 80) :: abort_message |
---|
| 165 | |
---|
[3366] | 166 | IF (debutphy) THEN |
---|
[3361] | 167 | |
---|
[3366] | 168 | ALLOCATE(flx_co2ff(klon,12)) |
---|
| 169 | ALLOCATE(flx_co2bb(klon,12)) |
---|
| 170 | |
---|
[3361] | 171 | !$OMP MASTER |
---|
[3366] | 172 | IF (is_mpi_root) THEN |
---|
| 173 | |
---|
[3383] | 174 | IF (.NOT.ALLOCATED(flx_co2ff_glo)) ALLOCATE(flx_co2ff_glo(klon_glo,12)) |
---|
| 175 | IF (.NOT.ALLOCATED(flx_co2bb_glo)) ALLOCATE(flx_co2bb_glo(klon_glo,12)) |
---|
[3361] | 176 | |
---|
[3366] | 177 | !--reading CO2 fossil fuel emissions |
---|
| 178 | IF (readco2ff) THEN |
---|
[3361] | 179 | |
---|
[3366] | 180 | ! ... Open the COZff file |
---|
| 181 | CALL nf95_open("sflx_lmdz_co2_ff.nc", nf90_nowrite, ncid_in) |
---|
[3361] | 182 | |
---|
[3366] | 183 | CALL nf95_inq_varid(ncid_in, "vector", varid) |
---|
| 184 | CALL nf95_gw_var(ncid_in, varid, vector) |
---|
| 185 | n_glo = size(vector) |
---|
| 186 | IF (n_glo.NE.klon_glo) THEN |
---|
[3531] | 187 | abort_message='sflx_lmdz_co2_ff: le nombre de points n est pas egal a klon_glo' |
---|
| 188 | CALL abort_physic(modname,abort_message,1) |
---|
[3366] | 189 | ENDIF |
---|
[3361] | 190 | |
---|
[3366] | 191 | CALL nf95_inq_varid(ncid_in, "time", varid) |
---|
| 192 | CALL nf95_gw_var(ncid_in, varid, time) |
---|
| 193 | n_month = size(time) |
---|
| 194 | IF (n_month.NE.12) THEN |
---|
[3531] | 195 | abort_message='sflx_lmdz_co2_ff: le nombre de month n est pas egal a 12' |
---|
| 196 | CALL abort_physic(modname,abort_message,1) |
---|
[3366] | 197 | ENDIF |
---|
[3361] | 198 | |
---|
[3366] | 199 | !--reading flx_co2 for fossil fuel |
---|
| 200 | CALL nf95_inq_varid(ncid_in, "flx_co2", varid) |
---|
| 201 | ncerr = nf90_get_var(ncid_in, varid, flx_co2ff_glo) |
---|
| 202 | |
---|
| 203 | CALL nf95_close(ncid_in) |
---|
| 204 | |
---|
| 205 | ELSE !--co2ff not to be read |
---|
| 206 | flx_co2ff_glo(:,:)=0.0 |
---|
| 207 | ENDIF |
---|
| 208 | |
---|
| 209 | !--reading CO2 biomass burning emissions |
---|
| 210 | IF (readco2bb) THEN |
---|
| 211 | |
---|
| 212 | ! ... Open the CO2bb file |
---|
| 213 | CALL nf95_open("sflx_lmdz_co2_bb.nc", nf90_nowrite, ncid_in) |
---|
| 214 | |
---|
| 215 | CALL nf95_inq_varid(ncid_in, "vector", varid) |
---|
| 216 | CALL nf95_gw_var(ncid_in, varid, vector) |
---|
| 217 | n_glo = size(vector) |
---|
| 218 | IF (n_glo.NE.klon_glo) THEN |
---|
[3531] | 219 | abort_message='sflx_lmdz_co2_bb: le nombre de points n est pas egal a klon_glo' |
---|
| 220 | CALL abort_physic(modname,abort_message,1) |
---|
[3366] | 221 | ENDIF |
---|
| 222 | |
---|
| 223 | CALL nf95_inq_varid(ncid_in, "time", varid) |
---|
| 224 | CALL nf95_gw_var(ncid_in, varid, time) |
---|
| 225 | n_month = size(time) |
---|
| 226 | IF (n_month.NE.12) THEN |
---|
[3531] | 227 | abort_message='sflx_lmdz_co2_bb: le nombre de month n est pas egal a 12' |
---|
| 228 | CALL abort_physic(modname,abort_message,1) |
---|
[3366] | 229 | ENDIF |
---|
| 230 | |
---|
| 231 | !--reading flx_co2 for biomass burning |
---|
| 232 | CALL nf95_inq_varid(ncid_in, "flx_co2", varid) |
---|
| 233 | ncerr = nf90_get_var(ncid_in, varid, flx_co2bb_glo) |
---|
| 234 | |
---|
| 235 | CALL nf95_close(ncid_in) |
---|
| 236 | |
---|
| 237 | ELSE !--co2bb not to be read |
---|
| 238 | flx_co2bb_glo(:,:)=0.0 |
---|
| 239 | ENDIF |
---|
| 240 | |
---|
| 241 | ENDIF |
---|
[3361] | 242 | !$OMP END MASTER |
---|
| 243 | |
---|
| 244 | !--scatter on all proc |
---|
[3366] | 245 | CALL scatter(flx_co2ff_glo,flx_co2ff) |
---|
| 246 | CALL scatter(flx_co2bb_glo,flx_co2bb) |
---|
[3361] | 247 | |
---|
| 248 | !$OMP MASTER |
---|
[3366] | 249 | IF (is_mpi_root) THEN |
---|
| 250 | DEALLOCATE(flx_co2ff_glo) |
---|
| 251 | DEALLOCATE(flx_co2bb_glo) |
---|
| 252 | ENDIF |
---|
[3361] | 253 | !$OMP END MASTER |
---|
| 254 | |
---|
| 255 | ENDIF !--end debuthy |
---|
| 256 | |
---|
| 257 | !---select the correct month |
---|
| 258 | IF (mth_cur.LT.1.OR.mth_cur.GT.12) THEN |
---|
[3366] | 259 | PRINT *,'probleme avec le mois dans co2_ini =', mth_cur |
---|
[3361] | 260 | ENDIF |
---|
[3421] | 261 | IF (.NOT.ALLOCATED(fco2_ff)) ALLOCATE(fco2_ff(klon)) |
---|
| 262 | IF (.NOT.ALLOCATED(fco2_bb)) ALLOCATE(fco2_bb(klon)) |
---|
| 263 | fco2_ff(:) = flx_co2ff(:,mth_cur) |
---|
| 264 | fco2_bb(:) = flx_co2bb(:,mth_cur) |
---|
[3361] | 265 | |
---|
| 266 | END SUBROUTINE co2_emissions |
---|
| 267 | |
---|
| 268 | END MODULE tracco2i_mod |
---|