[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gary Strand: netCDF, Solaris, and Sun's f77 v3.0



Barry,

> Hey Russ, I have an interesting problem; one of these you have to see
> it to believe it.

I think the problem is that you neglected to call NCCLOS(ncid) to flush the
buffers and close the netCDF file before your program exited.  That would
account for not all the data being on the disk.

> I turned a friend on to netcdf last week and he needs to write ascaii
> data as netcdf, so being the expert (ha ha) that I am, I showed
> him ncgen -o file.cdf cdl.file; had him set up a cdl and sent him
> on his way. Well, yesterday he comes by and shows me that his output
> netcdf file data has problems. He is writing 3 variables. No problem
> with the first two, but the 3rd which is dimensioned in FORTRAN as
> (88,55) writes all the data but when we do an ncdump on the file we
> get a bunch of fill values appended to the end of the file for the 
> 3rd variable. Well, obviously, I figured we had start and count all
> wrong (has to be the problem, right) but I spent all afternoon trying
> to figure out what the problem was, and still, I don't have a clue!!!
> It is so simple I must be missing something. Then I thought, his data
> array must have run out of bounds and that's what is clobbering the 
> netcdf array, but I do a ncdinq and nccvinq to make sure everything
> in the netcdf output file is O.K. and still no answer. Not only that,
> but to insure his arrays are O.K. we write them out and they look fine and 
> also
> compile the routine with the C option (checks array bounds at run time).
> So we are mystified. Below is our FORTRAN code; if you think you can
> find the problem without the data (jnput data) that's great. If you
> want the test data to read in, let me know and I'll ftp it to you.
> 
> By the way, we have the order of the dimensions in "C" order as required
> for the cdl file so that's not it. I'll include the cdl file
> also below.
> 
> c * *
> c * Converting ASCII to NETCDF
> c * *
> 
>          parameter (nx=88,nz=55)
>          character*32 varnam,dimnam
>          integer vdims(10)
>          real*4 xx(nx),zz(nz),rl(nz,nx),rll(nx,nz)
>          integer*4 start(10),count(10)
>          integer*4 rcode, varid1,varid2,varid3,vartyp
>          data varid1,varid2,varid3 /1,2,3/
>          parameter(ncwrit=1)
> 
> c * *
> c * Equivalent to fortran open statement (for write to netcdf file)
> c * *
>          ncid=ncopn('file.cdf', ncwrit, rcode)
>          print *,'rcode,ncid ',rcode,ncid
> 
> 
>          open(1,file='nt.out',status='old')
> 
>          do i=1,nx
>             do k=1,nz
>               read(1,*),xx(i),zz(k),rl(k,i)
>               write(10,*),xx(i),zz(k),rl(k,i),k,i
> c             rll(i,k)=rl(k,i)
>             enddo
>          enddo
>          close(1)
>          start(1)=1
>          count(1)=88
> 
>          call ncvpt(ncid,varid1,start,count,xx,rcode)
>          print *,'rcode after ncvpt, xx ',rcode
> 
>          start(1)=1
>          count(1)=55
> 
>          call ncvpt(ncid,varid2,start,count,zz,rcode)
>          print *,'rcode after ncvpt,zz ',rcode
> 
>          start(1)=1
>          start(2)=1
> 
>          count(1)=55
>          count(2)=88
> 
>          call ncvinq(ncid,varid3,varnam,vartyp,nvdims,vdims,
>      *nvatts,rcode)
>          call ncdinq(ncid,2,dimnam,ndimsiz,rcode)
>          call ncdinq(ncid,1,dimnam,ndimsiz,rcode)
>          call ncvpt(ncid,varid3,start,count,rl,rcode)
>          print *,'rcode after ncvpt,rl ',rcode
> 
> 
>          stop
>          end
> c****************************
> 
> netcdf gf
>     {
> 
>     dimensions:
>       nx = 88; 
>       nz = 55;
> 
>     variables:
>       //      Horizontal Distance [m]
> 
>       float
>           xx(nx);
>             xx:_FillValue = -99999.f;
> 
>       //      Vertical Distance [m]
> 
>       float
>           zz(nz);
>             zz:_FillValue = -99999.f;
> 
>       //      Liquid water content [g/kg]
> 
>       float
>           rl(nx,nz);
> 
>             rl:_FillValue = -99999.f;
>   
> 
>     }

______________________________________________________________________________

Russ Rew                                                UCAR Unidata Program
address@hidden                                          P.O. Box 3000
http://www.unidata.ucar.edu/                          Boulder, CO 80307-3000
______________________________________________________________________________