module phyetat0_mod implicit none real,save :: tab_cntrl_mod(100) !$OMP THREADPRIVATE(tab_cntrl_mod) contains subroutine phyetat0 (fichnom,tab0,Lmodif,nsoil,ngrid,nlay,nq, & day_ini,time0,tsurf,tsoil,albedo,emis,q2,qsurf,co2ice, & tauscaling,totcloudfrac,wstar,watercap) use tracer_mod, only: noms ! tracer names use surfdat_h, only: phisfi, albedodat, z0, z0_default,& zmea, zstd, zsig, zgam, zthe, hmons, summit, base use iostart, only: nid_start, open_startphy, close_startphy, & get_field, get_var, inquire_field, & inquire_dimension, inquire_dimension_length use nonoro_gwd_ran_mod, only: du_nonoro_gwd, dv_nonoro_gwd use compute_dtau_mod, only: dtau use dust_rad_adjust_mod, only: dust_rad_adjust_prev,dust_rad_adjust_next use dust_param_mod, only: dustscaling_mode USE ioipsl_getin_p_mod, ONLY : getin_p implicit none include "callkeys.h" !====================================================================== ! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818 ! Adaptation � Mars : Yann Wanherdrick ! Objet: Lecture de l etat initial pour la physique ! Modifs: Aug.2010 EM : use NetCDF90 to load variables (enables using ! r4 or r8 restarts independently of having compiled ! the GCM in r4 or r8) ! June 2013 TN : Possibility to read files with a time axis ! November 2013 EM : Enabeling parallel, using iostart module ! March 2020 AD: Enabling initialization of physics without startfi ! flag: startphy_file !====================================================================== INTEGER nbsrf !Mars nbsrf a 1 au lieu de 4 PARAMETER (nbsrf=1) ! nombre de sous-fractions pour une maille !====================================================================== ! Arguments: ! --------- ! inputs: ! logical,intent(in) :: startphy_file ! .true. if reading start file character*(*),intent(in) :: fichnom ! "startfi.nc" file integer,intent(in) :: tab0 integer,intent(in) :: Lmodif integer,intent(in) :: nsoil ! # of soil layers integer,intent(in) :: ngrid ! # of atmospheric columns integer,intent(in) :: nlay ! # of atmospheric layers integer,intent(in) :: nq integer :: day_ini real :: time0 ! outputs: real,intent(out) :: tsurf(ngrid) ! surface temperature real,intent(out) :: tsoil(ngrid,nsoil) ! soil temperature real,intent(out) :: albedo(ngrid,2) ! surface albedo real,intent(out) :: emis(ngrid) ! surface emissivity real,intent(out) :: q2(ngrid,nlay+1) ! real,intent(out) :: qsurf(ngrid,nq) ! tracers on surface real,intent(out) :: co2ice(ngrid) ! co2 ice cover real,intent(out) :: tauscaling(ngrid) ! dust conversion factor real,intent(out) :: totcloudfrac(ngrid) ! total cloud fraction real,intent(out) :: wstar(ngrid) ! Max vertical velocity in thermals (m/s) real,intent(out) :: watercap(ngrid) ! h2o_ice_cover !====================================================================== ! Local variables: real surffield(ngrid) ! to temporarily store a surface field real xmin,xmax ! to display min and max of a field ! INTEGER ig,iq,lmax INTEGER nid, nvarid INTEGER ierr, i, nsrf ! integer isoil ! INTEGER length ! PARAMETER (length=100) CHARACTER*7 str7 CHARACTER*2 str2 CHARACTER*1 yes ! REAL p_rad,p_omeg,p_g,p_mugaz,p_daysec INTEGER nqold ! flag which identifies if 'startfi.nc' file is using old names (qsurf01,...) logical :: oldtracernames=.false. integer :: count character(len=30) :: txt ! to store some text ! specific for time REAL,ALLOCATABLE :: time(:) ! times stored in start INTEGER timelen ! number of times stored in the file INTEGER indextime ! index of selected time INTEGER :: edges(3),corner(3) LOGICAL :: found REAL :: timestart ! to pick which initial state to start from REAL :: surfemis ! constant emissivity when no startfi REAL :: surfalbedo ! constant albedo when no startfi CHARACTER(len=5) :: modname="phyetat0" write(*,*) "phyetat0: startphy_file", startphy_file if (startphy_file) then ! open physics initial state file: call open_startphy(fichnom) ! possibility to modify tab_cntrl in tabfi write(*,*) write(*,*) 'TABFI in phyeta0: Lmodif=',Lmodif," tab0=",tab0 call tabfi (nid_start,Lmodif,tab0,day_ini,lmax,p_rad, & p_omeg,p_g,p_mugaz,p_daysec,time0) else ! "academic" initialization of planetary parameters via tabfi call tabfi (0,0,0,day_ini,lmax,p_rad, & p_omeg,p_g,p_mugaz,p_daysec,time0) endif ! of if (startphy_file) if (startphy_file) then ! Load surface geopotential: call get_field("phisfi",phisfi,found) if (.not.found) then call abort_physic(modname, & "phyetat0: Failed loading ",1) endif else phisfi(:)=0. endif ! of if (startphy_file) write(*,*) "phyetat0: surface geopotential range:", & minval(phisfi), maxval(phisfi) if (startphy_file) then ! Load bare ground albedo: call get_field("albedodat",albedodat,found) if (.not.found) then call abort_physic(modname, & "phyetat0: Failed loading ",1) endif else ! If no startfi file, use parameter surfalbedo in def file surfalbedo=0.1 call getin_p("surfalbedo_without_startfi",surfalbedo) print*,"surfalbedo_without_startfi",surfalbedo albedodat(:)=surfalbedo endif ! of if (startphy_file) write(*,*) "phyetat0: Bare ground albedo range:", & minval(albedodat), maxval(albedodat) ! ZMEA if (startphy_file) then call get_field("ZMEA",zmea,found) if (.not.found) then call abort_physic(modname, & "phyetat0: Failed loading ",1) endif else zmea(:)=0. endif ! of if (startphy_file) write(*,*) "phyetat0: range:", & minval(zmea), maxval(zmea) ! ZSTD if (startphy_file) then call get_field("ZSTD",zstd,found) if (.not.found) then call abort_physic(modname, & "phyetat0: Failed loading ",1) endif else zstd(:)=0. endif ! of if (startphy_file) write(*,*) "phyetat0: range:", & minval(zstd), maxval(zstd) ! ZSIG if (startphy_file) then call get_field("ZSIG",zsig,found) if (.not.found) then call abort_physic(modname, & "phyetat0: Failed loading ",1) endif else zsig(:)=0. endif ! of if (startphy_file) write(*,*) "phyetat0: range:", & minval(zsig), maxval(zsig) ! ZGAM if (startphy_file) then call get_field("ZGAM",zgam,found) if (.not.found) then call abort_physic(modname, & "phyetat0: Failed loading ",1) endif else zgam(:)=0. endif ! of if (startphy_file) write(*,*) "phyetat0: range:", & minval(zgam), maxval(zgam) ! ZTHE if (startphy_file) then call get_field("ZTHE",zthe,found) if (.not.found) then call abort_physic(modname, & "phyetat0: Failed loading ",1) endif else zthe(:)=0. endif ! of if (startphy_file) write(*,*) "phyetat0: range:", & minval(zthe), maxval(zthe) ! hmons if (startphy_file) then call get_field("hmons",hmons,found) if (.not.found) then write(*,*) "WARNING: phyetat0: Failed loading " if (rdstorm) then call abort_physic(modname, & "phyetat0: Failed loading ",1) else write(*,*) "will continue anyway..." write(*,*) "because you may not need it." hmons(:)=0. end if ! if (rdstorm) else do ig=1,ngrid if (hmons(ig) .eq. -999999.) hmons(ig)=0. enddo endif ! (.not.found) else hmons(:)=0. endif ! if (startphy_file) write(*,*) "phyetat0: range:", & minval(hmons), maxval(hmons) ! summit if (startphy_file) then call get_field("summit",summit,found) if (.not.found) then write(*,*) "WARNING: phyetat0: Failed loading " if (rdstorm) then call abort_physic(modname, & "phyetat0: Failed loading ",1) else write(*,*) "will continue anyway..." write(*,*) "because you may not need it." summit(:)=0. end if else do ig=1,ngrid if (summit(ig) .eq. -999999.) summit(ig)=0. enddo endif ! if (.not.found) else summit(:)=0. endif ! if (startphy_file) write(*,*) "phyetat0: range:", & minval(summit), maxval(summit) ! base if (startphy_file) then call get_field("base",base,found) if (.not.found) then write(*,*) "WARNING: phyetat0: Failed loading " if (rdstorm) then call abort_physic(modname, & "phyetat0: Failed loading ",1) else write(*,*) "will continue anyway..." write(*,*) "because you may not need it." base(:)=0. end if else do ig=1,ngrid if (base(ig) .eq. -999999.) base(ig)=0. enddo endif ! if(.not.found) else base(:)=0. endif ! if (startphy_file) write(*,*) "phyetat0: range:", & minval(base), maxval(base) ! Time axis ! obtain timestart from run.def timestart=-9999 ! default value call getin_p("timestart",timestart) if (startphy_file) then found=inquire_dimension("Time") if (.not.found) then indextime = 1 write(*,*) "phyetat0: No time axis found in "//trim(fichnom) else write(*,*) "phyetat0: Time axis found in "//trim(fichnom) timelen=inquire_dimension_length("Time") allocate(time(timelen)) ! load "Time" array: call get_var("Time",time,found) if (.not.found) then call abort_physic(modname, & "phyetat0: Failed loading