summaryrefslogtreecommitdiffstats
path: root/test/gass_write.c
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>1999-08-31 04:55:00 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>1999-08-31 04:55:00 (GMT)
commit06c8da20b126ed2947a36e48a065e67808f1f00e (patch)
tree3cd146cad057cfdb5bb96b3a8d830a0704ad08b0 /test/gass_write.c
parent17c0a1546cfb3b24c6955adbcc77aac5709f726c (diff)
downloadhdf5-06c8da20b126ed2947a36e48a065e67808f1f00e.zip
hdf5-06c8da20b126ed2947a36e48a065e67808f1f00e.tar.gz
hdf5-06c8da20b126ed2947a36e48a065e67808f1f00e.tar.bz2
[svn-r1621] Added GASS driver. Coded by Saurabh Bagchi, bagchi@uiuc.edu.
Minor changes done to test/gass_xxx.c so that they print the test skip message when GASS driver is not available. This change is the implementation of GASS within HDF5-1.3 (HDF5 with Virtual File Layer). The GASS driver gives the facility of accessing HDF files on remote ftp servers. To use the GASS driver, the option --with-gass=<GASS path> shoud be specified with configure. An example of the command line used to test the distribution was: ./configure --disable-shared --without-hdf4 --with-gass=/afs/ncsa/projects/hdf/v5/bagchi/globus/GLB/development/sparc-sun-solaris2.6_nothreads_standard_debug/include,/afs/ncsa/projects/hdf/v5/bagchi/globus/GLB/development/sparc-sun-solaris2.6_nothreads_standard_debug/lib --disable-parallel The user should change the path to point to his local GASS installation. Documentation about the features of GASS and the HDF-GASS design is available separately and till it is put up on the official web site, anyone interested may contact me. Test programs to read, write or append remote files have been provided in the test directory as "gass_read.c", "gass_write.c", "gass_append.c". The test programs have the ftp site to access #define-d at the top of the file which the user can change accordingly. ./src/H5Epublic. Added new error type for file close. ./src/H5F.c Added hooks for the GASS driver. ./src/H5public.h Added header files for GASS & Globus. ./src/Makefile.in Added dependancy on GASS driver in LIB_SRC. ./src/hdf5.h Included header file for GASS driver. ./src/H5FDgass.c [NEW] Routines for the GASS driver. ./src/H5FDgass.h [NEW] Header file for the GASS driver. ./test/Makefile.in Added dependancy on the gass test routines. ./test/gass_read.c File to test remote file reading using GASS. ./test/gass_write.c File to test remote file writing using GASS. ./test/gass_append.c File to test remote file appending using GASS.
Diffstat (limited to 'test/gass_write.c')
-rw-r--r--test/gass_write.c157
1 files changed, 157 insertions, 0 deletions
diff --git a/test/gass_write.c b/test/gass_write.c
new file mode 100644
index 0000000..a6000ed
--- /dev/null
+++ b/test/gass_write.c
@@ -0,0 +1,157 @@
+/*
+ * Copyright © 1998 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Saurabh Bagchi (bagchi@uiuc.edu)
+ * Friday, August 6, 1999.
+ *
+ * Modifications: Saurabh Bagchi (Aug 17, 1999)
+ * Modified to work with VFL (HDF51.3).
+ */
+
+/* Test the following functionality of the GASS driver.
+ 1. Open a remote file for write.
+ 2. Create a new dataset within the file.
+ 3. Create a local memory buffer to hold the data.
+ 4. Write the local data to the remote dataset.
+*/
+#include <h5test.h>
+
+#ifndef HAVE_GASS
+int main(void)
+{
+ printf("Test skipped because GASS driver not available\n");
+ return 0;
+}
+#else
+
+#define URL "ftp://bagchi:bagchi12@hdfspare1/scratch-fuga/home/bagchi/junk.w"
+
+#define DATASETNAME "IntArray"
+#define NX 5 /* dataset dimensions */
+#define NY 6
+#define RANK 2
+
+int main (void)
+{
+
+ hid_t fapl =-1, file;
+ hid_t dataspace, datatype, dataset;
+ hsize_t dimsf[2];
+
+ herr_t status = 0;
+ int data[NX][NY]; /* data to write */
+ int i, j;
+ GASS_Info ginf;
+
+ /*
+ * Data and output buffer initialization.
+ */
+ for (j = 0; j < NX; j++) {
+ for (i = 0; i < NY; i++)
+ data[j][i] = i + j;
+ }
+ /*
+ * 0 1 2 3 4 5
+ * 1 2 3 4 5 6
+ * 2 3 4 5 6 7
+ * 3 4 5 6 7 8
+ * 4 5 6 7 8 9
+ */
+
+ /* Create access property list and set the driver to GASS */
+ fapl = H5Pcreate (H5P_FILE_ACCESS);
+ if (fapl < 0) {
+ printf (" H5Pcreate failed. \n");
+ return -1;
+ }
+
+ ginf.block_size = 0;
+ ginf.max_length =0;
+ /* ginf = GASS_INFO_NULL;*/
+
+ status = H5Pset_fapl_gass (fapl, ginf);
+ if (status < 0) {
+ printf ("H5Pset_fapl_gass failed. \n");
+ return -1;
+ }
+
+ /*
+ * Create a new file using H5F_ACC_TRUNC access,
+ * default file creation properties, and gass file
+ * access properties.
+ */
+ // file = H5Fcreate(URL, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+ // Works. Truncates existing files.
+ // file = H5Fcreate(URL, H5F_ACC_EXCL, H5P_DEFAULT, fapl);
+ // Works. Croaks if existing file, else creates.
+ // Any other flag has no effect as long as one and exactly one of TRUNC/
+ // EXCL is there
+ /* printf ("I'm here just before H5Fcreate. \n");*/
+ file = H5Fcreate(URL, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+ if (file < 0) {
+ printf ("H5Fcreate failed. \n");
+ return -1;
+ }
+
+ /*
+ * Describe the size of the array and create the data space for fixed
+ * size dataset.
+ */
+ dimsf[0] = NX;
+ dimsf[1] = NY;
+ dataspace = H5Screate_simple(RANK, dimsf, NULL);
+ if (dataspace < 0) {
+ printf ("H5Screate failed. \n");
+ return -1;
+ }
+
+ /*
+ * Define datatype for the data in the file.
+ * We will store little endian INT numbers.
+ */
+ datatype = H5Tcopy(H5T_NATIVE_INT);
+ if (datatype < 0) {
+ printf ("H5Tcopy failed. \n");
+ return -1;
+ }
+
+ status = H5Tset_order(datatype, H5T_ORDER_LE);
+ if (status < 0) {
+ printf ("H5Tset_order failed. \n");
+ return -1;
+ }
+
+ /*
+ * Create a new dataset within the file using defined dataspace and
+ * datatype and default dataset creation properties.
+ */
+ dataset = H5Dcreate(file, DATASETNAME, datatype, dataspace,
+ H5P_DEFAULT);
+ if (dataset < 0) {
+ printf ("H5Dcreate failed. \n");
+ return -1;
+ }
+
+ /*
+ * Write the data to the dataset using default transfer properties.
+ */
+ status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ H5P_DEFAULT, data);
+ if (status < 0) {
+ printf ("H5Dwrite failed. \n");
+ return -1;
+ }
+
+ /*
+ * Close/release resources.
+ */
+ H5Sclose(dataspace);
+ H5Tclose(datatype);
+ H5Dclose(dataset);
+ H5Fclose(file);
+ H5Pclose(fapl);
+
+ return 0;
+}
+#endif