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

[netCDF #NPP-336771]: Netcdf 4 question, parallel IO



Hi Annette,

> My netcdf4 program (written in fortran 90, doing parallel I/O) is
> working with the exception of writing a "time step" value to the
> netcdf4 file.

Is the time variable you are trying to write a record variable, that
is a variable with an unlimited dimension?  This may seem irrelevant,
but it makes a difference for how the data value should be written.
As it says in the Users Guide documentation for nf90_put_var:

  Take care when using the simplest forms of this interface with
  record variables when you don't specify how many records are to be
  written. If you try to write all the values of a record variable
  into a netCDF file that has no record data yet (hence has 0
  records), nothing will be written. Similarly, if you try to write
  all of a record variable but there are more records in the file than
  you assume, more data may be written to the file than you supply,
  which may result in a segmentation violation.

> I am using this call in the subroutine that actually writes the time to
> the file:
> 
>      status   = nf90_put_var (gio_files(ifile)%fileID, &
>                               timevid,                 &
>                               the_time)

This is the "simplest form of this interface" that the paragraph above
warns about.  If you call this when no records have been written yet,
it will write all of the time variable, but since the number of
records is 0, this means it will write nothing.

> I have verified (via debug writes) that the processors doing IO have the
> proper value for "the_time". I think the problem is that I need to
> specify a "start" and "count" in the nf90_put_var() call, but the
> Fortran documentation is confusing:

Right, and count has to be 1 to write a single value.  If two
processors are each writing their own time step, they should use
different start values, for example 1 and 2.

> I tried this in my code:
> 
>      status   = nf90_put_var (gio_files(ifile)%fileID, &
>                               timevid,                 &
>                               the_time,                &
>                               start_time, count_time)
> 
> I get a compilation error with this syntax:
> 
>       ftn -O -c -I/usr/local/include -I./ -I
> /scratch/scratchdirs/mhowison/netcdf-4.0.1/include  io_write_netcdf4.F90
>       /opt/cray/xt-asyncpe/2.3/bin/ftn: INFO: linux target is being
> used
>       PGF90-S-0155-Could not resolve generic procedure nf90_put_var
> (io_write_netcdf4.F90: 1870)
>        0 inform,   0 warnings,   1 severes, 0 fatal for
> gio_update_time_field
>       make: *** [io_write_netcdf4.o] Error 2

The start and count parametters are optional, so you must provide the
name of the parameter in the call so the compiler can tell which of
the optional pararmeters you are providing.  So the proper syntax is
something like:

     status   = nf90_put_var (gio_files(ifile)%fileID, &
                              timevid,                 &
                              the_time,                &
                              start = start_time,      &
                              count = count_time)

where start_time is 1 when the_time is 0 and start_time is 2 when
the_time is 800.

> I have tried various combinations/permutations of this call (using the
> "start" and "count" keywords), but nothing compiles.
> 
> Basically, with the first call (without specifying "start" or "count", I
> get 2 time values in my netcdf4 file, but the values are:
> 
>                 :history = "created on: 2009-05-04 at 10:32:08" ;
> data:
> 
>  time = 800, _ ;
> 
> when the values for time should be "0, 800". The second time value is
> over-writing the first time value, which leads me to think I need to
> specify start and count parameters.
> 
> 
> Please advise on the proper syntax of the "nf90_put_var()". NOTE that
> "the_time" in this case is a double precision value.

Hope this helps ...

--Russ

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



Ticket Details
===================
Ticket ID: NPP-336771
Department: Support netCDF
Priority: Normal
Status: Closed