[Top] [Prev] [Next]
create_vgroups.c
#include "hdf.h"
#define FILE_NAME "Two_Vgroups.hdf"
main()
{
/************************* Variable declaration **************************/
intn status_n; /* returned status for functions returning an intn */
int32 status_32, /* returned status for functions returning an int32 */
vgroup_ref = -1,
vgroup1_id, vgroup2_id, file_id;
/********************** End of variable declaration **********************/
/*
* Create the HDF file.
*/
file_id = Hopen (FILE_NAME, DFACC_CREATE, 0);
/*
* Initialize the V interface.
*/
status_n = Vstart (file_id);
/*
* Create the first vgroup. Note that the vgroup reference number is set
* to -1 for creating and the access mode is "w" for writing.
*/
vgroup1_id = Vattach (file_id, vgroup_ref, "w");
/*
* Create the second vgroup.
*/
vgroup2_id = Vattach (file_id, vgroup_ref, "w");
/*
* Any operations on the vgroups.
*/
/*
* Terminate access to the first vgroup.
*/
status_32 = Vdetach (vgroup1_id);
/*
* Terminate access to the second vgroup.
*/
status_32 = Vdetach (vgroup2_id);
/*
* Terminate access to the V interface and close the HDF file.
*/
status_n = Vend (file_id);
status_n = Hclose (file_id);
}
create_vgroups.f
program create_vgroup
implicit none
C
C Parameter declaration
C
character*15 FILE_NAME
C
parameter (FILE_NAME = `Two_Vgroups.hdf')
integer DFACC_CREATE
parameter (DFACC_CREATE = 4)
C
C Function declaration
C
integer hopen, hclose
integer vfstart, vfatch, vfdtch, vfend
C
C**** Variable declaration *******************************************
C
integer status
integer file_id
integer vgroup1_id, vgroup2_id, vgroup_ref
C
C**** End of variable declaration ************************************
C
C
C Create the HDF file.
C
file_id = hopen(FILE_NAME, DFACC_CREATE, 0)
C
C Initialize the V interface.
C
status = vfstart(file_id)
C
C Create the first vgroup. Note that the vgroup reference number is set
C to -1 for creating and the access mode is `w' for writing.
C
vgroup_ref = -1
vgroup1_id = vfatch(file_id, vgroup_ref, `w')
C
C Create the second vgroup.
C
vgroup2_id = vfatch(file_id, vgroup_ref, `w')
C
C Any operations on the vgroups.
C
C ..............................
C
C Terminate access to the first vgroup.
C
status = vfdtch(vgroup1_id)
C
C Terminate access to the second vgroup.
C
status = vfdtch(vgroup2_id)
C
C Terminate access to the V interface and close the HDF file.
C
status = vfend(file_id)
status = hclose(file_id)
end
add_sds_to_vgroup.c
#include "hdf.h" /* Note: in this example, hdf.h can be omitted...*/
#include "mfhdf.h" /* ...since mfhdf.h already includes hdf.h */
#define FILE_NAME "General_Vgroups.hdf"
#define SDS_NAME "Test SD"
#define VG_NAME "SD Vgroup"
#define VG_CLASS "Common Vgroups"
main()
{
/************************* Variable declaration **************************/
intn status_n; /* returned status for functions returning an intn */
int32 status_32, /* returned status for functions returning an int32 */
sd_id, /* SD interface identifier */
sds_id, /* data set identifier */
sds_ref, /* reference number of the data set */
dim_sizes[1], /* dimension of the data set - only one */
rank = 1, /* rank of the data set array */
vgroup_id, /* vgroup identifier */
file_id; /* HDF file identifier, same for V interface */
/********************** End of variable declaration **********************/
/*
* Create the HDF file.
*/
file_id = Hopen (FILE_NAME, DFACC_CREATE, 0);
/*
* Initialize the V interface.
*/
status_n = Vstart (file_id);
/*
* Initialize the SD interface.
*/
sd_id = SDstart (FILE_NAME, DFACC_WRITE);
/*
* Set the size of the SDS's dimension.
*/
dim_sizes[0] = 10;
/*
* Create the SDS.
*/
sds_id = SDcreate (sd_id, SDS_NAME, DFNT_INT32, rank, dim_sizes);
/*
* Create a vgroup and set its name and class.
*/
vgroup_id = Vattach (file_id, -1, "w");
status_32 = Vsetname (vgroup_id, VG_NAME);
status_32 = Vsetclass (vgroup_id, VG_CLASS);
/*
* Obtain the reference number of the SDS using its identifier.
*/
sds_ref = SDidtoref (sds_id);
/*
* Add the SDS to the vgroup. Note: the tag DFTAG_NDG is used
* when adding an SDS. Refer to Appendix A for the entire list of tags.
*/
status_32 = Vaddtagref (vgroup_id, DFTAG_NDG, sds_ref);
/*
* Terminate access to the SDS and to the SD interface.
*/
status_n = SDendaccess (sds_id);
status_n = SDend (sd_id);
/*
* Terminate access to the vgroup and to the V interface, and
* close the HDF file.
*/
status_32 = Vdetach (vgroup_id);
status_n = Vend (file_id);
status_n = Hclose (file_id);
}
add_sds_to_vgroup.f
program add_SDS_to_a_vgroup
implicit none
C
C Parameter declaration
C
character*19 FILE_NAME
character*7 SDS_NAME
character*9 VG_NAME
character*13 VG_CLASS
C
parameter (FILE_NAME = `General_Vgroups.hdf',
+ SDS_NAME = `Test SD',
+ VG_NAME = `SD Vgroup',
+ VG_CLASS = `Common Vgroups')
integer DFACC_CREATE, DFACC_WRITE
parameter (DFACC_CREATE = 4, DFACC_WRITE = 2)
integer DFNT_INT32
parameter (DFNT_INT32 = 24)
integer DFTAG_NDG
parameter (DFTAG_NDG = 720)
C
C Function declaration
C
integer hopen, hclose
integer vfstart, vfatch, vfsnam, vfscls, vfadtr, vfdtch, vfend
integer sfstart, sfcreate, sfid2ref, sfendacc, sfend
C
C**** Variable declaration *******************************************
C
integer status
integer file_id
integer vgroup_id
integer sd_id, sds_id, sds_ref
integer dim_sizes(1), rank
C
C**** End of variable declaration ************************************
C
C
C Create the HDF file.
C
file_id = hopen(FILE_NAME, DFACC_CREATE, 0)
C
C Initialize the V interface.
C
status = vfstart(file_id)
C
C Initialize SD interface.
C
sd_id = sfstart(FILE_NAME, DFACC_WRITE)
C
C Set the rank and the size of SDS's dimension.
C
rank = 1
dim_sizes(1) = 10
C
C Create the SDS.
C
sds_id = sfcreate(sd_id, SDS_NAME, DFNT_INT32, rank, dim_sizes)
C
C Create a vgroup and set its name and class.
C
vgroup_id = vfatch(file_id, -1 , `w')
status = vfsnam(vgroup_id, VG_NAME)
status = vfscls(vgroup_id, VG_CLASS)
C
C Obtain the reference number of the SDS using its identifier.
C
sds_ref = sfid2ref(sds_id)
C
C Add the SDS to the vgroup. Note: the tag DFTAG_NDG is used
C when adding an SDS. Refer to HDF Reference Manual, Section III, Table 3K,
C for the entire list of tags.
C
status = vfadtr(vgroup_id, DFTAG_NDG, sds_ref)
C
C Terminate access to the SDS and to the SD interface.
C
status = sfendacc(sds_id)
status = sfend(sd_id)
C
C Terminate access to the vgroup.
C
status = vfdtch(vgroup_id)
C
C Terminate access to the V interface and close the HDF file.
C
status = vfend(file_id)
status = hclose(file_id)
end
insert_vdatas_to_vgroup.c
#include "hdf.h"
#define FILE_NAME "General_Vgroups.hdf"
#define N_RECORDS 30 /* number of records in the vdatas */
#define ORDER 3 /* order of field FIELD_VD2 */
#define VG_NAME "Vertices"
#define VG_CLASS "Vertex Set"
#define VD1_NAME "X,Y Coordinates" /* first vdata to hold X,Y...*/
#define VD1_CLASS "Position" /*...values of the vertices */
#define VD2_NAME "Temperature" /* second vdata to hold the...*/
#define VD2_CLASS "Property List" /*...temperature field */
#define VD3_NAME "Node List" /* third vdata to hold...*/
#define VD3_CLASS "Mesh" /*...the list of nodes */
#define FIELD1_VD1 "PX" /* first field of first vdata - X values */
#define FIELD2_VD1 "PY"/* second field of first vdata - Y values */
#define FIELD_VD2 "TMP"/* field of third vdata */
#define FIELD_VD3 "PLIST"/* field of second vdata */
#define FIELDNAME_LIST "PX,PY" /* field name list for first vdata */
/* Note that the second and third vdatas can use the field names as
the field name lists unless more fields are added to a vdata.
Then a field name list is needed for that vdata */
main( )
{
/************************* Variable declaration **************************/
intn status_n; /* returned status for functions returning an intn */
int32 status_32, /* returned status for functions returning an int32 */
file_id, vgroup_id,
vdata1_id, vdata2_id, vdata3_id;
int32 num_of_records, /* number of records actually written */
vd_index; /* position of a vdata in the vgroup */
int8 i, j, k = 0;
float32 pxy[N_RECORDS][2] = /* buffer for data of the first vdata */
{-1.5, 2.3, -1.5, 1.98, -2.4, .67,
-3.4, 1.46, -.65, 3.1, -.62, 1.23,
-.4, 3.8, -3.55, 2.3, -1.43, 2.44,
.23, 1.13, -1.4, 5.43, -1.4, 5.8,
-3.4, 3.85, -.55, .3, -.21, 1.22,
-1.44, 1.9, -1.4, 2.8, .94, 1.78,
-.4, 2.32, -.87, 1.99, -.54, 4.11,
-1.5, 1.35, -1.4, 2.21, -.22, 1.8,
-1.1, 4.55, -.44, .54, -1.11, 3.93,
-.76, 1.9, -2.34, 1.7, -2.2, 1.21};
float32 tmp[N_RECORDS]; /* buffer for data of the second vdata */
int16 plist[N_RECORDS][3]; /* buffer for data of the third vdata */
/********************** End of variable declaration ***********************/
/*
* Open the HDF file for writing.
*/
file_id = Hopen (FILE_NAME, DFACC_WRITE, 0);
/*
* Initialize the V interface.
*/
status_n = Vstart (file_id);
/*
* Buffer the data for the second and third vdatas.
*/
for (i = 0; i < N_RECORDS; i++)
for (j = 0; j < ORDER; j++)
plist[i][j] = ++k;
for (i = 0; i < N_RECORDS; i++)
tmp[i] = i * 10.0;
/*
* Create the vgroup then set its name and class. Note that the vgroup's
* reference number is set to -1 for creating and the access mode is "w" for
* writing.
*/
vgroup_id = Vattach (file_id, -1, "w");
status_32 = Vsetname (vgroup_id, VG_NAME);
status_32 = Vsetclass (vgroup_id, VG_CLASS);
/*
* Create the first vdata then set its name and class. Note that the vdata's
* reference number is set to -1 for creating and the access mode is "w" for
* writing.
*/
vdata1_id = VSattach (file_id, -1, "w");
status_32 = VSsetname (vdata1_id, VD1_NAME);
status_32 = VSsetclass (vdata1_id, VD1_CLASS);
/*
* Introduce and define the fields of the first vdata.
*/
status_n = VSfdefine (vdata1_id, FIELD1_VD1, DFNT_FLOAT32, 1);
status_n = VSfdefine (vdata1_id, FIELD2_VD1, DFNT_FLOAT32, 1);
status_n = VSsetfields (vdata1_id, FIELDNAME_LIST);
/*
* Write the buffered data into the first vdata with full interlace mode.
*/
num_of_records = VSwrite (vdata1_id, (uint8 *)pxy, N_RECORDS,
FULL_INTERLACE);
/*
* Insert the vdata into the vgroup using its identifier.
*/
vd_index = Vinsert (vgroup_id, vdata1_id);
/*
* Detach from the first vdata.
*/
status_32 = VSdetach (vdata1_id);
/*
* Create, write, and insert the second vdata to the vgroup using
* steps similar to those used for the first vdata.
*/
vdata2_id = VSattach (file_id, -1, "w");
status_32 = VSsetname (vdata2_id, VD2_NAME);
status_32 = VSsetclass (vdata2_id, VD2_CLASS);
status_n = VSfdefine (vdata2_id, FIELD_VD2, DFNT_FLOAT32, 1);
status_n = VSsetfields (vdata2_id, FIELD_VD2);
num_of_records = VSwrite (vdata2_id, (uint8 *)tmp, N_RECORDS,
FULL_INTERLACE);
vd_index = Vinsert (vgroup_id, vdata2_id);
status_32 = VSdetach (vdata2_id);
/*
* Create, write, and insert the third vdata to the vgroup using
* steps similar to those used for the first and second vdatas.
*/
vdata3_id = VSattach (file_id, -1, "w");
status_32 = VSsetname (vdata3_id, VD3_NAME);
status_32 = VSsetclass (vdata3_id, VD3_CLASS);
status_n = VSfdefine (vdata3_id, FIELD_VD3, DFNT_INT16, 3);
status_n = VSsetfields (vdata3_id, FIELD_VD3);
num_of_records = VSwrite (vdata3_id, (uint8 *)plist, N_RECORDS,
FULL_INTERLACE);
vd_index = Vinsert (vgroup_id, vdata3_id);
status_32 = VSdetach (vdata3_id);
/*
* Terminate access to the vgroup "Vertices".
*/
status_32 = Vdetach (vgroup_id);
/*
* Terminate access to the V interface and close the HDF file.
*/
status_n = Vend (file_id);
status_n = Hclose (file_id);
}
insert_vdatas_to_vgroup.f
program add_vdatas_to_a_vgroup
implicit none
C
C Parameter declaration
C
character*19 FILE_NAME
character*8 VG_NAME
character*10 VG_CLASS
character*15 VD1_NAME
character*8 VD1_CLASS
character*11 VD2_NAME
character*13 VD2_CLASS
character*9 VD3_NAME
character*4 VD3_CLASS
C
parameter (FILE_NAME = `General_Vgroups.hdf',
+ VG_NAME = `Vertices',
+ VG_CLASS = `Vertex Set')
parameter (VD1_NAME = `X,Y Coordinates',
+ VD2_NAME = `Temperature',
+ VD3_NAME = `Node List')
parameter (VD1_CLASS = `Position',
+ VD2_CLASS = `Property List',
+ VD3_CLASS = `Mesh')
character*2 FIELD1_VD1
character*2 FIELD2_VD1
character*3 FIELD_VD2
character*4 FIELD_VD3
character*5 FIELDNAME_LIST
parameter (FIELD1_VD1 = `PX',
+ FIELD2_VD1 = `PY',
+ FIELD_VD2 = `TMP',
+ FIELD_VD3 = `PLIST',
+ FIELDNAME_LIST = `PX,PY')
integer N_RECORDS
parameter (N_RECORDS = 30)
integer DFACC_WRITE
parameter (DFACC_WRITE = 2)
integer DFNT_FLOAT32, DFNT_INT16
parameter (DFNT_FLOAT32 = 5, DFNT_INT16 = 22)
integer FULL_INTERLACE
parameter (FULL_INTERLACE = 0)
C
C Function declaration
C
integer hopen, hclose
integer vfstart, vfatch, vfsnam, vfscls, vfinsrt, vfdtch, vfend
integer vsfatch, vsfsnam, vsfscls, vsffdef, vsfsfld,
+ vsfwrt, vsfwrtc, vsfdtch
C
C**** Variable declaration *******************************************
C
integer status
integer file_id
integer vgroup_id
integer vdata1_id, vdata2_id, vdata3_id, vd_index
integer num_of_records
integer i, j, k
real pxy(2,N_RECORDS), tmp(N_RECORDS)
integer plist(3,N_RECORDS)
data pxy /-1.5, 2.3, -1.5, 1.98, -2.4, .67,
+ -3.4, 1.46, -.65, 3.1, -.62, 1.23,
+ -.4, 3.8, -3.55, 2.3, -1.43, 2.44,
+ .23, 1.13, -1.4, 5.43, -1.4, 5.8,
+ -3.4, 3.85, -.55, .3, -.21, 1.22,
+ -1.44, 1.9, -1.4, 2.8, .94, 1.78,
+ -.4, 2.32, -.87, 1.99, -.54, 4.11,
+ -1.5, 1.35, -1.4, 2.21, -.22, 1.8,
+ -1.1, 4.55, -.44, .54, -1.11, 3.93,
+ -.76, 1.9, -2.34, 1.7, -2.2, 1.21/
C
C**** End of variable declaration ************************************
C
C
C Open the HDF file for writing.
C
file_id = hopen(FILE_NAME, DFACC_WRITE, 0)
C
C Initialize the V interface.
C
status = vfstart(file_id)
C
C Buffer the data for the third and second vdatas.
C
do 20 i = 1, N_RECORDS
do 10 j = 1, 3
plist(j,i) = k
k = k+1
10 continue
20 continue
do 30 i = 1, N_RECORDS
tmp(i) = (i-1) * 10.0
30 continue
C
C Create a vgroup and set its name and class.
C Note that the vgroup's reference number is set to -1 for creating
C and the access mode is `w' for writing.
C
vgroup_id = vfatch(file_id, -1 , `w')
status = vfsnam(vgroup_id, VG_NAME)
status = vfscls(vgroup_id, VG_CLASS)
C
C Create the first vdata then set its name and class. Note that the vdata's
C reference number is set to -1 for creating and the access mode is `w' for
C writing.
C
vdata1_id = vsfatch(file_id, -1, `w')
status = vsfsnam(vdata1_id, VD1_NAME)
status = vsfscls(vdata1_id, VD1_CLASS)
C
C Introduce and define the fields of the first vdata.
C
status = vsffdef(vdata1_id, FIELD1_VD1, DFNT_FLOAT32, 1)
status = vsffdef(vdata1_id, FIELD2_VD1, DFNT_FLOAT32, 1)
status = vsfsfld(vdata1_id, FIELDNAME_LIST)
C
C Write the buffered data into the first vdata.
C
num_of_records = vsfwrt(vdata1_id, pxy, N_RECORDS,
+ FULL_INTERLACE)
C
C Insert the vdata into the vgroup using its identifier.
C
vd_index = vfinsrt(vgroup_id, vdata1_id)
C
C Detach from the first vdata.
C
status = vsfdtch(vdata1_id)
C
C Create, write, and insert the second vdata to the vgroup using
C steps similar to those used for the first vdata.
C
vdata2_id = vsfatch(file_id, -1, `w')
status = vsfsnam(vdata2_id, VD2_NAME)
status = vsfscls(vdata2_id, VD2_CLASS)
status = vsffdef(vdata2_id, FIELD_VD2, DFNT_FLOAT32, 1)
status = vsfsfld(vdata2_id, FIELD_VD2)
num_of_records = vsfwrt(vdata2_id, tmp, N_RECORDS,
+ FULL_INTERLACE)
vd_index = vfinsrt(vgroup_id, vdata2_id)
status = vsfdtch(vdata2_id)
C
C Create, write, and insert the third vdata to the vgroup using
C steps similar to those used for the first and second vdatas.
C
vdata3_id = vsfatch(file_id, -1, `w')
status = vsfsnam(vdata3_id, VD3_NAME)
status = vsfscls(vdata3_id, VD3_CLASS)
status = vsffdef(vdata3_id, FIELD_VD3, DFNT_INT16, 3)
status = vsfsfld(vdata3_id, FIELD_VD3)
num_of_records = vsfwrtc(vdata3_id, plist, N_RECORDS,
+ FULL_INTERLACE)
vd_index = vfinsrt(vgroup_id, vdata3_id)
status = vsfdtch(vdata3_id)
C
C Terminate access to the vgroup `Vertices'.
C
status = vfdtch(vgroup_id)
C
C Terminate access to the V interface and close the HDF file.
C
status = vfend(file_id)
status = hclose(file_id)
end
get_vgroup_info.c
#include "hdf.h"
#define FILE_NAME "General_Vgroups.hdf"
main( )
{
/************************* Variable declaration **************************/
intn status_n; /* returned status for functions returning an intn */
int32 status_32, /* returned status for functions returning an int32 */
file_id, vgroup_id;
int32 lone_vg_number, /* current lone vgroup number */
num_of_lones = 0; /* number of lone vgroups */
int32 *ref_array; /* buffer to hold the ref numbers of lone vgroups */
char vgroup_name[VGNAMELENMAX], vgroup_class[VGNAMELENMAX];
/********************** End of variable declaration **********************/
/*
* Open the HDF file for reading.
*/
file_id = Hopen (FILE_NAME, DFACC_READ, 0);
/*
* Initialize the V interface.
*/
status_n = Vstart (file_id);
/*
* Get and print the names and class names of all the lone vgroups.
* First, call Vlone with num_of_lones set to 0 to get the number of
* lone vgroups in the file, but not to get their reference numbers.
*/
num_of_lones = Vlone (file_id, NULL, num_of_lones );
/*
* Then, if there are any lone vgroups,
*/
if (num_of_lones > 0)
{
/*
* use the num_of_lones returned to allocate sufficient space for the
* buffer ref_array to hold the reference numbers of all lone vgroups,
*/
ref_array = (int32 *) malloc(sizeof(int32) * num_of_lones);
/*
* and call Vlone again to retrieve the reference numbers into
* the buffer ref_array.
*/
num_of_lones = Vlone (file_id, ref_array, num_of_lones);
/*
* Display the name and class of each lone vgroup.
*/
printf ("Lone vgroups in this file are:\n");
for (lone_vg_number = 0; lone_vg_number < num_of_lones;
lone_vg_number++)
{
/*
* Attach to the current vgroup then get and display its
* name and class. Note: the current vgroup must be detached before
* moving to the next.
*/
vgroup_id = Vattach (file_id, ref_array[lone_vg_number], "r");
status_32 = Vgetname (vgroup_id, vgroup_name);
status_32 = Vgetclass (vgroup_id, vgroup_class);
printf (" Vgroup name %s and class %s\n", vgroup_name,
vgroup_class);
status_32 = Vdetach (vgroup_id);
} /* for */
} /* if */
/*
* Terminate access to the V interface and close the file.
*/
status_n = Vend (file_id);
status_n = Hclose (file_id);
/*
* Free the space allocated by this program.
*/
free (ref_array);
}
C
C Create, write, and insert the second vdata to the vgroup using
C steps similar to those used for the first vdata.
C
vdata2_id = vsfatch(file_id, -1, `w')
status = vsfsnam(vdata2_id, VD2_NAME)
status = vsfscls(vdata2_id, VD2_CLASS)
status = vsffdef(vdata2_id, FIELD_VD2, DFNT_FLOAT32, 1)
status = vsfsfld(vdata2_id, FIELD_VD2)
num_of_records = vsfwrt(vdata2_id, tmp, N_RECORDS,
+ FULL_INTERLACE)
vd_index = vfinsrt(vgroup_id, vdata2_id)
status = vsfdtch(vdata2_id)
C
C Create, write, and insert the third vdata to the vgroup using
C steps similar to those used for the first and second vdatas.
C
vdata3_id = vsfatch(file_id, -1, `w')
status = vsfsnam(vdata3_id, VD3_NAME)
status = vsfscls(vdata3_id, VD3_CLASS)
status = vsffdef(vdata3_id, FIELD_VD3, DFNT_INT16, 3)
status = vsfsfld(vdata3_id, FIELD_VD3)
num_of_records = vsfwrtc(vdata3_id, plist, N_RECORDS,
+ FULL_INTERLACE)
vd_index = vfinsrt(vgroup_id, vdata3_id)
status = vsfdtch(vdata3_id)
C
C Terminate access to the vgroup `Vertices'.
C
status = vfdtch(vgroup_id)
C
C Terminate access to the V interface and close the HDF file.
C
status = vfend(file_id)
status = hclose(file_id)
end
get_vgroup_info.c
#include "hdf.h"
#define FILE_NAME "General_Vgroups.hdf"
main( )
{
/************************* Variable declaration **************************/
intn status_n; /* returned status for functions returning an intn */
int32 status_32, /* returned status for functions returning an int32 */
file_id, vgroup_id;
int32 lone_vg_number, /* current lone vgroup number */
num_of_lones = 0; /* number of lone vgroups */
int32 *ref_array; /* buffer to hold the ref numbers of lone vgroups */
char vgroup_name[VGNAMELENMAX], vgroup_class[VGNAMELENMAX];
/********************** End of variable declaration **********************/
/*
* Open the HDF file for reading.
*/
file_id = Hopen (FILE_NAME, DFACC_READ, 0);
/*
* Initialize the V interface.
*/
status_n = Vstart (file_id);
/*
* Get and print the names and class names of all the lone vgroups.
* First, call Vlone with num_of_lones set to 0 to get the number of
* lone vgroups in the file, but not to get their reference numbers.
*/
num_of_lones = Vlone (file_id, NULL, num_of_lones );
/*
* Then, if there are any lone vgroups,
*/
if (num_of_lones > 0)
{
/*
* use the num_of_lones returned to allocate sufficient space for the
* buffer ref_array to hold the reference numbers of all lone vgroups,
*/
ref_array = (int32 *) malloc(sizeof(int32) * num_of_lones);
/*
* and call Vlone again to retrieve the reference numbers into
* the buffer ref_array.
*/
num_of_lones = Vlone (file_id, ref_array, num_of_lones);
/*
* Display the name and class of each lone vgroup.
*/
printf ("Lone vgroups in this file are:\n");
for (lone_vg_number = 0; lone_vg_number < num_of_lones;
lone_vg_number++)
{
/*
* Attach to the current vgroup then get and display its
* name and class. Note: the current vgroup must be detached before
* moving to the next.
*/
vgroup_id = Vattach (file_id, ref_array[lone_vg_number], "r");
status_32 = Vgetname (vgroup_id, vgroup_name);
status_32 = Vgetclass (vgroup_id, vgroup_class);
printf (" Vgroup name %s and class %s\n", vgroup_name,
vgroup_class);
status_32 = Vdetach (vgroup_id);
} /* for */
} /* if */
/*
* Terminate access to the V interface and close the file.
*/
status_n = Vend (file_id);
status_n = Hclose (file_id);
/*
* Free the space allocated by this program.
*/
free (ref_array);
}
C
C Create, write, and insert the second vdata to the vgroup using
C steps similar to those used for the first vdata.
C
vdata2_id = vsfatch(file_id, -1, `w')
status = vsfsnam(vdata2_id, VD2_NAME)
status = vsfscls(vdata2_id, VD2_CLASS)
status = vsffdef(vdata2_id, FIELD_VD2, DFNT_FLOAT32, 1)
status = vsfsfld(vdata2_id, FIELD_VD2)
num_of_records = vsfwrt(vdata2_id, tmp, N_RECORDS,
+ FULL_INTERLACE)
vd_index = vfinsrt(vgroup_id, vdata2_id)
status = vsfdtch(vdata2_id)
C
C Create, write, and insert the third vdata to the vgroup using
C steps similar to those used for the first and second vdatas.
C
vdata3_id = vsfatch(file_id, -1, `w')
status = vsfsnam(vdata3_id, VD3_NAME)
status = vsfscls(vdata3_id, VD3_CLASS)
status = vsffdef(vdata3_id, FIELD_VD3, DFNT_INT16, 3)
status = vsfsfld(vdata3_id, FIELD_VD3)
num_of_records = vsfwrtc(vdata3_id, plist, N_RECORDS,
+ FULL_INTERLACE)
vd_index = vfinsrt(vgroup_id, vdata3_id)
status = vsfdtch(vdata3_id)
C
C Terminate access to the vgroup `Vertices'.
C
status = vfdtch(vgroup_id)
C
C Terminate access to the V interface and close the HDF file.
C
status = vfend(file_id)
status = hclose(file_id)
end
get_vgroup_info.c
#include "hdf.h"
#define FILE_NAME "General_Vgroups.hdf"
main( )
{
/************************* Variable declaration **************************/
intn status_n; /* returned status for functions returning an intn */
int32 status_32, /* returned status for functions returning an int32 */
file_id, vgroup_id;
int32 lone_vg_number, /* current lone vgroup number */
num_of_lones = 0; /* number of lone vgroups */
int32 *ref_array; /* buffer to hold the ref numbers of lone vgroups */
char vgroup_name[VGNAMELENMAX], vgroup_class[VGNAMELENMAX];
/********************** End of variable declaration **********************/
/*
* Open the HDF file for reading.
*/
file_id = Hopen (FILE_NAME, DFACC_READ, 0);
/*
* Initialize the V interface.
*/
status_n = Vstart (file_id);
/*
* Get and print the names and class names of all the lone vgroups.
* First, call Vlone with num_of_lones set to 0 to get the number of
* lone vgroups in the file, but not to get their reference numbers.
*/
num_of_lones = Vlone (file_id, NULL, num_of_lones );
/*
* Then, if there are any lone vgroups,
*/
if (num_of_lones > 0)
{
/*
* use the num_of_lones returned to allocate sufficient space for the
* buffer ref_array to hold the reference numbers of all lone vgroups,
*/
ref_array = (int32 *) malloc(sizeof(int32) * num_of_lones);
/*
* and call Vlone again to retrieve the reference numbers into
* the buffer ref_array.
*/
num_of_lones = Vlone (file_id, ref_array, num_of_lones);
/*
* Display the name and class of each lone vgroup.
*/
printf ("Lone vgroups in this file are:\n");
for (lone_vg_number = 0; lone_vg_number < num_of_lones;
lone_vg_number++)
{
/*
* Attach to the current vgroup then get and display its
* name and class. Note: the current vgroup must be detached before
* moving to the next.
*/
vgroup_id = Vattach (file_id, ref_array[lone_vg_number], "r");
status_32 = Vgetname (vgroup_id, vgroup_name);
status_32 = Vgetclass (vgroup_id, vgroup_class);
printf (" Vgroup name %s and class %s\n", vgroup_name,
vgroup_class);
status_32 = Vdetach (vgroup_id);
} /* for */
} /* if */
/*
* Terminate access to the V interface and close the file.
*/
status_n = Vend (file_id);
status_n = Hclose (file_id);
/*
* Free the space allocated by this program.
*/
free (ref_array);
}
C
C Create, write, and insert the second vdata to the vgroup using
C steps similar to those used for the first vdata.
C
vdata2_id = vsfatch(file_id, -1, `w')
status = vsfsnam(vdata2_id, VD2_NAME)
status = vsfscls(vdata2_id, VD2_CLASS)
status = vsffdef(vdata2_id, FIELD_VD2, DFNT_FLOAT32, 1)
status = vsfsfld(vdata2_id, FIELD_VD2)
num_of_records = vsfwrt(vdata2_id, tmp, N_RECORDS,
+ FULL_INTERLACE)
vd_index = vfinsrt(vgroup_id, vdata2_id)
status = vsfdtch(vdata2_id)
C
C Create, write, and insert the third vdata to the vgroup using
C steps similar to those used for the first and second vdatas.
C
vdata3_id = vsfatch(file_id, -1, `w')
status = vsfsnam(vdata3_id, VD3_NAME)
status = vsfscls(vdata3_id, VD3_CLASS)
status = vsffdef(vdata3_id, FIELD_VD3, DFNT_INT16, 3)
status = vsfsfld(vdata3_id, FIELD_VD3)
num_of_records = vsfwrtc(vdata3_id, plist, N_RECORDS,
+ FULL_INTERLACE)
vd_index = vfinsrt(vgroup_id, vdata3_id)
status = vsfdtch(vdata3_id)
C
C Terminate access to the vgroup `Vertices'.
C
status = vfdtch(vgroup_id)
C
C Terminate access to the V interface and close the HDF file.
C
status = vfend(file_id)
status = hclose(file_id)
end
get_vgroup_info.c
#include "hdf.h"
#define FILE_NAME "General_Vgroups.hdf"
main( )
{
/************************* Variable declaration **************************/
intn status_n; /* returned status for functions returning an intn */
int32 status_32, /* returned status for functions returning an int32 */
file_id, vgroup_id;
int32 lone_vg_number, /* current lone vgroup number */
num_of_lones = 0; /* number of lone vgroups */
int32 *ref_array; /* buffer to hold the ref numbers of lone vgroups */
char vgroup_name[VGNAMELENMAX], vgroup_class[VGNAMELENMAX];
/********************** End of variable declaration **********************/
/*
* Open the HDF file for reading.
*/
file_id = Hopen (FILE_NAME, DFACC_READ, 0);
/*
* Initialize the V interface.
*/
status_n = Vstart (file_id);
/*
* Get and print the names and class names of all the lone vgroups.
* First, call Vlone with num_of_lones set to 0 to get the number of
* lone vgroups in the file, but not to get their reference numbers.
*/
num_of_lones = Vlone (file_id, NULL, num_of_lones );
/*
* Then, if there are any lone vgroups,
*/
if (num_of_lones > 0)
{
/*
* use the num_of_lones returned to allocate sufficient space for the
* buffer ref_array to hold the reference numbers of all lone vgroups,
*/
ref_array = (int32 *) malloc(sizeof(int32) * num_of_lones);
/*
* and call Vlone again to retrieve the reference numbers into
* the buffer ref_array.
*/
num_of_lones = Vlone (file_id, ref_array, num_of_lones);
/*
* Display the name and class of each lone vgroup.
*/
printf ("Lone vgroups in this file are:\n");
for (lone_vg_number = 0; lone_vg_number < num_of_lones;
lone_vg_number++)
{
/*
* Attach to the current vgroup then get and display its
* name and class. Note: the current vgroup must be detached before
* moving to the next.
*/
vgroup_id = Vattach (file_id, ref_array[lone_vg_number], "r");
status_32 = Vgetname (vgroup_id, vgroup_name);
status_32 = Vgetclass (vgroup_id, vgroup_class);
printf (" Vgroup name %s and class %s\n", vgroup_name,
vgroup_class);
status_32 = Vdetach (vgroup_id);
} /* for */
} /* if */
/*
* Terminate access to the V interface and close the file.
*/
status_n = Vend (file_id);
status_n = Hclose (file_id);
/*
* Free the space allocated by this program.
*/
free (ref_array);
}
C
C Create, write, and insert the second vdata to the vgroup using
C steps similar to those used for the first vdata.
C
vdata2_id = vsfatch(file_id, -1, `w')
status = vsfsnam(vdata2_id, VD2_NAME)
status = vsfscls(vdata2_id, VD2_CLASS)
status = vsffdef(vdata2_id, FIELD_VD2, DFNT_FLOAT32, 1)
status = vsfsfld(vdata2_id, FIELD_VD2)
num_of_records = vsfwrt(vdata2_id, tmp, N_RECORDS,
+ FULL_INTERLACE)
vd_index = vfinsrt(vgroup_id, vdata2_id)
status = vsfdtch(vdata2_id)
C
C Create, write, and insert the third vdata to the vgroup using
C steps similar to those used for the first and second vdatas.
C
vdata3_id = vsfatch(file_id, -1, `w')
status = vsfsnam(vdata3_id, VD3_NAME)
status = vsfscls(vdata3_id, VD3_CLASS)
status = vsffdef(vdata3_id, FIELD_VD3, DFNT_INT16, 3)
status = vsfsfld(vdata3_id, FIELD_VD3)
num_of_records = vsfwrtc(vdata3_id, plist, N_RECORDS,
+ FULL_INTERLACE)
vd_index = vfinsrt(vgroup_id, vdata3_id)
status = vsfdtch(vdata3_id)
C
C Terminate access to the vgroup `Vertices'.
C
status = vfdtch(vgroup_id)
C
C Terminate access to the V interface and close the HDF file.
C
status = vfend(file_id)
status = hclose(file_id)
end
get_vgroup_info.c
#include "hdf.h"
#define FILE_NAME "General_Vgroups.hdf"
main( )
{
/************************* Variable declaration **************************/
intn status_n; /* returned status for functions returning an intn */
int32 status_32, /* returned status for functions returning an int32 */
file_id, vgroup_id;
int32 lone_vg_number, /* current lone vgroup number */
num_of_lones = 0; /* number of lone vgroups */
int32 *ref_array; /* buffer to hold the ref numbers of lone vgroups */
char vgroup_name[VGNAMELENMAX], vgroup_class[VGNAMELENMAX];
/********************** End of variable declaration **********************/
/*
* Open the HDF file for reading.
*/
file_id = Hopen (FILE_NAME, DFACC_READ, 0);
/*
* Initialize the V interface.
*/
status_n = Vstart (file_id);
/*
* Get and print the names and class names of all the lone vgroups.
* First, call Vlone with num_of_lones set to 0 to get the number of
* lone vgroups in the file, but not to get their reference numbers.
*/
num_of_lones = Vlone (file_id, NULL, num_of_lones );
/*
* Then, if there are any lone vgroups,
*/
if (num_of_lones > 0)
{
/*
* use the num_of_lones returned to allocate sufficient space for the
* buffer ref_array to hold the reference numbers of all lone vgroups,
*/
ref_array = (int32 *) malloc(sizeof(int32) * num_of_lones);
/*
* and call Vlone again to retrieve the reference numbers into
* the buffer ref_array.
*/
num_of_lones = Vlone (file_id, ref_array, num_of_lones);
/*
* Display the name and class of each lone vgroup.
*/
printf ("Lone vgroups in this file are:\n");
for (lone_vg_number = 0; lone_vg_number < num_of_lones;
lone_vg_number++)
{
/*
* Attach to the current vgroup then get and display its
* name and class. Note: the current vgroup must be detached before
* moving to the next.
*/
vgroup_id = Vattach (file_id, ref_array[lone_vg_number], "r");
status_32 = Vgetname (vgroup_id, vgroup_name);
status_32 = Vgetclass (vgroup_id, vgroup_class);
printf (" Vgroup name %s and class %s\n", vgroup_name,
vgroup_class);
status_32 = Vdetach (vgroup_id);
} /* for */
} /* if */
/*
* Terminate access to the V interface and close the file.
*/
status_n = Vend (file_id);
status_n = Hclose (file_id);
/*
* Free the space allocated by this program.
*/
free (ref_array);
}
C
C Create, write, and insert the second vdata to the vgroup using
C steps similar to those used for the first vdata.
C
vdata2_id = vsfatch(file_id, -1, `w')
status = vsfsnam(vdata2_id, VD2_NAME)
status = vsfscls(vdata2_id, VD2_CLASS)
status = vsffdef(vdata2_id, FIELD_VD2, DFNT_FLOAT32, 1)
status = vsfsfld(vdata2_id, FIELD_VD2)
num_of_records = vsfwrt(vdata2_id, tmp,