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

20010212: variable attributes problems (cont.)



Edwin,

>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

The above message contained the following:

> 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?

I'm not aware of any way to get that to happen. ve CC'ed the creator of
I'the ncgen utility in case I'm wrong.  (Note: the INTEGER*2 data type
is non-standard and, hence, less portable.  This is a good reason for
the ncgen utility to avoid using it.)

> > > 3)
> > > when defining character strings, such as
> > > char ut_date(nvec, date_len);
> > > data:
> > > ut_date = "1999000" ;
> > > 
> > > I get
> > > 
> > >       iret = nf_put_vara_text(ncid, ut_date_id, ut_date_start, ut_date_c
> >      1ount, '1999000')
> > > 
> > > instead of using the variable name like it does for anything other than
> > > chars?  Is there a way to get ncgen to use the variable name instead of
> > > the actual text?
> > 
> > I'm afraid that I don't understand the question.  Please explain.
> 
> the generated code is as above, with the value for ut_date hard-coded to
> be what was specified in the .cdl -- I have to edit the writerec routine
> to get
> 
> iret = nf_put_vara_text(ncid, ut_date_id, ut_date_start, ut_date_count,
> ut_date)
> 
> whereas for other types of variables this is not needed (e.g., for ints:
> the generated code is
> 
> iret = nf_put_vara_int(ncid, ut_time_id, ut_time_start, ut_time_count,
> ut_time) )
> 
> Is there something I'm not doing right that begets the hard-coded
> statement for character strings?

No, you're doing everything right.  I think the difficulty comes from
your expectations of the "ncgen" utility.  The utility was intended to
generate a netCDF file corresponding to a CDL file, or to generate the C
or Fortran code that would create the corresponding CDL file.  It was
never intended to generate code that could do other things without
the additional step of manual editing.

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