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

Re: 20000320: Getting attributes with the netCDF F90 interface



Hi Russ and Robert,

> Bill, it would be helpful if you could compile the ex.F program I've
> appended for the Fortran 77 interface and see if it works as expected
> or shows the problem, because I can't make it occur in the f77
> interface.  Maybe there is some problem involving the "mean" array,
> which I removed from this example to try to isolate the problem ...

This morning I compiled Russ's ex.F program and tried it on my SGI.  The
results are mixed.  When using the -r8 flag for double precision, the
program output from the print statements is what one would expect when
writing and reading the value for scale (3.058104077E-3).  But, the
program is writing a double value into a single value in the netCDF file
so the ncdump gives the value of the scale factor as 0.9103593f.  When I
compile the program with -r4 for single precision, everything works fine.
I was able to make the -r8 version work by changing the put and get
attribute calls to double with NF_DOUBLE.

So, the long and short of it is that I think the F77 interface is working
on my macine with the netCDF v3.5 with -64.  

-Bill


> 
> --Russ
> 
> ----- ex.F, to test netCDF f77 interface for possible nf_get_att_real() 
> problem
> 
>       program ex
>       implicit none
> #include "/upc/netcdf/include/netcdf.inc"
>       integer ncid,varid
>       real scale
> 
>       call nccall( nf_open('eof.nc',NF_WRITE,ncid) )
>       call nccall( nf_inq_varid(ncid,'mean',varid) )
> 
>       call nccall( nf_redef(ncid) )
>       scale = 3.058104077E-3
>       print*,'scale used in nf_put_att_real call is',scale
> 
>       call nccall( nf_put_att_real(ncid,varid,'scale_factor',NF_FLOAT, 
>      *                             1,scale) )
>       call nccall( nf_enddef(ncid) )
> 
>       scale = 1.
>       print*,'before nf_get_att_real, scale is',scale
>       call nccall( nf_get_att_real(ncid,varid,'scale_factor',scale) )
>       print*,'after nf_get_att_real, scale is',scale
>       call nccall( nf_sync(ncid) )
> * nf_close should always be called before exiting, when writing to a file.
>       call nccall( nf_close(ncid) )
>       end
> 
> *------------------------------------------------------------------------
> *      nccall
> *          This subroutine checks if a netCDF error occured
> *          and quits the program if it did.
> *     
> *          ierr: Return value from a netCDF function call
> *     
> *------------------------------------------------------------------------
>       subroutine nccall(ierr)
>       integer ierr
> #include "/upc/netcdf/include/netcdf.inc"
>       if( ierr.ne.NF_NOERR ) then
>          print*,nf_strerror(ierr)
>          stop 'Stopped due to error associated with netCDF.'
>       endif
>       return
>       end
> 


______________________________________________________________
_________________________Bill Gustafson_______________________
School:                                                  Home:
Land, Air and Water Resources              1431 El Capitan St.
University of California, Davis                Davis, CA 95616
1 Shields Avenue                                 (530)753-8692
Davis, CA 95616-8627                    
U.S.A.
(530)752-1868                                 address@hidden