【发布时间】:2013-11-19 12:10:26
【问题描述】:
我正在使用 cdi(气候数据接口,https://code.zmaw.de/projects/cdi/wiki)来创建一个 netcdf 文件。我在文档中做了一个例子来编写一个 netcdf 文件,它工作正常。但是当第一次使用 cdi 时,它不会创建时间轴。 见代码:
! Now, we create the output file.
! We first create the grid.
gridID = gridCreate(y3D%GridType, NLons * NLats)
CALL gridDefXsize(gridID, NLons)
CALL gridDefYsize(gridID, NLats)
CALL gridDefXvals(gridID, y3D%Lons)
CALL gridDefYvals(gridID, y3D%Lats)
! Now, the z axis to be attached to the variable when created (there is one z axis per variable).
zaxisID = zaxisCreate(y3D%ZAxisType, 1) ! We only support predictands with one level. 1 creates a surface level.
! Now create the variable list
vlistID = vlistCreate()
! And define the variables in the variable list
Prevision = vlistDefVar(vlistID, gridID, zaxisID, TIME_VARIABLE)
! Now define the variable names
CALL vlistDefVarName(vlistID, Prevision , "Prevision")
! Now the time axis and attach it to the variable list.
taxisID = taxisCreate(TAXIS_RELATIVE) !ABSOLUTE)
write (*,*) "taxisID: ", taxisID
CALL taxisDefRDate(taxisID, 19000101)
CALL vlistDefTaxis(vlistID, taxisID)
! Now create the file
streamID = streamOpenWrite(char(ResultsFile), OutType)
if ( streamID < 0 ) then
write (*,*) "ERROR while attempting to create the file ", char(ResultsFile), " to store the results."
write (*,*) cdiStringError(streamID)
stop
end if
! Assign the variable list to the dataset
CALL streamDefVlist(streamID, vlistID)
! Now we have to loop over the time steps to store the data.
DO tsID = 0, NDates - 1
! Set the verification date
write (*,*) "Date ", ar_DatesPredicted(tsID+1)
CALL taxisDefVdate(taxisID, ar_DatesPredicted(tsID+1))
! Set the verification time to 12:00:00
CALL taxisDefVtime(taxisID, 120000)
! Define the time step
status = streamDefTimestep(streamID, tsID)
write (*,*) "Number of records of the time step: ", status
! Write values of each variable
CALL streamWriteVar(streamID, Prevision, ar_y_2DPrev(tsID+1, c_predictands)%Values, NMiss)
END DO
! Close the output stream
CALL streamClose(streamID)
! Destroy the objects
CALL vlistDestroy(vlistID)
CALL taxisDestroy(taxisID)
CALL zaxisDestroy(zaxisID)
CALL gridDestroy(gridID)
【问题讨论】:
-
当我说时间轴没有创建时,我的意思是当我用ncdump打开创建的netcdf文件时,它没有显示任何时间轴。
标签: linker shared-libraries static-libraries netcdf