source: trunk/LMDZ.PLUTO/libf/phypluto/phyetat0_mod.F90 @ 3506

Last change on this file since 3506 was 3506, checked in by afalco, 13 days ago

Pluto: import write_output function from Mars.
xios specific outputs.
AF

File size: 9.3 KB
Line 
1module phyetat0_mod
2
3implicit none
4
5real, save :: tab_cntrl_mod(100)
6
7!$OMP THREADPRIVATE(tab_cntrl_mod)
8
9
10contains
11
12subroutine phyetat0 (startphy_file, &
13                     ngrid,nlayer,fichnom,tab0,Lmodif,nsoil,nq, &
14                     day_ini,time,tsurf,tsoil, &
15                     emis,q2,qsurf,therm_inertia)
16                    !  ,cloudfrac,totcloudfrac,hice, &
17                    !  rnat,pctsrf_sic)
18                    !  ,tslab,tsea_ice,sea_ice) !AF24
19
20! to use  'getin_p'
21      use ioipsl_getin_p_mod, only: getin_p
22!!
23  use write_field_phy, only: Writefield_phy
24!!
25  use comsoil_h, only: nsoilmx
26  use tabfi_mod, only: tabfi
27  USE tracer_h, ONLY: noms
28  USE surfdat_h, only: phisfi, albedodat, zmea, zstd, zsig, zgam, zthe
29  use iostart, only: nid_start, open_startphy, close_startphy, &
30                     get_field, get_var, inquire_field, &
31                     inquire_dimension, inquire_dimension_length
32  use callkeys_mod, only: surfalbedo,surfemis, callsoil
33  use mod_phys_lmdz_para, only : is_master
34  implicit none
35
36!======================================================================
37!  Arguments:
38!  ---------
39!  inputs:
40  logical,intent(in) :: startphy_file ! .true. if reading start file
41  integer,intent(in) :: ngrid
42  integer,intent(in) :: nlayer
43  character*(*),intent(in) :: fichnom ! "startfi.nc" file
44  integer,intent(in) :: tab0
45  integer,intent(in) :: Lmodif
46  integer,intent(in) :: nsoil ! # of soil layers
47  integer,intent(in) :: nq
48  integer,intent(out) :: day_ini
49  real,intent(out) :: time
50
51!  outputs:
52  real,intent(out) :: tsurf(ngrid) ! surface temperature
53  real,intent(out) :: tsoil(ngrid,nsoil) ! soil temperature
54  real,intent(out) :: emis(ngrid) ! surface emissivity
55  real,intent(out) :: q2(ngrid,nlayer+1) !
56  real,intent(out) :: qsurf(ngrid,nq) ! tracers on surface
57  real,intent(out) :: therm_inertia(ngrid,nsoilmx) ! thermal inertia
58! real n2ice(ngrid) ! n2 ice cover
59
60!======================================================================
61!  Local variables:
62
63!      INTEGER radpas
64!      REAL n2_ppm
65!      REAL solaire
66
67      real xmin,xmax ! to display min and max of a field
68!
69      INTEGER ig,iq,lmax
70      INTEGER nid, nvarid
71      INTEGER ierr, i, nsrf
72!      integer isoil
73!      INTEGER length
74!      PARAMETER (length=100)
75      CHARACTER*7 str7
76      CHARACTER*2 str2
77      CHARACTER*1 yes
78!
79      REAL p_rad,p_omeg,p_g,p_cpp,p_mugaz,p_daysec,thermal_inertia_if_no_startfi
80      INTEGER nqold
81
82! flag which identifies if 'startfi.nc' file is using old names (qsurf01,...)
83!      logical :: oldtracernames=.false.
84      integer :: count
85      character(len=30) :: txt ! to store some text
86
87      INTEGER :: indextime=1 ! index of selected time, default value=1
88      logical :: found
89
90      character(len=8) :: modname="phyetat0"
91
92!
93! ALLOCATE ARRAYS IN surfdat_h
94!
95IF (.not. ALLOCATED(albedodat)) ALLOCATE(albedodat(ngrid))
96IF (.not. ALLOCATED(phisfi)) ALLOCATE(phisfi(ngrid))
97IF (.not. ALLOCATED(zmea)) ALLOCATE(zmea(ngrid))
98IF (.not. ALLOCATED(zstd)) ALLOCATE(zstd(ngrid))
99IF (.not. ALLOCATED(zsig)) ALLOCATE(zsig(ngrid))
100IF (.not. ALLOCATED(zgam)) ALLOCATE(zgam(ngrid))
101IF (.not. ALLOCATED(zthe)) ALLOCATE(zthe(ngrid))
102
103if (startphy_file) then
104  ! open physics initial state file:
105  call open_startphy(fichnom)
106
107  ! possibility to modify tab_cntrl in tabfi
108  if (is_master) write(*,*)
109  if (is_master) write(*,*) 'TABFI in phyeta0: Lmodif=',Lmodif," tab0=",tab0
110  call tabfi (ngrid,nid_start,Lmodif,tab0,day_ini,lmax,p_rad, &
111                   p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time)
112
113else ! "academic" initialization of planetary parameters via tabfi
114  call tabfi (ngrid,0,0,0,day_ini,lmax,p_rad, &
115                   p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time)
116endif ! of if (startphy_file)
117
118if (startphy_file) then
119  ! Load surface geopotential:
120  call get_field("phisfi",phisfi,found)
121  if (.not.found) then
122    call abort_physic(modname,"Failed loading <phisfi>",1)
123  endif
124else
125  phisfi(:)=0.
126endif ! of if (startphy_file)
127if (is_master) write(*,*) "phyetat0: surface geopotential <phisfi> range:", &
128               minval(phisfi), maxval(phisfi)
129
130if (startphy_file) then
131  ! Load bare ground albedo:
132  call get_field("albedodat",albedodat,found)
133  if (.not.found) then
134    call abort_physic(modname,"Failed loading <albedodat>",1)
135  endif
136else
137  ! If no startfi file, use parameter surfalbedo in def file
138  surfalbedo=0.5
139  call getin_p("surfalbedo",surfalbedo)
140  if (is_master) print*,"surfalbedo",surfalbedo
141  albedodat(:)=surfalbedo
142endif ! of if (startphy_file)
143if (is_master) write(*,*) "phyetat0: Bare ground albedo <albedodat> range:", &
144             minval(albedodat), maxval(albedodat)
145
146! ZMEA
147if (startphy_file) then
148  call get_field("ZMEA",zmea,found)
149  if (.not.found) then
150    call abort_physic(modname,"Failed loading <ZMEA>",1)
151  endif
152else
153  zmea(:)=0.
154endif ! of if (startphy_file)
155if (is_master) write(*,*) "phyetat0: <ZMEA> range:", &
156             minval(zmea), maxval(zmea)
157
158! ZSTD
159if (startphy_file) then
160  call get_field("ZSTD",zstd,found)
161  if (.not.found) then
162    call abort_physic(modname,"Failed loading <ZSTD>",1)
163  endif
164else
165  zstd(:)=0.
166endif ! of if (startphy_file)
167if (is_master) write(*,*) "phyetat0: <ZSTD> range:", &
168             minval(zstd), maxval(zstd)
169
170! ZSIG
171if (startphy_file) then
172  call get_field("ZSIG",zsig,found)
173  if (.not.found) then
174    call abort_physic(modname,"Failed loading <ZSIG>",1)
175  endif
176else
177  zsig(:)=0.
178endif ! of if (startphy_file)
179if (is_master) write(*,*) "phyetat0: <ZSIG> range:", &
180             minval(zsig), maxval(zsig)
181
182! ZGAM
183if (startphy_file) then
184  call get_field("ZGAM",zgam,found)
185  if (.not.found) then
186    call abort_physic(modname,"Failed loading <ZGAM>",1)
187  endif
188else
189  zgam(:)=0.
190endif ! of if (startphy_file)
191if (is_master) write(*,*) "phyetat0: <ZGAM> range:", &
192             minval(zgam), maxval(zgam)
193
194! ZTHE
195if (startphy_file) then
196  call get_field("ZTHE",zthe,found)
197  if (.not.found) then
198    call abort_physic(modname,"Failed loading <ZTHE>",1)
199  endif
200else
201  zthe(:)=0.
202endif ! of if (startphy_file)
203if (is_master) write(*,*) "phyetat0: <ZTHE> range:", &
204             minval(zthe), maxval(zthe)
205
206! Surface temperature :
207if (startphy_file) then
208  call get_field("tsurf",tsurf,found,indextime)
209  if (.not.found) then
210    call abort_physic(modname,"Failed loading <tsurf>",1)
211  endif
212else
213  tsurf(:)=0. ! will be updated afterwards in physiq !
214endif ! of if (startphy_file)
215if (is_master) write(*,*) "phyetat0: Surface temperature <tsurf> range:", &
216             minval(tsurf), maxval(tsurf)
217
218! Surface emissivity
219if (startphy_file) then
220  call get_field("emis",emis,found,indextime)
221  if (.not.found) then
222    call abort_physic(modname,"Failed loading <emis>",1)
223  endif
224else
225  ! If no startfi file, use parameter surfemis in def file
226  surfemis=1.0
227  call getin_p("surfemis",surfemis)
228  if (is_master) print*,"surfemis",surfemis
229  emis(:)=surfemis
230endif ! of if (startphy_file)
231if (is_master) write(*,*) "phyetat0: Surface emissivity <emis> range:", &
232             minval(emis), maxval(emis)
233
234! !AF24 removed ocean stuff
235
236! pbl wind variance
237if (startphy_file) then
238  call get_field("q2",q2,found,indextime)
239  if (.not.found) then
240    call abort_physic(modname,"Failed loading <q2>",1)
241  endif
242else
243  q2(:,:)=0.
244endif ! of if (startphy_file)
245if (is_master) write(*,*) "phyetat0: PBL wind variance <q2> range:", &
246             minval(q2), maxval(q2)
247
248! tracer on surface
249if (nq.ge.1) then
250  do iq=1,nq
251    txt=noms(iq)
252    if (startphy_file) then
253      call get_field(txt,qsurf(:,iq),found,indextime)
254      if (.not.found) then
255        write(*,*) "phyetat0: Failed loading <",trim(txt),">"
256        write(*,*) "         ",trim(txt)," is set to zero"
257        qsurf(:,iq) = 0.
258      endif
259    else
260      qsurf(:,iq)=0.
261    endif ! of if (startphy_file)
262    write(*,*) "phyetat0: Surface tracer <",trim(txt),"> range:", &
263                 minval(qsurf(:,iq)), maxval(qsurf(:,iq))
264  enddo! of do iq=1,nq
265endif ! of if (nq.ge.1)
266
267!!call WriteField_phy("in_phyetat0_qsurf",qsurf(1:ngrid,igcm_h2o_gas),1)
268
269if (startphy_file) then
270  ! Call to soil_settings, in order to read soil temperatures,
271  ! as well as thermal inertia and volumetric heat capacity
272  if (callsoil) then
273    call soil_settings(nid_start,ngrid,nsoil,tsurf,tsoil,indextime)
274  endif
275else
276  thermal_inertia_if_no_startfi=400 ! default value
277  call getin_p("thermal_inertia_if_no_startfi",thermal_inertia_if_no_startfi)
278  therm_inertia(:,:) = thermal_inertia_if_no_startfi
279    !AF24
280endif ! of if (startphy_file)
281
282!
283! close file:
284!
285if (startphy_file) call close_startphy
286
287end subroutine phyetat0
288
289
290!======================================================================
291subroutine ini_tab_controle_dyn_xios(idayref)
292
293use comcstfi_mod,        only: g, mugaz, omeg, rad, rcp
294use time_phylmdz_mod,  only: daysec, dtphys
295use mod_grid_phy_lmdz, only: nbp_lon, nbp_lat, nbp_lev
296
297implicit none
298
299integer*4, intent(in) :: idayref ! date (initial date for this run)
300
301integer :: length, l
302parameter (length = 100)
303real    :: tab_cntrl(length) ! run parameters are stored in this array
304
305do l = 1,length
306    tab_cntrl(l) = 0.
307enddo
308tab_cntrl(1)  = real(nbp_lon)
309tab_cntrl(2)  = real(nbp_lat-1)
310tab_cntrl(3)  = real(nbp_lev)
311tab_cntrl(4)  = real(idayref)
312tab_cntrl(5)  = rad
313tab_cntrl(6)  = omeg
314tab_cntrl(7)  = g
315tab_cntrl(8)  = mugaz
316tab_cntrl(9)  = rcp
317tab_cntrl(10) = daysec
318tab_cntrl(11) = dtphys
319
320tab_cntrl_mod = tab_cntrl
321
322end subroutine ini_tab_controle_dyn_xios
323
324
325end module phyetat0_mod
Note: See TracBrowser for help on using the repository browser.