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

20010131: Numeric conversion not representable?



Edwin,

>Date: Wed, 31 Jan 2001 10:14:08 -0500 (EST)
>From: "Edwin R Wolfe Jr." <address@hidden>
>Organization: University of Michigan
>To: Steve Emmerson <address@hidden>
>Subject: Re: 20010130: Numeric conversion not representable? 
>Keywords: 200101302121.f0ULLNX24572

The above message contained the following:

> running ncgen on the above cdl snippet did what it did before: it defined
> ms_time as an NF_INT2:
> 
>       iret = nf_def_var(ncid, 'ms_time', NF_INT2, ms_time_rank, ms_time_
>      1dims, ms_time_id)
> 
> then wrote it with nf_put_vara_int, not nf_put_vara_int2:
> 
>       integer  ms_time(ms_time_nr)
>       iret = nf_put_vara_int(ncid, ms_time_id, ms_time_start, ms_time_co
>      1unt, ms_time)
> 
>   I don't see how this is correct behavior?

Note that there are two "ms_time" entities.  One is the NF_INT2 (i.e.
2-byte) netCDF variable; the other is the Fortran integer array of
length 1.  Because this latter entity is an integer, the routine
"nf_put_vara_int(...)" must be used to write the integer values of the
Fortran variable into the NF_INT2 netCDF variable.  The netCDF library
takes care of converting the (probably) 4-byte values of the Fortran
variable into the 2-byte values of the netCDF variable.

If the Fortran variable "ms_time" were, instead, declared

    integer*2 ms_time(ms_time_nr)

then the routine "mf_put_vara_int2(...)" would have to be used to write
the2-byte Fortran values into the 2-byte, netCDF variable.

The suffix of the routine name must match the type of the variable in
the argument list that contains the values to be written or read.

Regards,
Steve Emmerson   <http://www.unidata.ucar.edu>