[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netCDF #EIA-757303]: netCDF General - Writing sequentially a 1d array with the f90 interface
- Subject: [netCDF #EIA-757303]: netCDF General - Writing sequentially a 1d array with the f90 interface
- Date: Fri, 15 Sep 2006 15:19:41 -0600
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