parent
1ebaeadf60
commit
4d54a22b49
6 changed files with 119 additions and 4 deletions
@ -0,0 +1,32 @@ |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
|
||||
#include "hdf5.h" |
||||
|
||||
int main(void) |
||||
{ |
||||
herr_t ier; |
||||
unsigned maj; |
||||
unsigned min; |
||||
unsigned 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,31 @@ |
||||
#include <iostream> |
||||
#include "hdf5.h" |
||||
|
||||
|
||||
int main(void) |
||||
{ |
||||
herr_t ier; |
||||
unsigned maj; |
||||
unsigned min; |
||||
unsigned 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,33 @@ |
||||
project('hdf5_test', 'c', 'cpp', 'fortran') |
||||
|
||||
|
||||
# --- 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 |
||||
h5f = dependency('hdf5', language : 'fortran') |
||||
exef = executable('exef', 'main.f90', |
||||
dependencies : h5f) |
||||
|
||||
test('HDF5 Fortran', exef) |
||||
|
||||
|
||||
# Check we can apply a version constraint |
||||
if h5c.version() != 'unknown' |
||||
dependency('hdf5', version: '>=@0@'.format(h5c.version())) |
||||
endif |
Loading…
Reference in new issue