Hi!
We are currently trying to compile my fortran project with ifort while linking
to hdf5. I am failing at compiling with cmake, which I would like to do, but I
finally managed to compile with a single line in bash. I attach my
CMakeLists.txt (which works for gfortran) and the bash command. If anyone can
give some hints on how to link to hdf5 successfully, I would be very grateful!
As a side note, it appears that on the cluster I am trying to use, only the
h5pfc compiler is installed, not h5fc. I do not need mpi support, so if it is
possible to skip the mpi linking, I would be happy with that - our end results
are in the sub-GB region anyway. We are planning to extend our program to use
MPI, but we do not need to write from more than one MPI process.
Regards,
Paul
+++++++++++++++++
Working command:
h5pfc -openmp Rayleigh2D_Modules/version.f90 Rayleigh2D_Modules/constants.f90
Rayleigh2D_Modules/derived_type_module.f90
Rayleigh2D_Modules/SFL_ISO_Fortran_Env.f90
Rayleigh2D_Modules/SFL_Logical_Units.f90
Rayleigh2D_Modules/Rayleigh2D_Utils.f90 Rayleigh2D_Modules/R_save.f90
Rayleigh2D_Modules/SFL_Error_Handling.f90 Rayleigh2D_Modules/SFL_Fourier.f90
Rayleigh2D_Modules/surface_util_module.f90
Rayleigh2D_Modules/surface_correlated_module.f90
Rayleigh2D_Modules/Rayleigh2D_Module.f90 FFT_Modules/fft_nms.f
FFT_Modules/fftpack.f90 Rayleigh2D.f90 -o Rayleigh2D -lmkl_intel_lp64
-lmkl_intel_thread -lmkl_core -lguide -I. -L.
$ h5pfc -show
mpif90 -fPIC -I/share/apps/modulessoftware/hdf5/hdf-5.1.8.5-intel/include
-L/share/apps/modulessoftware/hdf5/hdf-5.1.8.5-intel/lib
/share/apps/modulessoftware/hdf5/hdf-5.1.8.5-intel/lib/libhdf5hl_fortran.a
/share/apps/modulessoftware/hdf5/hdf-5.1.8.5-intel/lib/libhdf5_hl.a
/share/apps/modulessoftware/hdf5/hdf-5.1.8.5-intel/lib/libhdf5_fortran.a
/share/apps/modulessoftware/hdf5/hdf-5.1.8.5-intel/lib/libhdf5.a -lz -lm -lgpfs
-Wl,-rpath -Wl,/share/apps/modulessoftware/hdf5/hdf-5.1.8.5-intel/lib
$ mpif90 -show
ifort -I/share/apps/modulessoftware/openmpi/openmpi-1.4.3-intel/include
-I/share/apps/modulessoftware/openmpi/openmpi-1.4.3-intel/lib
-L/share/apps/modulessoftware/openmpi/openmpi-1.4.3-intel/lib -lmpi_f90
-lmpi_f77 -lmpi -lopen-rte -lopen-pal -ldl -Wl,--export-dynamic -lnsl -lutil
cmake_minimum_required (VERSION 2.8 FATAL_ERROR)
project (Rayleigh2D Fortran)
##################################################
# Add include and link directories to compilation.
# NB: Must happen before add_executable() !
##################################################
# Include modules (.mod files) in Rayleigh2D_Modules folder
include_directories (${CMAKE_CURRENT_BINARY_DIR}/Rayleigh2D_Modules)
# Search for my custom libraries in $HOME (PA).
link_directories ("/Users/paulanto/usr/local/lib/")
include_directories ("/Users/paulanto/usr/local/include/")
link_directories ("/home/gudrun/paulanto/usr/local/lib/")
include_directories ("/home/gudrun/paulanto/usr/local/include/")
add_executable (Rayleigh2D Rayleigh2D.f90)
# The FFT_Modules are treated specially with its own CMakeLists.txt file.
add_subdirectory (FFT_Modules)
##################################################
# Compiler-dependent flags for optimization
##################################################
if (CMAKE_Fortran_COMPILER MATCHES "gfortran")
set (CMAKE_Fortran_FLAGS_RELEASE " -fopenmp -funroll-loops -O3 ")
# This debug flag makes Ingve's surface generation code crash (27.jan.2011):
# -ffpe-trap=zero,denormal
set (CMAKE_Fortran_FLAGS_DEBUG
" -fopenmp -O0 -g3 -pg -Wall -Wextra -fimplicit-none -fbounds-check ")
endif (CMAKE_Fortran_COMPILER MATCHES "gfortran")
if (CMAKE_Fortran_COMPILER MATCHES "g95")
set (CMAKE_Fortran_FLAGS_RELEASE " -funroll-loops -O3 ")
set (CMAKE_Fortran_FLAGS_DEBUG
" -O0 -g3 -pg -Wall -Wextra -fimplicit-none -fbounds-check ")
endif (CMAKE_Fortran_COMPILER MATCHES "g95")
if (CMAKE_Fortran_COMPILER MATCHES "xlf")
# Possible optimization flags to include: -qessl -qhot
set (CMAKE_Fortran_FLAGS_RELEASE " -O3 -qsmp=omp ")
set (CMAKE_Fortran_FLAGS_DEBUG " -O1 -qcheck -qdbg ")
endif (CMAKE_Fortran_COMPILER MATCHES "xlf")
if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
set (CMAKE_Fortran_FLAGS_RELEASE " -O3 -openmp -funroll-loops ")
set (CMAKE_Fortran_FLAGS_DEBUG " -O0 -g -openmp ")
endif (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
##################################################
# Library linking is handled below
##################################################
# Common libraries for all compilers
target_link_libraries (Rayleigh2D Rayleigh2D_Module FFT_Modules fftw3 hdf5
hdf5_hl hdf5_fortran hdf5hl_fortran z)
# Gfortran and G95 calls LAPACK and BLAS by their names
if (CMAKE_Fortran_COMPILER MATCHES "gfortran" OR CMAKE_Fortran_COMPILER MATCHES
"g95")
#target_link_libraries (Rayleigh2D blas lapack)
target_link_libraries (Rayleigh2D goto2)
endif (CMAKE_Fortran_COMPILER MATCHES "gfortran" OR CMAKE_Fortran_COMPILER
MATCHES "g95")
# Xlf calls LAPACK and BLAS by the name "essl"
if (CMAKE_Fortran_COMPILER MATCHES "xlf")
target_link_libraries (Rayleigh2D essl)
endif (CMAKE_Fortran_COMPILER MATCHES "xlf")
# Intel compiler calls LAPACK and BLAS by the name "mkl" (and similar).
if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
#EXECUTE_PROCESS(COMMAND hostname
#OUTPUT_VARIABLE myhostname
#OUTPUT_STRIP_TRAILING_WHITESPACE)
#if (myhostname STREQUAL "kongull.hpc.ntnu.no")
# On kongull, according to the support people, one should link
# to -lguide. It does not exist on e.g. bakke.
target_link_libraries (Rayleigh2D mkl_intel_lp64 mkl_intel_thread
mkl_core guide)
endif (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
##################################################
# Set up libraries in subdirectories.
# NB: Must happen after compiler flags are set!
##################################################
add_library(Rayleigh2D_Module
Rayleigh2D_Modules/Rayleigh2D_Module.f90
Rayleigh2D_Modules/Rayleigh2D_Utils.f90
Rayleigh2D_Modules/SFL_Error_Handling.f90
Rayleigh2D_Modules/SFL_Fourier.f90
Rayleigh2D_Modules/SFL_ISO_Fortran_Env.f90
Rayleigh2D_Modules/SFL_Logical_Units.f90
Rayleigh2D_Modules/constants.f90
Rayleigh2D_Modules/derived_type_module.f90
Rayleigh2D_Modules/surface_correlated_module.f90
Rayleigh2D_Modules/surface_util_module.f90
Rayleigh2D_Modules/zbcg2_module.f90
Rayleigh2D_Modules/BiCGstab_module.f90
Rayleigh2D_Modules/R_save.f90
Rayleigh2D_Modules/version.f90
)
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org