This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Francois,
Rather than writing the three values 1, 2, 3 in to the variable time_from_start
your program is writing the value 1 into time_from_start(1),
time_from_start(2), and time_from_start(3) in the loop:
DO mcount = 1, max_length
time_mn(mcount) = FLOAT (mcount)
iret = nf90_put_var (ncid, time_from_start_id,
time_mn,start=(/mcount/),count=(/1/))
CALL check_err (iret, lunit)
ENDDO
because each time through the loop, it writes only 1 value (count=(/1/) from
the beginning of the time_mn array. You could write each value this way:
DO mcount = 1, max_length
time_mn(mcount) = FLOAT (mcount)
iret = nf90_put_var (ncid, time_from_start_id, &
time_mn+mcount-1,start=(/mcount/),count=(/1/))
CALL check_err (iret, lunit)
ENDDO
but this uses pretty tricky address calculation to specify that you want to
write data values not from time_mn(1), but from the time_mn(mcount).
A better way to do this would be to just write all three elements of time_mn
outsde the loop, as in
DO mcount = 1, max_length
time_mn(mcount) = FLOAT (mcount)
ENDDO
iret = nf90_put_var (ncid, time_from_start_id, time_mn,
start=(/1/),count=(/3/))
CALL check_err (iret, lunit)
Does this answer the question?
--Russ
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu
Ticket Details
===================
Ticket ID: EIA-757303
Department: Support netCDF
Priority: Critical
Status: Closed