1 | module physiq_mod |
---|
2 | |
---|
3 | implicit none |
---|
4 | |
---|
5 | contains |
---|
6 | |
---|
7 | subroutine physiq(ngrid,nlayer,nq, & |
---|
8 | nametrac, & |
---|
9 | firstcall,lastcall, & |
---|
10 | pday,ptime,ptimestep, & |
---|
11 | pplev,pplay,pphi, & |
---|
12 | pu,pv,pt,pq, & |
---|
13 | flxw, & |
---|
14 | pdu,pdv,pdt,pdq,pdpsrf) |
---|
15 | |
---|
16 | use radinc_h, only : L_NSPECTI,L_NSPECTV,naerkind |
---|
17 | use watercommon_h, only : RLVTT, Psat_water,epsi,su_watercycle, RV, T_h2o_ice_liq |
---|
18 | use thermcell_mod, only: init_thermcell_mod |
---|
19 | use gases_h, only: gnom, gfrac |
---|
20 | use radcommon_h, only: sigma, glat, grav, BWNV |
---|
21 | use radii_mod, only: h2o_reffrad, co2_reffrad |
---|
22 | use aerosol_mod, only: iaero_co2, iaero_h2o |
---|
23 | use surfdat_h, only: phisfi, zmea, zstd, zsig, zgam, zthe, & |
---|
24 | dryness, watercaptag |
---|
25 | use comdiurn_h, only: coslat, sinlat, coslon, sinlon |
---|
26 | use comsaison_h, only: mu0, fract, dist_star, declin, right_ascen |
---|
27 | use comsoil_h, only: nsoilmx, layer, mlayer, inertiedat |
---|
28 | use geometry_mod, only: latitude, longitude, cell_area |
---|
29 | USE comgeomfi_h, only: totarea, totarea_planet |
---|
30 | USE tracer_h, only: noms, mmol, radius, rho_q, qext, & |
---|
31 | alpha_lift, alpha_devil, qextrhor, & |
---|
32 | igcm_h2o_ice, igcm_h2o_vap, igcm_dustbin, & |
---|
33 | igcm_co2_ice, nesp, is_chim |
---|
34 | use time_phylmdz_mod, only: ecritphy, iphysiq, nday |
---|
35 | use phyetat0_mod, only: phyetat0 |
---|
36 | use phyredem, only: physdem0, physdem1 |
---|
37 | use slab_ice_h, only: capcalocean, capcalseaice,capcalsno, & |
---|
38 | noceanmx |
---|
39 | use ocean_slab_mod, only :ocean_slab_init, ocean_slab_ice, & |
---|
40 | ini_surf_heat_transp_mod, & |
---|
41 | ocean_slab_get_vars,ocean_slab_final |
---|
42 | use surf_heat_transp_mod,only :init_masquv |
---|
43 | use planetwide_mod, only: planetwide_minval,planetwide_maxval,planetwide_sumval |
---|
44 | use mod_phys_lmdz_para, only : is_master |
---|
45 | use planete_mod, only: apoastr, periastr, year_day, peri_day, & |
---|
46 | obliquit, nres, z0 |
---|
47 | use comcstfi_mod, only: pi, g, rcp, r, rad, mugaz, cpp |
---|
48 | use time_phylmdz_mod, only: daysec |
---|
49 | use callkeys_mod, only: albedo_spectral_mode, calladj, calldifv, & |
---|
50 | calllott_nonoro, callrad, callsoil, nosurf, & |
---|
51 | callstats, & |
---|
52 | calltherm, CLFvarying, co2cond, corrk, diagdtau, & |
---|
53 | diurnal, enertest, fat1au, flatten, j2, & |
---|
54 | hydrology, icetstep, intheat, iradia, kastprof, & |
---|
55 | lwrite, mass_redistrib, massplanet, meanOLR, & |
---|
56 | nearco2cond, newtonian, noseason_day, oblate, & |
---|
57 | ok_slab_ocean, photochem, rings_shadow, rmean, & |
---|
58 | season, sedimentation, sourceevol, specOLR, & |
---|
59 | startphy_file, testradtimes, tlocked, & |
---|
60 | tracer, UseTurbDiff, water, watercond, & |
---|
61 | waterrain, global1d, szangle |
---|
62 | use nonoro_gwd_ran_mod, only: nonoro_gwd_ran |
---|
63 | use conc_mod, only: rnew, cpnew, ini_conc_mod |
---|
64 | use phys_state_var_mod |
---|
65 | use callcorrk_mod, only: callcorrk |
---|
66 | use vdifc_mod, only: vdifc |
---|
67 | use turbdiff_mod, only: turbdiff |
---|
68 | use turb_mod, only : q2,sensibFlux,turb_resolved |
---|
69 | use mass_redistribution_mod, only: mass_redistribution |
---|
70 | #ifndef MESOSCALE |
---|
71 | use vertical_layers_mod, only: presnivs, pseudoalt |
---|
72 | use mod_phys_lmdz_omp_data, ONLY: is_omp_master |
---|
73 | #else |
---|
74 | use comm_wrf, only : comm_HR_SW, comm_HR_LW, & |
---|
75 | comm_CLOUDFRAC,comm_TOTCLOUDFRAC,& |
---|
76 | comm_SURFRAIN,comm_REEVAP,comm_HR_DYN,& |
---|
77 | comm_RAIN,comm_SNOW,comm_ALBEQ,& |
---|
78 | comm_FLUXTOP_DN,comm_FLUXABS_SW,& |
---|
79 | comm_FLUXTOP_LW,comm_FLUXSURF_SW,& |
---|
80 | comm_FLUXSURF_LW,comm_FLXGRD,& |
---|
81 | comm_LSCEZ,comm_H2OICE_REFF |
---|
82 | #endif |
---|
83 | |
---|
84 | #ifdef CPP_XIOS |
---|
85 | use xios_output_mod, only: initialize_xios_output, & |
---|
86 | update_xios_timestep, & |
---|
87 | send_xios_field |
---|
88 | use wxios, only: wxios_context_init, xios_context_finalize |
---|
89 | #endif |
---|
90 | |
---|
91 | implicit none |
---|
92 | |
---|
93 | |
---|
94 | !================================================================== |
---|
95 | ! |
---|
96 | ! Purpose |
---|
97 | ! ------- |
---|
98 | ! Central subroutine for all the physics parameterisations in the |
---|
99 | ! universal model. Originally adapted from the Mars LMDZ model. |
---|
100 | ! |
---|
101 | ! The model can be run without or with tracer transport |
---|
102 | ! depending on the value of "tracer" in file "callphys.def". |
---|
103 | ! |
---|
104 | ! |
---|
105 | ! It includes: |
---|
106 | ! |
---|
107 | ! I. Initialization : |
---|
108 | ! I.1 Firstcall initializations. |
---|
109 | ! I.2 Initialization for every call to physiq. |
---|
110 | ! |
---|
111 | ! II. Compute radiative transfer tendencies (longwave and shortwave) : |
---|
112 | ! II.a Option 1 : Call correlated-k radiative transfer scheme. |
---|
113 | ! II.b Option 2 : Call Newtonian cooling scheme. |
---|
114 | ! II.c Option 3 : Atmosphere has no radiative effect. |
---|
115 | ! |
---|
116 | ! III. Vertical diffusion (turbulent mixing) : |
---|
117 | ! |
---|
118 | ! IV. Convection : |
---|
119 | ! IV.a Thermal plume model |
---|
120 | ! IV.b Dry convective adjusment |
---|
121 | ! |
---|
122 | ! V. Condensation and sublimation of gases (currently just CO2). |
---|
123 | ! |
---|
124 | ! VI. Tracers |
---|
125 | ! VI.1. Water and water ice. |
---|
126 | ! VI.2 Photochemistry |
---|
127 | ! VI.3. Aerosols and particles. |
---|
128 | ! VI.4. Updates (pressure variations, surface budget). |
---|
129 | ! VI.5. Slab Ocean. |
---|
130 | ! VI.6. Surface Tracer Update. |
---|
131 | ! |
---|
132 | ! VII. Surface and sub-surface soil temperature. |
---|
133 | ! |
---|
134 | ! VIII. Perform diagnostics and write output files. |
---|
135 | ! |
---|
136 | ! |
---|
137 | ! arguments |
---|
138 | ! --------- |
---|
139 | ! |
---|
140 | ! INPUT |
---|
141 | ! ----- |
---|
142 | ! |
---|
143 | ! ngrid Size of the horizontal grid. |
---|
144 | ! nlayer Number of vertical layers. |
---|
145 | ! nq Number of advected fields. |
---|
146 | ! nametrac Name of corresponding advected fields. |
---|
147 | ! |
---|
148 | ! firstcall True at the first call. |
---|
149 | ! lastcall True at the last call. |
---|
150 | ! |
---|
151 | ! pday Number of days counted from the North. Spring equinoxe. |
---|
152 | ! ptime Universal time (0<ptime<1): ptime=0.5 at 12:00 UT. |
---|
153 | ! ptimestep timestep (s). |
---|
154 | ! |
---|
155 | ! pplay(ngrid,nlayer) Pressure at the middle of the layers (Pa). |
---|
156 | ! pplev(ngrid,nlayer+1) Intermediate pressure levels (Pa). |
---|
157 | ! pphi(ngrid,nlayer) Geopotential at the middle of the layers (m2.s-2). |
---|
158 | ! |
---|
159 | ! pu(ngrid,nlayer) u, zonal component of the wind (ms-1). |
---|
160 | ! pv(ngrid,nlayer) v, meridional component of the wind (ms-1). |
---|
161 | ! |
---|
162 | ! pt(ngrid,nlayer) Temperature (K). |
---|
163 | ! |
---|
164 | ! pq(ngrid,nlayer,nq) Advected fields. |
---|
165 | ! |
---|
166 | ! pudyn(ngrid,nlayer) \ |
---|
167 | ! pvdyn(ngrid,nlayer) \ Dynamical temporal derivative for the |
---|
168 | ! ptdyn(ngrid,nlayer) / corresponding variables. |
---|
169 | ! pqdyn(ngrid,nlayer,nq) / |
---|
170 | ! flxw(ngrid,nlayer) vertical mass flux (kg/s) at layer lower boundary |
---|
171 | ! |
---|
172 | ! OUTPUT |
---|
173 | ! ------ |
---|
174 | ! |
---|
175 | ! pdu(ngrid,nlayer) \ |
---|
176 | ! pdv(ngrid,nlayer) \ Temporal derivative of the corresponding |
---|
177 | ! pdt(ngrid,nlayer) / variables due to physical processes. |
---|
178 | ! pdq(ngrid,nlayer) / |
---|
179 | ! pdpsrf(ngrid) / |
---|
180 | ! |
---|
181 | ! |
---|
182 | ! Authors |
---|
183 | ! ------- |
---|
184 | ! Frederic Hourdin 15/10/93 |
---|
185 | ! Francois Forget 1994 |
---|
186 | ! Christophe Hourdin 02/1997 |
---|
187 | ! Subroutine completely rewritten by F. Forget (01/2000) |
---|
188 | ! Water ice clouds: Franck Montmessin (update 06/2003) |
---|
189 | ! Radiatively active tracers: J.-B. Madeleine (10/2008-06/2009) |
---|
190 | ! New correlated-k radiative scheme: R. Wordsworth (2009) |
---|
191 | ! Many specifically Martian subroutines removed: R. Wordsworth (2009) |
---|
192 | ! Improved water cycle: R. Wordsworth / B. Charnay (2010) |
---|
193 | ! To F90: R. Wordsworth (2010) |
---|
194 | ! New turbulent diffusion scheme: J. Leconte (2012) |
---|
195 | ! Loops converted to F90 matrix format: J. Leconte (2012) |
---|
196 | ! No more ngridmx/nqmx, F90 commons and adaptation to parallel: A. Spiga (2012) |
---|
197 | ! Purge of the code : M. Turbet (2015) |
---|
198 | ! Photochemical core developped by F. Lefevre: B. Charnay (2017) |
---|
199 | !================================================================== |
---|
200 | |
---|
201 | |
---|
202 | ! 0. Declarations : |
---|
203 | ! ------------------ |
---|
204 | |
---|
205 | include "netcdf.inc" |
---|
206 | |
---|
207 | ! Arguments : |
---|
208 | ! ----------- |
---|
209 | |
---|
210 | ! INPUTS: |
---|
211 | ! ------- |
---|
212 | |
---|
213 | integer,intent(in) :: ngrid ! Number of atmospheric columns. |
---|
214 | integer,intent(in) :: nlayer ! Number of atmospheric layers. |
---|
215 | integer,intent(in) :: nq ! Number of tracers. |
---|
216 | character*30,intent(in) :: nametrac(nq) ! Names of the tracers taken from dynamics. |
---|
217 | |
---|
218 | logical,intent(in) :: firstcall ! Signals first call to physics. |
---|
219 | logical,intent(in) :: lastcall ! Signals last call to physics. |
---|
220 | |
---|
221 | real,intent(in) :: pday ! Number of elapsed sols since reference Ls=0. |
---|
222 | real,intent(in) :: ptime ! "Universal time", given as fraction of sol (e.g.: 0.5 for noon). |
---|
223 | real,intent(in) :: ptimestep ! Physics timestep (s). |
---|
224 | real,intent(in) :: pplev(ngrid,nlayer+1) ! Inter-layer pressure (Pa). |
---|
225 | real,intent(in) :: pplay(ngrid,nlayer) ! Mid-layer pressure (Pa). |
---|
226 | real,intent(in) :: pphi(ngrid,nlayer) ! Geopotential at mid-layer (m2s-2). |
---|
227 | real,intent(in) :: pu(ngrid,nlayer) ! Zonal wind component (m/s). |
---|
228 | real,intent(in) :: pv(ngrid,nlayer) ! Meridional wind component (m/s). |
---|
229 | real,intent(in) :: pt(ngrid,nlayer) ! Temperature (K). |
---|
230 | real,intent(in) :: pq(ngrid,nlayer,nq) ! Tracers (kg/kg_of_air). |
---|
231 | real,intent(in) :: flxw(ngrid,nlayer) ! Vertical mass flux (ks/s) at lower boundary of layer |
---|
232 | |
---|
233 | ! OUTPUTS: |
---|
234 | ! -------- |
---|
235 | |
---|
236 | ! Physical tendencies : |
---|
237 | |
---|
238 | real,intent(out) :: pdu(ngrid,nlayer) ! Zonal wind tendencies (m/s/s). |
---|
239 | real,intent(out) :: pdv(ngrid,nlayer) ! Meridional wind tendencies (m/s/s). |
---|
240 | real,intent(out) :: pdt(ngrid,nlayer) ! Temperature tendencies (K/s). |
---|
241 | real,intent(out) :: pdq(ngrid,nlayer,nq) ! Tracer tendencies (kg/kg_of_air/s). |
---|
242 | real,intent(out) :: pdpsrf(ngrid) ! Surface pressure tendency (Pa/s). |
---|
243 | |
---|
244 | ! Local saved variables: |
---|
245 | ! ---------------------- |
---|
246 | integer,save :: day_ini ! Initial date of the run (sol since Ls=0). |
---|
247 | integer,save :: icount ! Counter of calls to physiq during the run. |
---|
248 | !$OMP THREADPRIVATE(day_ini,icount) |
---|
249 | |
---|
250 | ! Local variables : |
---|
251 | ! ----------------- |
---|
252 | |
---|
253 | ! Aerosol (dust or ice) extinction optical depth at reference wavelength |
---|
254 | ! for the "naerkind" optically active aerosols: |
---|
255 | |
---|
256 | real aerosol(ngrid,nlayer,naerkind) ! Aerosols. |
---|
257 | real zh(ngrid,nlayer) ! Potential temperature (K). |
---|
258 | real pw(ngrid,nlayer) ! Vertical velocity (m/s). (NOTE : >0 WHEN DOWNWARDS !!) |
---|
259 | real omega(ngrid,nlayer) ! omega velocity (Pa/s, >0 when downward) |
---|
260 | |
---|
261 | integer l,ig,ierr,iq,nw,isoil,iesp |
---|
262 | |
---|
263 | real zls ! Solar longitude (radians). |
---|
264 | real zlss ! Sub solar point longitude (radians). |
---|
265 | real zday ! Date (time since Ls=0, calculated in sols). |
---|
266 | real zzlay(ngrid,nlayer) ! Altitude at the middle of the atmospheric layers. |
---|
267 | real zzlev(ngrid,nlayer+1) ! Altitude at the atmospheric layer boundaries. |
---|
268 | |
---|
269 | ! VARIABLES for the thermal plume model |
---|
270 | |
---|
271 | real f(ngrid) ! Mass flux norm |
---|
272 | real fm(ngrid,nlayer+1) ! Mass flux |
---|
273 | real fm_bis(ngrid,nlayer) ! Recasted fm |
---|
274 | real entr(ngrid,nlayer) ! Entrainment |
---|
275 | real detr(ngrid,nlayer) ! Detrainment |
---|
276 | real dqevap(ngrid,nlayer,nq) ! water tracer mass mixing ratio variations due to evaporation |
---|
277 | real dtevap(ngrid,nlayer) ! temperature variation due to evaporation |
---|
278 | real zqtherm(ngrid,nlayer,nq) ! vapor mass mixing ratio after evaporation |
---|
279 | real zttherm(ngrid,nlayer) ! temperature after evaporation |
---|
280 | real fraca(ngrid,nlayer+1) ! Fraction of the surface that plumes occupies |
---|
281 | real zw2(ngrid,nlayer+1) ! Vertical speed |
---|
282 | real zw2_bis(ngrid,nlayer) ! Recasted zw2 |
---|
283 | |
---|
284 | ! TENDENCIES due to various processes : |
---|
285 | |
---|
286 | ! For Surface Temperature : (K/s) |
---|
287 | real zdtsurf(ngrid) ! Cumulated tendencies. |
---|
288 | real zdtsurfmr(ngrid) ! Mass_redistribution routine. |
---|
289 | real zdtsurfc(ngrid) ! Condense_co2 routine. |
---|
290 | real zdtsdif(ngrid) ! Turbdiff/vdifc routines. |
---|
291 | real zdtsurf_hyd(ngrid) ! Hydrol routine. |
---|
292 | |
---|
293 | ! For Atmospheric Temperatures : (K/s) |
---|
294 | real dtlscale(ngrid,nlayer) ! Largescale routine. |
---|
295 | real zdtc(ngrid,nlayer) ! Condense_co2 routine. |
---|
296 | real zdtdif(ngrid,nlayer) ! Turbdiff/vdifc routines. |
---|
297 | real zdttherm(ngrid,nlayer) ! Calltherm routine. |
---|
298 | real zdtmr(ngrid,nlayer) ! Mass_redistribution routine. |
---|
299 | real zdtrain(ngrid,nlayer) ! Rain routine. |
---|
300 | real dtmoist(ngrid,nlayer) ! Moistadj routine. |
---|
301 | real dt_ekman(ngrid,noceanmx), dt_hdiff(ngrid,noceanmx) ! Slab_ocean routine. |
---|
302 | real zdtsw1(ngrid,nlayer), zdtlw1(ngrid,nlayer) ! Callcorrk routine. |
---|
303 | real zdtchim(ngrid,nlayer) ! Calchim routine. |
---|
304 | |
---|
305 | ! For Surface Tracers : (kg/m2/s) |
---|
306 | real dqsurf(ngrid,nq) ! Cumulated tendencies. |
---|
307 | real zdqsurfc(ngrid) ! Condense_co2 routine. |
---|
308 | real zdqsdif(ngrid,nq) ! Turbdiff/vdifc routines. |
---|
309 | real zdqssed(ngrid,nq) ! Callsedim routine. |
---|
310 | real zdqsurfmr(ngrid,nq) ! Mass_redistribution routine. |
---|
311 | real zdqsrain(ngrid), zdqssnow(ngrid) ! Rain routine. |
---|
312 | real dqs_hyd(ngrid,nq) ! Hydrol routine. |
---|
313 | real reevap_precip(ngrid) ! re-evaporation flux of precipitation (integrated over the atmospheric column) |
---|
314 | |
---|
315 | ! For Tracers : (kg/kg_of_air/s) |
---|
316 | real zdqc(ngrid,nlayer,nq) ! Condense_co2 routine. |
---|
317 | real zdqadj(ngrid,nlayer,nq) ! Convadj routine. |
---|
318 | real zdqdif(ngrid,nlayer,nq) ! Turbdiff/vdifc routines. |
---|
319 | real zdqevap(ngrid,nlayer) ! Turbdiff routine. |
---|
320 | real zdqtherm(ngrid,nlayer,nq) ! Calltherm routine. |
---|
321 | real zdqsed(ngrid,nlayer,nq) ! Callsedim routine. |
---|
322 | real zdqmr(ngrid,nlayer,nq) ! Mass_redistribution routine. |
---|
323 | real zdqrain(ngrid,nlayer,nq) ! Rain routine. |
---|
324 | real dqmoist(ngrid,nlayer,nq) ! Moistadj routine. |
---|
325 | real dqvaplscale(ngrid,nlayer) ! Largescale routine. |
---|
326 | real dqcldlscale(ngrid,nlayer) ! Largescale routine. |
---|
327 | REAL,allocatable,save :: zdqchim(:,:,:) ! Calchim_asis routine |
---|
328 | REAL,allocatable,save :: zdqschim(:,:) ! Calchim_asis routine |
---|
329 | |
---|
330 | REAL array_zero1(ngrid) |
---|
331 | REAL array_zero2(ngrid,nlayer) |
---|
332 | |
---|
333 | ! For Winds : (m/s/s) |
---|
334 | real zdvadj(ngrid,nlayer), zduadj(ngrid,nlayer) ! Convadj routine. |
---|
335 | real zdutherm(ngrid,nlayer), zdvtherm(ngrid,nlayer) ! Calltherm routine. |
---|
336 | real zdumr(ngrid,nlayer), zdvmr(ngrid,nlayer) ! Mass_redistribution routine. |
---|
337 | real zdvdif(ngrid,nlayer), zdudif(ngrid,nlayer) ! Turbdiff/vdifc routines. |
---|
338 | real zdhdif(ngrid,nlayer) ! Turbdiff/vdifc routines. |
---|
339 | real zdhadj(ngrid,nlayer) ! Convadj routine. |
---|
340 | |
---|
341 | ! For Pressure and Mass : |
---|
342 | real zdmassmr(ngrid,nlayer) ! Atmospheric Mass tendency for mass_redistribution (kg_of_air/m2/s). |
---|
343 | real zdmassmr_col(ngrid) ! Atmospheric Column Mass tendency for mass_redistribution (kg_of_air/m2/s). |
---|
344 | real zdpsrfmr(ngrid) ! Pressure tendency for mass_redistribution routine (Pa/s). |
---|
345 | |
---|
346 | |
---|
347 | |
---|
348 | ! Local variables for LOCAL CALCULATIONS: |
---|
349 | ! --------------------------------------- |
---|
350 | real zflubid(ngrid) |
---|
351 | real zplanck(ngrid),zpopsk(ngrid,nlayer) |
---|
352 | real ztim1,ztim2,ztim3, z1,z2 |
---|
353 | real ztime_fin |
---|
354 | real zdh(ngrid,nlayer) |
---|
355 | real gmplanet |
---|
356 | real taux(ngrid),tauy(ngrid) |
---|
357 | |
---|
358 | |
---|
359 | ! local variables for DIAGNOSTICS : (diagfi & stat) |
---|
360 | ! ------------------------------------------------- |
---|
361 | real ps(ngrid) ! Surface Pressure. |
---|
362 | real zt(ngrid,nlayer) ! Atmospheric Temperature. |
---|
363 | real zu(ngrid,nlayer),zv(ngrid,nlayer) ! Zonal and Meridional Winds. |
---|
364 | real zq(ngrid,nlayer,nq) ! Atmospheric Tracers. |
---|
365 | real zdtadj(ngrid,nlayer) ! Convadj Diagnostic. |
---|
366 | real zdtdyn(ngrid,nlayer) ! Dynamical Heating (K/s). |
---|
367 | real zdudyn(ngrid,nlayer) ! Dynamical Zonal Wind tendency (m.s-2). |
---|
368 | |
---|
369 | real reff(ngrid,nlayer) ! Effective dust radius (used if doubleq=T). |
---|
370 | real vmr(ngrid,nlayer) ! volume mixing ratio |
---|
371 | real time_phys |
---|
372 | |
---|
373 | real ISR,ASR,OLR,GND,DYN,GSR,Ts1,Ts2,Ts3,TsS ! for Diagnostic. |
---|
374 | |
---|
375 | real qcol(ngrid,nq) ! Tracer Column Mass (kg/m2). |
---|
376 | |
---|
377 | ! included by RW for H2O Manabe scheme |
---|
378 | real rneb_man(ngrid,nlayer) ! H2O cloud fraction (moistadj). |
---|
379 | real rneb_lsc(ngrid,nlayer) ! H2O cloud fraction (large scale). |
---|
380 | |
---|
381 | |
---|
382 | ! to test energy conservation (RW+JL) |
---|
383 | real mass(ngrid,nlayer),massarea(ngrid,nlayer) |
---|
384 | real dEtot, dEtots, AtmToSurf_TurbFlux |
---|
385 | real,save :: dEtotSW, dEtotsSW, dEtotLW, dEtotsLW |
---|
386 | !$OMP THREADPRIVATE(dEtotSW, dEtotsSW, dEtotLW, dEtotsLW) |
---|
387 | |
---|
388 | !JL12 conservation test for mean flow kinetic energy has been disabled temporarily |
---|
389 | |
---|
390 | real dtmoist_max,dtmoist_min |
---|
391 | real dItot, dItot_tmp, dVtot, dVtot_tmp |
---|
392 | |
---|
393 | |
---|
394 | real h2otot ! Total Amount of water. For diagnostic. |
---|
395 | real icesrf,liqsrf,icecol,vapcol ! Total Amounts of water (ice,liq,vap). For diagnostic. |
---|
396 | real dWtot, dWtot_tmp, dWtots, dWtots_tmp |
---|
397 | logical,save :: watertest |
---|
398 | !$OMP THREADPRIVATE(watertest) |
---|
399 | |
---|
400 | real qsat(ngrid,nlayer) ! Water Vapor Volume Mixing Ratio at saturation (kg/kg_of_air). |
---|
401 | real RH(ngrid,nlayer) ! Relative humidity. |
---|
402 | real psat_tmp |
---|
403 | |
---|
404 | logical clearsky ! For double radiative transfer call. By BC |
---|
405 | |
---|
406 | ! For Clear Sky Case. |
---|
407 | real fluxsurfabs_sw1(ngrid) ! For SW/LW flux. |
---|
408 | real tau_col1(ngrid) ! For aerosol optical depth diagnostic. |
---|
409 | real OLR_nu1(ngrid,L_NSPECTI) ! Clear sky TOA LW radiation in each IR band |
---|
410 | real OSR_nu1(ngrid,L_NSPECTV) ! Clear sky TOA SW radiation in each VI band |
---|
411 | real GSR_nu1(ngrid,L_NSPECTV) ! Clear sky Surface SW radiation in each VI band |
---|
412 | real int_dtaui1(ngrid,nlayer,L_NSPECTI),int_dtauv1(ngrid,nlayer,L_NSPECTV) ! For optical thickness diagnostics. |
---|
413 | real tf, ntf |
---|
414 | |
---|
415 | real nconsMAX, vdifcncons(ngrid), cadjncons(ngrid) ! Vdfic water conservation test. By RW |
---|
416 | |
---|
417 | real muvar(ngrid,nlayer+1) ! For Runaway Greenhouse 1D study. By RW |
---|
418 | |
---|
419 | real reffcol(ngrid,naerkind) |
---|
420 | |
---|
421 | ! Sourceevol for 'accelerated ice evolution'. By RW |
---|
422 | real delta_ice,ice_tot |
---|
423 | integer num_run |
---|
424 | logical,save :: ice_update |
---|
425 | ! Non-oro GW tendencies |
---|
426 | REAL d_u_hin(ngrid,nlayer), d_v_hin(ngrid,nlayer) |
---|
427 | REAL d_t_hin(ngrid,nlayer) |
---|
428 | ! Diagnostics 2D of gw_nonoro |
---|
429 | REAL zustrhi(ngrid), zvstrhi(ngrid) |
---|
430 | |
---|
431 | |
---|
432 | real :: tsurf2(ngrid) |
---|
433 | real :: flux_o(ngrid),flux_g(ngrid) |
---|
434 | real :: flux_sens_lat(ngrid) |
---|
435 | real :: qsurfint(ngrid,nq) |
---|
436 | #ifdef MESOSCALE |
---|
437 | REAL :: lsf_dt(nlayer) |
---|
438 | REAL :: lsf_dq(nlayer) |
---|
439 | #endif |
---|
440 | |
---|
441 | ! Misc |
---|
442 | character*2 :: str2 |
---|
443 | !================================================================================================== |
---|
444 | |
---|
445 | ! ----------------- |
---|
446 | ! I. INITIALISATION |
---|
447 | ! ----------------- |
---|
448 | |
---|
449 | ! -------------------------------- |
---|
450 | ! I.1 First Call Initialisation. |
---|
451 | ! -------------------------------- |
---|
452 | if (firstcall) then |
---|
453 | ! Allocate saved arrays (except for 1D model, where this has already |
---|
454 | ! been done) |
---|
455 | #ifndef MESOSCALE |
---|
456 | if (ngrid>1) call phys_state_var_init(nq) |
---|
457 | #endif |
---|
458 | |
---|
459 | ! Variables set to 0 |
---|
460 | ! ~~~~~~~~~~~~~~~~~~ |
---|
461 | dtrad(:,:) = 0.0 |
---|
462 | fluxrad(:) = 0.0 |
---|
463 | tau_col(:) = 0.0 |
---|
464 | zdtsw(:,:) = 0.0 |
---|
465 | zdtlw(:,:) = 0.0 |
---|
466 | |
---|
467 | |
---|
468 | ! Initialize aerosol indexes. |
---|
469 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
470 | call iniaerosol() |
---|
471 | |
---|
472 | |
---|
473 | ! Initialize tracer names, indexes and properties. |
---|
474 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
475 | IF (.NOT.ALLOCATED(noms)) ALLOCATE(noms(nq)) ! (because noms is an argument of physdem1 whether or not tracer is on) |
---|
476 | if (tracer) then |
---|
477 | call initracer(ngrid,nq,nametrac) |
---|
478 | if(photochem) then |
---|
479 | call ini_conc_mod(ngrid,nlayer) |
---|
480 | IF (.NOT.ALLOCATED(zdqchim)) ALLOCATE(zdqchim(ngrid,nlayer,nesp)) |
---|
481 | IF (.NOT.ALLOCATED(zdqschim)) ALLOCATE(zdqschim(ngrid,nesp)) |
---|
482 | endif |
---|
483 | endif |
---|
484 | |
---|
485 | #ifdef CPP_XIOS |
---|
486 | ! Initialize XIOS context |
---|
487 | write(*,*) "physiq: call wxios_context_init" |
---|
488 | CALL wxios_context_init |
---|
489 | #endif |
---|
490 | |
---|
491 | ! Read 'startfi.nc' file. |
---|
492 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
493 | #ifndef MESOSCALE |
---|
494 | call phyetat0(startphy_file, & |
---|
495 | ngrid,nlayer,"startfi.nc",0,0,nsoilmx,nq, & |
---|
496 | day_ini,time_phys,tsurf,tsoil,emis,q2,qsurf, & |
---|
497 | cloudfrac,totcloudfrac,hice, & |
---|
498 | rnat,pctsrf_sic,tslab, tsea_ice,sea_ice) |
---|
499 | #else |
---|
500 | emis(:)=0.0 |
---|
501 | q2(:,:)=0.0 |
---|
502 | qsurf(:,:)=0.0 |
---|
503 | day_ini = pday |
---|
504 | #endif |
---|
505 | |
---|
506 | #ifndef MESOSCALE |
---|
507 | if (.not.startphy_file) then |
---|
508 | ! additionnal "academic" initialization of physics |
---|
509 | if (is_master) write(*,*) "Physiq: initializing tsurf(:) to pt(:,1) !!" |
---|
510 | tsurf(:)=pt(:,1) |
---|
511 | if (is_master) write(*,*) "Physiq: initializing tsoil(:) to pt(:,1) !!" |
---|
512 | do isoil=1,nsoilmx |
---|
513 | tsoil(1:ngrid,isoil)=tsurf(1:ngrid) |
---|
514 | enddo |
---|
515 | if (is_master) write(*,*) "Physiq: initializing day_ini to pdat !" |
---|
516 | day_ini=pday |
---|
517 | endif |
---|
518 | #endif |
---|
519 | if (pday.ne.day_ini) then |
---|
520 | write(*,*) "ERROR in physiq.F90:" |
---|
521 | write(*,*) "bad synchronization between physics and dynamics" |
---|
522 | write(*,*) "dynamics day: ",pday |
---|
523 | write(*,*) "physics day: ",day_ini |
---|
524 | stop |
---|
525 | endif |
---|
526 | |
---|
527 | write (*,*) 'In physiq day_ini =', day_ini |
---|
528 | |
---|
529 | ! Initialize albedo calculation. |
---|
530 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
531 | albedo(:,:)=0.0 |
---|
532 | albedo_bareground(:)=0.0 |
---|
533 | albedo_snow_SPECTV(:)=0.0 |
---|
534 | albedo_co2_ice_SPECTV(:)=0.0 |
---|
535 | call surfini(ngrid,nq,qsurf,albedo,albedo_bareground,albedo_snow_SPECTV,albedo_co2_ice_SPECTV) |
---|
536 | |
---|
537 | ! Initialize orbital calculation. |
---|
538 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
539 | call iniorbit(apoastr,periastr,year_day,peri_day,obliquit) |
---|
540 | |
---|
541 | |
---|
542 | if(tlocked)then |
---|
543 | print*,'Planet is tidally locked at resonance n=',nres |
---|
544 | print*,'Make sure you have the right rotation rate!!!' |
---|
545 | endif |
---|
546 | |
---|
547 | ! Initialize oceanic variables. |
---|
548 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
549 | |
---|
550 | if (ok_slab_ocean)then |
---|
551 | |
---|
552 | call ocean_slab_init(ngrid,ptimestep, tslab, & |
---|
553 | sea_ice, pctsrf_sic) |
---|
554 | |
---|
555 | call ini_surf_heat_transp_mod() |
---|
556 | |
---|
557 | knindex(:) = 0 |
---|
558 | |
---|
559 | do ig=1,ngrid |
---|
560 | zmasq(ig)=1 |
---|
561 | knindex(ig) = ig |
---|
562 | if (nint(rnat(ig)).eq.0) then |
---|
563 | zmasq(ig)=0 |
---|
564 | endif |
---|
565 | enddo |
---|
566 | |
---|
567 | CALL init_masquv(ngrid,zmasq) |
---|
568 | |
---|
569 | endif ! end of 'ok_slab_ocean'. |
---|
570 | |
---|
571 | |
---|
572 | ! Initialize soil. |
---|
573 | ! ~~~~~~~~~~~~~~~~ |
---|
574 | if (callsoil) then |
---|
575 | |
---|
576 | call soil(ngrid,nsoilmx,firstcall,lastcall,inertiedat, & |
---|
577 | ptimestep,tsurf,tsoil,capcal,fluxgrd) |
---|
578 | |
---|
579 | if (ok_slab_ocean) then |
---|
580 | do ig=1,ngrid |
---|
581 | if (nint(rnat(ig)).eq.2) then |
---|
582 | capcal(ig)=capcalocean |
---|
583 | if (pctsrf_sic(ig).gt.0.5) then |
---|
584 | capcal(ig)=capcalseaice |
---|
585 | if (qsurf(ig,igcm_h2o_ice).gt.0.) then |
---|
586 | capcal(ig)=capcalsno |
---|
587 | endif |
---|
588 | endif |
---|
589 | endif |
---|
590 | enddo |
---|
591 | endif ! end of 'ok_slab_ocean'. |
---|
592 | |
---|
593 | else ! else of 'callsoil'. |
---|
594 | |
---|
595 | print*,'WARNING! Thermal conduction in the soil turned off' |
---|
596 | capcal(:)=1.e6 |
---|
597 | fluxgrd(:)=intheat |
---|
598 | print*,'Flux from ground = ',intheat,' W m^-2' |
---|
599 | |
---|
600 | endif ! end of 'callsoil'. |
---|
601 | |
---|
602 | icount=1 |
---|
603 | |
---|
604 | ! Decide whether to update ice at end of run. |
---|
605 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
606 | ice_update=.false. |
---|
607 | if(sourceevol)then |
---|
608 | !$OMP MASTER |
---|
609 | open(128,file='num_run',form='formatted', & |
---|
610 | status="old",iostat=ierr) |
---|
611 | if (ierr.ne.0) then |
---|
612 | write(*,*) "physiq: Error! No num_run file!" |
---|
613 | write(*,*) " (which is needed for sourceevol option)" |
---|
614 | stop |
---|
615 | endif |
---|
616 | read(128,*) num_run |
---|
617 | close(128) |
---|
618 | !$OMP END MASTER |
---|
619 | !$OMP BARRIER |
---|
620 | |
---|
621 | if(num_run.ne.0.and.mod(num_run,2).eq.0)then |
---|
622 | print*,'Updating ice at end of this year!' |
---|
623 | ice_update=.true. |
---|
624 | ice_min(:)=1.e4 |
---|
625 | endif |
---|
626 | |
---|
627 | endif ! end of 'sourceevol'. |
---|
628 | |
---|
629 | |
---|
630 | ! Here is defined the type of the surface : Continent or Ocean. |
---|
631 | ! BC2014 : This is now already done in newstart. |
---|
632 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
633 | if (.not.ok_slab_ocean) then |
---|
634 | |
---|
635 | rnat(:)=1. |
---|
636 | if (.not.nosurf) then ! inertiedat only defined if there is a surface |
---|
637 | do ig=1,ngrid |
---|
638 | if(inertiedat(ig,1).gt.1.E4)then |
---|
639 | rnat(ig)=0 |
---|
640 | endif |
---|
641 | enddo |
---|
642 | |
---|
643 | print*,'WARNING! Surface type currently decided by surface inertia' |
---|
644 | print*,'This should be improved e.g. in newstart.F' |
---|
645 | endif |
---|
646 | endif ! end of 'ok_slab_ocean'. |
---|
647 | |
---|
648 | |
---|
649 | ! Initialize surface history variable. |
---|
650 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
651 | qsurf_hist(:,:)=qsurf(:,:) |
---|
652 | |
---|
653 | ! Initialize variable for dynamical heating and zonal wind tendency diagnostic |
---|
654 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
655 | ztprevious(:,:)=pt(:,:) |
---|
656 | zuprevious(:,:)=pu(:,:) |
---|
657 | |
---|
658 | ! Set temperature just above condensation temperature (for Early Mars) |
---|
659 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
660 | if(nearco2cond) then |
---|
661 | write(*,*)' WARNING! Starting at Tcond+1K' |
---|
662 | do l=1, nlayer |
---|
663 | do ig=1,ngrid |
---|
664 | pdt(ig,l)= ((-3167.8)/(log(.01*pplay(ig,l))-23.23)+4 & |
---|
665 | -pt(ig,l)) / ptimestep |
---|
666 | enddo |
---|
667 | enddo |
---|
668 | endif |
---|
669 | |
---|
670 | if(meanOLR)then |
---|
671 | call system('rm -f rad_bal.out') ! to record global radiative balance. |
---|
672 | call system('rm -f tem_bal.out') ! to record global mean/max/min temperatures. |
---|
673 | call system('rm -f h2o_bal.out') ! to record global hydrological balance. |
---|
674 | endif |
---|
675 | |
---|
676 | |
---|
677 | watertest=.false. |
---|
678 | if(water)then ! Initialize variables for water cycle |
---|
679 | |
---|
680 | if(enertest)then |
---|
681 | watertest = .true. |
---|
682 | endif |
---|
683 | |
---|
684 | if(ice_update)then |
---|
685 | ice_initial(:)=qsurf(:,igcm_h2o_ice) |
---|
686 | endif |
---|
687 | |
---|
688 | endif |
---|
689 | |
---|
690 | ! Set some parameters for the thermal plume model |
---|
691 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
692 | if (calltherm) then |
---|
693 | CALL init_thermcell_mod(g, rcp, r, pi, T_h2o_ice_liq, RV) |
---|
694 | endif |
---|
695 | |
---|
696 | call su_watercycle ! even if we don't have a water cycle, we might |
---|
697 | ! need epsi for the wvp definitions in callcorrk.F |
---|
698 | ! or RETV, RLvCp for the thermal plume model |
---|
699 | #ifndef MESOSCALE |
---|
700 | if (ngrid.ne.1) then ! Note : no need to create a restart file in 1d. |
---|
701 | call physdem0("restartfi.nc",longitude,latitude,nsoilmx,ngrid,nlayer,nq, & |
---|
702 | ptimestep,pday+nday,time_phys,cell_area, & |
---|
703 | albedo_bareground,inertiedat,zmea,zstd,zsig,zgam,zthe) |
---|
704 | endif |
---|
705 | #endif |
---|
706 | |
---|
707 | ! XIOS outputs |
---|
708 | #ifdef CPP_XIOS |
---|
709 | |
---|
710 | write(*,*) "physiq: call initialize_xios_output" |
---|
711 | call initialize_xios_output(pday,ptime,ptimestep,daysec, & |
---|
712 | presnivs,pseudoalt) |
---|
713 | #endif |
---|
714 | write(*,*) "physiq: end of firstcall" |
---|
715 | endif ! end of 'firstcall' |
---|
716 | |
---|
717 | ! ------------------------------------------------------ |
---|
718 | ! I.2 Initializations done at every physical timestep: |
---|
719 | ! ------------------------------------------------------ |
---|
720 | |
---|
721 | #ifdef CPP_XIOS |
---|
722 | ! update XIOS time/calendar |
---|
723 | call update_xios_timestep |
---|
724 | #endif |
---|
725 | |
---|
726 | ! Initialize various variables |
---|
727 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
728 | |
---|
729 | if ( .not.nearco2cond ) then |
---|
730 | pdt(1:ngrid,1:nlayer) = 0.0 |
---|
731 | endif |
---|
732 | zdtsurf(1:ngrid) = 0.0 |
---|
733 | pdq(1:ngrid,1:nlayer,1:nq) = 0.0 |
---|
734 | dqsurf(1:ngrid,1:nq)= 0.0 |
---|
735 | pdu(1:ngrid,1:nlayer) = 0.0 |
---|
736 | pdv(1:ngrid,1:nlayer) = 0.0 |
---|
737 | pdpsrf(1:ngrid) = 0.0 |
---|
738 | zflubid(1:ngrid) = 0.0 |
---|
739 | flux_sens_lat(1:ngrid) = 0.0 |
---|
740 | taux(1:ngrid) = 0.0 |
---|
741 | tauy(1:ngrid) = 0.0 |
---|
742 | |
---|
743 | zday=pday+ptime ! Compute time, in sols (and fraction thereof). |
---|
744 | |
---|
745 | ! Compute Stellar Longitude (Ls), and orbital parameters. |
---|
746 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
747 | if (season) then |
---|
748 | call stellarlong(zday,zls) |
---|
749 | else |
---|
750 | call stellarlong(noseason_day,zls) |
---|
751 | end if |
---|
752 | |
---|
753 | call orbite(zls,dist_star,declin,right_ascen) |
---|
754 | |
---|
755 | if (tlocked) then |
---|
756 | zlss=Mod(-(2.*pi*(zday/year_day)*nres - right_ascen),2.*pi) |
---|
757 | elseif (diurnal) then |
---|
758 | zlss=-2.*pi*(zday-.5) |
---|
759 | else if(diurnal .eqv. .false.) then |
---|
760 | zlss=9999. |
---|
761 | endif |
---|
762 | |
---|
763 | |
---|
764 | ! Compute variations of g with latitude (oblate case). |
---|
765 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
766 | if (oblate .eqv. .false.) then |
---|
767 | glat(:) = g |
---|
768 | else if (flatten .eq. 0.0 .or. J2 .eq. 0.0 .or. Rmean .eq. 0.0 .or. MassPlanet .eq. 0.0) then |
---|
769 | print*,'I need values for flatten, J2, Rmean and MassPlanet to compute glat (else set oblate=.false.)' |
---|
770 | call abort |
---|
771 | else |
---|
772 | gmplanet = MassPlanet*grav*1e24 |
---|
773 | do ig=1,ngrid |
---|
774 | glat(ig)= gmplanet/(Rmean**2) * (1.D0 + 0.75 *J2 - 2.0*flatten/3. + (2.*flatten - 15./4.* J2) * cos(2. * (pi/2. - latitude(ig)))) |
---|
775 | end do |
---|
776 | endif |
---|
777 | |
---|
778 | ! Compute geopotential between layers. |
---|
779 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
780 | zzlay(1:ngrid,1:nlayer)=pphi(1:ngrid,1:nlayer) |
---|
781 | do l=1,nlayer |
---|
782 | zzlay(1:ngrid,l)= zzlay(1:ngrid,l)/glat(1:ngrid) |
---|
783 | enddo |
---|
784 | |
---|
785 | zzlev(1:ngrid,1)=0. |
---|
786 | zzlev(1:ngrid,nlayer+1)=1.e7 ! Dummy top of last layer above 10000 km... |
---|
787 | |
---|
788 | do l=2,nlayer |
---|
789 | do ig=1,ngrid |
---|
790 | z1=(pplay(ig,l-1)+pplev(ig,l))/(pplay(ig,l-1)-pplev(ig,l)) |
---|
791 | z2=(pplev(ig,l)+pplay(ig,l))/(pplev(ig,l)-pplay(ig,l)) |
---|
792 | zzlev(ig,l)=(z1*zzlay(ig,l-1)+z2*zzlay(ig,l))/(z1+z2) |
---|
793 | enddo |
---|
794 | enddo |
---|
795 | |
---|
796 | ! Compute potential temperature |
---|
797 | ! Note : Potential temperature calculation may not be the same in physiq and dynamic... |
---|
798 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
799 | do l=1,nlayer |
---|
800 | do ig=1,ngrid |
---|
801 | zpopsk(ig,l)=(pplay(ig,l)/pplev(ig,1))**rcp |
---|
802 | zh(ig,l)=pt(ig,l)/zpopsk(ig,l) |
---|
803 | mass(ig,l) = (pplev(ig,l) - pplev(ig,l+1))/glat(ig) |
---|
804 | massarea(ig,l)=mass(ig,l)*cell_area(ig) |
---|
805 | enddo |
---|
806 | enddo |
---|
807 | |
---|
808 | ! Compute vertical velocity (m/s) from vertical mass flux |
---|
809 | ! w = F / (rho*area) and rho = P/(r*T) |
---|
810 | ! But first linearly interpolate mass flux to mid-layers |
---|
811 | do l=1,nlayer-1 |
---|
812 | pw(1:ngrid,l)=0.5*(flxw(1:ngrid,l)+flxw(1:ngrid,l+1)) |
---|
813 | enddo |
---|
814 | pw(1:ngrid,nlayer)=0.5*flxw(1:ngrid,nlayer) ! since flxw(nlayer+1)=0 |
---|
815 | do l=1,nlayer |
---|
816 | pw(1:ngrid,l)=(pw(1:ngrid,l)*r*pt(1:ngrid,l)) / & |
---|
817 | (pplay(1:ngrid,l)*cell_area(1:ngrid)) |
---|
818 | enddo |
---|
819 | ! omega in Pa/s |
---|
820 | do l=1,nlayer-1 |
---|
821 | omega(1:ngrid,l)=0.5*(flxw(1:ngrid,l)+flxw(1:ngrid,l+1)) |
---|
822 | enddo |
---|
823 | omega(1:ngrid,nlayer)=0.5*flxw(1:ngrid,nlayer) ! since flxw(nlayer+1)=0 |
---|
824 | do l=1,nlayer |
---|
825 | omega(1:ngrid,l)=g*omega(1:ngrid,l)/cell_area(1:ngrid) |
---|
826 | enddo |
---|
827 | |
---|
828 | ! ---------------------------------------------------------------- |
---|
829 | ! Compute mean mass, cp, and R |
---|
830 | ! -------------------------------- |
---|
831 | #ifndef MESOSCALE |
---|
832 | if(photochem) then |
---|
833 | call concentrations(ngrid,nlayer,nq,pplay,pt,pdt,pq,pdq,ptimestep) |
---|
834 | endif |
---|
835 | #endif |
---|
836 | |
---|
837 | !--------------------------------- |
---|
838 | ! II. Compute radiative tendencies |
---|
839 | !--------------------------------- |
---|
840 | |
---|
841 | if (callrad) then |
---|
842 | if( mod(icount-1,iradia).eq.0.or.lastcall) then |
---|
843 | |
---|
844 | ! Compute local stellar zenith angles |
---|
845 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
846 | if (tlocked) then |
---|
847 | ! JL14 corrects tidally resonant (and inclined) cases. nres=omega_rot/omega_orb |
---|
848 | ztim1=SIN(declin) |
---|
849 | ztim2=COS(declin)*COS(zlss) |
---|
850 | ztim3=COS(declin)*SIN(zlss) |
---|
851 | |
---|
852 | call stelang(ngrid,sinlon,coslon,sinlat,coslat, & |
---|
853 | ztim1,ztim2,ztim3,mu0,fract, flatten) |
---|
854 | |
---|
855 | elseif (diurnal) then |
---|
856 | ztim1=SIN(declin) |
---|
857 | ztim2=COS(declin)*COS(2.*pi*(zday-.5)) |
---|
858 | ztim3=-COS(declin)*SIN(2.*pi*(zday-.5)) |
---|
859 | |
---|
860 | call stelang(ngrid,sinlon,coslon,sinlat,coslat, & |
---|
861 | ztim1,ztim2,ztim3,mu0,fract, flatten) |
---|
862 | else if(diurnal .eqv. .false.) then |
---|
863 | |
---|
864 | call mucorr(ngrid,declin,latitude,mu0,fract,10000.,rad,flatten) |
---|
865 | ! WARNING: this function appears not to work in 1D |
---|
866 | |
---|
867 | if ((ngrid.eq.1).and.(global1d)) then ! Fixed zenith angle 'szangle' in 1D simulations w/ globally-averaged sunlight. |
---|
868 | mu0 = cos(pi*szangle/180.0) |
---|
869 | !print*,'acosz=',mu0,', szangle=',szangle |
---|
870 | endif |
---|
871 | |
---|
872 | endif |
---|
873 | |
---|
874 | ! Eclipse incoming sunlight (e.g. Saturn ring shadowing). |
---|
875 | if(rings_shadow) then |
---|
876 | call call_rings(ngrid, ptime, pday, diurnal) |
---|
877 | endif |
---|
878 | |
---|
879 | |
---|
880 | if (corrk) then |
---|
881 | |
---|
882 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
883 | ! II.a Call correlated-k radiative transfer scheme |
---|
884 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
885 | if(kastprof)then |
---|
886 | print*,'kastprof should not = true here' |
---|
887 | call abort |
---|
888 | endif |
---|
889 | if(water) then |
---|
890 | muvar(1:ngrid,1:nlayer)=mugaz/(1.e0+(1.e0/epsi-1.e0)*pq(1:ngrid,1:nlayer,igcm_h2o_vap)) |
---|
891 | muvar(1:ngrid,nlayer+1)=mugaz/(1.e0+(1.e0/epsi-1.e0)*pq(1:ngrid,nlayer,igcm_h2o_vap)) |
---|
892 | ! take into account water effect on mean molecular weight |
---|
893 | else |
---|
894 | muvar(1:ngrid,1:nlayer+1)=mugaz |
---|
895 | endif |
---|
896 | |
---|
897 | |
---|
898 | if(ok_slab_ocean) then |
---|
899 | tsurf2(:)=tsurf(:) |
---|
900 | do ig=1,ngrid |
---|
901 | if (nint(rnat(ig))==0) then |
---|
902 | tsurf(ig)=((1.-pctsrf_sic(ig))*tslab(ig,1)**4+pctsrf_sic(ig)*tsea_ice(ig)**4)**0.25 |
---|
903 | endif |
---|
904 | enddo |
---|
905 | endif !(ok_slab_ocean) |
---|
906 | |
---|
907 | ! standard callcorrk |
---|
908 | clearsky=.false. |
---|
909 | call callcorrk(ngrid,nlayer,pq,nq,qsurf, & |
---|
910 | albedo,albedo_equivalent,emis,mu0,pplev,pplay,pt, & |
---|
911 | tsurf,fract,dist_star,aerosol,muvar, & |
---|
912 | zdtlw,zdtsw,fluxsurf_lw,fluxsurf_sw, & |
---|
913 | fluxsurfabs_sw,fluxtop_lw, & |
---|
914 | fluxabs_sw,fluxtop_dn,OLR_nu,OSR_nu,GSR_nu, & |
---|
915 | int_dtaui,int_dtauv, & |
---|
916 | tau_col,cloudfrac,totcloudfrac, & |
---|
917 | clearsky,firstcall,lastcall) |
---|
918 | |
---|
919 | ! Option to call scheme once more for clear regions |
---|
920 | if(CLFvarying)then |
---|
921 | |
---|
922 | ! ---> PROBLEMS WITH ALLOCATED ARRAYS : temporary solution in callcorrk: do not deallocate if CLFvarying ... |
---|
923 | clearsky=.true. |
---|
924 | call callcorrk(ngrid,nlayer,pq,nq,qsurf, & |
---|
925 | albedo,albedo_equivalent1,emis,mu0,pplev,pplay,pt, & |
---|
926 | tsurf,fract,dist_star,aerosol,muvar, & |
---|
927 | zdtlw1,zdtsw1,fluxsurf_lw1,fluxsurf_sw1, & |
---|
928 | fluxsurfabs_sw1,fluxtop_lw1, & |
---|
929 | fluxabs_sw1,fluxtop_dn,OLR_nu1,OSR_nu1,GSR_nu1, & |
---|
930 | int_dtaui1,int_dtauv1, & |
---|
931 | tau_col1,cloudfrac,totcloudfrac, & |
---|
932 | clearsky,firstcall,lastcall) |
---|
933 | clearsky = .false. ! just in case. |
---|
934 | |
---|
935 | ! Sum the fluxes and heating rates from cloudy/clear cases |
---|
936 | do ig=1,ngrid |
---|
937 | tf=totcloudfrac(ig) |
---|
938 | ntf=1.-tf |
---|
939 | fluxsurf_lw(ig) = ntf*fluxsurf_lw1(ig) + tf*fluxsurf_lw(ig) |
---|
940 | fluxsurf_sw(ig) = ntf*fluxsurf_sw1(ig) + tf*fluxsurf_sw(ig) |
---|
941 | albedo_equivalent(ig) = ntf*albedo_equivalent1(ig) + tf*albedo_equivalent(ig) |
---|
942 | fluxsurfabs_sw(ig) = ntf*fluxsurfabs_sw1(ig) + tf*fluxsurfabs_sw(ig) |
---|
943 | fluxtop_lw(ig) = ntf*fluxtop_lw1(ig) + tf*fluxtop_lw(ig) |
---|
944 | fluxabs_sw(ig) = ntf*fluxabs_sw1(ig) + tf*fluxabs_sw(ig) |
---|
945 | tau_col(ig) = ntf*tau_col1(ig) + tf*tau_col(ig) |
---|
946 | |
---|
947 | zdtlw(ig,1:nlayer) = ntf*zdtlw1(ig,1:nlayer) + tf*zdtlw(ig,1:nlayer) |
---|
948 | zdtsw(ig,1:nlayer) = ntf*zdtsw1(ig,1:nlayer) + tf*zdtsw(ig,1:nlayer) |
---|
949 | |
---|
950 | OSR_nu(ig,1:L_NSPECTV) = ntf*OSR_nu1(ig,1:L_NSPECTV) + tf*OSR_nu(ig,1:L_NSPECTV) |
---|
951 | GSR_nu(ig,1:L_NSPECTV) = ntf*GSR_nu1(ig,1:L_NSPECTV) + tf*GSR_nu(ig,1:L_NSPECTV) |
---|
952 | OLR_nu(ig,1:L_NSPECTI) = ntf*OLR_nu1(ig,1:L_NSPECTI) + tf*OLR_nu(ig,1:L_NSPECTI) |
---|
953 | if (diagdtau) then |
---|
954 | int_dtauv(ig,:,1:L_NSPECTV) = ntf*int_dtauv1(ig,:,1:L_NSPECTV) + tf*int_dtauv(ig,:,1:L_NSPECTV) |
---|
955 | int_dtaui(ig,:,1:L_NSPECTI) = ntf*int_dtaui1(ig,:,1:L_NSPECTI) + tf*int_dtaui(ig,:,1:L_NSPECTI) |
---|
956 | endif |
---|
957 | enddo |
---|
958 | |
---|
959 | endif ! end of CLFvarying. |
---|
960 | |
---|
961 | if(ok_slab_ocean) then |
---|
962 | tsurf(:)=tsurf2(:) |
---|
963 | endif |
---|
964 | |
---|
965 | |
---|
966 | ! Radiative flux from the sky absorbed by the surface (W.m-2). |
---|
967 | GSR=0.0 |
---|
968 | fluxrad_sky(1:ngrid)=emis(1:ngrid)*fluxsurf_lw(1:ngrid)+fluxsurfabs_sw(1:ngrid) |
---|
969 | |
---|
970 | !if(noradsurf)then ! no lower surface; SW flux just disappears |
---|
971 | ! GSR = SUM(fluxsurf_sw(1:ngrid)*cell_area(1:ngrid))/totarea |
---|
972 | ! fluxrad_sky(1:ngrid)=emis(1:ngrid)*fluxsurf_lw(1:ngrid) |
---|
973 | ! print*,'SW lost in deep atmosphere = ',GSR,' W m^-2' |
---|
974 | !endif |
---|
975 | |
---|
976 | ! Net atmospheric radiative heating rate (K.s-1) |
---|
977 | dtrad(1:ngrid,1:nlayer)=zdtsw(1:ngrid,1:nlayer)+zdtlw(1:ngrid,1:nlayer) |
---|
978 | |
---|
979 | ! Late initialization of the Ice Spectral Albedo. We needed the visible bands to do that ! |
---|
980 | if (firstcall .and. albedo_spectral_mode) then |
---|
981 | call spectral_albedo_calc(albedo_snow_SPECTV) |
---|
982 | endif |
---|
983 | |
---|
984 | elseif(newtonian)then |
---|
985 | |
---|
986 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
987 | ! II.b Call Newtonian cooling scheme |
---|
988 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
989 | call newtrelax(ngrid,nlayer,mu0,sinlat,zpopsk,pt,pplay,pplev,dtrad,firstcall) |
---|
990 | |
---|
991 | zdtsurf(1:ngrid) = +(pt(1:ngrid,1)-tsurf(1:ngrid))/ptimestep |
---|
992 | ! e.g. surface becomes proxy for 1st atmospheric layer ? |
---|
993 | |
---|
994 | else |
---|
995 | |
---|
996 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
997 | ! II.c Atmosphere has no radiative effect |
---|
998 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
999 | fluxtop_dn(1:ngrid) = fract(1:ngrid)*mu0(1:ngrid)*Fat1AU/dist_star**2 |
---|
1000 | if(ngrid.eq.1)then ! / by 4 globally in 1D case... |
---|
1001 | fluxtop_dn(1) = fract(1)*Fat1AU/dist_star**2/2.0 |
---|
1002 | endif |
---|
1003 | fluxsurf_sw(1:ngrid) = fluxtop_dn(1:ngrid) |
---|
1004 | print*,'------------WARNING---WARNING------------' ! by MT2015. |
---|
1005 | print*,'You are in corrk=false mode, ' |
---|
1006 | print*,'and the surface albedo is taken equal to the first visible spectral value' |
---|
1007 | |
---|
1008 | fluxsurfabs_sw(1:ngrid) = fluxtop_dn(1:ngrid)*(1.-albedo(1:ngrid,1)) |
---|
1009 | fluxrad_sky(1:ngrid) = fluxsurfabs_sw(1:ngrid) |
---|
1010 | fluxtop_lw(1:ngrid) = emis(1:ngrid)*sigma*tsurf(1:ngrid)**4 |
---|
1011 | |
---|
1012 | dtrad(1:ngrid,1:nlayer)=0.0 ! no atmospheric radiative heating |
---|
1013 | |
---|
1014 | endif ! end of corrk |
---|
1015 | |
---|
1016 | endif ! of if(mod(icount-1,iradia).eq.0) |
---|
1017 | |
---|
1018 | |
---|
1019 | ! Transformation of the radiative tendencies |
---|
1020 | ! ------------------------------------------ |
---|
1021 | zplanck(1:ngrid)=tsurf(1:ngrid)*tsurf(1:ngrid) |
---|
1022 | zplanck(1:ngrid)=emis(1:ngrid)*sigma*zplanck(1:ngrid)*zplanck(1:ngrid) |
---|
1023 | fluxrad(1:ngrid)=fluxrad_sky(1:ngrid)-zplanck(1:ngrid) |
---|
1024 | pdt(1:ngrid,1:nlayer)=pdt(1:ngrid,1:nlayer)+dtrad(1:ngrid,1:nlayer) |
---|
1025 | |
---|
1026 | ! Test of energy conservation |
---|
1027 | !---------------------------- |
---|
1028 | if(enertest)then |
---|
1029 | call planetwide_sumval(cpp*massarea(:,:)*zdtsw(:,:)/totarea_planet,dEtotSW) |
---|
1030 | call planetwide_sumval(cpp*massarea(:,:)*zdtlw(:,:)/totarea_planet,dEtotLW) |
---|
1031 | !call planetwide_sumval(fluxsurf_sw(:)*(1.-albedo_equivalent(:))*cell_area(:)/totarea_planet,dEtotsSW) !JL13 carefull, albedo can have changed since the last time we called corrk |
---|
1032 | call planetwide_sumval(fluxsurfabs_sw(:)*cell_area(:)/totarea_planet,dEtotsSW) !JL13 carefull, albedo can have changed since the last time we called corrk |
---|
1033 | call planetwide_sumval((fluxsurf_lw(:)*emis(:)-zplanck(:))*cell_area(:)/totarea_planet,dEtotsLW) |
---|
1034 | dEzRadsw(:,:)=cpp*mass(:,:)*zdtsw(:,:) |
---|
1035 | dEzRadlw(:,:)=cpp*mass(:,:)*zdtlw(:,:) |
---|
1036 | if (is_master) then |
---|
1037 | print*,'---------------------------------------------------------------' |
---|
1038 | print*,'In corrk SW atmospheric heating =',dEtotSW,' W m-2' |
---|
1039 | print*,'In corrk LW atmospheric heating =',dEtotLW,' W m-2' |
---|
1040 | print*,'atmospheric net rad heating (SW+LW) =',dEtotLW+dEtotSW,' W m-2' |
---|
1041 | print*,'In corrk SW surface heating =',dEtotsSW,' W m-2' |
---|
1042 | print*,'In corrk LW surface heating =',dEtotsLW,' W m-2' |
---|
1043 | print*,'surface net rad heating (SW+LW) =',dEtotsLW+dEtotsSW,' W m-2' |
---|
1044 | endif |
---|
1045 | endif ! end of 'enertest' |
---|
1046 | |
---|
1047 | endif ! of if (callrad) |
---|
1048 | |
---|
1049 | |
---|
1050 | |
---|
1051 | ! -------------------------------------------- |
---|
1052 | ! III. Vertical diffusion (turbulent mixing) : |
---|
1053 | ! -------------------------------------------- |
---|
1054 | |
---|
1055 | if (calldifv) then |
---|
1056 | |
---|
1057 | zflubid(1:ngrid)=fluxrad(1:ngrid)+fluxgrd(1:ngrid) |
---|
1058 | |
---|
1059 | ! JL12 the following if test is temporarily there to allow us to compare the old vdifc with turbdiff. |
---|
1060 | if (UseTurbDiff) then |
---|
1061 | |
---|
1062 | call turbdiff(ngrid,nlayer,nq,rnat, & |
---|
1063 | ptimestep,capcal, & |
---|
1064 | pplay,pplev,zzlay,zzlev,z0, & |
---|
1065 | pu,pv,pt,zpopsk,pq,tsurf,emis,qsurf, & |
---|
1066 | pdt,pdq,zflubid, & |
---|
1067 | zdudif,zdvdif,zdtdif,zdtsdif, & |
---|
1068 | sensibFlux,q2,zdqdif,zdqevap,zdqsdif, & |
---|
1069 | taux,tauy) |
---|
1070 | |
---|
1071 | else |
---|
1072 | |
---|
1073 | zdh(1:ngrid,1:nlayer)=pdt(1:ngrid,1:nlayer)/zpopsk(1:ngrid,1:nlayer) |
---|
1074 | |
---|
1075 | call vdifc(ngrid,nlayer,nq,rnat,zpopsk, & |
---|
1076 | ptimestep,capcal,lwrite, & |
---|
1077 | pplay,pplev,zzlay,zzlev,z0, & |
---|
1078 | pu,pv,zh,pq,tsurf,emis,qsurf, & |
---|
1079 | zdh,pdq,zflubid, & |
---|
1080 | zdudif,zdvdif,zdhdif,zdtsdif, & |
---|
1081 | sensibFlux,q2,zdqdif,zdqsdif) |
---|
1082 | |
---|
1083 | zdtdif(1:ngrid,1:nlayer)=zdhdif(1:ngrid,1:nlayer)*zpopsk(1:ngrid,1:nlayer) ! for diagnostic only |
---|
1084 | zdqevap(1:ngrid,1:nlayer)=0. |
---|
1085 | |
---|
1086 | end if !end of 'UseTurbDiff' |
---|
1087 | |
---|
1088 | zdtsurf(1:ngrid)=zdtsurf(1:ngrid)+zdtsdif(1:ngrid) |
---|
1089 | |
---|
1090 | !!! this is always done, except for turbulence-resolving simulations |
---|
1091 | if (.not. turb_resolved) then |
---|
1092 | pdv(1:ngrid,1:nlayer)=pdv(1:ngrid,1:nlayer)+zdvdif(1:ngrid,1:nlayer) |
---|
1093 | pdu(1:ngrid,1:nlayer)=pdu(1:ngrid,1:nlayer)+zdudif(1:ngrid,1:nlayer) |
---|
1094 | pdt(1:ngrid,1:nlayer)=pdt(1:ngrid,1:nlayer)+zdtdif(1:ngrid,1:nlayer) |
---|
1095 | endif |
---|
1096 | |
---|
1097 | if(ok_slab_ocean)then |
---|
1098 | flux_sens_lat(1:ngrid)=(zdtsdif(1:ngrid)*capcal(1:ngrid)-fluxrad(1:ngrid)) |
---|
1099 | endif |
---|
1100 | |
---|
1101 | |
---|
1102 | if (tracer) then |
---|
1103 | pdq(1:ngrid,1:nlayer,1:nq)=pdq(1:ngrid,1:nlayer,1:nq)+ zdqdif(1:ngrid,1:nlayer,1:nq) |
---|
1104 | dqsurf(1:ngrid,1:nq)=dqsurf(1:ngrid,1:nq) + zdqsdif(1:ngrid,1:nq) |
---|
1105 | end if ! of if (tracer) |
---|
1106 | |
---|
1107 | |
---|
1108 | ! test energy conservation |
---|
1109 | !------------------------- |
---|
1110 | if(enertest)then |
---|
1111 | |
---|
1112 | dEzdiff(:,:)=cpp*mass(:,:)*zdtdif(:,:) |
---|
1113 | do ig = 1, ngrid |
---|
1114 | dEdiff(ig)=SUM(dEzdiff (ig,:))+ sensibFlux(ig)! subtract flux to the ground |
---|
1115 | dEzdiff(ig,1)= dEzdiff(ig,1)+ sensibFlux(ig)! subtract flux to the ground |
---|
1116 | enddo |
---|
1117 | |
---|
1118 | call planetwide_sumval(dEdiff(:)*cell_area(:)/totarea_planet,dEtot) |
---|
1119 | dEdiffs(:)=capcal(:)*zdtsdif(:)-zflubid(:)-sensibFlux(:) |
---|
1120 | call planetwide_sumval(dEdiffs(:)*cell_area(:)/totarea_planet,dEtots) |
---|
1121 | call planetwide_sumval(sensibFlux(:)*cell_area(:)/totarea_planet,AtmToSurf_TurbFlux) |
---|
1122 | |
---|
1123 | if (is_master) then |
---|
1124 | |
---|
1125 | if (UseTurbDiff) then |
---|
1126 | print*,'In TurbDiff sensible flux (atm=>surf) =',AtmToSurf_TurbFlux,' W m-2' |
---|
1127 | print*,'In TurbDiff non-cons atm nrj change =',dEtot,' W m-2' |
---|
1128 | print*,'In TurbDiff (correc rad+latent heat) surf nrj change =',dEtots,' W m-2' |
---|
1129 | else |
---|
1130 | print*,'In vdifc sensible flux (atm=>surf) =',AtmToSurf_TurbFlux,' W m-2' |
---|
1131 | print*,'In vdifc non-cons atm nrj change =',dEtot,' W m-2' |
---|
1132 | print*,'In vdifc (correc rad+latent heat) surf nrj change =',dEtots,' W m-2' |
---|
1133 | end if |
---|
1134 | endif ! end of 'is_master' |
---|
1135 | |
---|
1136 | ! JL12 : note that the black body radiative flux emitted by the surface has been updated by the implicit scheme but not given back elsewhere. |
---|
1137 | endif ! end of 'enertest' |
---|
1138 | |
---|
1139 | |
---|
1140 | ! Test water conservation. |
---|
1141 | if(watertest.and.water)then |
---|
1142 | |
---|
1143 | call planetwide_sumval(massarea(:,:)*zdqdif(:,:,igcm_h2o_vap)*ptimestep/totarea_planet,dWtot_tmp) |
---|
1144 | call planetwide_sumval(zdqsdif(:,igcm_h2o_vap)*cell_area(:)*ptimestep/totarea_planet,dWtots_tmp) |
---|
1145 | do ig = 1, ngrid |
---|
1146 | vdifcncons(ig)=SUM(mass(ig,:)*zdqdif(ig,:,igcm_h2o_vap)) |
---|
1147 | enddo |
---|
1148 | call planetwide_sumval(massarea(:,:)*zdqdif(:,:,igcm_h2o_ice)*ptimestep/totarea_planet,dWtot) |
---|
1149 | call planetwide_sumval(zdqsdif(:,igcm_h2o_ice)*cell_area(:)*ptimestep/totarea_planet,dWtots) |
---|
1150 | dWtot = dWtot + dWtot_tmp |
---|
1151 | dWtots = dWtots + dWtots_tmp |
---|
1152 | do ig = 1, ngrid |
---|
1153 | vdifcncons(ig)=vdifcncons(ig) + SUM(mass(ig,:)*zdqdif(ig,:,igcm_h2o_ice)) |
---|
1154 | enddo |
---|
1155 | call planetwide_maxval(vdifcncons(:),nconsMAX) |
---|
1156 | |
---|
1157 | if (is_master) then |
---|
1158 | print*,'---------------------------------------------------------------' |
---|
1159 | print*,'In difv atmospheric water change =',dWtot,' kg m-2' |
---|
1160 | print*,'In difv surface water change =',dWtots,' kg m-2' |
---|
1161 | print*,'In difv non-cons factor =',dWtot+dWtots,' kg m-2' |
---|
1162 | print*,'In difv MAX non-cons factor =',nconsMAX,' kg m-2 s-1' |
---|
1163 | endif |
---|
1164 | |
---|
1165 | endif ! end of 'watertest' |
---|
1166 | !------------------------- |
---|
1167 | |
---|
1168 | else ! calldifv |
---|
1169 | |
---|
1170 | if(.not.newtonian)then |
---|
1171 | |
---|
1172 | zdtsurf(1:ngrid) = zdtsurf(1:ngrid) + (fluxrad(1:ngrid) + fluxgrd(1:ngrid))/capcal(1:ngrid) |
---|
1173 | |
---|
1174 | endif |
---|
1175 | |
---|
1176 | endif ! end of 'calldifv' |
---|
1177 | |
---|
1178 | |
---|
1179 | !------------------- |
---|
1180 | ! IV. Convection : |
---|
1181 | !------------------- |
---|
1182 | |
---|
1183 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
1184 | ! IV.a Thermal plume model : |
---|
1185 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
1186 | |
---|
1187 | IF (calltherm) THEN |
---|
1188 | |
---|
1189 | ! AB: We need to evaporate ice before calling thermcell_main. |
---|
1190 | IF (water) THEN |
---|
1191 | CALL evap(ngrid,nlayer,nq,ptimestep,pt,pq,pdq,pdt,dqevap,dtevap,zqtherm,zttherm) |
---|
1192 | ELSE |
---|
1193 | zttherm(:,:) = pt(:,:) + pdt(:,:) * ptimestep |
---|
1194 | zqtherm(:,:,:) = pq(:,:,:) + pdq(:,:,:) * ptimestep |
---|
1195 | ENDIF |
---|
1196 | |
---|
1197 | CALL thermcell_main(ngrid, nlayer, nq, ptimestep, firstcall, & |
---|
1198 | pplay, pplev, pphi, zpopsk, & |
---|
1199 | pu, pv, zttherm, zqtherm, & |
---|
1200 | zdutherm, zdvtherm, zdttherm, zdqtherm, & |
---|
1201 | fm, entr, detr, zw2, fraca) |
---|
1202 | |
---|
1203 | pdu(1:ngrid,1:nlayer) = pdu(1:ngrid,1:nlayer) + zdutherm(1:ngrid,1:nlayer) |
---|
1204 | pdv(1:ngrid,1:nlayer) = pdv(1:ngrid,1:nlayer) + zdvtherm(1:ngrid,1:nlayer) |
---|
1205 | pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer) + zdttherm(1:ngrid,1:nlayer) |
---|
1206 | |
---|
1207 | IF (tracer) THEN |
---|
1208 | pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq) + zdqtherm(1:ngrid,1:nlayer,1:nq) |
---|
1209 | ENDIF |
---|
1210 | |
---|
1211 | ENDIF ! end of 'calltherm' |
---|
1212 | |
---|
1213 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
1214 | ! IV.b Dry convective adjustment : |
---|
1215 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
1216 | |
---|
1217 | if(calladj) then |
---|
1218 | |
---|
1219 | zdh(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)/zpopsk(1:ngrid,1:nlayer) |
---|
1220 | zduadj(1:ngrid,1:nlayer)=0.0 |
---|
1221 | zdvadj(1:ngrid,1:nlayer)=0.0 |
---|
1222 | zdhadj(1:ngrid,1:nlayer)=0.0 |
---|
1223 | |
---|
1224 | |
---|
1225 | call convadj(ngrid,nlayer,nq,ptimestep, & |
---|
1226 | pplay,pplev,zpopsk, & |
---|
1227 | pu,pv,zh,pq, & |
---|
1228 | pdu,pdv,zdh,pdq, & |
---|
1229 | zduadj,zdvadj,zdhadj, & |
---|
1230 | zdqadj) |
---|
1231 | |
---|
1232 | pdu(1:ngrid,1:nlayer) = pdu(1:ngrid,1:nlayer) + zduadj(1:ngrid,1:nlayer) |
---|
1233 | pdv(1:ngrid,1:nlayer) = pdv(1:ngrid,1:nlayer) + zdvadj(1:ngrid,1:nlayer) |
---|
1234 | pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer) + zdhadj(1:ngrid,1:nlayer)*zpopsk(1:ngrid,1:nlayer) |
---|
1235 | zdtadj(1:ngrid,1:nlayer) = zdhadj(1:ngrid,1:nlayer)*zpopsk(1:ngrid,1:nlayer) ! for diagnostic only |
---|
1236 | |
---|
1237 | if(tracer) then |
---|
1238 | pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq) + zdqadj(1:ngrid,1:nlayer,1:nq) |
---|
1239 | end if |
---|
1240 | |
---|
1241 | ! Test energy conservation |
---|
1242 | if(enertest)then |
---|
1243 | call planetwide_sumval(cpp*massarea(:,:)*zdtadj(:,:)/totarea_planet,dEtot) |
---|
1244 | if (is_master) print*,'In convadj atmospheric energy change =',dEtot,' W m-2' |
---|
1245 | endif |
---|
1246 | |
---|
1247 | ! Test water conservation |
---|
1248 | if(watertest)then |
---|
1249 | call planetwide_sumval(massarea(:,:)*zdqadj(:,:,igcm_h2o_vap)*ptimestep/totarea_planet,dWtot_tmp) |
---|
1250 | do ig = 1, ngrid |
---|
1251 | cadjncons(ig)=SUM(mass(ig,:)*zdqadj(ig,:,igcm_h2o_vap)) |
---|
1252 | enddo |
---|
1253 | call planetwide_sumval(massarea(:,:)*zdqadj(:,:,igcm_h2o_ice)*ptimestep/totarea_planet,dWtot) |
---|
1254 | dWtot = dWtot + dWtot_tmp |
---|
1255 | do ig = 1, ngrid |
---|
1256 | cadjncons(ig)=cadjncons(ig) + SUM(mass(ig,:)*zdqadj(ig,:,igcm_h2o_ice)) |
---|
1257 | enddo |
---|
1258 | call planetwide_maxval(cadjncons(:),nconsMAX) |
---|
1259 | |
---|
1260 | if (is_master) then |
---|
1261 | print*,'In convadj atmospheric water change =',dWtot,' kg m-2' |
---|
1262 | print*,'In convadj MAX non-cons factor =',nconsMAX,' kg m-2 s-1' |
---|
1263 | endif |
---|
1264 | |
---|
1265 | endif ! end of 'watertest' |
---|
1266 | |
---|
1267 | endif ! end of 'calladj' |
---|
1268 | !---------------------------------------------- |
---|
1269 | ! Non orographic Gravity Waves: |
---|
1270 | !--------------------------------------------- |
---|
1271 | IF (calllott_nonoro) THEN |
---|
1272 | |
---|
1273 | CALL nonoro_gwd_ran(ngrid,nlayer,ptimestep, & |
---|
1274 | cpnew, rnew, & |
---|
1275 | pplay, & |
---|
1276 | zmax_th, &! max altitude reached by thermals (m) |
---|
1277 | pt, pu, pv, & |
---|
1278 | pdt, pdu, pdv, & |
---|
1279 | zustrhi,zvstrhi, & |
---|
1280 | d_t_hin, d_u_hin, d_v_hin) |
---|
1281 | |
---|
1282 | ! Update tendencies |
---|
1283 | pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer) & |
---|
1284 | + d_t_hin(1:ngrid,1:nlayer) |
---|
1285 | pdu(1:ngrid,1:nlayer) = pdu(1:ngrid,1:nlayer) & |
---|
1286 | + d_u_hin(1:ngrid,1:nlayer) |
---|
1287 | pdv(1:ngrid,1:nlayer) = pdv(1:ngrid,1:nlayer) & |
---|
1288 | + d_v_hin(1:ngrid,1:nlayer) |
---|
1289 | print*,'du_nonoro: max ', maxval(d_u_hin), 'min ', minval(d_u_hin) |
---|
1290 | print*,'dv_nonoro: max ', maxval(d_v_hin), 'min ', minval(d_v_hin) |
---|
1291 | |
---|
1292 | ENDIF ! of IF (calllott_nonoro) |
---|
1293 | |
---|
1294 | |
---|
1295 | |
---|
1296 | !----------------------------------------------- |
---|
1297 | ! V. Carbon dioxide condensation-sublimation : |
---|
1298 | !----------------------------------------------- |
---|
1299 | |
---|
1300 | if (co2cond) then |
---|
1301 | |
---|
1302 | if (.not.tracer) then |
---|
1303 | print*,'We need a CO2 ice tracer to condense CO2' |
---|
1304 | call abort |
---|
1305 | endif |
---|
1306 | call condense_co2(ngrid,nlayer,nq,ptimestep, & |
---|
1307 | capcal,pplay,pplev,tsurf,pt, & |
---|
1308 | pdt,zdtsurf,pq,pdq, & |
---|
1309 | qsurf,zdqsurfc,albedo,emis, & |
---|
1310 | albedo_bareground,albedo_co2_ice_SPECTV, & |
---|
1311 | zdtc,zdtsurfc,pdpsrf,zdqc) |
---|
1312 | |
---|
1313 | pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)+zdtc(1:ngrid,1:nlayer) |
---|
1314 | zdtsurf(1:ngrid) = zdtsurf(1:ngrid) + zdtsurfc(1:ngrid) |
---|
1315 | |
---|
1316 | pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq)+ zdqc(1:ngrid,1:nlayer,1:nq) |
---|
1317 | dqsurf(1:ngrid,igcm_co2_ice) = dqsurf(1:ngrid,igcm_co2_ice) + zdqsurfc(1:ngrid) |
---|
1318 | |
---|
1319 | ! test energy conservation |
---|
1320 | if(enertest)then |
---|
1321 | call planetwide_sumval(cpp*massarea(:,:)*zdtc(:,:)/totarea_planet,dEtot) |
---|
1322 | call planetwide_sumval(capcal(:)*zdtsurfc(:)*cell_area(:)/totarea_planet,dEtots) |
---|
1323 | if (is_master) then |
---|
1324 | print*,'In co2cloud atmospheric energy change =',dEtot,' W m-2' |
---|
1325 | print*,'In co2cloud surface energy change =',dEtots,' W m-2' |
---|
1326 | endif |
---|
1327 | endif |
---|
1328 | |
---|
1329 | endif ! end of 'co2cond' |
---|
1330 | |
---|
1331 | |
---|
1332 | !--------------------------------------------- |
---|
1333 | ! VI. Specific parameterizations for tracers |
---|
1334 | !--------------------------------------------- |
---|
1335 | |
---|
1336 | if (tracer) then |
---|
1337 | |
---|
1338 | ! --------------------- |
---|
1339 | ! VI.1. Water and ice |
---|
1340 | ! --------------------- |
---|
1341 | if (water) then |
---|
1342 | |
---|
1343 | ! Water ice condensation in the atmosphere |
---|
1344 | if(watercond.and.(RLVTT.gt.1.e-8))then |
---|
1345 | |
---|
1346 | if (.not.calltherm) then |
---|
1347 | dqmoist(1:ngrid,1:nlayer,1:nq)=0. |
---|
1348 | dtmoist(1:ngrid,1:nlayer)=0. |
---|
1349 | |
---|
1350 | ! Moist Convective Adjustment. |
---|
1351 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
1352 | call moistadj(ngrid,nlayer,nq,pt,pq,pdq,pplev,pplay,dtmoist,dqmoist,ptimestep,rneb_man) |
---|
1353 | |
---|
1354 | pdq(1:ngrid,1:nlayer,igcm_h2o_vap) = pdq(1:ngrid,1:nlayer,igcm_h2o_vap) & |
---|
1355 | + dqmoist(1:ngrid,1:nlayer,igcm_h2o_vap) |
---|
1356 | pdq(1:ngrid,1:nlayer,igcm_h2o_ice) = pdq(1:ngrid,1:nlayer,igcm_h2o_ice) & |
---|
1357 | + dqmoist(1:ngrid,1:nlayer,igcm_h2o_ice) |
---|
1358 | pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)+dtmoist(1:ngrid,1:nlayer) |
---|
1359 | |
---|
1360 | ! Test energy conservation. |
---|
1361 | if(enertest)then |
---|
1362 | call planetwide_sumval(cpp*massarea(:,:)*dtmoist(:,:)/totarea_planet,dEtot) |
---|
1363 | call planetwide_maxval(dtmoist(:,:),dtmoist_max) |
---|
1364 | call planetwide_minval(dtmoist(:,:),dtmoist_min) |
---|
1365 | madjdEz(:,:)=cpp*mass(:,:)*dtmoist(:,:) |
---|
1366 | |
---|
1367 | do ig=1,ngrid |
---|
1368 | madjdE(ig) = cpp*SUM(mass(:,:)*dtmoist(:,:)) |
---|
1369 | enddo |
---|
1370 | |
---|
1371 | if (is_master) then |
---|
1372 | print*,'In moistadj atmospheric energy change =',dEtot,' W m-2' |
---|
1373 | print*,'In moistadj MAX atmospheric energy change =',dtmoist_max*ptimestep,'K/step' |
---|
1374 | print*,'In moistadj MIN atmospheric energy change =',dtmoist_min*ptimestep,'K/step' |
---|
1375 | endif |
---|
1376 | |
---|
1377 | call planetwide_sumval(massarea(:,:)*dqmoist(:,:,igcm_h2o_vap)*ptimestep/totarea_planet+ & |
---|
1378 | massarea(:,:)*dqmoist(:,:,igcm_h2o_ice)*ptimestep/totarea_planet,dWtot) |
---|
1379 | if (is_master) print*,'In moistadj atmospheric water change =',dWtot,' kg m-2' |
---|
1380 | |
---|
1381 | endif ! end of 'enertest' |
---|
1382 | endif ! end of '.not.calltherm' |
---|
1383 | |
---|
1384 | ! Large scale condensation/evaporation. |
---|
1385 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
1386 | call largescale(ngrid,nlayer,nq,ptimestep,pplev,pplay,pt,pq,pdt,pdq,dtlscale,dqvaplscale,dqcldlscale,rneb_lsc) |
---|
1387 | |
---|
1388 | pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)+dtlscale(1:ngrid,1:nlayer) |
---|
1389 | pdq(1:ngrid,1:nlayer,igcm_h2o_vap) = pdq(1:ngrid,1:nlayer,igcm_h2o_vap)+dqvaplscale(1:ngrid,1:nlayer) |
---|
1390 | pdq(1:ngrid,1:nlayer,igcm_h2o_ice) = pdq(1:ngrid,1:nlayer,igcm_h2o_ice)+dqcldlscale(1:ngrid,1:nlayer) |
---|
1391 | |
---|
1392 | ! Test energy conservation. |
---|
1393 | if(enertest)then |
---|
1394 | lscaledEz(:,:) = cpp*mass(:,:)*dtlscale(:,:) |
---|
1395 | do ig=1,ngrid |
---|
1396 | lscaledE(ig) = cpp*SUM(mass(:,:)*dtlscale(:,:)) |
---|
1397 | enddo |
---|
1398 | call planetwide_sumval(cpp*massarea(:,:)*dtlscale(:,:)/totarea_planet,dEtot) |
---|
1399 | |
---|
1400 | if (is_master) print*,'In largescale atmospheric energy change =',dEtot,' W m-2' |
---|
1401 | |
---|
1402 | ! Test water conservation. |
---|
1403 | call planetwide_sumval(massarea(:,:)*dqvaplscale(:,:)*ptimestep/totarea_planet+ & |
---|
1404 | SUM(massarea(:,:)*dqcldlscale(:,:))*ptimestep/totarea_planet,dWtot) |
---|
1405 | |
---|
1406 | if (is_master) print*,'In largescale atmospheric water change =',dWtot,' kg m-2' |
---|
1407 | endif ! end of 'enertest' |
---|
1408 | |
---|
1409 | ! Compute cloud fraction. |
---|
1410 | do l = 1, nlayer |
---|
1411 | do ig=1,ngrid |
---|
1412 | cloudfrac(ig,l)=MAX(rneb_lsc(ig,l),rneb_man(ig,l)) |
---|
1413 | enddo |
---|
1414 | enddo |
---|
1415 | |
---|
1416 | endif ! end of 'watercond' |
---|
1417 | |
---|
1418 | ! Water ice / liquid precipitation. |
---|
1419 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
1420 | zdqrain(1:ngrid,1:nlayer,1:nq) = 0.0 !JL18 need to do that everytimestep if mass redis is on. |
---|
1421 | |
---|
1422 | if(waterrain)then |
---|
1423 | |
---|
1424 | zdqsrain(1:ngrid) = 0.0 |
---|
1425 | zdqssnow(1:ngrid) = 0.0 |
---|
1426 | |
---|
1427 | call rain(ngrid,nlayer,nq,ptimestep,pplev,pplay,pt,pdt,pq,pdq, & |
---|
1428 | zdtrain,zdqrain,zdqsrain,zdqssnow,reevap_precip,cloudfrac) |
---|
1429 | |
---|
1430 | pdq(1:ngrid,1:nlayer,igcm_h2o_vap) = pdq(1:ngrid,1:nlayer,igcm_h2o_vap) & |
---|
1431 | + zdqrain(1:ngrid,1:nlayer,igcm_h2o_vap) |
---|
1432 | pdq(1:ngrid,1:nlayer,igcm_h2o_ice) = pdq(1:ngrid,1:nlayer,igcm_h2o_ice) & |
---|
1433 | + zdqrain(1:ngrid,1:nlayer,igcm_h2o_ice) |
---|
1434 | pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)+zdtrain(1:ngrid,1:nlayer) |
---|
1435 | |
---|
1436 | dqsurf(1:ngrid,igcm_h2o_vap) = dqsurf(1:ngrid,igcm_h2o_vap)+zdqsrain(1:ngrid) |
---|
1437 | dqsurf(1:ngrid,igcm_h2o_ice) = dqsurf(1:ngrid,igcm_h2o_ice)+zdqssnow(1:ngrid) |
---|
1438 | |
---|
1439 | ! Test energy conservation. |
---|
1440 | if(enertest)then |
---|
1441 | |
---|
1442 | call planetwide_sumval(cpp*massarea(:,:)*zdtrain(:,:)/totarea_planet,dEtot) |
---|
1443 | if (is_master) print*,'In rain atmospheric T energy change =',dEtot,' W m-2' |
---|
1444 | call planetwide_sumval(massarea(:,:)*zdqrain(:,:,igcm_h2o_ice)/totarea_planet*RLVTT/cpp,dItot_tmp) |
---|
1445 | call planetwide_sumval(cell_area(:)*zdqssnow(:)/totarea_planet*RLVTT/cpp,dItot) |
---|
1446 | dItot = dItot + dItot_tmp |
---|
1447 | call planetwide_sumval(massarea(:,:)*zdqrain(:,:,igcm_h2o_vap)*ptimestep/totarea_planet,dVtot_tmp) |
---|
1448 | call planetwide_sumval(cell_area(:)*zdqsrain(:)/totarea_planet*RLVTT/cpp,dVtot) |
---|
1449 | dVtot = dVtot + dVtot_tmp |
---|
1450 | dEtot = dItot + dVtot |
---|
1451 | |
---|
1452 | if (is_master) then |
---|
1453 | print*,'In rain dItot =',dItot,' W m-2' |
---|
1454 | print*,'In rain dVtot =',dVtot,' W m-2' |
---|
1455 | print*,'In rain atmospheric L energy change =',dEtot,' W m-2' |
---|
1456 | endif |
---|
1457 | |
---|
1458 | ! Test water conservation |
---|
1459 | call planetwide_sumval(massarea(:,:)*zdqrain(:,:,igcm_h2o_vap)*ptimestep/totarea_planet+ & |
---|
1460 | massarea(:,:)*zdqrain(:,:,igcm_h2o_ice)*ptimestep/totarea_planet,dWtot) |
---|
1461 | call planetwide_sumval((zdqsrain(:)+zdqssnow(:))*cell_area(:)*ptimestep/totarea_planet,dWtots) |
---|
1462 | |
---|
1463 | if (is_master) then |
---|
1464 | print*,'In rain atmospheric water change =',dWtot,' kg m-2' |
---|
1465 | print*,'In rain surface water change =',dWtots,' kg m-2' |
---|
1466 | print*,'In rain non-cons factor =',dWtot+dWtots,' kg m-2' |
---|
1467 | endif |
---|
1468 | |
---|
1469 | endif ! end of 'enertest' |
---|
1470 | |
---|
1471 | end if ! enf of 'waterrain' |
---|
1472 | |
---|
1473 | end if ! end of 'water' |
---|
1474 | |
---|
1475 | ! ------------------------- |
---|
1476 | ! VI.2. Photochemistry |
---|
1477 | ! ------------------------- |
---|
1478 | |
---|
1479 | #ifndef MESOSCALE |
---|
1480 | IF (photochem) then |
---|
1481 | |
---|
1482 | DO ig=1,ngrid |
---|
1483 | array_zero1(ig)=0.0 |
---|
1484 | DO l=1,nlayer |
---|
1485 | array_zero2(ig,l)=0. |
---|
1486 | ENDDO |
---|
1487 | ENDDO |
---|
1488 | |
---|
1489 | call calchim_asis(ngrid,nlayer,nq, & |
---|
1490 | ptimestep,pplay,pplev,pt,pdt,dist_star,mu0, & |
---|
1491 | fract,zzlev,zzlay,zday,pq,pdq,zdqchim,zdqschim, & |
---|
1492 | array_zero1,array_zero1, & |
---|
1493 | pu,pdu,pv,pdv,array_zero2,array_zero2,icount,zdtchim) |
---|
1494 | |
---|
1495 | ! increment values of tracers: |
---|
1496 | iesp = 0 |
---|
1497 | DO iq=1,nq ! loop on all tracers; tendencies for non-chemistry |
---|
1498 | ! tracers is zero anyways |
---|
1499 | ! September 2020: flag is_chim to increment only on chemical species |
---|
1500 | IF (is_chim(iq)==1) THEN |
---|
1501 | iesp = iesp + 1 |
---|
1502 | DO l=1,nlayer |
---|
1503 | DO ig=1,ngrid |
---|
1504 | pdq(ig,l,iq)=pdq(ig,l,iq)+zdqchim(ig,l,iesp) |
---|
1505 | ENDDO |
---|
1506 | ENDDO |
---|
1507 | ENDIF |
---|
1508 | ENDDO ! of DO iq=1,nq |
---|
1509 | |
---|
1510 | |
---|
1511 | ! increment surface values of tracers: |
---|
1512 | DO iq=1,nq ! loop on all tracers; tendencies for non-chemistry |
---|
1513 | ! tracers is zero anyways |
---|
1514 | DO ig=1,ngrid |
---|
1515 | ! dqsurf(ig,iq)=dqsurf(ig,iq)+zdqschim(ig,iq) |
---|
1516 | ENDDO |
---|
1517 | ENDDO ! of DO iq=1,nq |
---|
1518 | |
---|
1519 | ! increment values of temperature: |
---|
1520 | pdt(1:ngrid,1:nlayer)=pdt(1:ngrid,1:nlayer)+zdtchim(1:ngrid,1:nlayer) |
---|
1521 | |
---|
1522 | END IF ! of IF (photochem) |
---|
1523 | #endif |
---|
1524 | |
---|
1525 | |
---|
1526 | ! ------------------------- |
---|
1527 | ! VI.3. Aerosol particles |
---|
1528 | ! ------------------------- |
---|
1529 | |
---|
1530 | ! Sedimentation. |
---|
1531 | if (sedimentation) then |
---|
1532 | |
---|
1533 | zdqsed(1:ngrid,1:nlayer,1:nq) = 0.0 |
---|
1534 | zdqssed(1:ngrid,1:nq) = 0.0 |
---|
1535 | |
---|
1536 | if(watertest)then |
---|
1537 | |
---|
1538 | iq=igcm_h2o_ice |
---|
1539 | call planetwide_sumval(massarea(:,:)*pq(:,:,iq)*ptimestep/totarea_planet,dWtot) |
---|
1540 | call planetwide_sumval(massarea(:,:)*pdq(:,:,iq)*ptimestep/totarea_planet,dWtots) |
---|
1541 | if (is_master) then |
---|
1542 | print*,'Before sedim pq =',dWtot,' kg m-2' |
---|
1543 | print*,'Before sedim pdq =',dWtots,' kg m-2' |
---|
1544 | endif |
---|
1545 | endif |
---|
1546 | |
---|
1547 | call callsedim(ngrid,nlayer,ptimestep, & |
---|
1548 | pplev,zzlev,pt,pdt,pq,pdq, & |
---|
1549 | zdqsed,zdqssed,nq) |
---|
1550 | |
---|
1551 | if(watertest)then |
---|
1552 | iq=igcm_h2o_ice |
---|
1553 | call planetwide_sumval(massarea(:,:)*pq(:,:,iq)*ptimestep/totarea_planet,dWtot) |
---|
1554 | call planetwide_sumval(massarea(:,:)*pdq(:,:,iq)*ptimestep/totarea_planet,dWtots) |
---|
1555 | if (is_master) then |
---|
1556 | print*,'After sedim pq =',dWtot,' kg m-2' |
---|
1557 | print*,'After sedim pdq =',dWtots,' kg m-2' |
---|
1558 | endif |
---|
1559 | endif |
---|
1560 | |
---|
1561 | ! Whether it falls as rain or snow depends only on the surface temperature |
---|
1562 | pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq) + zdqsed(1:ngrid,1:nlayer,1:nq) |
---|
1563 | dqsurf(1:ngrid,1:nq) = dqsurf(1:ngrid,1:nq) + zdqssed(1:ngrid,1:nq) |
---|
1564 | |
---|
1565 | ! Test water conservation |
---|
1566 | if(watertest)then |
---|
1567 | call planetwide_sumval(massarea(:,:)*(zdqsed(:,:,igcm_h2o_vap)+zdqsed(:,:,igcm_h2o_ice))*ptimestep/totarea_planet,dWtot) |
---|
1568 | call planetwide_sumval((zdqssed(:,igcm_h2o_vap)+zdqssed(:,igcm_h2o_ice))*cell_area(:)*ptimestep/totarea_planet,dWtots) |
---|
1569 | if (is_master) then |
---|
1570 | print*,'In sedim atmospheric ice change =',dWtot,' kg m-2' |
---|
1571 | print*,'In sedim surface ice change =',dWtots,' kg m-2' |
---|
1572 | print*,'In sedim non-cons factor =',dWtot+dWtots,' kg m-2' |
---|
1573 | endif |
---|
1574 | endif |
---|
1575 | |
---|
1576 | end if ! end of 'sedimentation' |
---|
1577 | |
---|
1578 | |
---|
1579 | ! --------------- |
---|
1580 | ! VI.4. Updates |
---|
1581 | ! --------------- |
---|
1582 | |
---|
1583 | ! Updating Atmospheric Mass and Tracers budgets. |
---|
1584 | if(mass_redistrib) then |
---|
1585 | |
---|
1586 | zdmassmr(1:ngrid,1:nlayer) = mass(1:ngrid,1:nlayer) * & |
---|
1587 | ( zdqevap(1:ngrid,1:nlayer) & |
---|
1588 | + zdqrain(1:ngrid,1:nlayer,igcm_h2o_vap) & |
---|
1589 | + dqmoist(1:ngrid,1:nlayer,igcm_h2o_vap) & |
---|
1590 | + dqvaplscale(1:ngrid,1:nlayer) ) |
---|
1591 | |
---|
1592 | do ig = 1, ngrid |
---|
1593 | zdmassmr_col(ig)=SUM(zdmassmr(ig,1:nlayer)) |
---|
1594 | enddo |
---|
1595 | |
---|
1596 | call writediagfi(ngrid,"mass_evap","mass gain"," ",3,zdmassmr) |
---|
1597 | call writediagfi(ngrid,"mass_evap_col","mass gain col"," ",2,zdmassmr_col) |
---|
1598 | call writediagfi(ngrid,"mass","mass","kg/m2",3,mass) |
---|
1599 | |
---|
1600 | call mass_redistribution(ngrid,nlayer,nq,ptimestep, & |
---|
1601 | rnat,capcal,pplay,pplev,pt,tsurf,pq,qsurf, & |
---|
1602 | pu,pv,pdt,zdtsurf,pdq,pdu,pdv,zdmassmr, & |
---|
1603 | zdtmr,zdtsurfmr,zdpsrfmr,zdumr,zdvmr,zdqmr,zdqsurfmr) |
---|
1604 | |
---|
1605 | pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq) + zdqmr(1:ngrid,1:nlayer,1:nq) |
---|
1606 | dqsurf(1:ngrid,1:nq) = dqsurf(1:ngrid,1:nq) + zdqsurfmr(1:ngrid,1:nq) |
---|
1607 | pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer) + zdtmr(1:ngrid,1:nlayer) |
---|
1608 | pdu(1:ngrid,1:nlayer) = pdu(1:ngrid,1:nlayer) + zdumr(1:ngrid,1:nlayer) |
---|
1609 | pdv(1:ngrid,1:nlayer) = pdv(1:ngrid,1:nlayer) + zdvmr(1:ngrid,1:nlayer) |
---|
1610 | pdpsrf(1:ngrid) = pdpsrf(1:ngrid) + zdpsrfmr(1:ngrid) |
---|
1611 | zdtsurf(1:ngrid) = zdtsurf(1:ngrid) + zdtsurfmr(1:ngrid) |
---|
1612 | |
---|
1613 | endif |
---|
1614 | |
---|
1615 | ! ------------------ |
---|
1616 | ! VI.5. Slab Ocean |
---|
1617 | ! ------------------ |
---|
1618 | |
---|
1619 | if (ok_slab_ocean)then |
---|
1620 | |
---|
1621 | do ig=1,ngrid |
---|
1622 | qsurfint(:,igcm_h2o_ice)=qsurf(:,igcm_h2o_ice) |
---|
1623 | enddo |
---|
1624 | |
---|
1625 | call ocean_slab_ice(ptimestep, & |
---|
1626 | ngrid, knindex, tsea_ice, fluxrad, & |
---|
1627 | zdqssnow, qsurf(:,igcm_h2o_ice), & |
---|
1628 | - zdqsdif(:,igcm_h2o_vap), & |
---|
1629 | flux_sens_lat,tsea_ice, pctsrf_sic, & |
---|
1630 | taux,tauy,icount) |
---|
1631 | |
---|
1632 | |
---|
1633 | call ocean_slab_get_vars(ngrid,tslab, & |
---|
1634 | sea_ice, flux_o, & |
---|
1635 | flux_g, dt_hdiff, & |
---|
1636 | dt_ekman) |
---|
1637 | |
---|
1638 | do ig=1,ngrid |
---|
1639 | if (nint(rnat(ig)).eq.1)then |
---|
1640 | tslab(ig,1) = 0. |
---|
1641 | tslab(ig,2) = 0. |
---|
1642 | tsea_ice(ig) = 0. |
---|
1643 | sea_ice(ig) = 0. |
---|
1644 | pctsrf_sic(ig) = 0. |
---|
1645 | qsurf(ig,igcm_h2o_ice) = qsurfint(ig,igcm_h2o_ice) |
---|
1646 | endif |
---|
1647 | enddo |
---|
1648 | |
---|
1649 | endif ! end of 'ok_slab_ocean' |
---|
1650 | |
---|
1651 | ! ----------------------------- |
---|
1652 | ! VI.6. Surface Tracer Update |
---|
1653 | ! ----------------------------- |
---|
1654 | |
---|
1655 | if(hydrology)then |
---|
1656 | |
---|
1657 | call hydrol(ngrid,nq,ptimestep,rnat,tsurf,qsurf,dqsurf,dqs_hyd, & |
---|
1658 | capcal,albedo,albedo_bareground, & |
---|
1659 | albedo_snow_SPECTV,albedo_co2_ice_SPECTV, & |
---|
1660 | mu0,zdtsurf,zdtsurf_hyd,hice,pctsrf_sic, & |
---|
1661 | sea_ice) |
---|
1662 | |
---|
1663 | zdtsurf(1:ngrid) = zdtsurf(1:ngrid) + zdtsurf_hyd(1:ngrid) |
---|
1664 | dqsurf(1:ngrid,1:nq) = dqsurf(1:ngrid,1:nq) + dqs_hyd(1:ngrid,1:nq) |
---|
1665 | |
---|
1666 | qsurf(1:ngrid,1:nq) = qsurf(1:ngrid,1:nq) + ptimestep*dqsurf(1:ngrid,1:nq) |
---|
1667 | |
---|
1668 | ! Test energy conservation |
---|
1669 | if(enertest)then |
---|
1670 | call planetwide_sumval(cell_area(:)*capcal(:)*zdtsurf_hyd(:)/totarea_planet,dEtots) |
---|
1671 | if (is_master) print*,'In hydrol surface energy change =',dEtots,' W m-2' |
---|
1672 | endif |
---|
1673 | |
---|
1674 | ! test water conservation |
---|
1675 | if(watertest)then |
---|
1676 | call planetwide_sumval(dqs_hyd(:,igcm_h2o_ice)*cell_area(:)*ptimestep/totarea_planet,dWtots) |
---|
1677 | if (is_master) print*,'In hydrol surface ice change =',dWtots,' kg m-2' |
---|
1678 | call planetwide_sumval(dqs_hyd(:,igcm_h2o_vap)*cell_area(:)*ptimestep/totarea_planet,dWtots) |
---|
1679 | if (is_master) then |
---|
1680 | print*,'In hydrol surface water change =',dWtots,' kg m-2' |
---|
1681 | print*,'---------------------------------------------------------------' |
---|
1682 | endif |
---|
1683 | endif |
---|
1684 | |
---|
1685 | else ! of if (hydrology) |
---|
1686 | |
---|
1687 | qsurf(1:ngrid,1:nq) = qsurf(1:ngrid,1:nq) + ptimestep*dqsurf(1:ngrid,1:nq) |
---|
1688 | |
---|
1689 | end if ! of if (hydrology) |
---|
1690 | |
---|
1691 | ! Add qsurf to qsurf_hist, which is what we save in diagfi.nc. At the same time, we set the water |
---|
1692 | ! content of ocean gridpoints back to zero, in order to avoid rounding errors in vdifc, rain. |
---|
1693 | qsurf_hist(:,:) = qsurf(:,:) |
---|
1694 | |
---|
1695 | if(ice_update)then |
---|
1696 | ice_min(1:ngrid)=min(ice_min(1:ngrid),qsurf(1:ngrid,igcm_h2o_ice)) |
---|
1697 | endif |
---|
1698 | |
---|
1699 | endif! end of if 'tracer' |
---|
1700 | |
---|
1701 | |
---|
1702 | !------------------------------------------------ |
---|
1703 | ! VII. Surface and sub-surface soil temperature |
---|
1704 | !------------------------------------------------ |
---|
1705 | |
---|
1706 | |
---|
1707 | ! Increment surface temperature |
---|
1708 | if(ok_slab_ocean)then |
---|
1709 | do ig=1,ngrid |
---|
1710 | if (nint(rnat(ig)).eq.0)then |
---|
1711 | zdtsurf(ig)= (tslab(ig,1) & |
---|
1712 | + pctsrf_sic(ig)*(tsea_ice(ig)-tslab(ig,1))-tsurf(ig))/ptimestep |
---|
1713 | endif |
---|
1714 | tsurf(ig)=tsurf(ig)+ptimestep*zdtsurf(ig) |
---|
1715 | enddo |
---|
1716 | |
---|
1717 | else |
---|
1718 | tsurf(1:ngrid)=tsurf(1:ngrid)+ptimestep*zdtsurf(1:ngrid) |
---|
1719 | endif ! end of 'ok_slab_ocean' |
---|
1720 | |
---|
1721 | |
---|
1722 | ! Compute soil temperatures and subsurface heat flux. |
---|
1723 | if (callsoil) then |
---|
1724 | call soil(ngrid,nsoilmx,.false.,lastcall,inertiedat, & |
---|
1725 | ptimestep,tsurf,tsoil,capcal,fluxgrd) |
---|
1726 | endif |
---|
1727 | |
---|
1728 | |
---|
1729 | if (ok_slab_ocean) then |
---|
1730 | |
---|
1731 | do ig=1,ngrid |
---|
1732 | |
---|
1733 | fluxgrdocean(ig)=fluxgrd(ig) |
---|
1734 | if (nint(rnat(ig)).eq.0) then |
---|
1735 | capcal(ig)=capcalocean |
---|
1736 | fluxgrd(ig)=0. |
---|
1737 | fluxgrdocean(ig)=pctsrf_sic(ig)*flux_g(ig)+(1-pctsrf_sic(ig))*(dt_hdiff(ig,1)+dt_ekman(ig,1)) |
---|
1738 | do iq=1,nsoilmx |
---|
1739 | tsoil(ig,iq)=tsurf(ig) |
---|
1740 | enddo |
---|
1741 | if (pctsrf_sic(ig).gt.0.5) then |
---|
1742 | capcal(ig)=capcalseaice |
---|
1743 | if (qsurf(ig,igcm_h2o_ice).gt.0.) then |
---|
1744 | capcal(ig)=capcalsno |
---|
1745 | endif |
---|
1746 | endif |
---|
1747 | endif |
---|
1748 | |
---|
1749 | enddo |
---|
1750 | |
---|
1751 | endif !end of 'ok_slab_ocean' |
---|
1752 | |
---|
1753 | |
---|
1754 | ! Test energy conservation |
---|
1755 | if(enertest)then |
---|
1756 | call planetwide_sumval(cell_area(:)*capcal(:)*zdtsurf(:)/totarea_planet,dEtots) |
---|
1757 | if (is_master) print*,'Surface energy change =',dEtots,' W m-2' |
---|
1758 | endif |
---|
1759 | |
---|
1760 | |
---|
1761 | !--------------------------------------------------- |
---|
1762 | ! VIII. Perform diagnostics and write output files |
---|
1763 | !--------------------------------------------------- |
---|
1764 | |
---|
1765 | ! Note : For output only: the actual model integration is performed in the dynamics. |
---|
1766 | |
---|
1767 | |
---|
1768 | |
---|
1769 | ! Temperature, zonal and meridional winds. |
---|
1770 | zt(1:ngrid,1:nlayer) = pt(1:ngrid,1:nlayer) + pdt(1:ngrid,1:nlayer)*ptimestep |
---|
1771 | zu(1:ngrid,1:nlayer) = pu(1:ngrid,1:nlayer) + pdu(1:ngrid,1:nlayer)*ptimestep |
---|
1772 | zv(1:ngrid,1:nlayer) = pv(1:ngrid,1:nlayer) + pdv(1:ngrid,1:nlayer)*ptimestep |
---|
1773 | |
---|
1774 | ! Recast thermal plume vertical velocity array for outputs |
---|
1775 | IF (calltherm) THEN |
---|
1776 | DO ig=1,ngrid |
---|
1777 | DO l=1,nlayer |
---|
1778 | zw2_bis(ig,l) = zw2(ig,l) |
---|
1779 | fm_bis(ig,l) = fm(ig,l) |
---|
1780 | ENDDO |
---|
1781 | ENDDO |
---|
1782 | ENDIF |
---|
1783 | |
---|
1784 | ! Diagnostic. |
---|
1785 | zdtdyn(1:ngrid,1:nlayer) = (pt(1:ngrid,1:nlayer)-ztprevious(1:ngrid,1:nlayer)) / ptimestep |
---|
1786 | ztprevious(1:ngrid,1:nlayer) = zt(1:ngrid,1:nlayer) |
---|
1787 | |
---|
1788 | zdudyn(1:ngrid,1:nlayer) = (pu(1:ngrid,1:nlayer)-zuprevious(1:ngrid,1:nlayer)) / ptimestep |
---|
1789 | zuprevious(1:ngrid,1:nlayer) = zu(1:ngrid,1:nlayer) |
---|
1790 | |
---|
1791 | if(firstcall)then |
---|
1792 | zdtdyn(1:ngrid,1:nlayer)=0.0 |
---|
1793 | zdudyn(1:ngrid,1:nlayer)=0.0 |
---|
1794 | endif |
---|
1795 | |
---|
1796 | ! Dynamical heating diagnostic. |
---|
1797 | do ig=1,ngrid |
---|
1798 | fluxdyn(ig)= SUM(zdtdyn(ig,:) *mass(ig,:))*cpp |
---|
1799 | enddo |
---|
1800 | |
---|
1801 | ! Tracers. |
---|
1802 | zq(1:ngrid,1:nlayer,1:nq) = pq(1:ngrid,1:nlayer,1:nq) + pdq(1:ngrid,1:nlayer,1:nq)*ptimestep |
---|
1803 | |
---|
1804 | ! Surface pressure. |
---|
1805 | ps(1:ngrid) = pplev(1:ngrid,1) + pdpsrf(1:ngrid)*ptimestep |
---|
1806 | |
---|
1807 | |
---|
1808 | |
---|
1809 | ! Surface and soil temperature information |
---|
1810 | call planetwide_sumval(cell_area(:)*tsurf(:)/totarea_planet,Ts1) |
---|
1811 | call planetwide_minval(tsurf(:),Ts2) |
---|
1812 | call planetwide_maxval(tsurf(:),Ts3) |
---|
1813 | if(callsoil)then |
---|
1814 | TsS = SUM(cell_area(:)*tsoil(:,nsoilmx))/totarea ! mean temperature at bottom soil layer |
---|
1815 | if (is_master) then |
---|
1816 | print*,' ave[Tsurf] min[Tsurf] max[Tsurf] ave[Tdeep]' |
---|
1817 | print*,Ts1,Ts2,Ts3,TsS |
---|
1818 | end if |
---|
1819 | else |
---|
1820 | if (is_master) then |
---|
1821 | print*,' ave[Tsurf] min[Tsurf] max[Tsurf]' |
---|
1822 | print*,Ts1,Ts2,Ts3 |
---|
1823 | endif |
---|
1824 | end if |
---|
1825 | |
---|
1826 | |
---|
1827 | ! Check the energy balance of the simulation during the run |
---|
1828 | if(corrk)then |
---|
1829 | |
---|
1830 | call planetwide_sumval(cell_area(:)*fluxtop_dn(:)/totarea_planet,ISR) |
---|
1831 | call planetwide_sumval(cell_area(:)*fluxabs_sw(:)/totarea_planet,ASR) |
---|
1832 | call planetwide_sumval(cell_area(:)*fluxtop_lw(:)/totarea_planet,OLR) |
---|
1833 | call planetwide_sumval(cell_area(:)*fluxgrd(:)/totarea_planet,GND) |
---|
1834 | call planetwide_sumval(cell_area(:)*fluxdyn(:)/totarea_planet,DYN) |
---|
1835 | do ig=1,ngrid |
---|
1836 | if(fluxtop_dn(ig).lt.0.0)then |
---|
1837 | print*,'fluxtop_dn has gone crazy' |
---|
1838 | print*,'fluxtop_dn=',fluxtop_dn(ig) |
---|
1839 | print*,'tau_col=',tau_col(ig) |
---|
1840 | print*,'aerosol=',aerosol(ig,:,:) |
---|
1841 | print*,'temp= ',pt(ig,:) |
---|
1842 | print*,'pplay= ',pplay(ig,:) |
---|
1843 | call abort |
---|
1844 | endif |
---|
1845 | end do |
---|
1846 | |
---|
1847 | if(ngrid.eq.1)then |
---|
1848 | DYN=0.0 |
---|
1849 | endif |
---|
1850 | |
---|
1851 | if (is_master) then |
---|
1852 | print*,' ISR ASR OLR GND DYN [W m^-2]' |
---|
1853 | print*, ISR,ASR,OLR,GND,DYN |
---|
1854 | endif |
---|
1855 | |
---|
1856 | if(enertest .and. is_master)then |
---|
1857 | print*,'SW flux/heating difference SW++ - ASR = ',dEtotSW+dEtotsSW-ASR,' W m-2' |
---|
1858 | print*,'LW flux/heating difference LW++ - OLR = ',dEtotLW+dEtotsLW+OLR,' W m-2' |
---|
1859 | print*,'LW energy balance LW++ + ASR = ',dEtotLW+dEtotsLW+ASR,' W m-2' |
---|
1860 | endif |
---|
1861 | |
---|
1862 | if(meanOLR .and. is_master)then |
---|
1863 | if((ngrid.gt.1) .or. (mod(icount-1,ecritphy).eq.0))then |
---|
1864 | ! to record global radiative balance |
---|
1865 | open(92,file="rad_bal.out",form='formatted',position='append') |
---|
1866 | write(92,*) zday,ISR,ASR,OLR |
---|
1867 | close(92) |
---|
1868 | open(93,file="tem_bal.out",form='formatted',position='append') |
---|
1869 | if(callsoil)then |
---|
1870 | write(93,*) zday,Ts1,Ts2,Ts3,TsS |
---|
1871 | else |
---|
1872 | write(93,*) zday,Ts1,Ts2,Ts3 |
---|
1873 | endif |
---|
1874 | close(93) |
---|
1875 | endif |
---|
1876 | endif |
---|
1877 | |
---|
1878 | endif ! end of 'corrk' |
---|
1879 | |
---|
1880 | |
---|
1881 | ! Diagnostic to test radiative-convective timescales in code. |
---|
1882 | if(testradtimes)then |
---|
1883 | open(38,file="tau_phys.out",form='formatted',position='append') |
---|
1884 | ig=1 |
---|
1885 | do l=1,nlayer |
---|
1886 | write(38,*) -1./pdt(ig,l),pt(ig,l),pplay(ig,l) |
---|
1887 | enddo |
---|
1888 | close(38) |
---|
1889 | print*,'As testradtimes enabled,' |
---|
1890 | print*,'exiting physics on first call' |
---|
1891 | call abort |
---|
1892 | endif |
---|
1893 | |
---|
1894 | |
---|
1895 | ! Compute column amounts (kg m-2) if tracers are enabled. |
---|
1896 | if(tracer)then |
---|
1897 | qcol(1:ngrid,1:nq)=0.0 |
---|
1898 | do iq=1,nq |
---|
1899 | do ig=1,ngrid |
---|
1900 | qcol(ig,iq) = SUM( zq(ig,1:nlayer,iq) * mass(ig,1:nlayer)) |
---|
1901 | enddo |
---|
1902 | enddo |
---|
1903 | |
---|
1904 | ! Generalised for arbitrary aerosols now. By LK |
---|
1905 | reffcol(1:ngrid,1:naerkind)=0.0 |
---|
1906 | if(co2cond.and.(iaero_co2.ne.0))then |
---|
1907 | call co2_reffrad(ngrid,nlayer,nq,zq,reffrad(1,1,iaero_co2)) |
---|
1908 | do ig=1,ngrid |
---|
1909 | reffcol(ig,iaero_co2) = SUM(zq(ig,1:nlayer,igcm_co2_ice)*reffrad(ig,1:nlayer,iaero_co2)*mass(ig,1:nlayer)) |
---|
1910 | enddo |
---|
1911 | endif |
---|
1912 | if(water.and.(iaero_h2o.ne.0))then |
---|
1913 | call h2o_reffrad(ngrid,nlayer,zq(1,1,igcm_h2o_ice),zt, & |
---|
1914 | reffrad(1,1,iaero_h2o),nueffrad(1,1,iaero_h2o)) |
---|
1915 | do ig=1,ngrid |
---|
1916 | reffcol(ig,iaero_h2o) = SUM(zq(ig,1:nlayer,igcm_h2o_ice)*reffrad(ig,1:nlayer,iaero_h2o)*mass(ig,1:nlayer)) |
---|
1917 | enddo |
---|
1918 | endif |
---|
1919 | |
---|
1920 | endif ! end of 'tracer' |
---|
1921 | |
---|
1922 | |
---|
1923 | ! Test for water conservation. |
---|
1924 | if(water)then |
---|
1925 | |
---|
1926 | call planetwide_sumval(cell_area(:)*qsurf_hist(:,igcm_h2o_ice)/totarea_planet,icesrf) |
---|
1927 | call planetwide_sumval(cell_area(:)*qsurf_hist(:,igcm_h2o_vap)/totarea_planet,liqsrf) |
---|
1928 | call planetwide_sumval(cell_area(:)*qcol(:,igcm_h2o_ice)/totarea_planet,icecol) |
---|
1929 | call planetwide_sumval(cell_area(:)*qcol(:,igcm_h2o_vap)/totarea_planet,vapcol) |
---|
1930 | |
---|
1931 | h2otot = icesrf + liqsrf + icecol + vapcol |
---|
1932 | |
---|
1933 | if (is_master) then |
---|
1934 | print*,' Total water amount [kg m^-2]: ',h2otot |
---|
1935 | print*,' Surface ice Surface liq. Atmos. con. Atmos. vap. [kg m^-2] ' |
---|
1936 | print*, icesrf,liqsrf,icecol,vapcol |
---|
1937 | endif |
---|
1938 | |
---|
1939 | if(meanOLR .and. is_master)then |
---|
1940 | if((ngrid.gt.1) .or. (mod(icount-1,ecritphy).eq.0))then |
---|
1941 | ! to record global water balance |
---|
1942 | open(98,file="h2o_bal.out",form='formatted',position='append') |
---|
1943 | write(98,*) zday,icesrf,liqsrf,icecol,vapcol |
---|
1944 | close(98) |
---|
1945 | endif |
---|
1946 | endif |
---|
1947 | |
---|
1948 | endif |
---|
1949 | |
---|
1950 | |
---|
1951 | ! Calculate RH (Relative Humidity) for diagnostic. |
---|
1952 | if(water)then |
---|
1953 | |
---|
1954 | do l = 1, nlayer |
---|
1955 | do ig=1,ngrid |
---|
1956 | call Psat_water(zt(ig,l),pplay(ig,l),psat_tmp,qsat(ig,l)) |
---|
1957 | RH(ig,l) = zq(ig,l,igcm_h2o_vap) / qsat(ig,l) |
---|
1958 | enddo |
---|
1959 | enddo |
---|
1960 | |
---|
1961 | ! Compute maximum possible H2O column amount (100% saturation). |
---|
1962 | do ig=1,ngrid |
---|
1963 | H2Omaxcol(ig) = SUM( qsat(ig,:) * mass(ig,:)) |
---|
1964 | enddo |
---|
1965 | |
---|
1966 | endif ! end of 'water' |
---|
1967 | |
---|
1968 | |
---|
1969 | if (is_master) print*,'--> Ls =',zls*180./pi |
---|
1970 | |
---|
1971 | |
---|
1972 | !---------------------------------------------------------------------- |
---|
1973 | ! Writing NetCDF file "RESTARTFI" at the end of the run |
---|
1974 | !---------------------------------------------------------------------- |
---|
1975 | |
---|
1976 | ! Note: 'restartfi' is stored just before dynamics are stored |
---|
1977 | ! in 'restart'. Between now and the writting of 'restart', |
---|
1978 | ! there will have been the itau=itau+1 instruction and |
---|
1979 | ! a reset of 'time' (lastacll = .true. when itau+1= itaufin) |
---|
1980 | ! thus we store for time=time+dtvr |
---|
1981 | |
---|
1982 | |
---|
1983 | |
---|
1984 | if(lastcall) then |
---|
1985 | ztime_fin = ptime + ptimestep/(float(iphysiq)*daysec) |
---|
1986 | |
---|
1987 | ! Update surface ice distribution to iterate to steady state if requested |
---|
1988 | if(ice_update)then |
---|
1989 | |
---|
1990 | do ig=1,ngrid |
---|
1991 | |
---|
1992 | delta_ice = (qsurf(ig,igcm_h2o_ice)-ice_initial(ig)) |
---|
1993 | |
---|
1994 | ! add multiple years of evolution |
---|
1995 | qsurf_hist(ig,igcm_h2o_ice) = qsurf_hist(ig,igcm_h2o_ice) + delta_ice*icetstep |
---|
1996 | |
---|
1997 | ! if ice has gone -ve, set to zero |
---|
1998 | if(qsurf_hist(ig,igcm_h2o_ice).lt.0.0)then |
---|
1999 | qsurf_hist(ig,igcm_h2o_ice) = 0.0 |
---|
2000 | endif |
---|
2001 | |
---|
2002 | ! if ice is seasonal, set to zero (NEW) |
---|
2003 | if(ice_min(ig).lt.0.01)then |
---|
2004 | qsurf_hist(ig,igcm_h2o_ice) = 0.0 |
---|
2005 | endif |
---|
2006 | |
---|
2007 | enddo |
---|
2008 | |
---|
2009 | ! enforce ice conservation |
---|
2010 | ice_tot= SUM(qsurf_hist(:,igcm_h2o_ice)*cell_area(:) )/SUM(cell_area(:)) |
---|
2011 | qsurf_hist(:,igcm_h2o_ice) = qsurf_hist(:,igcm_h2o_ice)*(icesrf/ice_tot) |
---|
2012 | |
---|
2013 | endif |
---|
2014 | #ifndef MESOSCALE |
---|
2015 | |
---|
2016 | if (ngrid.ne.1) then |
---|
2017 | write(*,*)'PHYSIQ: for physdem ztime_fin =',ztime_fin |
---|
2018 | |
---|
2019 | call physdem1("restartfi.nc",nsoilmx,ngrid,nlayer,nq, & |
---|
2020 | ptimestep,ztime_fin, & |
---|
2021 | tsurf,tsoil,emis,q2,qsurf_hist, & |
---|
2022 | cloudfrac,totcloudfrac,hice, & |
---|
2023 | rnat,pctsrf_sic,tslab,tsea_ice,sea_ice) |
---|
2024 | endif |
---|
2025 | #endif |
---|
2026 | if(ok_slab_ocean) then |
---|
2027 | call ocean_slab_final!(tslab, seaice) |
---|
2028 | end if |
---|
2029 | |
---|
2030 | endif ! end of 'lastcall' |
---|
2031 | |
---|
2032 | |
---|
2033 | !----------------------------------- |
---|
2034 | ! Saving statistics : |
---|
2035 | !----------------------------------- |
---|
2036 | |
---|
2037 | ! Note :("stats" stores and accumulates 8 key variables in file "stats.nc" |
---|
2038 | ! which can later be used to make the statistic files of the run: |
---|
2039 | ! "stats") only possible in 3D runs !!! |
---|
2040 | |
---|
2041 | |
---|
2042 | if (callstats) then |
---|
2043 | |
---|
2044 | call wstats(ngrid,"ps","Surface pressure","Pa",2,ps) |
---|
2045 | call wstats(ngrid,"tsurf","Surface temperature","K",2,tsurf) |
---|
2046 | call wstats(ngrid,"fluxsurf_lw", & |
---|
2047 | "Thermal IR radiative flux to surface","W.m-2",2, & |
---|
2048 | fluxsurf_lw) |
---|
2049 | call wstats(ngrid,"fluxtop_lw", & |
---|
2050 | "Thermal IR radiative flux to space","W.m-2",2, & |
---|
2051 | fluxtop_lw) |
---|
2052 | |
---|
2053 | ! call wstats(ngrid,"fluxsurf_sw", & |
---|
2054 | ! "Solar radiative flux to surface","W.m-2",2, & |
---|
2055 | ! fluxsurf_sw_tot) |
---|
2056 | ! call wstats(ngrid,"fluxtop_sw", & |
---|
2057 | ! "Solar radiative flux to space","W.m-2",2, & |
---|
2058 | ! fluxtop_sw_tot) |
---|
2059 | |
---|
2060 | |
---|
2061 | call wstats(ngrid,"ISR","incoming stellar rad.","W m-2",2,fluxtop_dn) |
---|
2062 | call wstats(ngrid,"ASR","absorbed stellar rad.","W m-2",2,fluxabs_sw) |
---|
2063 | call wstats(ngrid,"OLR","outgoing longwave rad.","W m-2",2,fluxtop_lw) |
---|
2064 | !call wstats(ngrid,"ALB","Surface albedo"," ",2,albedo_equivalent) |
---|
2065 | !call wstats(ngrid,"ALB_1st","First Band Surface albedo"," ",2,albedo(:,1)) |
---|
2066 | call wstats(ngrid,"p","Pressure","Pa",3,pplay) |
---|
2067 | call wstats(ngrid,"temp","Atmospheric temperature","K",3,zt) |
---|
2068 | call wstats(ngrid,"u","Zonal (East-West) wind","m.s-1",3,zu) |
---|
2069 | call wstats(ngrid,"v","Meridional (North-South) wind","m.s-1",3,zv) |
---|
2070 | call wstats(ngrid,"w","Vertical (down-up) wind","m.s-1",3,pw) |
---|
2071 | call wstats(ngrid,"q2","Boundary layer eddy kinetic energy","m2.s-2",3,q2) |
---|
2072 | |
---|
2073 | if (tracer) then |
---|
2074 | do iq=1,nq |
---|
2075 | call wstats(ngrid,noms(iq),noms(iq),'kg/kg',3,zq(1,1,iq)) |
---|
2076 | call wstats(ngrid,trim(noms(iq))//'_surf',trim(noms(iq))//'_surf', & |
---|
2077 | 'kg m^-2',2,qsurf(1,iq) ) |
---|
2078 | call wstats(ngrid,trim(noms(iq))//'_col',trim(noms(iq))//'_col', & |
---|
2079 | 'kg m^-2',2,qcol(1,iq) ) |
---|
2080 | |
---|
2081 | ! call wstats(ngrid,trim(noms(iq))//'_reff', & |
---|
2082 | ! trim(noms(iq))//'_reff', & |
---|
2083 | ! 'm',3,reffrad(1,1,iq)) |
---|
2084 | |
---|
2085 | end do |
---|
2086 | |
---|
2087 | if (water) then |
---|
2088 | vmr=zq(1:ngrid,1:nlayer,igcm_h2o_vap)*mugaz/mmol(igcm_h2o_vap) |
---|
2089 | call wstats(ngrid,"vmr_h2ovapor", & |
---|
2090 | "H2O vapour volume mixing ratio","mol/mol", & |
---|
2091 | 3,vmr) |
---|
2092 | endif |
---|
2093 | |
---|
2094 | endif ! end of 'tracer' |
---|
2095 | |
---|
2096 | if(watercond.and.CLFvarying)then |
---|
2097 | call wstats(ngrid,"rneb_man","H2O cloud fraction (conv)"," ",3,rneb_man) |
---|
2098 | call wstats(ngrid,"rneb_lsc","H2O cloud fraction (large scale)"," ",3,rneb_lsc) |
---|
2099 | call wstats(ngrid,"CLF","H2O cloud fraction"," ",3,cloudfrac) |
---|
2100 | call wstats(ngrid,"CLFt","H2O column cloud fraction"," ",2,totcloudfrac) |
---|
2101 | call wstats(ngrid,"RH","relative humidity"," ",3,RH) |
---|
2102 | endif |
---|
2103 | |
---|
2104 | if (ok_slab_ocean) then |
---|
2105 | call wstats(ngrid,"dt_hdiff1","dt_hdiff1","K/s",2,dt_hdiff(:,1)) |
---|
2106 | call wstats(ngrid,"dt_hdiff2","dt_hdiff2","K/s",2,dt_hdiff(:,2)) |
---|
2107 | call wstats(ngrid,"dt_ekman1","dt_ekman1","K/s",2,dt_ekman(:,1)) |
---|
2108 | call wstats(ngrid,"dt_ekman2","dt_ekman2","K/s",2,dt_ekman(:,2)) |
---|
2109 | call wstats(ngrid,"tslab1","tslab1","K",2,tslab(:,1)) |
---|
2110 | call wstats(ngrid,"tslab2","tslab2","K",2,tslab(:,2)) |
---|
2111 | call wstats(ngrid,"pctsrf_sic","pct ice/sea","",2,pctsrf_sic) |
---|
2112 | call wstats(ngrid,"tsea_ice","tsea_ice","K",2,tsea_ice) |
---|
2113 | call wstats(ngrid,"sea_ice","sea ice","kg/m2",2,sea_ice) |
---|
2114 | call wstats(ngrid,"rnat","nature of the surface","",2,rnat) |
---|
2115 | endif |
---|
2116 | |
---|
2117 | if(lastcall) then |
---|
2118 | write (*,*) "Writing stats..." |
---|
2119 | call mkstats(ierr) |
---|
2120 | endif |
---|
2121 | |
---|
2122 | endif ! end of 'callstats' |
---|
2123 | |
---|
2124 | #ifndef MESOSCALE |
---|
2125 | |
---|
2126 | !----------------------------------------------------------------------------------------------------- |
---|
2127 | ! OUTPUT in netcdf file "DIAGFI.NC", containing any variable for diagnostic |
---|
2128 | ! |
---|
2129 | ! Note 1 : output with period "ecritphy", set in "run.def" |
---|
2130 | ! |
---|
2131 | ! Note 2 : writediagfi can also be called from any other subroutine for any variable, |
---|
2132 | ! but its preferable to keep all the calls in one place ... |
---|
2133 | !----------------------------------------------------------------------------------------------------- |
---|
2134 | |
---|
2135 | call writediagfi(ngrid,"Ls","solar longitude","deg",0,zls*180./pi) |
---|
2136 | call writediagfi(ngrid,"Lss","sub solar longitude","deg",0,zlss*180./pi) |
---|
2137 | call writediagfi(ngrid,"RA","right ascension","deg",0,right_ascen*180./pi) |
---|
2138 | call writediagfi(ngrid,"Declin","solar declination","deg",0,declin*180./pi) |
---|
2139 | call writediagfi(ngrid,"tsurf","Surface temperature","K",2,tsurf) |
---|
2140 | call writediagfi(ngrid,"ps","Surface pressure","Pa",2,ps) |
---|
2141 | call writediagfi(ngrid,"temp","temperature","K",3,zt) |
---|
2142 | call writediagfi(ngrid,"teta","potential temperature","K",3,zh) |
---|
2143 | call writediagfi(ngrid,"u","Zonal wind","m.s-1",3,zu) |
---|
2144 | call writediagfi(ngrid,"v","Meridional wind","m.s-1",3,zv) |
---|
2145 | call writediagfi(ngrid,"w","Vertical wind","m.s-1",3,pw) |
---|
2146 | call writediagfi(ngrid,"p","Pressure","Pa",3,pplay) |
---|
2147 | |
---|
2148 | ! Subsurface temperatures |
---|
2149 | ! call writediagsoil(ngrid,"tsurf","Surface temperature","K",2,tsurf) |
---|
2150 | ! call writediagsoil(ngrid,"temp","temperature","K",3,tsoil) |
---|
2151 | |
---|
2152 | ! Oceanic layers |
---|
2153 | if(ok_slab_ocean) then |
---|
2154 | call writediagfi(ngrid,"pctsrf_sic","pct ice/sea","",2,pctsrf_sic) |
---|
2155 | call writediagfi(ngrid,"tsea_ice","tsea_ice","K",2,tsea_ice) |
---|
2156 | call writediagfi(ngrid,"sea_ice","sea ice","kg/m2",2,sea_ice) |
---|
2157 | call writediagfi(ngrid,"tslab1","tslab1","K",2,tslab(:,1)) |
---|
2158 | call writediagfi(ngrid,"tslab2","tslab2","K",2,tslab(:,2)) |
---|
2159 | call writediagfi(ngrid,"dt_hdiff1","dt_hdiff1","K/s",2,dt_hdiff(:,1)) |
---|
2160 | call writediagfi(ngrid,"dt_hdiff2","dt_hdiff2","K/s",2,dt_hdiff(:,2)) |
---|
2161 | call writediagfi(ngrid,"dt_ekman1","dt_ekman1","K/s",2,dt_ekman(:,1)) |
---|
2162 | call writediagfi(ngrid,"dt_ekman2","dt_ekman2","K/s",2,dt_ekman(:,2)) |
---|
2163 | call writediagfi(ngrid,"rnat","nature of the surface","",2,rnat) |
---|
2164 | call writediagfi(ngrid,"sensibFlux","sensible heat flux","w.m^-2",2,sensibFlux) |
---|
2165 | call writediagfi(ngrid,"latentFlux","latent heat flux","w.m^-2",2,zdqsdif(:,igcm_h2o_vap)*RLVTT) |
---|
2166 | endif |
---|
2167 | |
---|
2168 | ! Thermal plume model |
---|
2169 | if (calltherm) then |
---|
2170 | call writediagfi(ngrid,'entr','Entrainment','kg m$^{-2}$ s$^{-1}$', 3, entr) |
---|
2171 | call writediagfi(ngrid,'detr','Detrainment','kg m$^{-2}$ s$^{-1}$', 3, detr) |
---|
2172 | call writediagfi(ngrid,'fm','Mass flux','kg m$^{-2}$ s$^{-1}$', 3, fm_bis) |
---|
2173 | call writediagfi(ngrid,'w_plm','Squared vertical velocity','m s$^{-1}$', 3, zw2_bis) |
---|
2174 | call writediagfi(ngrid,'fraca','Updraft fraction','', 3, fraca) |
---|
2175 | endif |
---|
2176 | |
---|
2177 | ! GW non-oro outputs |
---|
2178 | if (calllott_nonoro) then |
---|
2179 | call WRITEDIAGFI(ngrid,"dugwno","GW non-oro dU","m/s2", 3,d_u_hin) |
---|
2180 | call WRITEDIAGFI(ngrid,"dvgwno","GW non-oro dV","m/s2", 3,d_v_hin) |
---|
2181 | endif |
---|
2182 | |
---|
2183 | ! Total energy balance diagnostics |
---|
2184 | if(callrad.and.(.not.newtonian))then |
---|
2185 | |
---|
2186 | !call writediagfi(ngrid,"ALB","Surface albedo"," ",2,albedo_equivalent) |
---|
2187 | !call writediagfi(ngrid,"ALB_1st","First Band Surface albedo"," ",2,albedo(:,1)) |
---|
2188 | call writediagfi(ngrid,"ISR","incoming stellar rad.","W m-2",2,fluxtop_dn) |
---|
2189 | call writediagfi(ngrid,"ASR","absorbed stellar rad.","W m-2",2,fluxabs_sw) |
---|
2190 | call writediagfi(ngrid,"OLR","outgoing longwave rad.","W m-2",2,fluxtop_lw) |
---|
2191 | call writediagfi(ngrid,"shad","rings"," ", 2, fract) |
---|
2192 | |
---|
2193 | ! call writediagfi(ngrid,"ASRcs","absorbed stellar rad (cs).","W m-2",2,fluxabs_sw1) |
---|
2194 | ! call writediagfi(ngrid,"OLRcs","outgoing longwave rad (cs).","W m-2",2,fluxtop_lw1) |
---|
2195 | ! call writediagfi(ngrid,"fluxsurfsw","sw surface flux.","W m-2",2,fluxsurf_sw) |
---|
2196 | ! call writediagfi(ngrid,"fluxsurflw","lw back radiation.","W m-2",2,fluxsurf_lw) |
---|
2197 | ! call writediagfi(ngrid,"fluxsurfswcs","sw surface flux (cs).","W m-2",2,fluxsurf_sw1) |
---|
2198 | ! call writediagfi(ngrid,"fluxsurflwcs","lw back radiation (cs).","W m-2",2,fluxsurf_lw1) |
---|
2199 | |
---|
2200 | if(ok_slab_ocean) then |
---|
2201 | call writediagfi(ngrid,"GND","heat flux from ground","W m-2",2,fluxgrdocean) |
---|
2202 | else |
---|
2203 | call writediagfi(ngrid,"GND","heat flux from ground","W m-2",2,fluxgrd) |
---|
2204 | endif |
---|
2205 | |
---|
2206 | call writediagfi(ngrid,"DYN","dynamical heat input","W m-2",2,fluxdyn) |
---|
2207 | |
---|
2208 | endif ! end of 'callrad' |
---|
2209 | |
---|
2210 | if(enertest) then |
---|
2211 | |
---|
2212 | if (calldifv) then |
---|
2213 | |
---|
2214 | call writediagfi(ngrid,"q2","turbulent kinetic energy","J.kg^-1",3,q2) |
---|
2215 | call writediagfi(ngrid,"sensibFlux","sensible heat flux","w.m^-2",2,sensibFlux) |
---|
2216 | |
---|
2217 | ! call writediagfi(ngrid,"dEzdiff","turbulent diffusion heating (-sensible flux)","w.m^-2",3,dEzdiff) |
---|
2218 | ! call writediagfi(ngrid,"dEdiff","integrated turbulent diffusion heating (-sensible flux)","w.m^-2",2,dEdiff) |
---|
2219 | ! call writediagfi(ngrid,"dEdiffs","In TurbDiff (correc rad+latent heat) surf nrj change","w.m^-2",2,dEdiffs) |
---|
2220 | |
---|
2221 | endif |
---|
2222 | |
---|
2223 | if (corrk) then |
---|
2224 | call writediagfi(ngrid,"dEzradsw","radiative heating","w.m^-2",3,dEzradsw) |
---|
2225 | call writediagfi(ngrid,"dEzradlw","radiative heating","w.m^-2",3,dEzradlw) |
---|
2226 | endif |
---|
2227 | |
---|
2228 | if(watercond) then |
---|
2229 | |
---|
2230 | call writediagfi(ngrid,"lscaledE","heat from largescale","W m-2",2,lscaledE) |
---|
2231 | call writediagfi(ngrid,"madjdE","heat from moistadj","W m-2",2,madjdE) |
---|
2232 | call writediagfi(ngrid,"qsatatm","atm qsat"," ",3,qsat) |
---|
2233 | |
---|
2234 | ! call writediagfi(ngrid,"lscaledEz","heat from largescale","W m-2",3,lscaledEz) |
---|
2235 | ! call writediagfi(ngrid,"madjdEz","heat from moistadj","W m-2",3,madjdEz) |
---|
2236 | ! call writediagfi(ngrid,"h2o_max_col","maximum H2O column amount","kg.m^-2",2,H2Omaxcol) |
---|
2237 | |
---|
2238 | endif |
---|
2239 | |
---|
2240 | endif ! end of 'enertest' |
---|
2241 | |
---|
2242 | ! Diagnostics of optical thickness |
---|
2243 | ! Warning this is exp(-tau), I let you postproc with -log to have tau itself - JVO 19 |
---|
2244 | if (diagdtau) then |
---|
2245 | do nw=1,L_NSPECTV |
---|
2246 | write(str2,'(i2.2)') nw |
---|
2247 | call writediagfi(ngrid,'dtauv'//str2,'Layer optical thickness attenuation in VI band '//str2,'',1,int_dtauv(:,nlayer:1:-1,nw)) |
---|
2248 | enddo |
---|
2249 | do nw=1,L_NSPECTI |
---|
2250 | write(str2,'(i2.2)') nw |
---|
2251 | call writediagfi(ngrid,'dtaui'//str2,'Layer optical thickness attenuation in IR band '//str2,'',1,int_dtaui(:,nlayer:1:-1,nw)) |
---|
2252 | enddo |
---|
2253 | endif |
---|
2254 | |
---|
2255 | |
---|
2256 | ! Temporary inclusions for heating diagnostics. |
---|
2257 | !call writediagfi(ngrid,"zdtsw","SW heating","T s-1",3,zdtsw) |
---|
2258 | !call writediagfi(ngrid,"zdtlw","LW heating","T s-1",3,zdtlw) |
---|
2259 | call writediagfi(ngrid,"dtrad","radiative heating","K s-1",3,dtrad) |
---|
2260 | ! call writediagfi(ngrid,"zdtdyn","Dyn. heating","T s-1",3,zdtdyn) |
---|
2261 | |
---|
2262 | ! For Debugging. |
---|
2263 | !call writediagfi(ngrid,'rnat','Terrain type',' ',2,real(rnat)) |
---|
2264 | !call writediagfi(ngrid,'pphi','Geopotential',' ',3,pphi) |
---|
2265 | |
---|
2266 | |
---|
2267 | ! Output aerosols. |
---|
2268 | if (igcm_co2_ice.ne.0.and.iaero_co2.ne.0) & |
---|
2269 | call writediagfi(ngrid,'CO2ice_reff','CO2ice_reff','m',3,reffrad(1,1,iaero_co2)) |
---|
2270 | if (igcm_h2o_ice.ne.0.and.iaero_h2o.ne.0) & |
---|
2271 | call writediagfi(ngrid,'H2Oice_reff','H2Oice_reff','m',3,reffrad(:,:,iaero_h2o)) |
---|
2272 | if (igcm_co2_ice.ne.0.and.iaero_co2.ne.0) & |
---|
2273 | call writediagfi(ngrid,'CO2ice_reffcol','CO2ice_reffcol','um kg m^-2',2,reffcol(1,iaero_co2)) |
---|
2274 | if (igcm_h2o_ice.ne.0.and.iaero_h2o.ne.0) & |
---|
2275 | call writediagfi(ngrid,'H2Oice_reffcol','H2Oice_reffcol','um kg m^-2',2,reffcol(1,iaero_h2o)) |
---|
2276 | |
---|
2277 | ! Output tracers. |
---|
2278 | if (tracer) then |
---|
2279 | |
---|
2280 | do iq=1,nq |
---|
2281 | call writediagfi(ngrid,noms(iq),noms(iq),'kg/kg',3,zq(1,1,iq)) |
---|
2282 | call writediagfi(ngrid,trim(noms(iq))//'_surf',trim(noms(iq))//'_surf', & |
---|
2283 | 'kg m^-2',2,qsurf_hist(1,iq) ) |
---|
2284 | call writediagfi(ngrid,trim(noms(iq))//'_col',trim(noms(iq))//'_col', & |
---|
2285 | 'kg m^-2',2,qcol(1,iq) ) |
---|
2286 | |
---|
2287 | ! call writediagfi(ngrid,trim(noms(iq))//'_surf',trim(noms(iq))//'_surf', & |
---|
2288 | ! 'kg m^-2',2,qsurf(1,iq) ) |
---|
2289 | |
---|
2290 | if(watercond.or.CLFvarying)then |
---|
2291 | call writediagfi(ngrid,"rneb_man","H2O cloud fraction (conv)"," ",3,rneb_man) |
---|
2292 | call writediagfi(ngrid,"rneb_lsc","H2O cloud fraction (large scale)"," ",3,rneb_lsc) |
---|
2293 | call writediagfi(ngrid,"CLF","H2O cloud fraction"," ",3,cloudfrac) |
---|
2294 | call writediagfi(ngrid,"CLFt","H2O column cloud fraction"," ",2,totcloudfrac) |
---|
2295 | call writediagfi(ngrid,"RH","relative humidity"," ",3,RH) |
---|
2296 | endif |
---|
2297 | |
---|
2298 | if(waterrain)then |
---|
2299 | call writediagfi(ngrid,"rain","rainfall","kg m-2 s-1",2,zdqsrain) |
---|
2300 | call writediagfi(ngrid,"snow","snowfall","kg m-2 s-1",2,zdqssnow) |
---|
2301 | call writediagfi(ngrid,"reevap","reevaporation of precipitation","kg m-2 s-1",2,reevap_precip) |
---|
2302 | endif |
---|
2303 | |
---|
2304 | if((hydrology).and.(.not.ok_slab_ocean))then |
---|
2305 | call writediagfi(ngrid,"hice","oceanic ice height","m",2,hice) |
---|
2306 | endif |
---|
2307 | |
---|
2308 | if(ice_update)then |
---|
2309 | call writediagfi(ngrid,"ice_min","min annual ice","m",2,ice_min) |
---|
2310 | call writediagfi(ngrid,"ice_ini","initial annual ice","m",2,ice_initial) |
---|
2311 | endif |
---|
2312 | |
---|
2313 | do ig=1,ngrid |
---|
2314 | if(tau_col(ig).gt.1.e3)then |
---|
2315 | print*,'WARNING: tau_col=',tau_col(ig) |
---|
2316 | print*,'at ig=',ig,'in PHYSIQ' |
---|
2317 | endif |
---|
2318 | end do |
---|
2319 | |
---|
2320 | call writediagfi(ngrid,"tau_col","Total aerosol optical depth","[]",2,tau_col) |
---|
2321 | |
---|
2322 | enddo ! end of 'nq' loop |
---|
2323 | |
---|
2324 | endif ! end of 'tracer' |
---|
2325 | |
---|
2326 | |
---|
2327 | ! Output spectrum. |
---|
2328 | if(specOLR.and.corrk)then |
---|
2329 | call writediagspecIR(ngrid,"OLR3D","OLR(lon,lat,band)","W/m^2/cm^-1",3,OLR_nu) |
---|
2330 | call writediagspecVI(ngrid,"OSR3D","OSR(lon,lat,band)","W/m^2/cm^-1",3,OSR_nu) |
---|
2331 | call writediagspecVI(ngrid,"GSR3D","GSR(lon,lat,band)","W/m^2/cm^-1",3,GSR_nu) |
---|
2332 | endif |
---|
2333 | |
---|
2334 | #else |
---|
2335 | comm_HR_SW(1:ngrid,1:nlayer) = zdtsw(1:ngrid,1:nlayer) |
---|
2336 | comm_HR_LW(1:ngrid,1:nlayer) = zdtlw(1:ngrid,1:nlayer) |
---|
2337 | if ((tracer).and.(water)) then |
---|
2338 | comm_CLOUDFRAC(1:ngrid,1:nlayer)=cloudfrac(1:ngrid,1:nlayer) |
---|
2339 | comm_TOTCLOUDFRAC(1:ngrid)=totcloudfrac(1:ngrid) |
---|
2340 | comm_RAIN(1:ngrid,1:nlayer)=zdqrain(1:ngrid,1:nlayer,igcm_h2o_vap) |
---|
2341 | comm_SURFRAIN(1:ngrid)=zdqsrain(1:ngrid) |
---|
2342 | comm_SNOW(1:ngrid,1:nlayer)=zdqrain(1:ngrid,1:nlayer,igcm_h2o_ice) |
---|
2343 | comm_ALBEQ(1:ngrid)=albedo_equivalent(1:ngrid) |
---|
2344 | comm_H2OICE_REFF(1:ngrid,1:nlayer)=reffrad(1:ngrid,1:nlayer,iaero_h2o) |
---|
2345 | comm_REEVAP(1:ngrid)=reevap_precip(1:ngrid) |
---|
2346 | endif |
---|
2347 | comm_FLUXTOP_DN(1:ngrid)=fluxtop_dn(1:ngrid) |
---|
2348 | comm_FLUXABS_SW(1:ngrid)=fluxabs_sw(1:ngrid) |
---|
2349 | comm_FLUXTOP_LW(1:ngrid)=fluxtop_lw(1:ngrid) |
---|
2350 | comm_FLUXSURF_SW(1:ngrid)=fluxsurf_sw(1:ngrid) |
---|
2351 | comm_FLUXSURF_LW(1:ngrid)=fluxsurf_lw(1:ngrid) |
---|
2352 | comm_FLXGRD(1:ngrid)=fluxgrd(1:ngrid) |
---|
2353 | comm_LSCEZ(1:ngrid,1:nlayer)=lscaledEz(1:ngrid,1:nlayer) |
---|
2354 | sensibFlux(1:ngrid) = zflubid(1:ngrid) - capcal(1:ngrid)*zdtsdif(1:ngrid) !!! ???? |
---|
2355 | |
---|
2356 | if (turb_resolved) then |
---|
2357 | open(17,file='lsf.txt',form='formatted',status='old') |
---|
2358 | rewind(17) |
---|
2359 | DO l=1,nlayer |
---|
2360 | read(17,*) lsf_dt(l),lsf_dq(l) |
---|
2361 | ENDDO |
---|
2362 | close(17) |
---|
2363 | do ig=1,ngrid |
---|
2364 | if ((tracer).and.(water)) then |
---|
2365 | pdq(ig,:,igcm_h2o_vap) = pdq(ig,:,igcm_h2o_vap) + lsf_dq(:) |
---|
2366 | endif |
---|
2367 | pdt(ig,:) = pdt(ig,:) + lsf_dt(:) |
---|
2368 | comm_HR_DYN(ig,:) = lsf_dt(:) |
---|
2369 | enddo |
---|
2370 | endif |
---|
2371 | #endif |
---|
2372 | |
---|
2373 | ! XIOS outputs |
---|
2374 | #ifdef CPP_XIOS |
---|
2375 | ! Send fields to XIOS: (NB these fields must also be defined as |
---|
2376 | ! <field id="..." /> in context_lmdz_physics.xml to be correctly used) |
---|
2377 | CALL send_xios_field("ls",zls) |
---|
2378 | |
---|
2379 | CALL send_xios_field("ps",ps) |
---|
2380 | CALL send_xios_field("area",cell_area) |
---|
2381 | |
---|
2382 | CALL send_xios_field("temperature",zt) |
---|
2383 | CALL send_xios_field("u",zu) |
---|
2384 | CALL send_xios_field("v",zv) |
---|
2385 | CALL send_xios_field("omega",omega) |
---|
2386 | |
---|
2387 | IF (calltherm) THEN |
---|
2388 | CALL send_xios_field('w_plm',zw2_bis) |
---|
2389 | CALL send_xios_field('entr',entr) |
---|
2390 | CALL send_xios_field('detr',detr) |
---|
2391 | ! CALL send_xios_field('fm',fm_bis) |
---|
2392 | ! CALL send_xios_field('fraca',fraca) |
---|
2393 | ENDIF |
---|
2394 | |
---|
2395 | IF (water) THEN |
---|
2396 | CALL send_xios_field('h2o_vap',zq(:,:,igcm_h2o_vap)) |
---|
2397 | CALL send_xios_field('h2o_ice',zq(:,:,igcm_h2o_ice)) |
---|
2398 | ENDIF |
---|
2399 | |
---|
2400 | CALL send_xios_field("ISR",fluxtop_dn) |
---|
2401 | CALL send_xios_field("OLR",fluxtop_lw) |
---|
2402 | |
---|
2403 | if (lastcall.and.is_omp_master) then |
---|
2404 | write(*,*) "physiq: call xios_context_finalize" |
---|
2405 | call xios_context_finalize |
---|
2406 | endif |
---|
2407 | #endif |
---|
2408 | |
---|
2409 | icount=icount+1 |
---|
2410 | |
---|
2411 | end subroutine physiq |
---|
2412 | |
---|
2413 | end module physiq_mod |
---|