SUBROUTINE phyetat0 (fichnom,tab0,Lmodif,nsoil,nq, . day_ini,time0, . tsurf,tsoil,emis,q2,qsurf,co2ice) use netcdf implicit none c====================================================================== c Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818 c Adaptation à Mars : Yann Wanherdrick c 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 c====================================================================== !#include "netcdf.inc" #include "dimensions.h" #include "dimphys.h" !#include "comgeomfi.h" #include "surfdat.h" #include "planete.h" #include "dimradmars.h" #include "yomaer.h" #include "comcstfi.h" !#include "tracer.h" #include "advtrac.h" #include "control.h" c====================================================================== INTEGER nbsrf !Mars nbsrf a 1 au lieu de 4 PARAMETER (nbsrf=1) ! nombre de sous-fractions pour une maille !====================================================================== ! Arguments: ! --------- ! inputs: character*(*) fichnom ! "startfi.nc" file integer tab0 integer Lmodif integer nsoil ! # of soil layers integer nq integer day_ini real time0 ! outputs: real tsurf(ngridmx) ! surface temperature real tsoil(ngridmx,nsoil) ! soil temperature real emis(ngridmx) ! surface emissivity real q2(ngridmx, llm+1) ! real qsurf(ngridmx,nq) ! tracers on surface real co2ice(ngridmx) ! co2 ice cover !====================================================================== ! Local variables: real surffield(ngridmx) ! to temporarily store a surface field real xmin,xmax ! to display min and max of a field c 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 c 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) c c Ouvrir le fichier contenant l etat initial: c ierr=nf90_open(fichnom,NF90_NOWRITE,nid) IF (ierr.NE.nf90_noerr) THEN write(6,*)' Pb d''ouverture du fichier ',trim(fichnom) write(*,*)trim(nf90_strerror(ierr)) CALL ABORT ENDIF ! Preliminary stuff: check if tracers follow old naming convention (qsurf01, ! qsurf02, ...) count=0 do iq=1,nqmx txt= " " write(txt,'(a5,i2.2)')'qsurf',iq ierr=nf90_inq_varid(nid,txt,nvarid) if (ierr.ne.nf90_noerr) then ! did not find old tracer name exit ! might as well stop here else ! found old tracer name count=count+1 endif enddo if (count.eq.nqmx) then write(*,*) "phyetat0:tracers seem to follow old naming ", & "convention (qsurf01,qsurf02,...)" write(*,*) " => will work for now ... " write(*,*) " but you should run newstart to rename them" oldtracernames=.true. endif c modifications possibles des variables de tab_cntrl PRINT* write(*,*) 'TABFI de phyeta0',Lmodif,tab0 call tabfi (nid,Lmodif,tab0,day_ini,lmax,p_rad, . p_omeg,p_g,p_mugaz,p_daysec,time0) c c Read latitudes (coordinates): No need, these are provided by the dynamics c ! ierr=nf90_inq_varid(nid,"latitude",nvarid) ! IF (ierr.NE.nf90_noerr) THEN ! PRINT*, 'phyetat0: Le champ est absent' ! write(*,*)trim(nf90_strerror(ierr)) ! CALL abort ! ENDIF ! ierr=nf90_get_var(nid,nvarid,lati) ! IF (ierr.NE.nf90_noerr) THEN ! PRINT*, 'phyetat0: Lecture echouee pour ' ! write(*,*)trim(nf90_strerror(ierr)) ! CALL abort ! ENDIF c c read longitudes (coordinates): No need, these are provided by the dynamics c ! ierr=nf90_inq_varid(nid,"longitude",nvarid) ! IF (ierr.NE.nf90_noerr) THEN ! PRINT*, 'phyetat0: Le champ est absent' ! write(*,*)trim(nf90_strerror(ierr)) ! CALL abort ! ENDIF ! ierr=nf90_get_var(nid,nvarid,long) ! IF (ierr.NE.nf90_noerr) THEN ! PRINT*, 'phyetat0: Lecture echouee pour ' ! write(*,*)trim(nf90_strerror(ierr)) ! CALL abort ! ENDIF c c Read areas of meshes: No need, these are provided by the dynamics c ! ierr=nf90_inq_varid(nid,"area",nvarid) ! IF (ierr.NE.nf90_noerr) THEN ! PRINT*, 'phyetat0: Le champ est absent' ! write(*,*)trim(nf90_strerror(ierr)) ! CALL abort ! ENDIF ! ierr=nf90_get_var(nid,nvarid,area) ! IF (ierr.NE.nf90_noerr) THEN ! PRINT*, 'phyetat0: Lecture echouee pour ' ! write(*,*)trim(nf90_strerror(ierr)) ! CALL abort ! ENDIF ! xmin = 1.0E+20 ! xmax = -1.0E+20 ! xmin = MINVAL(area) ! xmax = MAXVAL(area) ! PRINT*,'Aires des mailles :', xmin, xmax c c Lecture du geopotentiel au sol: c ierr=nf90_inq_varid(nid,"phisfi",nvarid) IF (ierr.NE.nf90_noerr) THEN PRINT*, 'phyetat0: Le champ est absent' write(*,*)trim(nf90_strerror(ierr)) CALL abort ENDIF ierr=nf90_get_var(nid,nvarid,phisfi) IF (ierr.NE.nf90_noerr) THEN PRINT*, 'phyetat0: Lecture echouee pour ' write(*,*)trim(nf90_strerror(ierr)) CALL abort ENDIF xmin = 1.0E+20 xmax = -1.0E+20 xmin = MINVAL(phisfi) xmax = MAXVAL(phisfi) PRINT*,'Geopotentiel au sol :', xmin, xmax c c Lecture de l''albedo du sol nu: c ierr=nf90_inq_varid(nid,"albedodat",nvarid) IF (ierr.NE.nf90_noerr) THEN PRINT*, 'phyetat0: Le champ est absent' write(*,*)trim(nf90_strerror(ierr)) CALL abort ENDIF ierr=nf90_get_var(nid,nvarid,albedodat) IF (ierr.NE.nf90_noerr) THEN PRINT*, 'phyetat0: Lecture echouee pour ' CALL abort ENDIF xmin = 1.0E+20 xmax = -1.0E+20 xmin = MINVAL(albedodat) xmax = MAXVAL(albedodat) PRINT*,'Albedo du sol nu :', xmin, xmax c c Lecture de l''inertie thermique du sol: c ! ierr = NF_INQ_VARID (nid, "inertiedat", nvarid) ! IF (ierr.NE.nf90_noerr) THEN ! PRINT*, 'phyetat0: Le champ est absent' ! CALL abort ! ENDIF !#ifdef NC_DOUBLE ! ierr = NF_GET_VAR_DOUBLE(nid, nvarid, inertiedat) !#else ! ierr = NF_GET_VAR_REAL(nid, nvarid, inertiedat) !#endif ! IF (ierr.NE.nf90_noerr) THEN ! PRINT*, 'phyetat0: Lecture echouee pour ' ! CALL abort ! ENDIF ! xmin = 1.0E+20 ! xmax = -1.0E+20 ! xmin = MINVAL(inertiedat) ! xmax = MAXVAL(inertiedat) ! PRINT*,'Inertie thermique du sol :', xmin, xmax c c ZMEA c ierr=nf90_inq_varid(nid,"ZMEA",nvarid) IF (ierr.NE.nf90_noerr) THEN PRINT*, 'phyetat0: Le champ est absent' write(*,*)trim(nf90_strerror(ierr)) CALL abort ENDIF ierr=nf90_get_var(nid,nvarid,zmea) IF (ierr.NE.nf90_noerr) THEN PRINT*, 'phyetat0: Lecture echouee pour ' write(*,*)trim(nf90_strerror(ierr)) CALL abort ENDIF xmin = 1.0E+20 xmax = -1.0E+20 DO i = 1, ngridmx xmin = MIN(zmea(i),xmin) xmax = MAX(zmea(i),xmax) ENDDO PRINT*,':', xmin, xmax c c ZSTD c ierr=nf90_inq_varid(nid,"ZSTD",nvarid) IF (ierr.NE.nf90_noerr) THEN PRINT*, 'phyetat0: Le champ est absent' write(*,*)trim(nf90_strerror(ierr)) CALL abort ENDIF ierr=nf90_get_var(nid,nvarid,zstd) IF (ierr.NE.nf90_noerr) THEN PRINT*, 'phyetat0: Lecture echouee pour ' write(*,*)trim(nf90_strerror(ierr)) CALL abort ENDIF xmin = 1.0E+20 xmax = -1.0E+20 DO i = 1, ngridmx xmin = MIN(zstd(i),xmin) xmax = MAX(zstd(i),xmax) ENDDO PRINT*,':', xmin, xmax c c ZSIG c ierr=nf90_inq_varid(nid,"ZSIG",nvarid) IF (ierr.NE.nf90_noerr) THEN PRINT*, 'phyetat0: Le champ est absent' write(*,*)trim(nf90_strerror(ierr)) CALL abort ENDIF ierr=nf90_get_var(nid,nvarid,zsig) IF (ierr.NE.nf90_noerr) THEN PRINT*, 'phyetat0: Lecture echouee pour ' write(*,*)trim(nf90_strerror(ierr)) CALL abort ENDIF xmin = 1.0E+20 xmax = -1.0E+20 DO i = 1, ngridmx xmin = MIN(zsig(i),xmin) xmax = MAX(zsig(i),xmax) ENDDO PRINT*,':', xmin, xmax c c ZGAM c ierr=nf90_inq_varid(nid,"ZGAM",nvarid) IF (ierr.NE.nf90_noerr) THEN PRINT*, 'phyetat0: Le champ est absent' write(*,*)trim(nf90_strerror(ierr)) CALL abort ENDIF ierr=nf90_get_var(nid,nvarid,zgam) IF (ierr.NE.nf90_noerr) THEN PRINT*, 'phyetat0: Lecture echouee pour ' write(*,*)trim(nf90_strerror(ierr)) CALL abort ENDIF xmin = 1.0E+20 xmax = -1.0E+20 DO i = 1, ngridmx xmin = MIN(zgam(i),xmin) xmax = MAX(zgam(i),xmax) ENDDO PRINT*,':', xmin, xmax c c ZTHE c ierr=nf90_inq_varid(nid,"ZTHE",nvarid) IF (ierr.NE.nf90_noerr) THEN PRINT*, 'phyetat0: Le champ est absent' write(*,*)trim(nf90_strerror(ierr)) CALL abort ENDIF ierr=nf90_get_var(nid,nvarid,zthe) IF (ierr.NE.nf90_noerr) THEN PRINT*, 'phyetat0: Lecture echouee pour ' write(*,*)trim(nf90_strerror(ierr)) CALL abort ENDIF xmin = 1.0E+20 xmax = -1.0E+20 DO i = 1, ngridmx xmin = MIN(zthe(i),xmin) xmax = MAX(zthe(i),xmax) ENDDO PRINT*,':', xmin, xmax c c Time axis c ierr = nf90_inq_dimid(nid,"Time",nvarid) IF (ierr .NE. nf90_noerr) THEN indextime = 1 print*, "phyetat0: No time axis found in "//fichnom ELSE print*, "phyetat0: Time axis found in "//fichnom ierr = nf90_inquire_dimension(nid,nvarid,len=timelen) ALLOCATE(time(timelen)) ierr=nf90_inq_varid(nid,"Time",nvarid) IF (ierr .NE. nf90_noerr) THEN ierr=nf90_inq_varid(nid,"temps", nvarid) IF (ierr .NE. nf90_noerr) THEN PRINT*, "dynetat0: