Code: Select all
status=nf_open('dysim.nc',nf_nowrite,ncid)
if ( status/=nf_noerr ) write (*,*) nf_strerror(status)
status=nf_inq(ncid,ndims,nvars,ngatts,recdim) !recdim=id of unlimdimid
if ( status/=nf_noerr ) write (*,*) nf_strerror(status)
do i=1,ndims
dimid=i
status=nf_inq_dim(ncid,dimid,dimnam(i),dimsiz(i))
if ( status/=nf_noerr ) write (*,*) nf_strerror(status)
if (recdim.ne.-1) numrecs=dimsiz(recdim)
end do
do i=1,nvars
varid=i
do j=1,nvatts(i)
status=nf_inq_attname(ncid,varid,j,attnam(i,j))
if ( status/=nf_noerr ) write (*,*) nf_strerror(status)
status=nf_inq_atttype(ncid,varid,attnam(i,j),attype(i,j))
if ( status/=nf_noerr ) write (*,*) nf_strerror(status)
status=nf_inq_attlen(ncid,varid,attnam(i,j),attlen(i,j))
if ( status/=nf_noerr ) write (*,*) nf_strerror(status)
end do
end do
do i=1,nvars
varid=i
status=nf_inq_var(ncid,varid,varnam(i),vartyp(i),nvdims(i),vdims(I),nvatts(I))
if ( status/=nf_noerr ) write (*,*) nf_strerror(status)
if (nvdims(i).ne.0) then
do k=1,nvdims(i)
vvdims(i,k)=vdims(k)
end do
endif
end do
do i=1,nvars
varid=i
WRITE(6,*)vARID,NVARS,vartyp(varid)
avt(i)=avartyp(vartyp(varid))
avtgetvar(i)=getvartyp(vartyp(varid))
end do
STATUS=NF_CLOSE(NCID)
status=nf_open('dysim.nc',nf_nowrite,ncid)
if ( status/=nf_noerr ) write (*,*) nf_strerror(status)
Thanks,
Liancong email: lluo@waikato.ac.nz