Skip to content

Conversation

@scivision
Copy link

@scivision scivision commented Jun 8, 2022

This provides several fixes to CMake with regard to finding and linking HDF5 as well as canonical specification of compiler options. Now it's stuck on not finding json_module.mod from JsonFortran, I didn't look into that.

A key distinction is find_package(HDF5 ...) uses my FindHDF5.cmake in h5fortran, which works for more scenarios and generally is more robust than factory CMake FindHDF5.

@scivision
Copy link
Author

I didn't look at if you wanted to make HDF5 optional etc. that would probably also be possible (may switch source files depending if HDF5 found or similar)

@milancurcic
Copy link
Owner

Interesting, I still have the same issue with your patch:

(venv) milan@mars:~/Work/neural-fortran/neural-fortran_scivision/build$ cmake .. -DSERIAL=1
-- The C compiler identification is GNU 9.4.0
-- The Fortran compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /usr/bin/gfortran - skipped
-- Configuring build for serial execution
-- h5fortran 4.6.3  CMake 3.22.5
-- checking that C and Fortran compilers can link
-- checking that C and Fortran compilers can link - OK
-- Looking for H5_HAVE_FILTER_SZIP
-- Looking for H5_HAVE_FILTER_SZIP - found
-- Looking for H5_HAVE_FILTER_DEFLATE
-- Looking for H5_HAVE_FILTER_DEFLATE - found
-- Looking for H5_HAVE_PARALLEL
-- Looking for H5_HAVE_PARALLEL - not found
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
-- Found SZIP: /usr/lib/x86_64-linux-gnu/libsz.so  
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Performing Test HDF5_C_links
-- Performing Test HDF5_C_links - Success
-- Performing Test HDF5_Fortran_links
-- Performing Test HDF5_Fortran_links - Success
-- Found HDF5: /usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5_hl.so;/usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5.so (found suitable version "1.10.4", minimum required is "1.8.7") found components: Fortran HL 
CMake Deprecation Warning at build/_deps/jsonfortran-src/CMakeLists.txt:12 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- CMake build configuration for JSON-Fortran 8.3.0
-- Dynamically computing FORD output information...
-- Running FORD to dynamically compute documentation outputs, this could take a while...
-- Caching FORD outputs
-- Done dynamically computing FORD outputs.
-- Found HDF5: /usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5_hl.so;/usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5.so (found version "1.10.4") found components: Fortran 
-- Configuring to build with -fcoarray=single
-- Configuring done
-- Generating done
-- Build files have been written to: /home/milan/Work/neural-fortran/neural-fortran_scivision/build
(venv) milan@mars:~/Work/neural-fortran/neural-fortran_scivision/build$ make
Scanning dependencies of target neural
[  0%] Building Fortran object CMakeFiles/neural.dir/src/nf/nf_datasets_mnist.f90.o
[  2%] Building Fortran object CMakeFiles/neural.dir/src/nf/nf_activation.f90.o
[  2%] Building Fortran object CMakeFiles/neural.dir/src/nf/nf_base_layer.f90.o
[  4%] Building Fortran object CMakeFiles/neural.dir/src/nf/nf_layer.f90.o
[  6%] Building Fortran object CMakeFiles/neural.dir/src/nf/nf_layer_constructors.f90.o
[  8%] Building Fortran object CMakeFiles/neural.dir/src/nf/nf_optimizers.f90.o
[ 10%] Building Fortran object CMakeFiles/neural.dir/src/nf/nf_network.f90.o
[ 10%] Building Fortran object CMakeFiles/neural.dir/src/nf.f90.o
[ 10%] Building Fortran object CMakeFiles/neural.dir/src/nf/io/nf_io_binary.f90.o
[ 12%] Building Fortran object CMakeFiles/neural.dir/src/nf/io/nf_io_binary_submodule.f90.o
[ 12%] Building Fortran object CMakeFiles/neural.dir/src/nf/io/nf_io_hdf5.f90.o
[ 14%] Building Fortran object CMakeFiles/neural.dir/src/nf/io/nf_io_hdf5_submodule.f90.o
f951: Fatal Error: Module file ‘h5fortran.mod’ has not been generated, either because the module does not contain a MODULE PROCEDURE or there is an error in the module.
compilation terminated.
make[2]: *** [CMakeFiles/neural.dir/build.make:569: CMakeFiles/neural.dir/src/nf/io/nf_io_hdf5_submodule.f90.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:251: CMakeFiles/neural.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

@scivision
Copy link
Author

Thanks I pushed a fix for linking for GNU Make. It stops build again at missing json_module.mod

@scivision
Copy link
Author

OK I see jsonfortran has a older style CMake. It may be more expedient to simply control it from this Cmake script. I'll give it a quick try (ignoring the jsonfortran/CMakeLists.txt and using this project's code to control it).

@milancurcic
Copy link
Owner

Thanks a lot. As you can probably guess, I'm OK with any one approach that will just work. What I really hope to avoid is dropping CMake support.

@scivision
Copy link
Author

scivision commented Jun 8, 2022

OK give that a try, it works for me with GCC and Intel oneAPI

@milancurcic
Copy link
Owner

Thanks, Michael, that works like a charm. You rock as usual. If you agree, I'll merge these. And these new cmake files you added seem like nice examples for me to study.

@scivision
Copy link
Author

Yes it's ready to merge. I didn't add in the JsonFortran Coarray features but that can be done separately if needed.

@milancurcic
Copy link
Owner

Well UTF-8 support in JSON now breaks the code because my fields are ASCII. I'd prefer to keep them ASCII if possible. Any good reason to do UTF-8?

[ 52%] Building Fortran object CMakeFiles/neural.dir/src/nf/nf_keras_submodule.f90.o
/home/milan/Work/neural-fortran/neural-fortran_scivision/src/nf/nf_keras_submodule.f90:40:15:

   40 |       call json % get(layer_json, 'class_name', res(n) % class)
      |               1
Error: Found no matching specific binding for the call to the GENERIC ‘get’ at (1)
/home/milan/Work/neural-fortran/neural-fortran_scivision/src/nf/nf_keras_submodule.f90:46:15:

   46 |       call json % get(layer_config_json, 'name', res(n) % name)
      |               1
Error: Found no matching specific binding for the call to the GENERIC ‘get’ at (1)
/home/milan/Work/neural-fortran/neural-fortran_scivision/src/nf/nf_keras_submodule.f90:59:19:

   59 |           call json % get(layer_config_json, 'activation', res(n) % activation)
      |                   1
Error: Found no matching specific binding for the call to the GENERIC ‘get’ at (1)
make[2]: *** [CMakeFiles/neural.dir/build.make:322: CMakeFiles/neural.dir/src/nf/nf_keras_submodule.f90.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:238: CMakeFiles/neural.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

@scivision
Copy link
Author

OK this is fixed

@milancurcic
Copy link
Owner

Perfect, thanks again, I'll merge.

@milancurcic milancurcic merged commit b923736 into milancurcic:hdf5-reader Jun 8, 2022
@scivision scivision deleted the hdf5-reader branch June 9, 2022 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants