Merge pull request #4831 from scivision/hdf5
commit
abad2ff005
10 changed files with 184 additions and 3 deletions
@ -0,0 +1,3 @@ |
||||
## HDF5 |
||||
|
||||
HDF5 support is added via pkg-config. |
@ -0,0 +1,30 @@ |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
|
||||
#include "hdf5.h" |
||||
|
||||
int main(void) |
||||
{ |
||||
herr_t ier; |
||||
unsigned maj, min, rel; |
||||
|
||||
ier = H5open(); |
||||
if (ier) { |
||||
fprintf(stderr,"Unable to initialize HDF5: %d\n", ier); |
||||
return EXIT_FAILURE; |
||||
} |
||||
|
||||
ier = H5get_libversion(&maj, &min, &rel); |
||||
if (ier) { |
||||
fprintf(stderr,"HDF5 did not initialize!\n"); |
||||
return EXIT_FAILURE; |
||||
} |
||||
printf("C HDF5 version %d.%d.%d\n", maj, min, rel); |
||||
|
||||
ier = H5close(); |
||||
if (ier) { |
||||
fprintf(stderr,"Unable to close HDF5: %d\n", ier); |
||||
return EXIT_FAILURE; |
||||
} |
||||
return EXIT_SUCCESS; |
||||
} |
@ -0,0 +1,29 @@ |
||||
#include <iostream> |
||||
#include "hdf5.h" |
||||
|
||||
|
||||
int main(void) |
||||
{ |
||||
herr_t ier; |
||||
unsigned maj, min, rel; |
||||
|
||||
ier = H5open(); |
||||
if (ier) { |
||||
std::cerr << "Unable to initialize HDF5: %d" << ier << std::endl; |
||||
return EXIT_FAILURE; |
||||
} |
||||
|
||||
ier = H5get_libversion(&maj, &min, &rel); |
||||
if (ier) { |
||||
std::cerr << "HDF5 did not initialize!" << std::endl; |
||||
return EXIT_FAILURE; |
||||
} |
||||
printf("C++ HDF5 version %d.%d.%d\n", maj, min, rel); |
||||
|
||||
ier = H5close(); |
||||
if (ier) { |
||||
std::cerr << "Unable to close HDF5: %d" << ier << std::endl; |
||||
return EXIT_FAILURE; |
||||
} |
||||
return EXIT_SUCCESS; |
||||
} |
@ -0,0 +1,17 @@ |
||||
use hdf5 |
||||
|
||||
implicit none |
||||
|
||||
integer :: ier, major, minor, rel |
||||
|
||||
call h5open_f(ier) |
||||
if (ier /= 0) error stop 'Unable to initialize HDF5' |
||||
|
||||
call h5get_libversion_f(major, minor, rel, ier) |
||||
if (ier /= 0) error stop 'Unable to check HDF5 version' |
||||
print '(A,I1,A1,I0.2,A1,I1)','Fortran HDF5 version ',major,'.',minor,'.',rel |
||||
|
||||
call h5close_f(ier) |
||||
if (ier /= 0) error stop 'Unable to close HDF5 library' |
||||
|
||||
end program |
@ -0,0 +1,44 @@ |
||||
project('hdf5_test', 'c', 'cpp') |
||||
|
||||
if build_machine.system() == 'darwin' |
||||
error('MESON_SKIP_TEST: HDF5 CI image not setup for OSX.') |
||||
endif |
||||
|
||||
if build_machine.system() == 'cygwin' |
||||
error('MESON_SKIP_TEST: HDF5 CI image not setup for Cygwin.') |
||||
endif |
||||
|
||||
|
||||
# --- C tests |
||||
h5c = dependency('hdf5', language : 'c', required : false) |
||||
if not h5c.found() |
||||
error('MESON_SKIP_TEST: HDF5 not found, skipping.') |
||||
endif |
||||
exec = executable('exec', 'main.c', |
||||
dependencies : h5c) |
||||
|
||||
test('HDF5 C', exec) |
||||
|
||||
# --- C++ tests |
||||
h5cpp = dependency('hdf5', language : 'cpp') |
||||
execpp = executable('execpp', 'main.cpp', |
||||
dependencies : h5cpp) |
||||
|
||||
test('HDF5 C++', execpp) |
||||
|
||||
|
||||
# --- Fortran tests |
||||
if build_machine.system() != 'windows' |
||||
add_languages('fortran') |
||||
|
||||
h5f = dependency('hdf5', language : 'fortran') |
||||
exef = executable('exef', 'main.f90', |
||||
dependencies : h5f) |
||||
|
||||
test('HDF5 Fortran', exef) |
||||
endif |
||||
|
||||
# Check we can apply a version constraint |
||||
if h5c.version() != 'unknown' |
||||
dependency('hdf5', version: '>=@0@'.format(h5c.version())) |
||||
endif |
Loading…
Reference in new issue