[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 20010212: variable attributes problems (cont.)
- Subject: Re: 20010212: variable attributes problems (cont.)
- Date: Mon, 12 Feb 2001 14:02:50 -0700
>Date: Mon, 12 Feb 2001 13:55:18 -0500 (EST)
>From: "Edwin R Wolfe Jr." <address@hidden>
>Organization: University of Michigan
>To: Steve Emmerson <address@hidden>
>Subject: Re: 20010212: variable attributes problems (cont.)
>Keywords: 200102091837.f19IbPL07744
Hi Ed,
> if I say
> short ms_time(nvec);
> ms_time:missing_value = -1s;
>
> it gives
> iret = nf_put_att_int(ncid, ms_time_id, 'valid_min', NF_INT2, 1, int2val)
>
> if I also say
>
> data:
> ms_time = 1s;
>
> the generated code has
>
> iret = nf_put_vara_int(ncid, ms_time_id, ms_time_start, ms_time_count,
> ms_time)
>
> I was hoping for put_vara_int2, since that's what will be passed to the
> writerec routine. Is there a way to get that to happen?
No, but I'm not sure why you would want that to happen. If a variable
is declared to be of netCDF type "short" corresponding to a 2-byte
integer, conversion to that external type will occur from integer data
when nf_put_vara_int() is called, just as conversion to a 2-byte
integer would occur from double precision data if you write to that
variable using nf_put_vara_double() and provide double precision
data. The advantage of using an INTEGER data type is as Steve pointed
out, for portability, since 2-byte integers may not be supported as a
valid data type in the Fortran compiler you are using.
I'm not sure what the relevance of the writerecs() is here. That's
just an internal FORTRAN subroutine that ncgen generates to write
record variables, and is an implementation detail of ncgen that should
probably not be modeled in your own code. In fact none of the
arguments to the writerecs() subroutine are for the data; they are
just the netCDF ID and the variable ID. The data is initialized in an
internal DATA statement in writerecs(), which is almost surely not the
way you would do it in your code.
The ncgen-generated code is deceptively well-commented so it looks
like it might be used as a template for your own code, but it would be
better to use the example code fragments in the documentation.
--Russ