C: status = DFSDadddata(filename, rank, dim_sizes, data); FORTRAN: status = dsadata(filename, rank, dim_sizes, data)
C: status = DFSDputdata(filename, rank, dim_sizes, data); FORTRAN: status = dspdata(filename, rank, dim_sizes, data)
DFSDadddata appends data to a file when given an existing file name and creates a new file when given a unique file name. DFSDputdata replaces the contents of a file when given an existing file name and creates a new file when given a unique file name. To avoid accidentally overwriting data in a file, the use of DFSDadddata is recommended.
TABLE 11B DFSDadddata and DFSDputdata Parameter List.
C: status = DFSDsetNT(number_type); status = DFSDadddata(filename, rank, dim_sizes, data);
FORTRAN: status = dssnt(number_type) status = dsadata(filename, rank, dim_sizes, data)
DFSDsetNT defines the data type for all subsequent DFSDadddata and DFSDputdata calls until it is changed by a subsequent call to DFSDsetNT or reset to the default by DFSDclear. DFSDsetNT's only parameter is the data type.
EXAMPLE 1. Creating and Writing to a DFSD Scientific Data Set
In the following code examples, DFSDadddata is used to write an array of 64-bit floating-point numbers to a file named "Example1.hdf". Although the DFSDsetNT function call is optional, it is included here to demonstrate how to override the float32 default.
#include "hdf.h" #define LENGTH 3 #define HEIGHT 2 #define WIDTH 5 main( ) { /* Create data array - store dimensions in array 'dims' */ static float64 scien_data[LENGTH][HEIGHT][WIDTH] = { 1., 2., 3., 4., 5., 6., 7., 8., 9.,10., 11.,12.,13.,14.,15., 16.,17.,18.,19.,20., 21.,22.,23.,24.,25., 26.,27.,28.,29.,30. }; intn status; int32 dims[3] = {LENGTH, HEIGHT, WIDTH}; /* Set number type to 64-bit float */ status = DFSDsetNT(DFNT_FLOAT64); /* Write the data to file */ status = DFSDadddata("Example1.hdf", 3, dims, scien_data); }
PROGRAM WRITE SDS integer dsadata, dssnt, dims(3), status real*8 sci_data(5,2,3) C Create array called 'sci_data'; store dimensions in array 'dims'. data sci_data/ 1., 2., 3., 4., 5., $ 6., 7., 8., 9.,10., $ 11.,12.,13.,14.,15., $ 16.,17.,18.,19.,20., $ 21.,22.,23.,24.,25., $ 26.,27.,28.,29.,30./ data dims /3,2,5/ C Set number type to 64-bit float status = dssnt(6) C Write the data to file status = dsadata('Example1.hdf', 3, dims, sci_data) end
11.4.3 Overwriting Data for a Given Reference Number: DFSDwriteref
DFSDwriteref is a highly specialized function call that overwrites data referred to by the specified reference number.
C: status = DFSDwriteref(filename, ref_number); status = DFSDadddata(filename, rank, dim_sizes, data);
FORTRAN: status = dswref(filename, ref_number) status = dsadata(filename, rank, dim_sizes, data)
If the filename passed to DFSDwriteref is different from the filename in the DFSDadddata or DFSDputdata routine calls, it will be ignored. The next scientific data set written, regardless of the filename, is assigned the reference number ref_number.
TABLE 11C DFSDsetNT and DFSDwriteref Parameter List
Information stored in primary memory is retained by the HDF library until explicitly changed by a call to DFSDsetdims or reset to NULL by calling DFSDclear. DFSDsetdims and DFSDclear are used to prevent assignments of attributes created for a group of data sets to data sets outside the group. For more information on assigning attributes see Section 11.7.1 on page 293 and Section 11.7.3 on page 299.
11.4.5 Preventing the Reassignment of DFSD Data Set Attributes: DFSDsetdims
Information stored in primary memory is retained by the HDF library until explicitly changed by a call to DFSDsetdims or reset to NULL by calling DFSDclear. DFSDsetdims and DFSDclear are used to prevent assignments of attributes created for a group of data sets to data sets outside the group.
C: status = DFSDsetdims(rank, dim_sizes); FORTRAN: status = dssdims(rank, dim_sizes)
DFSDsetdims is not used here to define the rank and dimension sizes to be used in the next operation, but to alert the DFSD interface to stop the automatic assignment of attributes to the data sets to be written to file. DFSDsetdims has two parameters: rank and dim_sizes. The rank of an array is the total number of dimensions in the array and the dimension sizes are the length of each individual dimension.
TABLE 11D DFSDsetdims Parameter List
C: status = DFSDclear( ); FORTRAN: status = dsclear( )
The DFSDclear routine clears all interface settings defined by any of the DFSDset routines (DFSDsetNT, DFSDsetfillvalue, DFSDsetdims, DFSDsetdatastrs, DFSDsetdatalengths, DFSDsetrange, DFSDsetcal, DFSDsetdimscale and DFSDsetdimstrs). After the DFSDclear has been called, calls to any of the DFSDset routines will result in the corresponding value not being written. To write new values, call the appropriate DFSDset routine again.
TABLE 11E DFSDclear Parameter List
Routine Name (Fortran-77)
|
Parameter
|
Data Type
|
Description
| |
C
|
Fortran-77
| |||
DFSDclear (dsclear)
|
None
|
None
|
None
|
Clears all DFSD interface settings.
|