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 | LOGICAL, PARAMETER :: readco2ff=.TRUE., readco2bb=.FALSE. !!may be controlled via the .def later on |
---|
138 | |
---|
139 | IF (debutphy) THEN |
---|
140 | |
---|
141 | ALLOCATE(flx_co2ff(klon,12)) |
---|
142 | ALLOCATE(flx_co2bb(klon,12)) |
---|
143 | |
---|
144 | !$OMP MASTER |
---|
145 | IF (is_mpi_root) THEN |
---|
146 | |
---|
147 | IF (.NOT.ALLOCATED(flx_co2ff_glo)) ALLOCATE(flx_co2ff_glo(n_glo,n_month)) |
---|
148 | IF (.NOT.ALLOCATED(flx_co2bb_glo)) ALLOCATE(flx_co2bb_glo(n_glo,n_month)) |
---|
149 | |
---|
150 | !--reading CO2 fossil fuel emissions |
---|
151 | IF (readco2ff) THEN |
---|
152 | |
---|
153 | ! ... Open the COZff file |
---|
154 | CALL nf95_open("sflx_lmdz_co2_ff.nc", nf90_nowrite, ncid_in) |
---|
155 | |
---|
156 | CALL nf95_inq_varid(ncid_in, "vector", varid) |
---|
157 | CALL nf95_gw_var(ncid_in, varid, vector) |
---|
158 | n_glo = size(vector) |
---|
159 | IF (n_glo.NE.klon_glo) THEN |
---|
160 | PRINT *,'sflx_lmdz_co2_ff: le nombre de points n est pas egal a klon_glo' |
---|
161 | STOP |
---|
162 | ENDIF |
---|
163 | |
---|
164 | CALL nf95_inq_varid(ncid_in, "time", varid) |
---|
165 | CALL nf95_gw_var(ncid_in, varid, time) |
---|
166 | n_month = size(time) |
---|
167 | IF (n_month.NE.12) THEN |
---|
168 | PRINT *,'sflx_lmdz_co2_ff: le nombre de month n est pas egal a 12' |
---|
169 | STOP |
---|
170 | ENDIF |
---|
171 | |
---|
172 | !--reading flx_co2 for fossil fuel |
---|
173 | CALL nf95_inq_varid(ncid_in, "flx_co2", varid) |
---|
174 | ncerr = nf90_get_var(ncid_in, varid, flx_co2ff_glo) |
---|
175 | |
---|
176 | CALL nf95_close(ncid_in) |
---|
177 | |
---|
178 | ELSE !--co2ff not to be read |
---|
179 | flx_co2ff_glo(:,:)=0.0 |
---|
180 | ENDIF |
---|
181 | |
---|
182 | !--reading CO2 biomass burning emissions |
---|
183 | IF (readco2bb) THEN |
---|
184 | |
---|
185 | ! ... Open the CO2bb file |
---|
186 | CALL nf95_open("sflx_lmdz_co2_bb.nc", nf90_nowrite, ncid_in) |
---|
187 | |
---|
188 | CALL nf95_inq_varid(ncid_in, "vector", varid) |
---|
189 | CALL nf95_gw_var(ncid_in, varid, vector) |
---|
190 | n_glo = size(vector) |
---|
191 | IF (n_glo.NE.klon_glo) THEN |
---|
192 | PRINT *,'sflx_lmdz_co2_bb: le nombre de points n est pas egal a klon_glo' |
---|
193 | STOP |
---|
194 | ENDIF |
---|
195 | |
---|
196 | CALL nf95_inq_varid(ncid_in, "time", varid) |
---|
197 | CALL nf95_gw_var(ncid_in, varid, time) |
---|
198 | n_month = size(time) |
---|
199 | IF (n_month.NE.12) THEN |
---|
200 | PRINT *,'sflx_lmdz_co2_bb: le nombre de month n est pas egal a 12' |
---|
201 | STOP |
---|
202 | ENDIF |
---|
203 | |
---|
204 | !--reading flx_co2 for biomass burning |
---|
205 | CALL nf95_inq_varid(ncid_in, "flx_co2", varid) |
---|
206 | ncerr = nf90_get_var(ncid_in, varid, flx_co2bb_glo) |
---|
207 | |
---|
208 | CALL nf95_close(ncid_in) |
---|
209 | |
---|
210 | ELSE !--co2bb not to be read |
---|
211 | flx_co2bb_glo(:,:)=0.0 |
---|
212 | ENDIF |
---|
213 | |
---|
214 | ENDIF |
---|
215 | !$OMP END MASTER |
---|
216 | |
---|
217 | !--scatter on all proc |
---|
218 | CALL scatter(flx_co2ff_glo,flx_co2ff) |
---|
219 | CALL scatter(flx_co2bb_glo,flx_co2bb) |
---|
220 | |
---|
221 | !$OMP MASTER |
---|
222 | IF (is_mpi_root) THEN |
---|
223 | DEALLOCATE(flx_co2ff_glo) |
---|
224 | DEALLOCATE(flx_co2bb_glo) |
---|
225 | ENDIF |
---|
226 | !$OMP END MASTER |
---|
227 | |
---|
228 | ENDIF !--end debuthy |
---|
229 | |
---|
230 | !---select the correct month |
---|
231 | IF (mth_cur.LT.1.OR.mth_cur.GT.12) THEN |
---|
232 | PRINT *,'probleme avec le mois dans co2_ini =', mth_cur |
---|
233 | ENDIF |
---|
234 | co2ff(:) = flx_co2ff(:,mth_cur) |
---|
235 | co2bb(:) = flx_co2bb(:,mth_cur) |
---|
236 | |
---|
237 | END SUBROUTINE co2_emissions |
---|
238 | |
---|
239 | END MODULE tracco2i_mod |
---|