diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 78e111535b0..ae429a2dfc1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,7 @@ jobs: os: ubuntu-latest build_type: "Release" cpp: ON - fortran: OFF + fortran: ON java: ON ts: OFF hl: ON diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index b50bf59933a..0acaf2d2860 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -31,7 +31,7 @@ jobs: os: ubuntu-latest build_type: "Release" cpp: ON - fortran: OFF + fortran: ON java: ON ts: OFF hl: ON diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index d849086ebac..e59a8294cab 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -74,7 +74,7 @@ add_executable (H5match_types target_include_directories (H5match_types PRIVATE "${HDF5_SRC_BINARY_DIR};${HDF5_SRC_DIR};${HDF5_F90_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") add_custom_command (TARGET H5match_types POST_BUILD - BYPRODUCTS H5f90i_gen.h H5fortran_types.F90 + BYPRODUCTS ${HDF5_F90_BINARY_DIR}/H5f90i_gen.h ${HDF5_F90_BINARY_DIR}/H5fortran_types.F90 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} DEPENDS H5match_types @@ -82,7 +82,7 @@ add_custom_command (TARGET H5match_types POST_BUILD if (NOT ONLY_SHARED_LIBS) add_custom_command (TARGET H5match_types POST_BUILD - BYPRODUCTS H5f90i_gen.h H5fortran_types.F90 + BYPRODUCTS ${HDF5_F90_BINARY_DIR}/static/H5f90i_gen.h ${HDF5_F90_BINARY_DIR}/static/H5fortran_types.F90 COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_F90_BINARY_DIR}/H5f90i_gen.h ${HDF5_F90_BINARY_DIR}/static/H5f90i_gen.h COMMAND ${CMAKE_COMMAND} @@ -95,7 +95,7 @@ if (NOT ONLY_SHARED_LIBS) endif () if (BUILD_SHARED_LIBS) add_custom_command (TARGET H5match_types POST_BUILD - BYPRODUCTS H5f90i_gen.h H5fortran_types.F90 + BYPRODUCTS ${HDF5_F90_BINARY_DIR}/shared/H5f90i_gen.h ${HDF5_F90_BINARY_DIR}/shared/H5fortran_types.F90 COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_F90_BINARY_DIR}/H5f90i_gen.h ${HDF5_F90_BINARY_DIR}/shared/H5f90i_gen.h COMMAND ${CMAKE_COMMAND} @@ -235,7 +235,7 @@ add_custom_command (TARGET H5_buildiface POST_BUILD ) if (NOT ONLY_SHARED_LIBS) add_custom_command (TARGET H5_buildiface POST_BUILD - BYPRODUCTS H5_gen.F90 + BYPRODUCTS ${HDF5_F90_BINARY_DIR}/static/H5_gen.F90 COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_F90_BINARY_DIR}/H5_gen.F90 ${HDF5_F90_BINARY_DIR}/static/H5_gen.F90 WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR}/static @@ -250,7 +250,7 @@ endif () if (BUILD_SHARED_LIBS) add_custom_command (TARGET H5_buildiface POST_BUILD - BYPRODUCTS H5_gen.F90 + BYPRODUCTS ${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_F90_BINARY_DIR}/H5_gen.F90 ${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR}/shared diff --git a/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt index 147746c8188..1e879e73d8c 100644 --- a/fortran/test/CMakeLists.txt +++ b/fortran/test/CMakeLists.txt @@ -92,7 +92,7 @@ endif () if (NOT BUILD_SHARED_LIBS) add_custom_command (TARGET H5_test_buildiface POST_BUILD - BYPRODUCTS tf_gen.F90 + BYPRODUCTS ${HDF5_FORTRAN_TESTS_BINARY_DIR}/static/tf_gen.F90 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_FORTRAN_TESTS_BINARY_DIR}/static DEPENDS H5_test_buildiface @@ -104,7 +104,7 @@ if (NOT BUILD_SHARED_LIBS) set_source_files_properties (${HDF5_FORTRAN_TESTS_BINARY_DIR}/static/tf_gen.F90 PROPERTIES GENERATED TRUE) else () add_custom_command (TARGET H5_test_buildiface POST_BUILD - BYPRODUCTS tf_gen.F90 + BYPRODUCTS ${HDF5_FORTRAN_TESTS_BINARY_DIR}/shared/tf_gen.F90 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_FORTRAN_TESTS_BINARY_DIR}/shared DEPENDS H5_test_buildiface diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt index 6c97886f9fb..973299f9ed6 100644 --- a/hl/fortran/src/CMakeLists.txt +++ b/hl/fortran/src/CMakeLists.txt @@ -115,7 +115,7 @@ set (HDF5_HL_F90_F_BASE_SOURCES if (NOT ONLY_SHARED_LIBS) add_custom_command (TARGET H5HL_buildiface POST_BUILD - BYPRODUCTS $H5LTff_gen.F90 H5TBff_gen.F90 + BYPRODUCTS ${HDF5_HL_F90_BINARY_DIR}/static/H5LTff_gen.F90 ${HDF5_HL_F90_BINARY_DIR}/static/H5TBff_gen.F90 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_HL_F90_BINARY_DIR}/static DEPENDS ${HDF5_HL_F90_F_BASE_SOURCES} @@ -132,7 +132,7 @@ if (NOT ONLY_SHARED_LIBS) endif () if (BUILD_SHARED_LIBS) add_custom_command (TARGET H5HL_buildiface POST_BUILD - BYPRODUCTS H5LTff_gen.F90 H5TBff_gen.F90 + BYPRODUCTS ${HDF5_HL_F90_BINARY_DIR}/shared/H5LTff_gen.F90 ${HDF5_HL_F90_BINARY_DIR}/shared/H5TBff_gen.F90 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ WORKING_DIRECTORY ${HDF5_HL_F90_BINARY_DIR}/shared DEPENDS ${HDF5_HL_F90_F_BASE_SOURCES} diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index aef0ba112bc..63547df6aad 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -10726,7 +10726,18 @@ public synchronized static native byte[] H5Rcopy(byte[] src_ref_ptr) * @exception IllegalArgumentException * - an input array is invalid. **/ - public synchronized static native long H5Ropen_object(byte[] ref_ptr, long rapl_id, long oapl_id) + public static long H5Ropen_object(byte[] ref_ptr, long rapl_id, long oapl_id) + throws HDF5LibraryException, NullPointerException, IllegalArgumentException { + long id = _H5Ropen_object(ref_ptr, rapl_id, oapl_id); + if (id > 0) { + log.trace("OPEN_IDS: H5Ropen_object add {}", id); + OPEN_IDS.add(id); + log.trace("OPEN_IDS: {}", OPEN_IDS.size()); + } + return id; + } + + private synchronized static native long _H5Ropen_object(byte[] ref_ptr, long rapl_id, long oapl_id) throws HDF5LibraryException, NullPointerException, IllegalArgumentException; /** @@ -10754,7 +10765,18 @@ public synchronized static native long H5Ropen_object(byte[] ref_ptr, long rapl_ * @exception IllegalArgumentException * - an input array is invalid. **/ - public synchronized static native long H5Ropen_region(byte[] ref_ptr, long rapl_id, long oapl_id) + public static long H5Ropen_region(byte[] ref_ptr, long rapl_id, long oapl_id) + throws HDF5LibraryException, NullPointerException, IllegalArgumentException { + long id = _H5Ropen_region(ref_ptr, rapl_id, oapl_id); + if (id > 0) { + log.trace("OPEN_IDS: H5Ropen_region add {}", id); + OPEN_IDS.add(id); + log.trace("OPEN_IDS: {}", OPEN_IDS.size()); + } + return id; + } + + private synchronized static native long _H5Ropen_region(byte[] ref_ptr, long rapl_id, long oapl_id) throws HDF5LibraryException, NullPointerException, IllegalArgumentException; /** @@ -10782,7 +10804,18 @@ public synchronized static native long H5Ropen_region(byte[] ref_ptr, long rapl_ * @exception IllegalArgumentException * - an input array is invalid. **/ - public synchronized static native long H5Ropen_attr(byte[] ref_ptr, long rapl_id, long aapl_id) + public static long H5Ropen_attr(byte[] ref_ptr, long rapl_id, long aapl_id) + throws HDF5LibraryException, NullPointerException, IllegalArgumentException { + long id = _H5Ropen_attr(ref_ptr, rapl_id, aapl_id); + if (id > 0) { + log.trace("OPEN_IDS: H5Ropen_attr add {}", id); + OPEN_IDS.add(id); + log.trace("OPEN_IDS: {}", OPEN_IDS.size()); + } + return id; + } + + private synchronized static native long _H5Ropen_attr(byte[] ref_ptr, long rapl_id, long aapl_id) throws HDF5LibraryException, NullPointerException, IllegalArgumentException; // Get type // diff --git a/java/src/jni/h5rImp.c b/java/src/jni/h5rImp.c index c08f5de2281..9fe07019cf0 100644 --- a/java/src/jni/h5rImp.c +++ b/java/src/jni/h5rImp.c @@ -336,7 +336,7 @@ Java_hdf_hdf5lib_H5_H5Rcopy(JNIEnv *env, jclass clss, jbyteArray src_ref) * Signature: ([BJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ropen_1object(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong oapl_id) +Java_hdf_hdf5lib_H5__1H5Ropen_1object(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong oapl_id) { jboolean isCopy; jbyte * refBuf = NULL; @@ -371,7 +371,7 @@ Java_hdf_hdf5lib_H5_H5Ropen_1object(JNIEnv *env, jclass clss, jbyteArray ref, jl * Signature: ([BJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ropen_1region(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong oapl_id) +Java_hdf_hdf5lib_H5__1H5Ropen_1region(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong oapl_id) { jboolean isCopy; jbyte * refBuf = NULL; @@ -406,7 +406,7 @@ Java_hdf_hdf5lib_H5_H5Ropen_1region(JNIEnv *env, jclass clss, jbyteArray ref, jl * Signature: ([BJJ)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Ropen_1attr(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong aapl_id) +Java_hdf_hdf5lib_H5__1H5Ropen_1attr(JNIEnv *env, jclass clss, jbyteArray ref, jlong rapl_id, jlong aapl_id) { jboolean isCopy; jbyte * refBuf = NULL; diff --git a/java/src/jni/h5rImp.h b/java/src/jni/h5rImp.h index cdfdd8e038e..ffd77370f07 100644 --- a/java/src/jni/h5rImp.h +++ b/java/src/jni/h5rImp.h @@ -78,21 +78,21 @@ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_H5_H5Rcopy(JNIEnv *, jclass, jbyte * Method: H5Ropen_object * Signature: ([BJJ)J */ -JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Ropen_1object(JNIEnv *, jclass, jbyteArray, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Ropen_1object(JNIEnv *, jclass, jbyteArray, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Ropen_region * Signature: ([BJJ)J */ -JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Ropen_1region(JNIEnv *, jclass, jbyteArray, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Ropen_1region(JNIEnv *, jclass, jbyteArray, jlong, jlong); /* * Class: hdf_hdf5lib_H5 * Method: H5Ropen_attr * Signature: ([BJJ)J */ -JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Ropen_1attr(JNIEnv *, jclass, jbyteArray, jlong, jlong); +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Ropen_1attr(JNIEnv *, jclass, jbyteArray, jlong, jlong); /* * Class: hdf_hdf5lib_H5 diff --git a/java/test/TestH5Rref.java b/java/test/TestH5Rref.java index cbdabdd7b70..5733aaed66b 100644 --- a/java/test/TestH5Rref.java +++ b/java/test/TestH5Rref.java @@ -134,7 +134,7 @@ public void testH5Rget_object() { try {H5.H5Tclose(f_type);} catch (Exception ex) {} } try { - ndims = H5.H5Sget_simple_extent_ndims(H5dsid); + ndims = (int)H5.H5Sget_simple_extent_npoints(H5dsid); } catch (Throwable err) { err.printStackTrace(); @@ -209,7 +209,7 @@ public void testH5Rget_obj_type3() { try {H5.H5Tclose(f_type);} catch (Exception ex) {} } try { - ndims = H5.H5Sget_simple_extent_ndims(H5dsid); + ndims = (int)H5.H5Sget_simple_extent_npoints(H5dsid); } catch (Throwable err) { err.printStackTrace(); @@ -286,7 +286,7 @@ public void testH5Rget_region_dataset() { try {H5.H5Tclose(f_type);} catch (Exception ex) {} } try { - ndims = H5.H5Sget_simple_extent_ndims(H5dsid); + ndims = (int)H5.H5Sget_simple_extent_npoints(H5dsid); } catch (Throwable err) { err.printStackTrace(); @@ -305,80 +305,81 @@ public void testH5Rget_region_dataset() { } for (int i = 0; i < ndims; i++) { try { - ret_val = H5.H5Rget_type(refbuf[i]); + try { + ret_val = H5.H5Rget_type(refbuf[i]); + } + catch (Throwable err) { + err.printStackTrace(); + fail("testH5Rget_region_dataset: H5Rget_type["+i+"]: " + err); + } assertTrue("testH5Rget_region_dataset: H5Rget_type["+i+"]="+ret_val, ret_val == ref_type); try { loc_id = H5.H5Ropen_object(refbuf[i], HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); assertTrue(loc_id >= 0); - boolean regionzero = byteArrayCheck(refbuf[i]); - if (i > 1) - assertTrue(regionzero); - else { + try { + loc_sid = H5.H5Ropen_region(refbuf[i], HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + assertTrue(loc_sid >= 0); + int region_type = -1; try { - loc_sid = H5.H5Ropen_region(refbuf[i], HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); - assertTrue(loc_sid >= 0); - int region_type = -1; - try { - int reg_ndims = H5.H5Sget_simple_extent_ndims(loc_sid); - region_type = H5.H5Sget_select_type(loc_sid); - if (i == 1) - assertTrue(region_type == HDF5Constants.H5S_SEL_POINTS); - else - assertTrue(region_type == HDF5Constants.H5S_SEL_HYPERSLABS); - if (region_type == HDF5Constants.H5S_SEL_POINTS) { - long reg_npoints = H5.H5Sget_select_elem_npoints(loc_sid); - // Coordinates for get point selection - long getcoord[] = new long[reg_ndims * (int)reg_npoints]; - // Known coordinates for point selection - long coord[][] = {{6,9},{2,2},{8,4},{1,6},{2,8},{3,2}, - {0,4},{9,0},{7,1},{3,3}}; - try { - H5.H5Sget_select_elem_pointlist(loc_sid, 0, reg_npoints, getcoord); - assertTrue("H5.H5Sget_select_elem_pointlist", coord[0][0] == getcoord[0]); - assertTrue("H5.H5Sget_select_elem_pointlist", coord[0][1] == getcoord[1]); - assertTrue("H5.H5Sget_select_elem_pointlist", coord[1][0] == getcoord[2]); - assertTrue("H5.H5Sget_select_elem_pointlist", coord[1][1] == getcoord[3]); - assertTrue("H5.H5Sget_select_elem_pointlist", coord[2][0] == getcoord[4]); - assertTrue("H5.H5Sget_select_elem_pointlist", coord[2][1] == getcoord[5]); - } - catch (Throwable err3) { - err3.printStackTrace(); - fail("H5.H5Sget_select_elem_pointlist: " + err3); - } + int reg_ndims = H5.H5Sget_simple_extent_ndims(loc_sid); + region_type = H5.H5Sget_select_type(loc_sid); + if (i == 1) + assertTrue(region_type == HDF5Constants.H5S_SEL_POINTS); + else + assertTrue(region_type == HDF5Constants.H5S_SEL_HYPERSLABS); + if (region_type == HDF5Constants.H5S_SEL_POINTS) { + long reg_npoints = H5.H5Sget_select_elem_npoints(loc_sid); + // Coordinates for get point selection + long getcoord[] = new long[reg_ndims * (int)reg_npoints]; + // Known coordinates for point selection + long coord[][] = {{6,9},{2,2},{8,4},{1,6},{2,8},{3,2}, + {0,4},{9,0},{7,1},{3,3}}; + try { + H5.H5Sget_select_elem_pointlist(loc_sid, 0, reg_npoints, getcoord); + assertTrue("H5.H5Sget_select_elem_pointlist", coord[0][0] == getcoord[0]); + assertTrue("H5.H5Sget_select_elem_pointlist", coord[0][1] == getcoord[1]); + assertTrue("H5.H5Sget_select_elem_pointlist", coord[1][0] == getcoord[2]); + assertTrue("H5.H5Sget_select_elem_pointlist", coord[1][1] == getcoord[3]); + assertTrue("H5.H5Sget_select_elem_pointlist", coord[2][0] == getcoord[4]); + assertTrue("H5.H5Sget_select_elem_pointlist", coord[2][1] == getcoord[5]); } - else if (region_type == HDF5Constants.H5S_SEL_HYPERSLABS) { - long reg_nblocks = H5.H5Sget_select_hyper_nblocks(loc_sid); - assertTrue("H5Sget_select_hyper_nblocks", reg_nblocks == 1); - // Coordinates for get block selection - long getblocks[] = new long[reg_ndims * (int)reg_nblocks * 2]; - long start[] = {2,2}; - long block[] = {8,8}; - try { - H5.H5Sget_select_hyper_blocklist(loc_sid, 0, reg_nblocks, getblocks); - assertTrue("H5.H5Sget_select_hyper_blocklist", start[0] == getblocks[0]); - assertTrue("H5.H5Sget_select_hyper_blocklist", start[1] == getblocks[1]); - assertTrue("H5.H5Sget_select_hyper_blocklist", (block[0]-1) == getblocks[2]); - assertTrue("H5.H5Sget_select_hyper_blocklist", (block[1]-1) == getblocks[3]); - } - catch (Throwable err3) { - err3.printStackTrace(); - fail("H5.H5Sget_select_hyper_blocklist: " + err3); - } + catch (Throwable err3) { + err3.printStackTrace(); + fail("H5.H5Sget_select_elem_pointlist: " + err3); } } - catch (Throwable err2) { - err2.printStackTrace(); - fail("testH5Rget_region_dataset: H5Sget_select_type: " + err2); + else if (region_type == HDF5Constants.H5S_SEL_HYPERSLABS) { + long reg_nblocks = H5.H5Sget_select_hyper_nblocks(loc_sid); + assertTrue("H5Sget_select_hyper_nblocks", reg_nblocks == 1); + // Coordinates for get block selection + long getblocks[] = new long[reg_ndims * (int)reg_nblocks * 2]; + long start[] = {2,2}; + long block[] = {8,8}; + try { + H5.H5Sget_select_hyper_blocklist(loc_sid, 0, reg_nblocks, getblocks); + assertTrue("H5.H5Sget_select_hyper_blocklist", start[0] == getblocks[0]); + assertTrue("H5.H5Sget_select_hyper_blocklist", start[1] == getblocks[1]); + assertTrue("H5.H5Sget_select_hyper_blocklist", (block[0]-1) == getblocks[2]); + assertTrue("H5.H5Sget_select_hyper_blocklist", (block[1]-1) == getblocks[3]); + } + catch (Throwable err3) { + err3.printStackTrace(); + fail("H5.H5Sget_select_hyper_blocklist: " + err3); + } } } - catch (Throwable err1) { - err1.printStackTrace(); - fail("testH5Rget_region_dataset: " + err1); - } - finally { - try {H5.H5Sclose(loc_sid);} catch (Exception ex) {} + catch (Throwable err2) { + err2.printStackTrace(); + assertTrue("testH5Rget_region_dataset: H5Sget_select_type: " + err2, i > 1); } } + catch (Throwable err1) { + err1.printStackTrace(); + fail("testH5Rget_region_dataset: " + err1); + } + finally { + try {H5.H5Sclose(loc_sid);} catch (Exception ex) {} + } } catch (Throwable err0) { err0.printStackTrace(); @@ -432,7 +433,7 @@ public void testH5Rget_region_attribute() { try {H5.H5Tclose(f_type);} catch (Exception ex) {} } try { - ndims = H5.H5Sget_simple_extent_ndims(H5dsid); + ndims = (int)H5.H5Sget_simple_extent_npoints(H5dsid); } catch (Throwable err) { err.printStackTrace(); @@ -473,7 +474,8 @@ public void testH5Rget_region_attribute() { } catch (Throwable err0) { err0.printStackTrace(); - fail("testH5Rget_region_attribute: " + err0); + // second attribute is null + assertTrue("testH5Rget_region_attribute: " + err0, i == 1); } finally { try {H5.H5Aclose(loc_id);} catch (Exception ex) {}