[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
970110: netCDF
- Subject: 970110: netCDF
- Date: Fri, 10 Jan 97 15:23:08 -0700
Bill,
> To: address@hidden
> From: Bill Spotz <address@hidden>
> Organization: UCAR/NCAR/SCD
> Keywords: 199701102032.NAA01266
In the above message you wrote:
> The netCDF library is not behaving the way I am expecting it to, and I
> was hoping you could help. I have some two-dimensional data, and I am
> trying to write a hyperslab which does not include the boundary. I
> want to get the default missing value there so that an NCAR Graphics
> contour plot of the data will leave the boundary data unplotted.
>
> I am using the FORTRAN interface and have included a short program
> which recreates the problem. My intent is to write the variable
> "info" such that the zero's get written and the minus one's do not.
> But that is not the result I get.
>
> Thanks in advance,
> Bill Spotz
>
> =====================================================================
> program junk
>
> integer IMAX
> integer JMAX
> parameter (IMAX=11, JMAX=11)
>
> double precision info(IMAX,JMAX)
> integer i
> integer j
>
> integer start(3)
> integer count(3)
> integer vdim(3)
> integer infoid
>
> integer ncid
> integer ier
>
> include 'netcdf.inc'
>
> do 20 i = 1, IMAX
> do 10 j = 1, JMAX
> if (i.eq.1 .or. i.eq.IMAX .or. j.eq.1 .or. j.eq.JMAX) then
> info(i,j) = -1.0
> else
> info(i,j) = 0.0
> end if
> 10 continue
> 20 continue
>
> start(1) = 2
> start(2) = 2
> start(3) = 1
> count(1) = IMAX-2
> count(2) = JMAX-2
> count(3) = 1
>
> ncid = nccre("info.cdf",NCCLOB,ier)
> vdim(1) = ncddef(ncid,'i',IMAX,ier)
> vdim(2) = ncddef(ncid,'j',JMAX,ier)
> vdim(3) = ncddef(ncid,'iterate',NCUNLIM,ier)
> infoid = ncvdef(ncid,'info',NCDOUBLE,3,vdim,ier)
> call ncendf(ncid,ier)
> call ncvpt(ncid,infoid,start,count,info,ier)
> call ncclos(ncid,ier)
>
> stop
> end
>
> ------- End of Forwarded Message
What you need to realize is that the `start' and `count' arrays refer to
the external hyperslab and not the internal one. The netCDF library is
going to start writing from the first element of the `info' array (i.e.
info(1,1)) and not from where you think (i.e. info(2,2)). You should
change the output code to something that writes the array one J-line at
a time, e.g.
start(1) = 2
start(3) = 1
count(1) = IMAX-2
count(2) = 1
count(3) = 1
do 30, j = 2, JMAX-1
start(2) = j
call ncvpt(ncid,infoid,start,count,info(2,j),ier)
30 continue
Please let me know if this helps.
--------
Steve Emmerson <address@hidden>