source: trunk/LMDZ.GENERIC/libf/phystd/phyetat0_mod.F90 @ 2176

Last change on this file since 2176 was 1763, checked in by jvatant, 7 years ago

Fixed a bug in phyetat0_mod : typo leading to uninitialized field sea_ice
JVO

File size: 11.4 KB
RevLine 
[1669]1module phyetat0_mod
2
3implicit none
4
5contains
6
7subroutine phyetat0 (startphy_file, &
8                     ngrid,nlayer,fichnom,tab0,Lmodif,nsoil,nq, &
[1216]9                     day_ini,time,tsurf,tsoil, &
[1297]10                     emis,q2,qsurf,cloudfrac,totcloudfrac,hice, &
11                     rnat,pctsrf_sic,tslab,tsea_ice,sea_ice)
[787]12
[1709]13! to use  'getin_p'
14      use ioipsl_getin_p_mod, only: getin_p
15
[1669]16  use tabfi_mod, only: tabfi
[1621]17  USE tracer_h, ONLY: noms
[1216]18  USE surfdat_h, only: phisfi, albedodat, zmea, zstd, zsig, zgam, zthe
19  use iostart, only: nid_start, open_startphy, close_startphy, &
20                     get_field, get_var, inquire_field, &
21                     inquire_dimension, inquire_dimension_length
[1297]22  use slab_ice_h, only: noceanmx
[1709]23  use callkeys_mod, only: CLFvarying,surfalbedo,surfemis
[787]24
[1216]25  implicit none
[787]26
[1216]27!======================================================================
[135]28!  Arguments:
29!  ---------
30!  inputs:
[1669]31  logical,intent(in) :: startphy_file ! .true. if reading start file
[1216]32  integer,intent(in) :: ngrid
[1308]33  integer,intent(in) :: nlayer
[1216]34  character*(*),intent(in) :: fichnom ! "startfi.nc" file
35  integer,intent(in) :: tab0
36  integer,intent(in) :: Lmodif
37  integer,intent(in) :: nsoil ! # of soil layers
38  integer,intent(in) :: nq
[1669]39  integer,intent(out) :: day_ini
40  real,intent(out) :: time
[135]41
42!  outputs:
[1216]43  real,intent(out) :: tsurf(ngrid) ! surface temperature
44  real,intent(out) :: tsoil(ngrid,nsoil) ! soil temperature
45  real,intent(out) :: emis(ngrid) ! surface emissivity
[1308]46  real,intent(out) :: q2(ngrid,nlayer+1) !
[1216]47  real,intent(out) :: qsurf(ngrid,nq) ! tracers on surface
48! real co2ice(ngrid) ! co2 ice cover
[1308]49  real,intent(out) :: cloudfrac(ngrid,nlayer)
[1216]50  real,intent(out) :: hice(ngrid), totcloudfrac(ngrid)
[1297]51  real,intent(out) :: pctsrf_sic(ngrid),tslab(ngrid,noceanmx) 
52  real,intent(out) :: tsea_ice(ngrid),sea_ice(ngrid)
53  real,intent(out) :: rnat(ngrid)
[135]54
55!======================================================================
56!  Local variables:
57
58!      INTEGER radpas
59!      REAL co2_ppm
60!      REAL solaire
61
62      real xmin,xmax ! to display min and max of a field
[1216]63!
[135]64      INTEGER ig,iq,lmax
65      INTEGER nid, nvarid
66      INTEGER ierr, i, nsrf
67!      integer isoil
68!      INTEGER length
69!      PARAMETER (length=100)
70      CHARACTER*7 str7
71      CHARACTER*2 str2
72      CHARACTER*1 yes
[1216]73!
[135]74      REAL p_rad,p_omeg,p_g,p_cpp,p_mugaz,p_daysec
75      INTEGER nqold
76
77! flag which identifies if 'startfi.nc' file is using old names (qsurf01,...)
[1216]78!      logical :: oldtracernames=.false.
[135]79      integer :: count
80      character(len=30) :: txt ! to store some text
[1216]81     
82      INTEGER :: indextime=1 ! index of selected time, default value=1
83      logical :: found
[1669]84     
85      character(len=8) :: modname="phyetat0"
[135]86
[1216]87!
88! ALLOCATE ARRAYS IN surfdat_h
89!
90IF (.not. ALLOCATED(albedodat)) ALLOCATE(albedodat(ngrid))
91IF (.not. ALLOCATED(phisfi)) ALLOCATE(phisfi(ngrid))
92IF (.not. ALLOCATED(zmea)) ALLOCATE(zmea(ngrid))
93IF (.not. ALLOCATED(zstd)) ALLOCATE(zstd(ngrid))
94IF (.not. ALLOCATED(zsig)) ALLOCATE(zsig(ngrid))
95IF (.not. ALLOCATED(zgam)) ALLOCATE(zgam(ngrid))
96IF (.not. ALLOCATED(zthe)) ALLOCATE(zthe(ngrid))
[787]97
[1669]98if (startphy_file) then
99  ! open physics initial state file:
100  call open_startphy(fichnom)
[1297]101
[1669]102  ! possibility to modify tab_cntrl in tabfi
103  write(*,*)
104  write(*,*) 'TABFI in phyeta0: Lmodif=',Lmodif," tab0=",tab0
105  call tabfi (ngrid,nid_start,Lmodif,tab0,day_ini,lmax,p_rad, &
106                   p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time)
[135]107
[1669]108else ! "academic" initialization of planetary parameters via tabfi
109  call tabfi (ngrid,0,0,0,day_ini,lmax,p_rad, &
[1216]110                   p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time)
[1669]111endif ! of if (startphy_file)
[135]112
[1669]113if (startphy_file) then
114  ! Load surface geopotential:
115  call get_field("phisfi",phisfi,found)
116  if (.not.found) then
117    call abort_physic(modname,"Failed loading <phisfi>",1)
118  endif
[1216]119else
[1709]120  phisfi(:)=0.
[1669]121endif ! of if (startphy_file)
122write(*,*) "phyetat0: surface geopotential <phisfi> range:", &
123               minval(phisfi), maxval(phisfi)
[253]124
[1669]125if (startphy_file) then
126  ! Load bare ground albedo:
127  call get_field("albedodat",albedodat,found)
128  if (.not.found) then
129    call abort_physic(modname,"Failed loading <albedodat>",1)
130  endif
[1216]131else
[1709]132  ! If no startfi file, use parameter surfalbedo in def file
133  surfalbedo=0.5
134  call getin_p("surfalbedo",surfalbedo)
135  print*,"surfalbedo",surfalbedo
136  albedodat(:)=surfalbedo
[1669]137endif ! of if (startphy_file)
138write(*,*) "phyetat0: Bare ground albedo <albedodat> range:", &
[1216]139             minval(albedodat), maxval(albedodat)
[253]140
[1216]141! ZMEA
[1669]142if (startphy_file) then
143  call get_field("ZMEA",zmea,found)
144  if (.not.found) then
145    call abort_physic(modname,"Failed loading <ZMEA>",1)
146  endif
[1216]147else
[1709]148  zmea(:)=0.
[1669]149endif ! of if (startphy_file)
150write(*,*) "phyetat0: <ZMEA> range:", &
[1216]151             minval(zmea), maxval(zmea)
[253]152
[1216]153! ZSTD
[1669]154if (startphy_file) then
155  call get_field("ZSTD",zstd,found)
156  if (.not.found) then
157    call abort_physic(modname,"Failed loading <ZSTD>",1)
158  endif
[1216]159else
[1709]160  zstd(:)=0.
[1669]161endif ! of if (startphy_file)
162write(*,*) "phyetat0: <ZSTD> range:", &
[1216]163             minval(zstd), maxval(zstd)
[253]164
[1216]165! ZSIG
[1669]166if (startphy_file) then
167  call get_field("ZSIG",zsig,found)
168  if (.not.found) then
169    call abort_physic(modname,"Failed loading <ZSIG>",1)
170  endif
[1216]171else
[1709]172  zsig(:)=0.
[1669]173endif ! of if (startphy_file)
174write(*,*) "phyetat0: <ZSIG> range:", &
[1216]175             minval(zsig), maxval(zsig)
[253]176
[1216]177! ZGAM
[1669]178if (startphy_file) then
179  call get_field("ZGAM",zgam,found)
180  if (.not.found) then
181    call abort_physic(modname,"Failed loading <ZGAM>",1)
182  endif
[1216]183else
[1709]184  zgam(:)=0.
[1669]185endif ! of if (startphy_file)
186write(*,*) "phyetat0: <ZGAM> range:", &
[1216]187             minval(zgam), maxval(zgam)
[253]188
[1216]189! ZTHE
[1669]190if (startphy_file) then
191  call get_field("ZTHE",zthe,found)
192  if (.not.found) then
193    call abort_physic(modname,"Failed loading <ZTHE>",1)
194  endif
[1216]195else
[1709]196  zthe(:)=0.
[1669]197endif ! of if (startphy_file)
198write(*,*) "phyetat0: <ZTHE> range:", &
[1216]199             minval(zthe), maxval(zthe)
[253]200
[1216]201! Surface temperature :
[1669]202if (startphy_file) then
203  call get_field("tsurf",tsurf,found,indextime)
204  if (.not.found) then
205    call abort_physic(modname,"Failed loading <tsurf>",1)
206  endif
[1216]207else
[1709]208  tsurf(:)=0. ! will be updated afterwards in physiq !
[1669]209endif ! of if (startphy_file)
210write(*,*) "phyetat0: Surface temperature <tsurf> range:", &
[1216]211             minval(tsurf), maxval(tsurf)
[135]212
[1216]213! Surface emissivity
[1669]214if (startphy_file) then
215  call get_field("emis",emis,found,indextime)
216  if (.not.found) then
217    call abort_physic(modname,"Failed loading <emis>",1)
218  endif
[1216]219else
[1709]220  ! If no startfi file, use parameter surfemis in def file
221  surfemis=1.0
222  call getin_p("surfemis",surfemis)
223  print*,"surfemis",surfemis
224  emis(:)=surfemis
[1669]225endif ! of if (startphy_file)
226write(*,*) "phyetat0: Surface emissivity <emis> range:", &
[1216]227             minval(emis), maxval(emis)
[135]228
[1216]229! Cloud fraction (added by BC 2010)
[1421]230if (CLFvarying) then
[1669]231  if (startphy_file) then
232    call get_field("cloudfrac",cloudfrac,found,indextime)
233    if (.not.found) then
234      call abort_physic(modname,"Failed loading <cloudfrac>",1)
235    endif
236  else
[1709]237    cloudfrac(:,:)=0.0
[1669]238  endif ! of if (startphy_file)
[1216]239  write(*,*) "phyetat0: Cloud fraction <cloudfrac> range:", &
[1669]240               minval(cloudfrac), maxval(cloudfrac)
[1421]241else
[1669]242  cloudfrac(:,:)=0.0
243endif ! of if (CLFvarying)
[1216]244
245! Total cloud fraction (added by BC 2010)
[1421]246if (CLFvarying) then
[1669]247  if (startphy_file) then
248    call get_field("totcloudfrac",totcloudfrac,found,indextime)
249    if (.not.found) then
250      call abort_physic(modname,"Failed loading <totcloudfrac>",1)
251    endif
252  else
[1709]253    totcloudfrac(:)=0.0
[1669]254  endif ! of if (startphy_file)
[1216]255  write(*,*) "phyetat0: Total cloud fraction <totcloudfrac> range:", &
256             minval(totcloudfrac), maxval(totcloudfrac)
[1421]257else
[1669]258  totcloudfrac(:)=0.0
259endif ! of if (CLFvarying)
[1216]260
261! Height of oceanic ice (added by BC 2010)
[1669]262if (startphy_file) then
263  call get_field("hice",hice,found,indextime)
264  if (.not.found) then
265    write(*,*) "phyetat0: Failed loading <hice>"
266    !  call abort
[1709]267    hice(:)=0.
[1669]268  endif
[1216]269else
[1709]270  hice(:)=0.
[1669]271endif ! of if (startphy_file)
272write(*,*) "phyetat0: Height of oceanic ice <hice> range:", &
[1216]273             minval(hice), maxval(hice)
274
[1297]275! SLAB OCEAN (added by BC 2014)
[1669]276if (startphy_file) then
277  ! nature of the surface
278  call get_field("rnat",rnat,found,indextime)
279  if (.not.found) then
280    write(*,*) "phyetat0: Failed loading <rnat>"
281        rnat(1:ngrid)=1.
282  else
[1297]283      do ig=1,ngrid
284        if((nint(rnat(ig)).eq.2).or.(nint(rnat(ig)).eq.0))then
285          rnat(ig)=0.
286        else
287          rnat(ig)=1.
288        endif     
289      enddo
[1669]290  endif ! of if (.not.found)
291else
[1709]292  rnat(:)=1.
[1669]293endif ! of if (startphy_file)
294write(*,*) "phyetat0: Nature of surface <rnat> range:", &
295             minval(rnat), maxval(rnat)
[1297]296
[1669]297if (startphy_file) then
298  ! Pourcentage of sea ice cover
299  call get_field("pctsrf_sic",pctsrf_sic,found,indextime)
300  if (.not.found) then
301    write(*,*) "phyetat0: Failed loading <pctsrf_sic>"
302    pctsrf_sic(1:ngrid)=0.
303  endif
[1297]304else
[1709]305  pctsrf_sic(:)=0.
[1669]306endif ! of if (startphy_file)
307write(*,*) "phyetat0: Pourcentage of sea ice cover <pctsrf_sic> range:", &
[1297]308             minval(pctsrf_sic), maxval(pctsrf_sic)
[1669]309
310if (startphy_file) then
311  ! Slab ocean temperature (2 layers)
312  call get_field("tslab",tslab,found,indextime)
313  if (.not.found) then
314    write(*,*) "phyetat0: Failed loading <tslab>"
315    do iq=1,noceanmx
316      tslab(1:ngrid,iq)=tsurf(1:ngrid)
317    enddo
318  endif
[1297]319else
[1669]320  do iq=1,noceanmx
321    tslab(1:ngrid,iq)=tsurf(1:ngrid)
322  enddo
323endif ! of if (startphy_file)
324write(*,*) "phyetat0: Slab ocean temperature <tslab> range:", &
[1297]325             minval(tslab), maxval(tslab)
[1669]326
327if (startphy_file) then
328  ! Oceanic ice temperature
329  call get_field("tsea_ice",tsea_ice,found,indextime)
330  if (.not.found) then
331    write(*,*) "phyetat0: Failed loading <tsea_ice>"
332    tsea_ice(1:ngrid)=273.15-1.8
333  endif
[1297]334else
[1669]335  tsea_ice(1:ngrid)=273.15-1.8
336endif ! of if (startphy_file)
337write(*,*) "phyetat0: Oceanic ice temperature <tsea_ice> range:", &
[1297]338             minval(tsea_ice), maxval(tsea_ice)
[1669]339
340if (startphy_file) then
341  !  Oceanic ice quantity (kg/m^2)
342  call get_field("sea_ice",sea_ice,found,indextime)
343  if (.not.found) then
344    write(*,*) "phyetat0: Failed loading <sea_ice>"
[1763]345    sea_ice(1:ngrid)=0.
[1669]346  endif
[1297]347else
[1763]348  sea_ice(1:ngrid)=0.
[1669]349endif ! of if (startphy_file)
350write(*,*) "phyetat0: Oceanic ice quantity <sea_ice> range:", &
[1297]351             minval(sea_ice), maxval(sea_ice)
352
353
[1216]354! pbl wind variance
[1669]355if (startphy_file) then
356  call get_field("q2",q2,found,indextime)
357  if (.not.found) then
358    call abort_physic(modname,"Failed loading <q2>",1)
359  endif
[1216]360else
[1709]361  q2(:,:)=0.
[1669]362endif ! of if (startphy_file)
363write(*,*) "phyetat0: PBL wind variance <q2> range:", &
[1216]364             minval(q2), maxval(q2)
365
366! tracer on surface
367if (nq.ge.1) then
368  do iq=1,nq
[1621]369    txt=noms(iq)
[1669]370    if (startphy_file) then
371      call get_field(txt,qsurf(:,iq),found,indextime)
372      if (.not.found) then
373        write(*,*) "phyetat0: Failed loading <",trim(txt),">"
374        write(*,*) "         ",trim(txt)," is set to zero"
375        qsurf(:,iq) = 0.
376      endif
[1216]377    else
[1709]378      qsurf(:,iq)=0.
[1669]379    endif ! of if (startphy_file)
380    write(*,*) "phyetat0: Surface tracer <",trim(txt),"> range:", &
[1216]381                 minval(qsurf(:,iq)), maxval(qsurf(:,iq))
[1669]382  enddo! of do iq=1,nq
[1216]383endif ! of if (nq.ge.1)
384
[1297]385
[1669]386if (startphy_file) then
387  ! Call to soil_settings, in order to read soil temperatures,
388  ! as well as thermal inertia and volumetric heat capacity
389  call soil_settings(nid_start,ngrid,nsoil,tsurf,tsoil,indextime)
390endif ! of if (startphy_file)
[1216]391!
392! close file:
393!
[1669]394if (startphy_file) call close_startphy
[1216]395
[1669]396end subroutine phyetat0
397
398end module phyetat0_mod
Note: See TracBrowser for help on using the repository browser.