Skip to content

Commit 4a69468

Browse files
committed
Merge branch 'issue-421' of ssh://github.com/nexusformat/code into issue-421
Refs #421 Conflicts: src/napi5.c
2 parents 523a52a + 0929e8b commit 4a69468

3 files changed

Lines changed: 46 additions & 19 deletions

File tree

include/napi5.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
/* Hide deprecated API from HDF5 versions before 1.8
77
* Required to build on Ubuntu 12.04 */
8-
#define H5_NO_DEPRECATED_SYMBOLS
98

109
#include <hdf5.h>
1110

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ endif(WITH_HDF4)
5959
#-----------------------------------------------------------------------------
6060
if (WITH_HDF5)
6161
set (NAPISRC ${NAPISRC} napi5.c)
62+
add_definitions(-DH5_USE_18_API=1)
6263
include_directories(${HDF5_INCLUDE_DIRS})
6364
link_directories(${HDF5_LIBRARY_DIRS})
6465
endif (WITH_HDF5)

src/napi5.c

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
477503
NXstatus 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

Comments
 (0)