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