program rdOcn c include '/disk12/wd01db/Ocode/include/netcdf.inc' c integer i,j,k,t parameter (i=360,j=200,k=40,t=1) integer ii,jj,kk,ncid,status integer ndims, nvars, natts, idunlm integer dsiz(20), vtype, nvdm, vdm(10), nvatts, indx(4) integer start(4), count(4) character*20 dname, vname c real temp(i,j,k,t) c c ! open existing netCDF dataset c ncid=NCOPN('ocn9601.nc',NCNOWRIT,status) write(6,*)'ncid=',ncid,' status=',status c c inquire about the file c call NCINQ(ncid, ndims, nvars, natts, idunlm, status) write(6,*)'ndims=',ndims,' nvars=',nvars,' natts=',natts c c inquire about the dimensions c write(6,*) 'DIMENSIONS' do n = 1,ndims call NCDINQ(ncid, n, dname, dsiz(n), status) write(6,*)'n=',n,' name=',dname,' size=',dsiz(n) enddo c c inquire about the variables c write(6,*) 'VARIABLES' do n = 1,nvars call NCVINQ(ncid, n, vname, vtype, nvdm, vdm, nvatts, status) write(6,*)'n=',n,' name=',vname,' n.dims=',nvdm enddo c c inquire about the variable named 'temp' c write(6,*) 'TEMP' nid = NCVID(ncid,'temp',status) call NCVINQ(ncid, nid, vname, vtype, nvdm, vdm, nvatts, status) write(6,*) ' name=',vname,' n.dims=',nvdm do n = 1,nvdm write(6,*)' n=',n,' dim.no.=',vdm(n),' siz=',dsiz(vdm(n)) enddo c c get one 'temp' value c write(6,*) 'TEMP at the point (i,j,k,t) = (150,90,2,1)' indx(1) = 150 indx(2) = 90 indx(3) = 2 indx(4) = 1 nid = NCVID(ncid,'temp',status) call NCVGT1(ncid, nid, indx, tval, status) write(6,*) ' t(150,90,2,1)=', tval c c get whole 'temp' array c write(6,*) 'TEMP' nid = NCVID(ncid,'temp',status) call NCVINQ(ncid, nid, vname, vtype, nvdm, vdm, nvatts, status) do n = 1,nvdm start(n) = 1 count(n) = dsiz(vdm(n)) write(6,*) start(n), count(n) enddo call NCVGT(ncid, nid, start, count, temp, status) c c replace land values with -9.0 c do kk=1,k do jj=1,j do ii=1,i if (temp(ii,jj,kk,1) .lt. -999.) temp(ii,jj,kk,1) = -9.0 enddo enddo enddo c do kk=1,k,10 do jj=1,j,10 write(6,100) (temp(ii,jj,kk,1),ii=1,i,36) end do end do 100 format(10f8.2) c call NCCLOS(ncid,status) ! close netCDF dataset c end