source: trunk/LMDZ.MARS/libf/phymars/phyredem.F90 @ 3807

Last change on this file since 3807 was 3804, checked in by jbclement, 5 days ago

Mars PCM:
Move paleoclimate variables from time-independent to time-dependent writing of "stratfi.nc".
JBC

File size: 15.6 KB
Line 
1module phyredem
2
3implicit none
4
5!=======================================================================
6contains
7!=======================================================================
8
9subroutine physdem0(filename,lonfi,latfi,nsoil,ngrid,nlay,nq,phystep,day_ini, &
10                    time,airefi,alb,ith,def_slope,subslope_dist)
11! create physics restart file and write time-independent variables
12
13  use comsoil_h,          only: inertiedat, volcapa, mlayer
14  use geometry_mod,       only: cell_area
15  use surfdat_h,          only: zmea, zstd, zsig, zgam, zthe, z0_default, &
16                                albedice, emisice, emissiv, iceradius,    &
17                                dtemisice, phisfi, z0, hmons, summit, base, watercaptag
18  use dimradmars_mod,     only: tauvis
19  use iostart,            only: open_restartphy, close_restartphy, &
20                                put_var, put_field, length, ldscrpt, ndscrpt
21  use mod_grid_phy_lmdz,  only: klon_glo
22  use planete_h,          only: aphelie, emin_turb, lmixmin, obliquit, &
23                                peri_day, periheli, year_day
24  use comcstfi_h,         only: g, mugaz, omeg, rad, rcp
25  use time_phylmdz_mod,   only: daysec
26  use comslope_mod,       only: nslope
27
28  implicit none
29 
30  character(len=*), intent(in) :: filename
31  real,intent(in) :: lonfi(ngrid)
32  real,intent(in) :: latfi(ngrid)
33  integer,intent(in) :: nsoil
34  integer,intent(in) :: ngrid
35  integer,intent(in) :: nlay
36  integer,intent(in) :: nq
37  real,intent(in) :: phystep
38  real,intent(in) :: day_ini
39  real,intent(in) :: time
40  real,intent(in) :: airefi(ngrid)
41  real,intent(in) :: alb(ngrid)
42  real,intent(in) :: ith(ngrid,nsoil) ! thermal inertia for present day
43  real, intent(in) :: def_slope(nslope+1) !boundaries for bining of the slopes
44  real, intent(in) :: subslope_dist(ngrid,nslope) !undermesh statistics
45
46  character(ndscrpt), dimension(ldscrpt), parameter :: dscrpt_tab_cntrl = (/ &
47      "(1)  Total number of nodes on physics grid        ", &
48      "(2)  Number of atmospheric layers                 ", &
49      "(3)  Initial day                                  ", &
50      "(4)  Initial time of day                          ", &
51      "(5)  Radius of Mars (m) ~3397200                  ", &
52      "(6)  Rotation rate (rad.s-1)                      ", &
53      "(7)  Gravity (m.s-2) ~3.72                        ", &
54      "(8)  Molar mass of the atmosphere (g.mol-1) ~43.49", &
55      "(9)  = r/Cp ~0.256793 (=kappa in the dynamics)    ", &
56      "(10) Length of a sol (s) ~88775                   ", &
57      "(11) Time step in the physics                     ", &
58      "(12) -                                            ", &
59      "(13) -                                            ", &
60      "(14) Length of year (sols) ~668.6                 ", &
61      "(15) Min. Sun-Mars distance (Mkm) ~206.66         ", &
62      "(16) Max. Sun-Mars distance (Mkm) ~249.22         ", &
63      "(17) Date of perihelion (sols since N. spring)    ", &
64      "(18) Obliquity of the planet (deg) ~23.98         ", &
65      "(19) Default surface roughness (m) ~0.01          ", &
66      "(20) Mixing length ~100                           ", &
67      "(21) Minimal energy ~1.e-8                        ", &
68      "(22) Albedo of northern cap ~0.5                  ", &
69      "(23) Albedo of southern cap ~0.5                  ", &
70      "(24) Emissivity of northern cap ~0.95             ", &
71      "(25) Emissivity of southern cap ~0.95             ", &
72      "(26) Emissivity of martian soil ~.95              ", &
73      "(27) Mean visible optical depth                   ", &
74      "(28) -                                            ", &
75      "(29) -                                            ", &
76      "(30) -                                            ", &
77      "(31) Mean scat radius of CO2 snow (north)         ", &
78      "(32) Mean scat radius of CO2 snow (south)         ", &
79      "(33) Time scale for snow metamorphism (north)     ", &
80      "(34) Time scale for snow metamorphism (south)     ", &
81      "(35) Soil volumetric heat capacity                "/)
82  real, dimension(length) :: tab_cntrl ! nb "length=100" defined in iostart module
83  integer                 :: ig
84  real, dimension(ngrid)  :: watercaptag_tmp
85
86  ! Create physics start file
87  call open_restartphy(filename)
88
89  ! Build tab_cntrl(:) array
90  tab_cntrl(:)=0.0
91  !cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
92  ! Fill control array tab_cntrl(:) with parameters for this run
93  !cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
94  ! Informations on the physics grid
95  tab_cntrl(1) = float(klon_glo)     ! Total number of nodes on physics grid
96  tab_cntrl(2) = float(nlay)         ! Number of atmospheric layers
97  tab_cntrl(3) = day_ini + int(time) ! Initial day
98  tab_cntrl(4) = time -int(time)     ! Initial time of day
99
100  ! Informations about Mars, used by dynamics and physics
101  tab_cntrl(5) = rad      ! Radius of Mars (m) ~3397200
102  tab_cntrl(6) = omeg     ! Rotation rate (rad.s-1)
103  tab_cntrl(7) = g        ! Gravity (m.s-2) ~3.72
104  tab_cntrl(8) = mugaz    ! Molar mass of the atmosphere (g.mol-1) ~43.49
105  tab_cntrl(9) = rcp      ! = r/cp  ~0.256793 (=kappa dans dynamique)
106  tab_cntrl(10) = daysec  ! Length of a sol (s) ~88775
107  tab_cntrl(11) = phystep ! Time step in the physics
108
109  ! Informations about Mars, only for physics
110  tab_cntrl(14) = year_day  ! Length of year (sols) ~668.6
111  tab_cntrl(15) = periheli  ! Min. Sun-Mars distance (Mkm) ~206.66
112  tab_cntrl(16) = aphelie   ! Max. SUn-Mars distance (Mkm) ~249.22
113  tab_cntrl(17) = peri_day  ! Date of perihelion (sols since N. spring)
114  tab_cntrl(18) = obliquit  ! Obliquity of the planet (deg) ~23.98
115
116  ! Boundary layer and turbulence
117  tab_cntrl(19) = z0_default ! Default surface roughness (m) ~0.01
118  tab_cntrl(20) = lmixmin    ! Mixing length ~100
119  tab_cntrl(21) = emin_turb  ! Minimal energy ~1.e-8
120
121  ! Optical properties of polar caps and ground emissivity
122  tab_cntrl(22) = albedice(1)  ! Albedo of northern cap ~0.5
123  tab_cntrl(23) = albedice(2)  ! Albedo of southern cap ~0.5
124  tab_cntrl(24) = emisice(1)   ! Emissivity of northern cap ~0.95
125  tab_cntrl(25) = emisice(2)   ! Emissivity of southern cap ~0.95
126  tab_cntrl(26) = emissiv      ! Emissivity of martian soil ~.95
127  tab_cntrl(31) = iceradius(1) ! Mean scat radius of CO2 snow (north)
128  tab_cntrl(32) = iceradius(2) ! Mean scat radius of CO2 snow (south)
129  tab_cntrl(33) = dtemisice(1) ! Time scale for snow metamorphism (north)
130  tab_cntrl(34) = dtemisice(2) ! Time scale for snow metamorphism (south)
131
132  ! dust aerosol properties
133  tab_cntrl(27) = tauvis ! Mean visible optical depth
134
135  ! Soil properties:
136  tab_cntrl(35) = volcapa ! Soil volumetric heat capacity
137
138  ! Write the controle array
139  call put_var("controle","Control parameters",tab_cntrl)
140
141  ! Write the controle array descriptor
142  call put_var("controle_descriptor","Description of control parameters",dscrpt_tab_cntrl)
143 
144  ! Write the mid-layer depths
145  call put_var("soildepth","Soil mid-layer depth",mlayer)
146 
147  ! Write longitudes
148  call put_field("longitude","Longitudes of physics grid",lonfi)
149 
150  ! Write latitudes
151  call put_field("latitude","Latitudes of physics grid",latfi)
152 
153  ! Write mesh areas
154  call put_field("area","Mesh area",cell_area)
155 
156  ! Write surface geopotential
157  call put_field("phisfi","Geopotential at the surface",phisfi)
158 
159  ! Write surface albedo
160  call put_field("albedodat","Albedo of bare ground",alb)
161 
162  ! Subgrid topogaphy variables
163  call put_field("ZMEA","Relief: mean relief",zmea)
164  call put_field("ZSTD","Relief: standard deviation",zstd)
165  call put_field("ZSIG","Relief: sigma parameter",zsig)
166  call put_field("ZGAM","Relief: gamma parameter",zgam)
167  call put_field("ZTHE","Relief: theta parameter",zthe)
168  call put_field("hmons","Relief: hmons parameter (summit - base)",hmons)
169  call put_field("summit","Relief: altitude from the aeroid of the summit of the highest subgrid topography",summit)
170  call put_field("base","Relief: altitude from the aeroid of the base of the highest subgrid topography",base)
171     
172  ! Soil thermal inertia
173  call put_field("inertiedat","Soil thermal inertia - present day",ith)
174 
175  ! Surface roughness length
176  call put_field("z0","Surface roughness length",z0)
177
178  ! Water cap
179  watercaptag_tmp = 0
180  where (watercaptag) watercaptag_tmp = 1
181  call put_field("watercaptag","Infinite water reservoir",watercaptag_tmp)
182
183  ! Sub grid scale slope parametrization
184  call put_var("def_slope","slope criterium stages",def_slope)
185  call put_field("subslope_dist","under mesh slope distribution",subslope_dist)
186
187  ! Close file
188  call close_restartphy
189 
190end subroutine physdem0
191
192!=======================================================================
193
194subroutine physdem1(filename,nsoil,ngrid,nlay,nq,nqsoil,phystep,time,tsurf,tsoil,inertiesoil, &
195                    albedo,emis,q2,qsurf,qsoil,tauscaling,totcloudfrac,wstar,watercap,perennial_co2ice)
196  ! write time-dependent variable to restart file
197
198  use iostart,             only: open_restartphy, close_restartphy, put_var, put_field
199  use tracer_mod,          only: noms ! tracer names
200  use nonoro_gwd_ran_mod,  only: du_nonoro_gwd, dv_nonoro_gwd
201  use compute_dtau_mod,    only: dtau
202  use dust_rad_adjust_mod, only: dust_rad_adjust_prev,dust_rad_adjust_next
203  use dust_param_mod,      only: dustscaling_mode
204  use comsoil_h,           only: flux_geo,adsorption_soil,igcm_h2o_vap_soil, &
205                                 igcm_h2o_ice_soil,igcm_h2o_vap_ads
206  use comslope_mod,        only: nslope
207  use paleoclimate_mod,    only: paleoclimate
208  use callkeys_mod,        only: calltherm, dustinjection, calllott_nonoro
209  use paleoclimate_mod,    only: paleoclimate, h2o_ice_depth, lag_co2_ice, d_coef, zdqsdif_ssi_tot
210
211  implicit none
212 
213  character(len=*),intent(in) :: filename
214  integer,intent(in) :: nsoil
215  integer,intent(in) :: ngrid
216  integer,intent(in) :: nlay
217  integer,intent(in) :: nq
218  integer,intent(in) :: nqsoil
219  real,intent(in) :: phystep
220  real,intent(in) :: time
221  real,intent(in) :: tsurf(ngrid,nslope)
222  real,intent(in) :: tsoil(ngrid,nsoil,nslope)
223  real,intent(in) :: inertiesoil(ngrid,nsoil,nslope)
224  real,intent(in) :: albedo(ngrid,2,nslope)
225  real,intent(in) :: emis(ngrid,nslope)
226  real,intent(in) :: q2(ngrid,nlay+1)
227  real,intent(in) :: qsurf(ngrid,nq,nslope)
228  real,intent(in) :: qsoil(ngrid,nsoil,nqsoil,nslope)
229  real,intent(in) :: tauscaling(ngrid)
230  real,intent(in) :: totcloudfrac(ngrid)
231  real,intent(in) :: wstar(ngrid)
232  real,intent(in) :: watercap(ngrid,nslope)
233  real,intent(in) :: perennial_co2ice(ngrid,nslope)
234
235  integer :: iq
236  character(len=30) :: txt ! to store some text
237  ! indexes of water vapour & water ice tracers (if any):
238  integer :: i_h2o_vap=0
239  integer :: i_h2o_ice=0
240  integer :: i_hdo_vap=0
241  integer :: i_hdo_ice=0
242
243 
244  ! Open file
245  call open_restartphy(filename)
246 
247  ! First variable to write must be "Time", in order to correctly
248  ! set time counter in file
249  call put_var("Time","Temps de simulation",time)
250
251  ! Water ice layer
252  call put_field("watercap","H2O ice cover",watercap,time)
253 
254  ! Perennial CO2 ice layer
255  if (paleoclimate) call put_field("perennial_co2ice","CO2 ice cover",perennial_co2ice,time)
256
257  ! Surface temperature
258  call put_field("tsurf","Surface temperature",tsurf,time)
259
260  ! Soil temperature
261  call put_field("inertiesoil","Soil thermal inertia",inertiesoil,time)
262 
263  ! Soil temperature
264  call put_field("tsoil","Soil temperature",tsoil,time)
265 
266  ! Albedo of the surface
267  call put_field("albedo","Surface albedo",albedo(:,1,:),time)
268 
269  ! Emissivity of the surface
270  call put_field("emis","Surface emissivity",emis,time)
271 
272  ! Planetary Boundary Layer
273  call put_field("q2","pbl wind variance",q2,time)
274
275  ! Sub-grid cloud fraction
276  call put_field("totcloudfrac","Total cloud fraction",totcloudfrac,time)
277 
278  ! Dust conversion factor
279  ! Only to be read by newstart to convert to actual dust values
280  ! Or by any user who wants to reconstruct dust, opacity from the start files.
281  call put_field("tauscaling","dust conversion factor",tauscaling,time)
282
283  ! Radiative scaling coefficients
284  if (dustscaling_mode==2) then
285    call put_field("dust_rad_adjust_prev", &
286                   "radiative dust adjustement factor prev. sol", &
287                   dust_rad_adjust_prev,time)
288    call put_field("dust_rad_adjust_next", &
289                   "radiative dust adjustement factor next sol", &
290                   dust_rad_adjust_next,time)
291  endif
292 
293  if (dustinjection.gt.0) then
294    call put_field("dtau","dust opacity difference between GCM and scenario",&
295                   dtau,time)
296  endif
297
298  if (calltherm) then
299    call put_field("wstar","Max vertical velocity in thermals",wstar,time)
300  endif
301
302  ! Tracers on the surface
303  ! preliminary stuff: look for water vapour & water ice tracers (if any)
304  do iq=1,nq
305    if (noms(iq).eq."h2o_vap") then
306      i_h2o_vap=iq
307    endif
308    if (noms(iq).eq."h2o_ice") then
309      i_h2o_ice=iq
310    endif
311
312  ! look for HDO vapour & HDO ice tracers (if any)
313    if (noms(iq).eq."hdo_vap") then
314      i_hdo_vap=iq
315    endif
316    if (noms(iq).eq."hdo_ice") then
317      i_hdo_ice=iq
318    endif
319  enddo
320
321 
322  if (nq.gt.0) then
323    do iq=1,nq
324      txt=noms(iq)
325      ! Exception: there is no water vapour surface tracer
326      if (txt.eq."h2o_vap") then
327        write(*,*)"physdem1: skipping water vapour tracer"
328        if (i_h2o_ice.eq.i_h2o_vap) then
329          ! then there is no "water ice" tracer; but still
330          ! there is some water ice on the surface
331          write(*,*)"          writing water ice instead"
332          txt="h2o_ice"
333        else
334          ! there is a "water ice" tracer which has been / will be
335          ! delt with in due time
336          cycle
337        endif ! of if (igcm_h2o_ice.eq.igcm_h2o_vap)
338      endif ! of if (txt.eq."h2o_vap")
339
340      if (txt.eq."hdo_vap") then
341        write(*,*)"physdem1: skipping HDO vapour tracer"
342        if (i_hdo_ice.eq.i_hdo_vap) then
343          ! then there is no "water ice" tracer; but still
344          ! there is some water ice on the surface
345          write(*,*)"          writing HDO ice instead"
346          txt="hdo_ice"
347        else
348          ! there is a "water ice" tracer which has been / will be
349          ! delt with in due time
350          cycle
351        endif ! of if (igcm_hdo_ice.eq.igcm_hdo_vap)
352      endif ! of if (txt.eq."hdo_vap")
353
354      ! co2_ice has been added to qsurf(:,igcm_co2) in co2condens4micro
355      if (txt.eq."co2_ice") then
356        write(*,*)"physdem1: skipping co2_ice tracer"
357        cycle
358      end if     
359
360      call put_field(trim(txt),"tracer on surface",qsurf(:,iq,:),time)
361    enddo
362  endif
363
364  ! Non-orographic gavity waves
365  if (calllott_nonoro) then
366     call put_field("du_nonoro_gwd","Zonal wind tendency due to GW",du_nonoro_gwd,time)
367     call put_field("dv_nonoro_gwd","Meridional wind tendency due to GW",dv_nonoro_gwd,time)
368  endif
369
370  ! Geothermal Flux
371     call put_field('flux_geo','Geothermal flux',flux_geo,time)
372
373  ! Adsorption
374  if (adsorption_soil) then
375     call put_field("h2o_vap_soil","subsurface water vapour", &
376                        qsoil(:,:,igcm_h2o_vap_soil,:), time)
377     call put_field("h2o_ice_soil","subsurface water ice", &
378                        qsoil(:,:,igcm_h2o_ice_soil,:), time)
379     call put_field("h2o_vap_ads", "adsorbed water", &
380                        qsoil(:,:,igcm_h2o_vap_ads,:), time)
381  endif
382
383  ! Paleoclimate
384  if (paleoclimate) then
385    print*, 'yooooooooo', h2o_ice_depth
386    call put_field("h2o_ice_depth","Depth to the fisrt H2O ice",h2o_ice_depth)
387    call put_field("lag_co2_ice","Depth of the CO2 lags",lag_co2_ice)
388    call put_field("zdqsdif_ssi_tot","Total flux with SSI",zdqsdif_ssi_tot)
389    call put_field("d_coef","Diffusion coefficent",d_coef)
390  endif
391
392  ! Close file
393  call close_restartphy
394 
395end subroutine physdem1
396
397end module phyredem
Note: See TracBrowser for help on using the repository browser.