source: trunk/LMDZ.MARS/libf/phymars/phyetat0.F90 @ 1747

Last change on this file since 1747 was 1711, checked in by mvals, 8 years ago

Mars GCM

  • implementation of a sub-grid water cloud fraction scheme (by A. Pottier): If CLFvarying is set to true in callphys.def, then the sub-grid cloud fraction routine is applied in watercloud.F and aeropacity.F.
  • accordingly modified files are: watercloud.F, aeropacity.F, callradite.F, conf_phys.F, phyetat0.F, phyredem.F90, physiq_mod.F, testphys1d.F, callkeys.h, newtsart.F, start2archive.F, lect_start_archive.F
  • added file: tcondwater.F90, used by watercloud.F to calculate the condensation temperature of water
  • watercloud.F, aeropacity.F, callradite.F are converted to module files as watercloud_mod.F, aeropacity_mod.F, callradite_mod.F

MV

File size: 9.5 KB
Line 
1subroutine phyetat0 (fichnom,tab0,Lmodif,nsoil,ngrid,nlay,nq, &
2                     day_ini,time0,tsurf,tsoil,emis,q2,qsurf,co2ice, &
3                     tauscaling,totcloudfrac)
4!  use netcdf
5  use tracer_mod, only: noms ! tracer names
6  use surfdat_h, only: phisfi, albedodat, z0, z0_default,&
7                       zmea, zstd, zsig, zgam, zthe
8  use iostart, only: nid_start, open_startphy, close_startphy, &
9                     get_field, get_var, inquire_field, &
10                     inquire_dimension, inquire_dimension_length
11  use ioipsl_getincom, only : getin
12
13  implicit none
14!======================================================================
15! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
16!  Adaptation à Mars : Yann Wanherdrick
17! Objet: Lecture de l etat initial pour la physique
18! Modifs: Aug.2010 EM : use NetCDF90 to load variables (enables using
19!                      r4 or r8 restarts independently of having compiled
20!                      the GCM in r4 or r8)
21!         June 2013 TN : Possibility to read files with a time axis
22!         November 2013 EM : Enabeling parallel, using iostart module
23!======================================================================
24  INTEGER nbsrf !Mars nbsrf a 1 au lieu de 4
25  PARAMETER (nbsrf=1) ! nombre de sous-fractions pour une maille
26!======================================================================
27!  Arguments:
28!  ---------
29!  inputs:
30  character*(*),intent(in) :: fichnom ! "startfi.nc" file
31  integer,intent(in) :: tab0
32  integer,intent(in) :: Lmodif
33  integer,intent(in) :: nsoil ! # of soil layers
34  integer,intent(in) :: ngrid ! # of atmospheric columns
35  integer,intent(in) :: nlay ! # of atmospheric layers
36  integer,intent(in) :: nq
37  integer :: day_ini
38  real :: time0
39
40!  outputs:
41  real,intent(out) :: tsurf(ngrid) ! surface temperature
42  real,intent(out) :: tsoil(ngrid,nsoil) ! soil temperature
43  real,intent(out) :: emis(ngrid) ! surface emissivity
44  real,intent(out) :: q2(ngrid,nlay+1) !
45  real,intent(out) :: qsurf(ngrid,nq) ! tracers on surface
46  real,intent(out) :: co2ice(ngrid) ! co2 ice cover
47  real,intent(out) :: tauscaling(ngrid) ! dust conversion factor
48  real,intent(out) :: totcloudfrac(ngrid) ! total cloud fraction
49!======================================================================
50!  Local variables:
51
52      real surffield(ngrid) ! to temporarily store a surface field
53      real xmin,xmax ! to display min and max of a field
54!
55      INTEGER ig,iq,lmax
56      INTEGER nid, nvarid
57      INTEGER ierr, i, nsrf
58!      integer isoil
59!      INTEGER length
60!      PARAMETER (length=100)
61      CHARACTER*7 str7
62      CHARACTER*2 str2
63      CHARACTER*1 yes
64!
65      REAL p_rad,p_omeg,p_g,p_mugaz,p_daysec
66      INTEGER nqold
67
68! flag which identifies if 'startfi.nc' file is using old names (qsurf01,...)
69      logical :: oldtracernames=.false.
70      integer :: count
71      character(len=30) :: txt ! to store some text
72
73! specific for time
74      REAL,ALLOCATABLE :: time(:) ! times stored in start
75      INTEGER timelen ! number of times stored in the file
76      INTEGER indextime ! index of selected time
77
78      INTEGER :: edges(3),corner(3)
79      LOGICAL :: found
80
81      REAL :: timestart ! to pick which initial state to start from
82
83! open physics initial state file:
84call open_startphy(fichnom)
85
86
87! possibility to modify tab_cntrl in tabfi
88write(*,*)
89write(*,*) 'TABFI in phyeta0: Lmodif=',Lmodif," tab0=",tab0
90call tabfi (nid_start,Lmodif,tab0,day_ini,lmax,p_rad, &
91            p_omeg,p_g,p_mugaz,p_daysec,time0)
92
93
94! Load surface geopotential:
95call get_field("phisfi",phisfi,found)
96if (.not.found) then
97  write(*,*) "phyetat0: Failed loading <phisfi>"
98  call abort
99else
100  write(*,*) "phyetat0: surface geopotential <phisfi> range:", &
101             minval(phisfi), maxval(phisfi)
102endif
103
104
105! Load bare ground albedo:
106call get_field("albedodat",albedodat,found)
107if (.not.found) then
108  write(*,*) "phyetat0: Failed loading <albedodat>"
109  call abort
110else
111  write(*,*) "phyetat0: Bare ground albedo <albedodat> range:", &
112             minval(albedodat), maxval(albedodat)
113endif
114
115! ZMEA
116call get_field("ZMEA",zmea,found)
117if (.not.found) then
118  write(*,*) "phyetat0: Failed loading <ZMEA>"
119  call abort
120else
121  write(*,*) "phyetat0: <ZMEA> range:", &
122             minval(zmea), maxval(zmea)
123endif
124
125
126! ZSTD
127call get_field("ZSTD",zstd,found)
128if (.not.found) then
129  write(*,*) "phyetat0: Failed loading <ZSTD>"
130  call abort
131else
132  write(*,*) "phyetat0: <ZSTD> range:", &
133             minval(zstd), maxval(zstd)
134endif
135
136
137! ZSIG
138call get_field("ZSIG",zsig,found)
139if (.not.found) then
140  write(*,*) "phyetat0: Failed loading <ZSIG>"
141  call abort
142else
143  write(*,*) "phyetat0: <ZSIG> range:", &
144             minval(zsig), maxval(zsig)
145endif
146
147
148! ZGAM
149call get_field("ZGAM",zgam,found)
150if (.not.found) then
151  write(*,*) "phyetat0: Failed loading <ZGAM>"
152  call abort
153else
154  write(*,*) "phyetat0: <ZGAM> range:", &
155             minval(zgam), maxval(zgam)
156endif
157
158
159! ZTHE
160call get_field("ZTHE",zthe,found)
161if (.not.found) then
162  write(*,*) "phyetat0: Failed loading <ZTHE>"
163  call abort
164else
165  write(*,*) "phyetat0: <ZTHE> range:", &
166             minval(zthe), maxval(zthe)
167endif
168
169     
170! Time axis
171! obtain timestart from run.def
172timestart=-9999 ! default value
173call getin("timestart",timestart)
174
175found=inquire_dimension("Time")
176if (.not.found) then
177  indextime = 1
178  write(*,*) "phyetat0: No time axis found in "//trim(fichnom)
179else
180  write(*,*) "phyetat0: Time axis found in "//trim(fichnom)
181  timelen=inquire_dimension_length("Time")
182  allocate(time(timelen))
183  ! load "Time" array:
184  call get_var("Time",time,found)
185  if (.not.found) then
186    write(*,*) "phyetat0: Failed loading <Time>"
187    call abort
188  endif
189  ! seclect the desired time index
190  IF (timestart .lt. 0) THEN  ! default: we use the last time value
191    indextime = timelen
192  ELSE  ! else we look for the desired value in the time axis
193    indextime = 0
194    DO i=1,timelen
195      IF (abs(time(i) - timestart) .lt. 0.01) THEN
196        indextime = i
197        EXIT
198      ENDIF
199    ENDDO
200    IF (indextime .eq. 0) THEN
201      PRINT*, "Time", timestart," is not in "//trim(fichnom)//"!!"
202      PRINT*, "Stored times are:"
203      DO i=1,timelen
204         PRINT*, time(i)
205      ENDDO
206      CALL abort
207    ENDIF
208  ENDIF ! of IF (timestart .lt. 0)
209  ! In startfi the absolute date is day_ini + time0 + time
210  ! For now on, in the GCM physics, it is day_ini + time0
211  time0 = time(indextime) + time0
212  day_ini = day_ini + INT(time0)
213  time0 = time0 - INT(time0)
214       
215  PRINT*, "phyetat0: Selected time ",time(indextime), &
216          " at index ",indextime
217     
218  DEALLOCATE(time)
219endif ! of if Time not found in file
220
221
222! CO2 ice cover
223call get_field("co2ice",co2ice,found,indextime)
224if (.not.found) then
225  write(*,*) "phyetat0: Failed loading <co2ice>"
226  call abort
227else
228  write(*,*) "phyetat0: CO2 ice cover <co2ice> range:", &
229             minval(co2ice), maxval(co2ice)
230endif
231
232
233! Dust conversion factor
234call get_field("tauscaling",tauscaling,found,indextime)
235if (.not.found) then
236  write(*,*) "phyetat0: <tauscaling> not in file"
237  tauscaling(:) = -1
238else
239  write(*,*) "phyetat0: dust conversion factor <tauscaling> range:", &
240             minval(tauscaling), maxval(tauscaling)
241endif
242
243! Sub-grid cloud fraction
244call get_field("totcloudfrac",totcloudfrac,found,indextime)
245if (.not.found) then
246  write(*,*) "phyetat0: <totcloudfrac> not in file WARNING put to 1"
247  totcloudfrac(:) = 1.0 !valeur par defaut (CLFfixval par defaut)
248else
249  write(*,*) "phyetat0: total cloud fraction <totcloudfrac> range:", &
250             minval(totcloudfrac), maxval(totcloudfrac)
251endif
252
253! Surface temperature :
254call get_field("tsurf",tsurf,found,indextime)
255if (.not.found) then
256  write(*,*) "phyetat0: Failed loading <tsurf>"
257  call abort
258else
259  write(*,*) "phyetat0: Surface temperature <tsurf> range:", &
260             minval(tsurf), maxval(tsurf)
261endif
262
263! Surface emissivity
264call get_field("emis",emis,found,indextime)
265if (.not.found) then
266  write(*,*) "phyetat0: Failed loading <emis>"
267  call abort
268else
269  write(*,*) "phyetat0: Surface emissivity <emis> range:", &
270             minval(emis), maxval(emis)
271endif
272
273
274! surface roughness length (NB: z0 is a common in surfdat_h)
275call get_field("z0",z0,found)
276if (.not.found) then
277  write(*,*) "phyetat0: Failed loading <z0>"
278  write(*,*) 'will use constant value of z0_default:',z0_default
279  z0(:)=z0_default
280else
281  write(*,*) "phyetat0: Surface roughness <z0> range:", &
282             minval(z0), maxval(z0)
283endif
284
285
286! pbl wind variance
287call get_field("q2",q2,found,indextime)
288if (.not.found) then
289  write(*,*) "phyetat0: Failed loading <q2>"
290  call abort
291else
292  write(*,*) "phyetat0: PBL wind variance <q2> range:", &
293             minval(q2), maxval(q2)
294endif
295
296
297! tracer on surface
298if (nq.ge.1) then
299  do iq=1,nq
300    txt=noms(iq)
301    if (txt.eq."h2o_vap") then
302      ! There is no surface tracer for h2o_vap;
303      ! "h2o_ice" should be loaded instead
304      txt="h2o_ice"
305      write(*,*) 'phyetat0: loading surface tracer', &
306                           ' h2o_ice instead of h2o_vap'
307    endif
308    call get_field(txt,qsurf(:,iq),found,indextime)
309    if (.not.found) then
310      write(*,*) "phyetat0: Failed loading <",trim(txt),">"
311      write(*,*) "         ",trim(txt)," is set to zero"
312    else
313      write(*,*) "phyetat0: Surface tracer <",trim(txt),"> range:", &
314                 minval(qsurf(:,iq)), maxval(qsurf(:,iq))
315    endif
316  enddo
317endif ! of if (nq.ge.1)
318
319! Call to soil_settings, in order to read soil temperatures,
320! as well as thermal inertia and volumetric heat capacity
321
322      call soil_settings(nid_start,ngrid,nsoil,tsurf,tsoil,indextime)
323
324!
325! close file:
326!
327      call close_startphy
328
329      END
Note: See TracBrowser for help on using the repository browser.