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

Re: 20000320: Getting attributes with the netCDF F90 interface



>To: address@hidden
>From: Bill Gustafson <address@hidden>
>Subject: Getting attributes with the netCDF F90 interface
>Organization: .
>Keywords: 200003202010.NAA26542

Hi Bill,

> Last week I installed the new F90 interface for netCDF.  It is a great
> improvement over the old Fortran interface!  I have come across one area
> that is causing me trouble though.  I can write, but seem unable to read
> attribute values from my netCDF file.
>
> Here are some of the details...  
>
> I am on an SGI O200 with Irix 6.5.  
>
> The Fortran90 flags I am using are "-cpp -mips4 -r10000 -64 -O3 -r8 -mp".
>
> The section of the CDL listing for the variable is:
>            short mean(latitude, longitude) ;
>                 mean:long_name = "Time Mean" ;
>                 mean:units = "m/s" ;
>                 mean:scale_factor = 20.f ;
>                 mean:missing_value = -32000s ;
>                 mean:_FillValue = -32000s ;
>
> The code causing problems is:
> !
> ! Write mean
> !
>   call nccall( nf90_inq_varid(ncid,'mean',varid) )
>   scale=1.
>   print*,'mean scale before',scale
>   call nccall( nf90_redef(ncid) )
>   call nccall( nf90_put_att(ncid,varid,'scale_factor',20._4) )
>   call nccall( nf90_enddef(ncid) )
>   call nccall( nf90_get_att(ncid,varid,'scale_factor',scale) )
>   print*,'mean scale after',scale
>   call nccall( nf90_put_var(ncid,varid,mean/scale) )
>   call nccall( nf90_sync(ncid) )
>   print*,'   Mean written.'
>
> where nccall is a simple little error handling routine that parses the
> returned error value if necessary.
>
> The output from this section of code is:
>  mean scale before 1.
>  mean scale after 1.
>     Mean written.
>
> If I use ncgen to make the netCDF file with a scale_factor other than the
> 20. used here, the netCDF file changes to the new scale_factor of 20. when
> I run the program.  But, as can be seen from the output, the nf90_get_att
> call is not updating the variable scale.

If you use ncdump on the resulting file, is the scale_factor attribute
displayed as 20.?  If so, that indicates the problem is with reading
the attribute, not writing it.

> I do not know if this is a problem on my side with my compilation of the
> netCDF package or if it is really a bug.  If it is a bug, I thought you
> would be interested.  If there is a workaround, I would be interested in
> hearing that as well.

The above descriptions doesn't provide quite enough information for us
to reproduce the problem.  For example, what is the declaration for
the "scale" variable?  If you could possible send a complete small
program that demonstrates the problem, it would help.  I'm also CC:ing
Robert Pincus, the developer, in case he recognizes the symptoms you
describe.

--Russ

_____________________________________________________________________

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu