#include "dims.h" ! subroutine zatmos_import(icalday) ! ! Define zatmos ht,tn,un (arrays in zatmos.h) for given calendar ! day icalday (1-365) from mss data file (mss file written from ! vishnu.hao:~foster/zatmos/lowbound). ! These will be used for annual tide (lat structure only) ! This routine may be called at beginning of run, and again when ! and if the model calendar day is advanced. ! (the diskfile is opened the first time this routine is called, then ! left open, and local stack arrays (ndays,zjmx) are reread from the ! disk on subsequent calls only if icalday has changed from the previous ! call) ! 12/00: use netcdf file. ! use input_module,only: tempdir use netcdf_module,only: handle_ncerr,nc_open,nc_close, | nc_get_var_real implicit none ! ! Args: integer,intent(in) :: icalday ! ! Includes: #include "netcdf.inc" #include "params.h" #include "zatmos.h" ! ! Local: integer,parameter :: ndays=365, mxdims=10 character(len=40),save :: ! ! Nov, 2010 btf: mss access not available in this code. ! Use $TGCMDATA/zatmos_bndry.nc (copied by the job script) ! (it is identical to mss:/TGCM/data/zatmos_import.nc) ! ! | mssfile = '/TGCM/data/zatmos_import.nc ', | mssfile = '/TGCM/data/zatmos_bndry.nc ', | dskfile = 'zatmos_import.nc ' character(len=80) :: varname integer,save :: ncalls=0,iprevcalday=0 integer,save :: ncid,id_lat integer :: istat,nlat real :: tn(ndays,zjmx), ht(ndays,zjmx), un(ndays,zjmx) real :: fmin,fmax integer :: i,itype,natts,ndims,iddims(mxdims),idunlim, | ngatts,nvars ! ! Exec: ncalls = ncalls+1 ! ! Validate calendar day icalday: ! if (icalday.lt.1.or.icalday.gt.ndays) then write(6,"(/'>>> zatmos_import: bad calendar day = ',i5)") + icalday stop 'icalday' endif ! ! Acquire and open mss file (1st call only): if (ncalls==1) then call mkdiskflnm(mssfile,dskfile) call getms(mssfile,dskfile,tempdir,' ') call nc_open(ncid,dskfile,'OLD','READ') ! ! Get and verify latitude dimension: istat = nf_inq_dimid(ncid,'lat',id_lat) istat = nf_inq_dimlen(ncid,id_lat,nlat) if (istat /= NF_NOERR) call handle_ncerr(istat, | 'Error getting latitude dimension') if (nlat /= zjmx) then write(6,"(/,'>>> zatmos_import: bad nlat=',i3, | ' -- should be zjmx=',i3)") nlat,zjmx stop 'zatmos_import' endif endif ! ncalls==1 ! ! If new calendar day, read all calendar days into local arrays: ! if (icalday.ne.iprevcalday) then write(6,"(/,72('-'))") write(6,"('zatmos_import: calendar day ',i3)") icalday write(6,"('Reading from disk file ',a)") trim(dskfile) ! ! Get number of dims, vars, atts, and id of unlimited dimension: istat = nf_inq(ncid,ndims,nvars,ngatts,idunlim) ! ! Read the variables (not including lat): do i=1,nvars istat = nf_inq_var(ncid,i,varname,itype,ndims,iddims,natts) select case(trim(varname)) case('lat') ! latitude coord variable case('HT') istat = nc_get_var_real(ncid,i,ht) ! call fminmax(ht,ndays*zjmx,fmin,fmax) ! write(6,"('HT min,max=',2e12.4)") fmin,fmax case('TN') istat = nc_get_var_real(ncid,i,tn) ! call fminmax(tn,ndays*zjmx,fmin,fmax) ! write(6,"('TN min,max=',2e12.4)") fmin,fmax case('UN') istat = nc_get_var_real(ncid,i,un) ! call fminmax(un,ndays*zjmx,fmin,fmax) ! write(6,"('UN min,max=',2e12.4)") fmin,fmax case default write(6,"('>>> zatmos_import: unknown variable ',a)") | trim(varname) end select enddo ! ! Define zatmos arrays (zatmos.h) according to given calendar day: ! (zatmos arrays are shared common vectors in latitude) ! zatmos_tn(:) = tn(icalday,:) call fminmax(zatmos_tn,zjmx,fmin,fmax) write(6,"('zatmos_tn(zjmx) min,max=',2e12.4)") fmin,fmax ! zatmos_ht(:) = ht(icalday,:) call fminmax(zatmos_ht,zjmx,fmin,fmax) write(6,"('zatmos_ht(zjmx) min,max=',2e12.4)") fmin,fmax ! zatmos_un(:) = un(icalday,:) call fminmax(zatmos_un,zjmx,fmin,fmax) write(6,"('zatmos_un(zjmx) min,max=',2e12.4)") fmin,fmax ! iprevcalday = icalday write(6,"(72('-')/)") endif end subroutine zatmos_import