source: trunk/LMDZ.TITAN/libf/phytitan/phyredem.F90 @ 3094

Last change on this file since 3094 was 1903, checked in by jvatant, 7 years ago

+ Generalize the use of nkim parameter in comchem_h instead
of having x=44 hardcoded everywhere in the code.
If ever one day we have nkim!=44 it will be useful !
+ Also add the other parameters for the chem. in comchem_h
+ Some rearrangment in physiq_mod of chemistry variables

-> especially less unsane "nq-nmicro" -> nkim instead.

+ In calchim, preliminary modifs to adapt to the new managment
of i/o chemistry implemented in last commits.
--JVO

File size: 6.9 KB
Line 
1module phyredem
2
3implicit none
4
5contains
6
7subroutine physdem0(filename,lonfi,latfi,nsoil,ngrid,nlay,nq, &
8                         phystep,day_ini,time,airefi, &
9                         alb,ith,pzmea,pzstd,pzsig,pzgam,pzthe)
10! create physics restart file and write time-independent variables
11  use comchem_h, only: preskim
12  use comsoil_h, only: volcapa, mlayer
13  use geometry_mod, only: cell_area
14  use surfdat_h, only: zmea, zstd, zsig, zgam, zthe, &
15                       emisice, emissiv,             &
16                       iceradius, dtemisice, phisfi
17  use iostart, only : open_restartphy, close_restartphy, &
18                      put_var, put_field, length
19  use mod_grid_phy_lmdz, only : klon_glo
20  use planete_mod, only: year_day, periastr, apoastr, peri_day, &
21                         obliquit, z0, lmixmin, emin_turb
22  use comcstfi_mod, only: rad, omeg, g, mugaz, rcp
23  use time_phylmdz_mod, only: daysec
24
25  implicit none
26
27  character(len=*), intent(in) :: filename
28  real,intent(in) :: lonfi(ngrid)
29  real,intent(in) :: latfi(ngrid)
30  integer,intent(in) :: nsoil
31  integer,intent(in) :: ngrid
32  integer,intent(in) :: nlay
33  integer,intent(in) :: nq
34  real,intent(in) :: phystep
35  real,intent(in) :: day_ini
36  real,intent(in) :: time
37  real,intent(in) :: airefi(ngrid)
38  real,intent(in) :: alb(ngrid)
39  real,intent(in) :: ith(ngrid,nsoil)
40  real,intent(in) :: pzmea(ngrid)
41  real,intent(in) :: pzstd(ngrid)
42  real,intent(in) :: pzsig(ngrid)
43  real,intent(in) :: pzgam(ngrid)
44  real,intent(in) :: pzthe(ngrid)
45 
46  real :: tab_cntrl(length) ! nb "length=100" defined in iostart module
47 
48  ! Create physics start file
49  call open_restartphy(filename)
50
51! tab_cntrl() contains run parameters
52  tab_cntrl(:)=0 ! initialization
53!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
54! Fill control array tab_cntrl(:) with paramleters for this run
55!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
56! Informations on the physics grid
57  tab_cntrl(1) = float(klon_glo)  ! number of nodes on physics grid
58  tab_cntrl(2) = float(nlay) ! number of atmospheric layers
59  tab_cntrl(3) = day_ini + int(time)         ! final day
60  tab_cntrl(4) = time -int(time)            ! final time of day
61
62! Informations about Mars, used by dynamics and physics
63  tab_cntrl(5) = rad      ! radius of Mars (m) ~3397200
64  tab_cntrl(6) = omeg     ! rotation rate (rad.s-1)
65  tab_cntrl(7) = g        ! gravity (m.s-2) ~3.72
66  tab_cntrl(8) = mugaz    ! Molar mass of the atmosphere (g.mol-1) ~43.49
67  tab_cntrl(9) = rcp      !  = r/cp  ~0.256793 (=kappa dans dynamique)
68  tab_cntrl(10) = daysec  ! length of a sol (s)  ~88775
69
70  tab_cntrl(11) = phystep  ! time step in the physics
71  tab_cntrl(12) = 0.
72  tab_cntrl(13) = 0.
73
74! Informations about Mars, only for physics
75  tab_cntrl(14) = year_day  ! length of year (sols) ~668.6
76  tab_cntrl(15) = periastr  ! min. star-planet distance (AU)
77  tab_cntrl(16) = apoastr   ! max. star-planet distance (AU)
78  tab_cntrl(17) = peri_day  ! date of periastron (sols since N. spring)
79  tab_cntrl(18) = obliquit  ! Obliquity of the planet (deg) ~23.98
80
81! Boundary layer and turbulence
82  tab_cntrl(19) = z0        ! surface roughness (m) ~0.01
83  tab_cntrl(20) = lmixmin   ! mixing length ~100
84  tab_cntrl(21) = emin_turb ! minimal energy ~1.e-8
85
86! Optical properties of polar caps and ground emissivity
87  tab_cntrl(24) = emisice(1)   ! Emissivity of northern cap ~0.95
88  tab_cntrl(25) = emisice(2)   ! Emissivity of southern cap ~0.95
89  tab_cntrl(26) = emissiv      ! Emissivity of martian soil ~.95
90  tab_cntrl(31) = iceradius(1) ! mean scat radius of CO2 snow (north)
91  tab_cntrl(32) = iceradius(2) ! mean scat radius of CO2 snow (south)
92  tab_cntrl(33) = dtemisice(1) ! time scale for snow metamorphism (north)
93  tab_cntrl(34) = dtemisice(2) ! time scale for snow metamorphism (south)
94
95  tab_cntrl(28) = 0.
96  tab_cntrl(29) = 0.
97  tab_cntrl(30) = 0.
98
99! Soil properties:
100  tab_cntrl(35) = volcapa ! soil volumetric heat capacity
101
102  call put_var("controle","Control parameters",tab_cntrl)
103 
104  ! Write the mid-layer depths
105  call put_var("soildepth","Soil mid-layer depth",mlayer)
106 
107  ! Write the mid-layer upper chemistry pressure
108  call put_var("preskim","Upper chemistry mid-layer pressure",preskim)
109 
110  ! Write longitudes
111  call put_field("longitude","Longitudes of physics grid",lonfi)
112 
113  ! Write latitudes
114  call put_field("latitude","Latitudes of physics grid",latfi)
115 
116  ! Write mesh areas
117  call put_field("area","Mesh area",cell_area)
118 
119  ! Write surface geopotential
120  call put_field("phisfi","Geopotential at the surface",phisfi)
121 
122  ! Write surface albedo
123  call put_field("albedodat","Albedo of bare ground",alb)
124 
125  ! Subgrid topogaphy variables
126  call put_field("ZMEA","Relief: mean relief",zmea)
127  call put_field("ZSTD","Relief: standard deviation",zstd)
128  call put_field("ZSIG","Relief: sigma parameter",zsig)
129  call put_field("ZGAM","Relief: gamma parameter",zgam)
130  call put_field("ZTHE","Relief: theta parameter",zthe)
131 
132  ! Soil thermal inertia
133  call put_field("inertiedat","Soil thermal inertia",ith)
134 
135  ! Close file
136  call close_restartphy
137 
138end subroutine physdem0
139
140subroutine physdem1(filename,nsoil,ngrid,nlay,nq, &
141                    phystep,time,tsurf,tsoil,emis,q2,qsurf,tankCH4)
142  ! write time-dependent variable to restart file
143  use iostart, only : open_restartphy, close_restartphy, &
144                      put_var, put_field
145  use comchem_h, only: nkim, cnames, ykim_up
146  use tracer_h, only: noms
147  use callkeys_mod, only: callchim
148
149  implicit none
150
151  character(len=*),intent(in) :: filename
152  integer,intent(in) :: nsoil
153  integer,intent(in) :: ngrid
154  integer,intent(in) :: nlay
155  integer,intent(in) :: nq
156  real,intent(in) :: phystep
157  real,intent(in) :: time
158  real,intent(in) :: tsurf(ngrid)
159  real,intent(in) :: tsoil(ngrid,nsoil)
160  real,intent(in) :: emis(ngrid)
161  real,intent(in) :: q2(ngrid,nlay+1)
162  real,intent(in) :: qsurf(ngrid,nq)
163  real,intent(in) :: tankCH4(ngrid)
164
165  integer :: iq
166 
167  ! Open file
168  call open_restartphy(filename)
169
170  ! First variable to write must be "Time", in order to correctly
171  ! set time counter in file
172  !call put_var("Time","Temps de simulation",time)
173 
174  ! Surface temperature
175  call put_field("tsurf","Surface temperature",tsurf)
176 
177  ! Soil temperature
178  call put_field("tsoil","Soil temperature",tsoil)
179 
180  ! Emissivity of the surface
181  call put_field("emis","Surface emissivity",emis)
182 
183  ! Planetary Boundary Layer
184  call put_field("q2","pbl wind variance",q2)
185
186  ! Methane tank depth
187  call put_field("tankCH4","Depth of methane tank",tankCH4)
188 
189  ! Tracers
190  if (nq>0) then
191    do iq=1,nq
192      call put_field(noms(iq),"tracer on surface",qsurf(:,iq))
193    enddo
194  endif ! of if (nq>0)
195 
196  ! Upper chemistry
197  if (callchim) then
198    do iq=1,nkim
199      call put_field(trim(cnames(iq))//"_up",trim(cnames(iq))//" in upper atmosphere",ykim_up(iq,:,:))
200    enddo
201  endif ! of if callchim
202 
203! close file
204      CALL close_restartphy
205!$OMP BARRIER
206
207end subroutine physdem1
208
209end module phyredem
Note: See TracBrowser for help on using the repository browser.