subroutine getvar(lurd,plev,typef,dayx,utcx, + rlatmn,rlatmx,rlonmn,rlonmx,dlat,dlon, + nlat,nlon,fxy,ifound) c c This routine gets the variable (type) at pressure level c plev from a packed ASCII file at all the c required pressure levels. c c Modified Feb 2023 (KM) for NCO specifications c c Input: lurd Unit number of packed ASCII file c (must already be open) c plev Pressure level of requested data c type 1 character descriptor of requested data c (U,V,Z,T,R,S or O) c c Output: dayx Date variable (yymmdd.) on packed ASCII file c utcx Time variabel (e.g., 1200. for 12 UTC) c rlatmn Minimum latitude c rlatmx Maximum latitude c rlonmn Minimum longitude (usually deg W positive) c rlonmx Maximum longitude (usually deg W positive) c dlat Latitude increment c dlon Longitude increment c nlat Number of latitude points c nlon Number of longitude points c fxy Array containing unpack field on lon/lat grid c ifound = 1 if requested variable was found c = 0 if data was not found c =-1 if data file could not be read properly c *********************************************************************** c **** Warning: nx,ny must match those of fxy in the calling routine **** c *********************************************************************** c parameter(nx=360,ny=181) parameter(imax=nx*ny) c dimension fxy(nx,ny) c character *1 typef c c Local variables for unpacking dimension tra(imax) character *1 type character *2 code(imax) c c Rewind data file before reading it rewind(lurd) c c Read main header on packed data file read(lurd,100,err=900) wx,dayx,utcx,rlatmn,rlatmx,rlonmn,rlonmx, + dlat,dlon 100 format(1x,f3.0,f7.0,f5.0,4f8.3,2f4.1) c c Calculate lat,lon points epsil = 0.001 nlati = ifix((rlatmx-rlatmn)/dlat + epsil) nloni = ifix((rlonmx-rlonmn)/dlon + epsil) nlat = nlati + 1 nlon = nloni + 1 ipts = nlat*nlon c c Unpack the data nrow = 1 + (ipts-1)/36 do read(lurd,105,end=600,err=900) type,ptem,bsub,smpy 105 format(1x,a1,1x,f6.1,2(1x,g15.9)) c do n=1,nrow is = 1 + (n-1)*36 ie = is + 35 read(lurd,110,err=900) (code(i),i=is,ie) 110 format(36(a2)) enddo c c Check if data is the requested type and is c at the requested pressure if (type .ne. typef) cycle if (ptem .ne. plev) cycle exit enddo c c Unpack the data and put it in a 2-D array do i=1,ipts ix = idecod(code(i)) tra(i) = ix*smpy - bsub enddo c do j=1,nlat do i=1,nlon ij = i + (j-1)*nlon fxy(i,j) = tra(ij) enddo enddo c ifound=1 return c 600 continue c End of data file was reached without finding the requested data ifound=0 return c 900 continue c There was an error reading the data file ifound=-1 return end