diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-11 16:24:11 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-11 16:24:11 (GMT) |
commit | d9e5ca72f39934531b534524d07cf784c3d0e613 (patch) | |
tree | 1913b13a317132523091035f1175b2291c8b9db7 /hl/fortran/src | |
parent | 053807fa81579e6bd9ac6a701ddcaac39e4d0b87 (diff) | |
download | hdf5-d9e5ca72f39934531b534524d07cf784c3d0e613.zip hdf5-d9e5ca72f39934531b534524d07cf784c3d0e613.tar.gz hdf5-d9e5ca72f39934531b534524d07cf784c3d0e613.tar.bz2 |
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Diffstat (limited to 'hl/fortran/src')
-rw-r--r-- | hl/fortran/src/H5IMcc.c | 186 |
1 files changed, 91 insertions, 95 deletions
diff --git a/hl/fortran/src/H5IMcc.c b/hl/fortran/src/H5IMcc.c index 0b0f75a..651c60b 100644 --- a/hl/fortran/src/H5IMcc.c +++ b/hl/fortran/src/H5IMcc.c @@ -23,7 +23,7 @@ * private functions *------------------------------------------------------------------------- */ -herr_t H5IM_get_palette( hid_t loc_id, +herr_t H5IM_get_palette(hid_t loc_id, const char *image_name, int pal_number, hid_t tid, @@ -50,11 +50,11 @@ herr_t H5IM_get_palette( hid_t loc_id, *------------------------------------------------------------------------- */ -herr_t H5IMmake_image_8bitf( hid_t loc_id, +herr_t H5IMmake_image_8bitf(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height, - int_f *buf ) + int_f *buf) { hid_t did; /* dataset ID */ hid_t sid; /* space ID */ @@ -71,35 +71,34 @@ herr_t H5IMmake_image_8bitf( hid_t loc_id, */ /* create the data space for the dataset. */ - if ((sid=H5Screate_simple(IMAGE8_RANK,dims,NULL))<0) + if((sid = H5Screate_simple(IMAGE8_RANK, dims, NULL)) < 0) return -1; /* create the dataset as H5T_NATIVE_UCHAR */ - if ((did=H5Dcreate(loc_id,dset_name,H5T_NATIVE_UINT8,sid,H5P_DEFAULT))<0) + if((did = H5Dcreate2(loc_id, dset_name, H5T_NATIVE_UINT8, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; /* write with memory type H5T_NATIVE_INT */ /* Use long type if Fortran integer is 8 bytes and C long long is also 8 bytes*/ /* Fail if otherwise */ - if (buf) - { - if (sizeof(int_f) == sizeof(int)) { - if (H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) - return -1;} - else if (sizeof(int_f) == sizeof(long)) { - if (H5Dwrite(did,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) - return -1;} - else if (sizeof(int_f) == sizeof(long_long)) { - if (H5Dwrite(did,H5T_NATIVE_LLONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) - return -1;} - else - return -1; + if(buf) { + if(sizeof(int_f) == sizeof(int)) { + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + return -1; + } else if(sizeof(int_f) == sizeof(long)) { + if(H5Dwrite(did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + return -1; + } else if(sizeof(int_f) == sizeof(long_long)) { + if(H5Dwrite(did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + return -1; + } else + return -1; } /* close */ - if (H5Dclose(did)<0) + if(H5Dclose(did) < 0) return -1; - if (H5Sclose(sid)<0) + if(H5Sclose(sid) < 0) return -1; /*------------------------------------------------------------------------- @@ -108,15 +107,15 @@ herr_t H5IMmake_image_8bitf( hid_t loc_id, */ /* attach the CLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0 ) + if(H5LTset_attribute_string(loc_id, dset_name, "CLASS", IMAGE_CLASS) < 0) return -1; /* attach the VERSION attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0 ) + if(H5LTset_attribute_string(loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION) < 0) return -1; /* attach the IMAGE_SUBCLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED" ) < 0 ) + if(H5LTset_attribute_string(loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED") < 0) return -1; return 0; @@ -150,7 +149,7 @@ herr_t H5IMmake_image_8bitf( hid_t loc_id, *------------------------------------------------------------------------- */ -herr_t H5IMmake_image_24bitf( hid_t loc_id, +herr_t H5IMmake_image_24bitf(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height, @@ -165,22 +164,21 @@ herr_t H5IMmake_image_24bitf( hid_t loc_id, * attach the image dimensions according to the interlace mode *------------------------------------------------------------------------- */ - if ( strcmp( interlace, "INTERLACE_PIXEL" ) == 0 ) - { + if(strcmp(interlace, "INTERLACE_PIXEL") == 0) { /* Number of color planes is defined as the third dimension */ dims[0] = height; dims[1] = width; dims[2] = IMAGE24_RANK; } else - if ( strcmp( interlace, "INTERLACE_PLANE" ) == 0 ) - { + if(strcmp(interlace, "INTERLACE_PLANE") == 0) { /* Number of color planes is defined as the first dimension */ dims[0] = IMAGE24_RANK; dims[1] = height; dims[2] = width; } - else return -1; + else + return -1; /*------------------------------------------------------------------------- * create and write the dataset @@ -188,33 +186,32 @@ herr_t H5IMmake_image_24bitf( hid_t loc_id, */ /* create the data space for the dataset. */ - if ((sid=H5Screate_simple(IMAGE24_RANK,dims,NULL))<0) + if((sid = H5Screate_simple(IMAGE24_RANK, dims, NULL)) < 0) return -1; /* create the dataset as H5T_NATIVE_UCHAR */ - if ((did=H5Dcreate(loc_id,dset_name,H5T_NATIVE_UCHAR,sid,H5P_DEFAULT))<0) + if((did = H5Dcreate2(loc_id, dset_name, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; /* write with memory type H5T_NATIVE_INT */ - if (buf) - { - if (sizeof(int_f) == sizeof(int)) { - if (H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) - return -1;} - else if (sizeof(int_f) == sizeof(long)) { - if (H5Dwrite(did,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) - return -1;} - else if (sizeof(int_f) == sizeof(long_long)) { - if (H5Dwrite(did,H5T_NATIVE_LLONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) - return -1;} - else + if(buf) { + if(sizeof(int_f) == sizeof(int)) { + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + return -1; + } else if(sizeof(int_f) == sizeof(long)) { + if(H5Dwrite(did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + return -1; + } else if(sizeof(int_f) == sizeof(long_long)) { + if(H5Dwrite(did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + return -1; + } else return -1; } /* close */ - if (H5Dclose(did)<0) + if(H5Dclose(did) < 0) return -1; - if (H5Sclose(sid)<0) + if(H5Sclose(sid) < 0) return -1; /*------------------------------------------------------------------------- @@ -223,19 +220,19 @@ herr_t H5IMmake_image_24bitf( hid_t loc_id, */ /* Attach the CLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0 ) + if(H5LTset_attribute_string(loc_id, dset_name, "CLASS", IMAGE_CLASS) < 0) return -1; /* Attach the VERSION attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0 ) + if(H5LTset_attribute_string(loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION) < 0) return -1; /* Attach the IMAGE_SUBCLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR" ) < 0 ) + if(H5LTset_attribute_string(loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR") < 0) return -1; /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */ - if ( H5LTset_attribute_string( loc_id, dset_name, "INTERLACE_MODE", interlace ) < 0 ) + if(H5LTset_attribute_string(loc_id, dset_name, "INTERLACE_MODE", interlace) < 0) return -1; return 0; @@ -264,9 +261,9 @@ herr_t H5IMmake_image_24bitf( hid_t loc_id, *------------------------------------------------------------------------- */ -herr_t H5IMread_imagef( hid_t loc_id, +herr_t H5IMread_imagef(hid_t loc_id, const char *dset_name, - int_f *buf ) + int_f *buf) { hid_t did; hid_t tid; @@ -325,10 +322,10 @@ out: *------------------------------------------------------------------------- */ -herr_t H5IMmake_palettef( hid_t loc_id, +herr_t H5IMmake_palettef(hid_t loc_id, const char *pal_name, const hsize_t *pal_dims, - int_f *pal_data ) + int_f *pal_data) { @@ -337,10 +334,10 @@ herr_t H5IMmake_palettef( hid_t loc_id, int has_pal; /* Check if the dataset already exists */ - has_pal = H5LTfind_dataset( loc_id, pal_name ); + has_pal = H5LTfind_dataset(loc_id, pal_name); /* It exists. Return */ - if ( has_pal == 1 ) + if(has_pal == 1) return 0; /*------------------------------------------------------------------------- @@ -349,33 +346,32 @@ herr_t H5IMmake_palettef( hid_t loc_id, */ /* create the data space for the dataset. */ - if ((sid=H5Screate_simple(2,pal_dims,NULL))<0) + if((sid = H5Screate_simple(2, pal_dims, NULL)) < 0) return -1; /* create the dataset as H5T_NATIVE_UCHAR */ - if ((did=H5Dcreate(loc_id,pal_name,H5T_NATIVE_UCHAR,sid,H5P_DEFAULT))<0) + if((did = H5Dcreate2(loc_id, pal_name, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) return -1; /* write with memory type H5T_NATIVE_INT */ - if (pal_data) - { - if (sizeof(int_f) == sizeof(int)) { - if (H5Dwrite(did,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,pal_data)<0) - return -1;} - else if (sizeof(int_f) == sizeof(long)) { - if (H5Dwrite(did,H5T_NATIVE_LONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,pal_data)<0) - return -1;} - else if (sizeof(int_f) == sizeof(long_long)) { - if (H5Dwrite(did,H5T_NATIVE_LLONG,H5S_ALL,H5S_ALL,H5P_DEFAULT,pal_data)<0) - return -1;} - else - return -1; + if(pal_data) { + if(sizeof(int_f) == sizeof(int)) { + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0) + return -1; + } else if(sizeof(int_f) == sizeof(long)) { + if(H5Dwrite(did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0) + return -1; + } else if(sizeof(int_f) == sizeof(long_long)) { + if(H5Dwrite(did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0) + return -1; + } else + return -1; } /* close */ - if (H5Dclose(did)<0) + if(H5Dclose(did) < 0) return -1; - if (H5Sclose(sid)<0) + if(H5Sclose(sid) < 0) return -1; /*------------------------------------------------------------------------- @@ -384,11 +380,11 @@ herr_t H5IMmake_palettef( hid_t loc_id, */ /* Attach the attribute "CLASS" to the >>palette<< dataset*/ - if ( H5LTset_attribute_string( loc_id, pal_name, "CLASS", PALETTE_CLASS ) < 0 ) + if(H5LTset_attribute_string(loc_id, pal_name, "CLASS", PALETTE_CLASS) < 0) return -1; /* Attach the attribute "PAL_VERSION" to the >>palette<< dataset*/ - if ( H5LTset_attribute_string( loc_id, pal_name, "PAL_VERSION", "1.2" ) < 0 ) + if(H5LTset_attribute_string(loc_id, pal_name, "PAL_VERSION", "1.2") < 0) return -1; return 0; @@ -420,16 +416,16 @@ herr_t H5IMmake_palettef( hid_t loc_id, *------------------------------------------------------------------------- */ -herr_t H5IMget_palettef( hid_t loc_id, +herr_t H5IMget_palettef(hid_t loc_id, const char *image_name, int pal_number, - int_f *pal_data ) + int_f *pal_data) { if(sizeof(int_f) == sizeof(int)) return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_INT,pal_data); - else if (sizeof(int_f) == sizeof(long)) + else if(sizeof(int_f) == sizeof(long)) return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_LONG,pal_data); - else if (sizeof(int_f) == sizeof(long_long)) + else if(sizeof(int_f) == sizeof(long_long)) return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_LLONG,pal_data); else return -1; @@ -462,7 +458,7 @@ herr_t H5IMget_palettef( hid_t loc_id, * *------------------------------------------------------------------------- */ -herr_t H5IM_get_palette( hid_t loc_id, +herr_t H5IM_get_palette(hid_t loc_id, const char *image_name, int pal_number, hid_t tid, @@ -486,7 +482,7 @@ herr_t H5IM_get_palette( hid_t loc_id, /* Try to find the attribute "PALETTE" on the >>image<< dataset */ has_pal = H5IM_find_palette(image_id); - if(has_pal == 1 ) + if(has_pal == 1) { if((attr_id = H5Aopen(image_id, ".", "PALETTE", H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -495,62 +491,62 @@ herr_t H5IM_get_palette( hid_t loc_id, if((attr_type = H5Aget_type(attr_id)) < 0) goto out; - if ( (attr_class = H5Tget_class( attr_type )) < 0 ) + if((attr_class = H5Tget_class(attr_type)) < 0) goto out; /* Check if it is really a reference */ - if ( attr_class == H5T_REFERENCE ) + if(attr_class == H5T_REFERENCE) { /* Get the reference(s) */ - if ( (attr_space_id = H5Aget_space( attr_id )) < 0 ) + if((attr_space_id = H5Aget_space(attr_id)) < 0) goto out; - n_refs = H5Sget_simple_extent_npoints( attr_space_id ); + n_refs = H5Sget_simple_extent_npoints(attr_space_id); dim_ref = n_refs; - refbuf = malloc( sizeof(hobj_ref_t) * (int)dim_ref ); + refbuf = malloc(sizeof(hobj_ref_t) * (int)dim_ref); - if ( H5Aread( attr_id, attr_type, refbuf ) < 0 ) + if(H5Aread(attr_id, attr_type, refbuf) < 0) goto out; /* Get the palette id */ - if ( (pal_id = H5Rdereference( image_id, H5R_OBJECT, &refbuf[pal_number] )) < 0 ) + if((pal_id = H5Rdereference(image_id, H5R_OBJECT, &refbuf[pal_number])) < 0) goto out; /* Read the palette dataset using the memory type TID */ - if ( H5Dread( pal_id, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data ) < 0 ) + if(H5Dread(pal_id, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0) goto out; - if ( H5Sclose( attr_space_id ) < 0 ) + if(H5Sclose(attr_space_id) < 0) goto out; /* close the dereferenced dataset */ - if (H5Dclose(pal_id)<0) + if(H5Dclose(pal_id) < 0) goto out; - free( refbuf ); + free(refbuf); } /* H5T_REFERENCE */ - if ( H5Tclose( attr_type ) < 0 ) + if(H5Tclose(attr_type) < 0) goto out; /* Close the attribute. */ - if ( H5Aclose( attr_id ) < 0 ) + if(H5Aclose(attr_id) < 0) goto out; } /* Close the image dataset. */ - if ( H5Dclose( image_id ) < 0 ) + if(H5Dclose(image_id) < 0) return -1; return 0; out: - H5Dclose( image_id ); + H5Dclose(image_id); return -1; |