--- trunk/phylmd/phyetat0.f 2014/07/02 18:39:15 99 +++ trunk/Sources/phylmd/phyetat0.f 2015/07/08 17:03:45 155 @@ -4,14 +4,16 @@ IMPLICIT none - REAL, save:: rlat(klon), rlon(klon) ! latitude and longitude, in degrees + REAL, save:: rlat(klon), rlon(klon) + ! latitude and longitude of a point of the scalar grid identified + ! by a simple index, in degrees private klon contains SUBROUTINE phyetat0(pctsrf, tsol, tsoil, tslab, seaice, qsurf, qsol, & - snow, albe, alblw, evap, rain_fall, snow_fall, solsw, sollw, fder, & + snow, albe, evap, rain_fall, snow_fall, solsw, sollw, fder, & radsol, frugs, agesno, zmea, zstd, zsig, zgam, zthe, zpic, zval, & t_ancien, q_ancien, ancien_ok, rnebcon, ratqs, clwcon, run_off_lic_0, & sig1, w01) @@ -24,10 +26,10 @@ use dimphy, only: zmasq, klev USE dimsoil, ONLY : nsoilmx USE indicesol, ONLY : epsfra, is_lic, is_oce, is_sic, is_ter, nbsrf - use netcdf, only: nf90_get_att, nf90_global, nf90_inq_varid, NF90_NOERR, & + use netcdf, only: nf90_global, nf90_inq_varid, NF90_NOERR, & NF90_NOWRITE - use netcdf95, only: handle_err, nf95_get_var, nf95_close, NF95_OPEN, & - nf95_inq_varid + use netcdf95, only: nf95_close, nf95_get_att, nf95_get_var, & + nf95_inq_varid, nf95_inquire_variable, NF95_OPEN USE temps, ONLY : itau_phy REAL pctsrf(klon, nbsrf) @@ -38,7 +40,6 @@ REAL, intent(out):: qsol(:) ! (klon) REAL snow(klon, nbsrf) REAL albe(klon, nbsrf) - REAL alblw(klon, nbsrf) REAL evap(klon, nbsrf) REAL, intent(out):: rain_fall(klon) REAL snow_fall(klon) @@ -67,9 +68,8 @@ ! Local: REAL fractint(klon) REAL xmin, xmax - INTEGER ncid, varid - INTEGER ierr, i, nsrf, isoil - CHARACTER(len=7) str7 + INTEGER ncid, varid, ndims + INTEGER ierr, i, nsrf CHARACTER(len=2) str2 !--------------------------------------------------------------- @@ -79,8 +79,7 @@ ! Fichier contenant l'état initial : call NF95_OPEN("startphy.nc", NF90_NOWRITE, ncid) - ierr = nf90_get_att(ncid, nf90_global, "itau_phy", itau_phy) - call handle_err("phyetat0 itau_phy", ierr, ncid, nf90_global) + call nf95_get_att(ncid, nf90_global, "itau_phy", itau_phy) ! Lecture des latitudes (coordonnees): @@ -94,13 +93,9 @@ ! Lecture du masque terre mer - ierr = NF90_INQ_VARID(ncid, "masque", varid) - IF (ierr == NF90_NOERR) THEN - call nf95_get_var(ncid, varid, zmasq) - else - PRINT *, 'phyetat0: Le champ est absent' - PRINT *, 'fichier startphy non compatible avec phyetat0' - ENDIF + call NF95_INQ_VARID(ncid, "masque", varid) + call nf95_get_var(ncid, varid, zmasq) + ! Lecture des fractions pour chaque sous-surface ! initialisation des sous-surfaces @@ -163,66 +158,20 @@ END DO ! Lecture des temperatures du sol: - - ierr = NF90_INQ_VARID(ncid, "TS", varid) - IF (ierr /= NF90_NOERR) THEN - PRINT *, 'phyetat0 : Le champ est absent' - PRINT *, ' Mais je vais essayer de lire TS**' - DO nsrf = 1, nbsrf - IF (nsrf > 99) THEN - PRINT *, "Trop de sous-mailles" - stop 1 - ENDIF - WRITE(str2, '(i2.2)') nsrf - call NF95_INQ_VARID(ncid, "TS"//str2, varid) - call NF95_GET_VAR(ncid, varid, tsol(:, nsrf)) - xmin = 1.0E+20 - xmax = -1.0E+20 - DO i = 1, klon - xmin = MIN(tsol(i, nsrf), xmin) - xmax = MAX(tsol(i, nsrf), xmax) - ENDDO - PRINT *, 'Temperature du sol TS**:', nsrf, xmin, xmax - ENDDO - ELSE - PRINT *, 'phyetat0: Le champ est present' - PRINT *, ' J ignore donc les autres temperatures TS**' + call NF95_INQ_VARID(ncid, "TS", varid) + call nf95_inquire_variable(ncid, varid, ndims = ndims) + if (ndims == 2) then + call NF95_GET_VAR(ncid, varid, tsol) + else + print *, "Found only one surface type for soil temperature." call nf95_get_var(ncid, varid, tsol(:, 1)) - xmin = 1.0E+20 - xmax = -1.0E+20 - DO i = 1, klon - xmin = MIN(tsol(i, 1), xmin) - xmax = MAX(tsol(i, 1), xmax) - ENDDO - PRINT *, 'Temperature du sol ', xmin, xmax - DO nsrf = 2, nbsrf - DO i = 1, klon - tsol(i, nsrf) = tsol(i, 1) - ENDDO - ENDDO - ENDIF + tsol(:, 2:nbsrf) = spread(tsol(:, 1), dim = 2, ncopies = nbsrf - 1) + end if - ! Lecture des temperatures du sol profond: + ! Lecture des temperatures du sol profond: - DO nsrf = 1, nbsrf - DO isoil=1, nsoilmx - IF (isoil > 99 .AND. nsrf > 99) THEN - PRINT *, "Trop de couches ou sous-mailles" - stop 1 - ENDIF - WRITE(str7, '(i2.2, "srf", i2.2)') isoil, nsrf - ierr = NF90_INQ_VARID(ncid, 'Tsoil'//str7, varid) - IF (ierr /= NF90_NOERR) THEN - PRINT *, "phyetat0: Le champ est absent" - PRINT *, " Il prend donc la valeur de surface" - DO i=1, klon - tsoil(i, isoil, nsrf)=tsol(i, nsrf) - ENDDO - ELSE - call NF95_GET_VAR(ncid, varid, tsoil(:, isoil, nsrf)) - ENDIF - ENDDO - ENDDO + call NF95_INQ_VARID(ncid, 'Tsoil', varid) + call NF95_GET_VAR(ncid, varid, tsoil) !IM "slab" ocean ! Lecture de tslab (pour slab ocean seulement): @@ -360,36 +309,6 @@ ENDDO ENDIF - ! Lecture de albedo au sol LW: - - ierr = NF90_INQ_VARID(ncid, "ALBLW", varid) - IF (ierr /= NF90_NOERR) THEN - PRINT *, 'phyetat0: Le champ est absent' - ! PRINT *, ' Mais je vais essayer de lire ALBLW**' - PRINT *, ' Mais je vais prendre ALBE**' - DO nsrf = 1, nbsrf - DO i = 1, klon - alblw(i, nsrf) = albe(i, nsrf) - ENDDO - ENDDO - ELSE - PRINT *, 'phyetat0: Le champ est present' - PRINT *, ' J ignore donc les autres ALBLW**' - call nf95_get_var(ncid, varid, alblw(:, 1)) - xmin = 1.0E+20 - xmax = -1.0E+20 - DO i = 1, klon - xmin = MIN(alblw(i, 1), xmin) - xmax = MAX(alblw(i, 1), xmax) - ENDDO - PRINT *, 'Neige du sol ', xmin, xmax - DO nsrf = 2, nbsrf - DO i = 1, klon - alblw(i, nsrf) = alblw(i, 1) - ENDDO - ENDDO - ENDIF - ! Lecture de evaporation: ierr = NF90_INQ_VARID(ncid, "EVAP", varid) @@ -434,13 +353,6 @@ call NF95_INQ_VARID(ncid, "rain_f", varid) call NF95_GET_VAR(ncid, varid, rain_fall) - xmin = 1.0E+20 - xmax = -1.0E+20 - DO i = 1, klon - xmin = MIN(rain_fall(i), xmin) - xmax = MAX(rain_fall(i), xmax) - ENDDO - PRINT *, 'Precipitation liquide rain_f:', xmin, xmax ! Lecture precipitation solide: