--- trunk/libf/dyn3d/limit.f90 2008/03/31 12:24:17 7 +++ trunk/libf/dyn3d/limit.f90 2012/01/30 12:54:02 57 @@ -1,7 +1,5 @@ module limit_mod - ! This module is clean: no C preprocessor directive, no include line. - IMPLICIT none contains @@ -14,25 +12,23 @@ ! It uses files with climatological data. ! Both grids must be regular. + use comgeom, only: rlonu, rlatv + use conf_dat2d_m, only: conf_dat2d use dimens_m, only: iim, jjm - use comconst, only: daysec, dtvr - use indicesol, only: epsfra, nbsrf, is_ter, is_oce, is_lic, is_sic use dimphy, only: klon, zmasq - use conf_gcm_m, only: day_step - use comgeom, only: rlonu, rlatv use etat0_mod, only: pctsrf - use start_init_orog_m, only: masque - use conf_dat2d_m, only: conf_dat2d - use inter_barxy_m, only: inter_barxy - use interpolation, only: spline, splint use grid_change, only: dyn_phy - - use netcdf95, only: handle_err, nf95_get_coord, NF95_CLOSE, NF95_DEF_DIM, & + use indicesol, only: epsfra, nbsrf, is_ter, is_oce, is_lic, is_sic + use inter_barxy_m, only: inter_barxy + use netcdf95, only: handle_err, nf95_gw_var, NF95_CLOSE, NF95_DEF_DIM, & nf95_enddef, NF95_CREATE, nf95_inq_dimid, nf95_inquire_dimension, & nf95_inq_varid, NF95_OPEN use netcdf, only: NF90_CLOBBER, nf90_def_var, NF90_FLOAT, NF90_GET_VAR, & NF90_GLOBAL, NF90_NOWRITE, NF90_PUT_ATT, NF90_PUT_VAR, & NF90_UNLIMITED + use numer_rec, only: spline, splint + use start_init_orog_m, only: mask + use unit_nml_m, only: unit_nml ! Variables local to the procedure: @@ -84,31 +80,33 @@ print *, "Enter namelist 'limit_nml'." read (unit=*, nml=limit_nml) - write(unit=*, nml=limit_nml) - - ! Initializations: - dtvr = daysec / real(day_step) - CALL inigeom + write(unit_nml, nml=limit_nml) ! Process rugosity: PRINT *, 'Processing rugosity...' call NF95_OPEN('Rugos.nc', NF90_NOWRITE, ncid) - call nf95_get_coord(ncid, "longitude", dlon_ini) + ! Read coordinate variables: + + call nf95_inq_varid(ncid, "longitude", varid) + call nf95_gw_var(ncid, varid, dlon_ini) imdep = size(dlon_ini) - call nf95_get_coord(ncid, "latitude", dlat_ini) + call nf95_inq_varid(ncid, "latitude", varid) + call nf95_gw_var(ncid, varid, dlat_ini) jmdep = size(dlat_ini) - call nf95_get_coord(ncid, "temps", timeyear) + call nf95_inq_varid(ncid, "temps", varid) + call nf95_gw_var(ncid, varid, timeyear) lmdep = size(timeyear) ALLOCATE(champ(imdep, jmdep), champtime(iim, jjm + 1, lmdep)) allocate(dlon(imdep), dlat(jmdep)) call NF95_INQ_VARID(ncid, 'RUGOS', varid) - ! Compute "champtime": + ! Read the primary variable day by day and regrid horizontally, + ! result in "champtime": DO l = 1, lmdep ierr = NF90_GET_VAR(ncid, varid, champ, start=(/1, 1, l/)) call handle_err("NF90_GET_VAR", ierr) @@ -117,7 +115,7 @@ CALL inter_barxy(dlon, dlat(:jmdep -1), LOG(champ), rlonu(:iim), & rlatv, champtime(:, :, l)) champtime(:, :, l) = EXP(champtime(:, :, l)) - where (nint(masque(:iim, :)) /= 1) champtime(:, :, l) = 0.001 + where (nint(mask(:iim, :)) /= 1) champtime(:, :, l) = 0.001 end do call NF95_CLOSE(ncid) @@ -125,6 +123,7 @@ DEALLOCATE(dlon, dlat, champ, dlon_ini, dlat_ini) allocate(yder(lmdep)) + ! Interpolate monthly values to daily values, at each horizontal position: DO j = 1, jjm + 1 DO i = 1, iim yder(:) = SPLINE(timeyear, champtime(i, j, :)) @@ -144,14 +143,16 @@ PRINT *, 'Processing sea ice...' call NF95_OPEN('amipbc_sic_1x1.nc', NF90_NOWRITE, ncid) - call nf95_get_coord(ncid, "longitude", dlon_ini) + call nf95_inq_varid(ncid, "longitude", varid) + call nf95_gw_var(ncid, varid, dlon_ini) imdep = size(dlon_ini) - call nf95_get_coord(ncid, "latitude", dlat_ini) + call nf95_inq_varid(ncid, "latitude", varid) + call nf95_gw_var(ncid, varid, dlat_ini) jmdep = size(dlat_ini) call nf95_inq_dimid(ncid, "time", dimid) - call NF95_INQuire_DIMension(ncid, dimid, len=lmdep) + call NF95_INQuire_DIMension(ncid, dimid, nclen=lmdep) print *, 'lmdep = ', lmdep ! PM 28/02/2002 : nouvelle coordonnée temporelle, fichiers AMIP ! pas en jours @@ -241,14 +242,16 @@ PRINT *, 'Traitement de la sst' call NF95_OPEN('amipbc_sst_1x1.nc', NF90_NOWRITE, ncid) - call nf95_get_coord(ncid, "longitude", dlon_ini) + call nf95_inq_varid(ncid, "longitude", varid) + call nf95_gw_var(ncid, varid, dlon_ini) imdep = size(dlon_ini) - call nf95_get_coord(ncid, "latitude", dlat_ini) + call nf95_inq_varid(ncid, "latitude", varid) + call nf95_gw_var(ncid, varid, dlat_ini) jmdep = size(dlat_ini) call nf95_inq_dimid(ncid, "time", dimid) - call NF95_INQuire_DIMension(ncid, dimid, len=lmdep) + call NF95_INQuire_DIMension(ncid, dimid, nclen=lmdep) print *, 'lmdep = ', lmdep !PM28/02/2002 : nouvelle coord temporelle fichiers AMIP pas en jours ! Ici on suppose qu'on a 12 mois (de 30 jours). @@ -310,13 +313,16 @@ PRINT *, 'Traitement de l albedo' call NF95_OPEN('Albedo.nc', NF90_NOWRITE, ncid) - call nf95_get_coord(ncid, "longitude", dlon_ini) + call nf95_inq_varid(ncid, "longitude", varid) + call nf95_gw_var(ncid, varid, dlon_ini) imdep = size(dlon_ini) - call nf95_get_coord(ncid, "latitude", dlat_ini) + call nf95_inq_varid(ncid, "latitude", varid) + call nf95_gw_var(ncid, varid, dlat_ini) jmdep = size(dlat_ini) - call nf95_get_coord(ncid, "temps", timeyear) + call nf95_inq_varid(ncid, "temps", varid) + call nf95_gw_var(ncid, varid, timeyear) lmdep = size(timeyear) ALLOCATE ( champ(imdep, jmdep), champtime(iim, jjm + 1, lmdep))