@@ -275,31 +275,57 @@ NXstatus NX5open(CONSTCHAR * filename, NXaccess am, NXhandle * pHandle)
275275 return NX_ERROR ;
276276 }
277277 memset (pNew , 0 , sizeof (NexusFile5 ));
278+
279+ /* create file access property list - required in all cases*/
280+ if ((fapl = H5Pcreate (H5P_FILE_ACCESS ))< 0 ){
281+ sprintf (pBuffer ,"Error: failed to create file access property "
282+ "list for file %s" ,filename );
283+ NXReportError (pBuffer );
284+ free (pNew );
285+ return NX_ERROR ;
286+ }
287+
288+ /* set file close policy - need this in all cases*/
289+ if (H5Pset_fclose_degree (fapl , H5F_CLOSE_STRONG )< 0 ){
290+ sprintf (pBuffer ,"Error: cannot set close policy for file "
291+ "%s" ,filename );
292+ NXReportError (pBuffer );
293+ free (pNew );
294+ return NX_ERROR ;
295+ }
278296
279297 /* start HDF5 interface */
280298 if (am == NXACC_CREATE5 ) {
281- fapl = H5Pcreate (H5P_FILE_ACCESS );
282- H5Pget_cache (fapl , & mdc_nelmts , & rdcc_nelmts , & rdcc_nbytes ,
283- & rdcc_w0 );
299+ if (H5Pget_cache (fapl , & mdc_nelmts , & rdcc_nelmts , & rdcc_nbytes ,
300+ & rdcc_w0 ) < 0 ){
301+ sprintf (pBuffer ,"Error: cannot obtain HDF5 cache size"
302+ " for file %s" ,filename );
303+ NXReportError (pBuffer );
304+ free (pNew );
305+ return NX_ERROR ;
306+ }
307+
284308 rdcc_nbytes = (size_t ) nx_cacheSize ;
285- H5Pset_cache (fapl , mdc_nelmts , rdcc_nelmts , rdcc_nbytes ,
286- rdcc_w0 );
287- H5Pset_fclose_degree (fapl , H5F_CLOSE_STRONG );
309+ if (H5Pset_cache (fapl , mdc_nelmts , rdcc_nelmts , rdcc_nbytes ,
310+ rdcc_w0 ) < 0 ){
311+ sprintf (pBuffer ,"Error: cannot set cache size "
312+ "for file %s" ,filename );
313+ NXReportError (pBuffer );
314+ free (pNew );
315+ return NX_ERROR ;
316+ }
317+
288318 am1 = H5F_ACC_TRUNC ;
289319 pNew -> iFID = H5Fcreate (filename , am1 , H5P_DEFAULT , fapl );
290320 } else {
291- if (am == NXACC_READ ) {
292- am1 = H5F_ACC_RDONLY ;
293- } else {
294- am1 = H5F_ACC_RDWR ;
295- }
296- fapl = H5Pcreate (H5P_FILE_ACCESS );
297- H5Pset_fclose_degree (fapl , H5F_CLOSE_STRONG );
321+ if (am == NXACC_READ ) am1 = H5F_ACC_RDONLY ;
322+ else am1 = H5F_ACC_RDWR ;
323+
298324 pNew -> iFID = H5Fopen (filename , am1 , fapl );
299325 }
300- if ( fapl != -1 ) {
301- H5Pclose (fapl );
302- }
326+
327+ if ( fapl != -1 ) H5Pclose (fapl ); /*close file access property list*/
328+
303329 if (pNew -> iFID <= 0 ) {
304330 sprintf (pBuffer , "ERROR: cannot open file: %s" , filename );
305331 NXReportError (pBuffer );
@@ -477,7 +503,7 @@ NXstatus NX5close(NXhandle * fid)
477503NXstatus NX5makegroup (NXhandle fid , CONSTCHAR * name , CONSTCHAR * nxclass )
478504{
479505 pNexusFile5 pFile ;
480- herr_t iRet ;
506+ hid_t iRet ;
481507 hid_t iVID ;
482508 hid_t attr1 , aid1 , aid2 ;
483509 char pBuffer [1024 ] = "" ;
@@ -710,7 +736,7 @@ NXstatus NX5compmakedata64(NXhandle fid, CONSTCHAR * name,
710736 int rank , int64_t dimensions [],
711737 int compress_type , int64_t chunk_size [])
712738{
713- hid_t datatype1 , dataspace , iNew , dID ;
739+ hid_t datatype1 , dataspace , iNew , dID ;
714740 herr_t iRet ;
715741 hid_t type , cparms = -1 ;
716742 pNexusFile5 pFile ;
@@ -1056,6 +1082,7 @@ NXstatus NX5putattr(NXhandle fid, CONSTCHAR * name, const void *data,
10561082 pNexusFile5 pFile ;
10571083 hid_t attr1 , aid1 , aid2 ;
10581084 hid_t type ;
1085+ hid_t attr_id ;
10591086 herr_t iRet ;
10601087 hid_t vid , attRet ;
10611088
0 commit comments