Hi Elena and Hdf users,
I have compiled the library and the test program with the same compiler and
the same default options of gfortran.
I have noticed that H5T_NATIVE_INTEGER refers to a global variable.
I have used CMake to generate the HDF5 library as a dynamic library with
Win32 and GNU Gfortran 4.7.2.
The CTest tests reports no error on the test, however when I try to execute
the program h5_crtdat.f90 (f90_ex_h5_crtdatdll.exe) myself, it returns
error on the creation of the dataset.
At the end of this message is the Ctest log that tells me that everything
should have run fine.
Compiling the library with the debug option does not do the trick.
I create a minimal complete example, where clearly the function h5dcreate_f
fails to create the dataset (error is -1).
I write some returned values of the program as comments
Any help will be apreciated.
PROGRAM H5_TEST
USE HDF5
IMPLICIT NONE
INTEGER(HID_T) :: error
CHARACTER(LEN=8), PARAMETER :: filename = "dsetf.h5" ! File name
CHARACTER(LEN=4), PARAMETER :: dsetname = "dset" ! Dataset name
INTEGER(HID_T) :: file_id ! File identifier
INTEGER(HID_T) :: dset_id ! Dataset identifier
INTEGER(HID_T) :: dspace_id ! Dataspace identifier
INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/4,6/) ! Dataset dimensions
INTEGER :: rank = 2 ! Dataset rank
CALL h5open_f(error)
WRITE(*,*)
error
! Return 0 -> OK
CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error)
WRITE(*,*)
error
! Return 0 -> OK
CALL h5screate_simple_f(rank, dims, dspace_id, error)
WRITE(*,*)
error
! Return 0 -> OK
WRITE(*,*) "H5T_NATIVE_INTEGER :",
H5T_NATIVE_INTEGER ! Display 0 , is that OK?
WRITE(*,*) "H5T_NATIVE_REAL :",
H5T_NATIVE_REAL ! Display 0 , is that OK?
CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dspace_id,
dset_id, error)
WRITE(*,*)
error
! Display -1 , definitely NOK?
CALL h5close_f(error)
WRITE(*,*) error
END PROGRAM H5_TEST
Here is the log of ctest on f90 example with dynamic library hdf5 1.8.12
compilew with MinGW Gfortran 4.7.2 on win32
Start 70: f90_ex-clear-objects
70/1972 Test #70: f90_ex-clear-objects
...................................... Passed 0.05 sec
Start 71: f90_ex_h5_cmprss
71/1972 Test #71: f90_ex_h5_cmprss
.......................................... Passed 0.05 sec
Start 72: f90_ex_h5_crtdat
72/1972 Test #72: f90_ex_h5_crtdat
.......................................... Passed 0.03 sec
Start 73: f90_ex_h5_rdwt
73/1972 Test #73: f90_ex_h5_rdwt
............................................ Passed 0.03 sec
Start 74: f90_ex_h5_crtatt
74/1972 Test #74: f90_ex_h5_crtatt
.......................................... Passed 0.03 sec
Start 75: f90_ex_h5_crtgrp
75/1972 Test #75: f90_ex_h5_crtgrp
.......................................... Passed 0.03 sec
Start 76: f90_ex_h5_crtgrpar
76/1972 Test #76: f90_ex_h5_crtgrpar
........................................ Passed 0.03 sec
Start 77: f90_ex_h5_crtgrpd
77/1972 Test #77: f90_ex_h5_crtgrpd
......................................... Passed 0.03 sec
···
----------------------------------------------------------------------
Message: 1
Date: Tue, 10 Dec 2013 17:40:22 -0600
From: Elena Pourmal <epourmal@hdfgroup.org>
To: HDF Users Discussion List <hdf-forum@lists.hdfgroup.org>
Subject: Re: [Hdf-forum] HDF5 - Fortran - Execution of basic
Message-ID: <006EC19B-B38E-449A-A4BF-C2B7F66DAF83@hdfgroup.org>
Content-Type: text/plain; charset="us-ascii"Hi Guillaume,
H5T_NATIVE_INTEGER is a global variable that is defined with the call to
h5open_f.Did you build the HDF5 library using the same compiler and the same
compiler flags? Did Fortran tests pass on your system?Elena
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Elena Pourmal The HDF Group http://hdfgroup.org
1800 So. Oak St., Suite 203, Champaign IL 61820
217.531.6112
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~On Dec 10, 2013, at 8:39 AM, Guillaume Jacquenot < > guillaume.jacquenot@gmail.com> wrote:
> Dear HDF5 users.
>
> I try to execute the F90 example h5_crtdat.f90 provided in
'1.8.12\fortran\examples\h5_crtdat.f90'
> This should create an empty dataset. It should create a file called
'dsetf.h5', defines the dataset dataspace, creates a dataset which is a 4x6
integer array, and then closes the dataspace, the dataset, and the file.
>
> However when I execute the program I have the following error
>
> D:\GJ\svn\tools\ThirdParty\hdf5\1.8.12_compil\bin>f90_ex_h5_crtdatdll.exe
> HDF5-DIAG: Error detected in HDF5 (1.8.12) thread 0:
> #000: d:/GJ/svn/tools/ThirdParty/hdf5/1.8.12/src/H5D.c line 143 in
H5Dcreate2(): not a datatype ID
> major: Invalid arguments to routine
> minor: Inappropriate type
> HDF5-DIAG: Error detected in HDF5 (1.8.12) thread 0:
> #000: d:/GJ/svn/tools/ThirdParty/hdf5/1.8.12/src/H5D.c line 391 in
H5Dclose(): not a dataset
> major: Invalid arguments to routine
> minor: Inappropriate type
>
> My guess is that the H5T_NATIVE_INTEGER is not recognized, hence
H5Dcreate2 is throwing an error.
>
> I compile two times:
> - one time with the activation of examples/tests in the generation of
HDF5 library.
> - one time as a full projet
> But the same mistake occurs.
>
> I have the problems with different examples.
>
> I run the program with Win 32, MinGW, Gfortran 4.7.2, HDF5 1.8.12.
> Below is the CMakeLists.txt I use to compile the example h5_crtdat.f90
as a full project.
>
>
> Is there any specific operation for H5T_NATIVE_INTEGER to be understood?
At compilation, at linking stage, at run time stage?
> Any help will be apreciated.
>
> Best regards
> Guillaume Jacquenot
>
>
>
>
> CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
> PROJECT(F90 Fortran)
>
> ENABLE_LANGUAGE(Fortran)
> GET_FILENAME_COMPONENT (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER}
NAME_WE)
> IF(Fortran_COMPILER_NAME STREQUAL "gfortran")
> SET(CMAKE_Fortran_FLAGS_RELEASE "-fmessage-length=0
-ffixed-line-length-none -ffree-line-length-none -fno-automatic
-fdefault-real-8 -fdefault-double-8 -funroll-all-loops -fno-f2c -O3")
> SET(CMAKE_Fortran_FLAGS_DEBUG "-fmessage-length=0
-ffixed-line-length-none -ffree-line-length-none -fno-automatic
-fdefault-real-8 -fdefault-double-8 -fno-f2c -O0 -g")
> ELSEIF(Fortran_COMPILER_NAME STREQUAL "ifort")
> SET(CMAKE_Fortran_FLAGS_RELEASE "-f77rtl -O3")
> SET(CMAKE_Fortran_FLAGS_DEBUG "-f77rtl -O0 -g")
> ELSEIF(Fortran_COMPILER_NAME STREQUAL "g77")
> SET(CMAKE_Fortran_FLAGS_RELEASE "-funroll-all-loops -fno-f2c -O3
-m32")
> SET(CMAKE_Fortran_FLAGS_DEBUG "-fno-f2c -O0 -g -m32")
> ELSE(Fortran_COMPILER_NAME STREQUAL "gfortran")
> MESSAGE(STATUS "CMAKE_Fortran_COMPILER full path: "
${CMAKE_Fortran_COMPILER})
> MESSAGE(STATUS "Fortran compiler: " ${Fortran_COMPILER_NAME})
> MESSAGE(STATUS "No optimized Fortran compiler flags are known, we
just try -O2...")
> SET(CMAKE_Fortran_FLAGS_RELEASE "-O2 ")
> SET(CMAKE_Fortran_FLAGS_DEBUG "-O0 -g")
> ENDIF(Fortran_COMPILER_NAME STREQUAL "gfortran")
>
> FIND_PACKAGE(HDF5 NAMES hdf5)
>
> IF(HDF5_FOUND)
> MESSAGE(STATUS "HDF5 : ${HDF5}")
> MESSAGE(STATUS "HDF5_INCLUDE_DIR : ${HDF5_INCLUDE_DIR}")
> ELSE(HDF5_FOUND)
> MESSAGE(STATUS "HDF5 NOT FOUND")
> ENDIF(HDF5_FOUND)
>
> INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIR})
>
> FOREACH(f h5_crtdat)
> ADD_EXECUTABLE(${f}
> ${f}.f90)
> TARGET_LINK_LIBRARIES(${f} ${HDF5_LIBRARIES})
> SET_TARGET_PROPERTIES(${f} PROPERTIES LINKER_LANGUAGE Fortran)
> IF (WIN32 AND NOT CYGWIN)
> SET_PROPERTY (TARGET ${f}
> APPEND PROPERTY COMPILE_DEFINITIONS HDF5F90_WINDOWS)
> ENDIF (WIN32 AND NOT CYGWIN)
> ENDFOREACH(f)