Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emancipation from serialbox via HDF5 for C-style variants #62

Merged
merged 4 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ endif()
### HDF5
ecbuild_add_option( FEATURE HDF5
DESCRIPTION "Use HDF5 to read input and reference data"
REQUIRED_PACKAGES "HDF5 COMPONENTS Fortran"
REQUIRED_PACKAGES "HDF5 COMPONENTS Fortran C"
DEFAULT ON )
if( HAVE_HDF5 )
list(APPEND CLOUDSC_DEFINITIONS HAVE_HDF5 )
Expand Down
38 changes: 32 additions & 6 deletions src/cloudsc_c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@
# Define this dwarf variant as an ECBuild feature
ecbuild_add_option( FEATURE CLOUDSC_C
DESCRIPTION "Build the C version CLOUDSC using Serialbox" DEFAULT ON
CONDITION Serialbox_FOUND
CONDITION Serialbox_FOUND OR HDF5_FOUND
)

if( HAVE_CLOUDSC_C )

message("HDF5 include dirs: ${HDF5_C_INCLUDE_DIRS}")
message("HDF5 lib: ${HDF5_LIBRARIES}")
message("HDF5 lib c: ${HDF5_C_LIBRARIES}")
message("HDF5 library dirs: ${HDF5_C_LIBRARY_DIRS}")

set( CMAKE_C_STANDARD 11 )
set( CMAKE_C_STANDARD_REQUIRED ON )

# necessary for AC
link_directories(string (REPLACE ";" " " DEST "${HDF5_C_LIBRARY_DIRS}")>)

ecbuild_add_library(
TARGET dwarf-cloudsc-c-lib
INSTALL_HEADERS LISTED
Expand All @@ -37,12 +45,19 @@ if( HAVE_CLOUDSC_C )
cloudsc/cloudsc_validate.c
cloudsc/mycpu.h
cloudsc/mycpu.c
PUBLIC_INCLUDES
PRIVATE_INCLUDES
# $<${HAVE_HDF5}:${HDF5_C_INCLUDE_DIRS}> # works on LUMI, doesn't work on AC
$<${HAVE_HDF5}:string (REPLACE ";" " " DEST "${HDF5_C_INCLUDE_DIRS}")> # necessar on AC, not on LUMI
PUBLIC_INCLUDES
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cloudsc>
PUBLIC_LIBS
Serialbox::Serialbox_C
$<${HAVE_OMP}:OpenMP::OpenMP_C>
$<${HAVE_HDF5}:hdf5>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use here the target exported via FindHDF5:

Suggested change
$<${HAVE_HDF5}:hdf5>
$<${HAVE_HDF5}:hdf5::hdf5>

This will automatically inject include paths, link flags & co, so you can drop all of the PRIVATE_INCLUDES part and link_directories fuff.

# $<${HAVE_HDF5}:string (REPLACE ";" " " DEST "${HDF5_C_LIBRARIES}")>
$<${HAVE_SERIALBOX}:Serialbox::Serialbox_C>
$<${HAVE_OMP}:OpenMP::OpenMP_C>
DEFINITIONS
${CLOUDSC_DEFINITIONS}
)

ecbuild_add_executable(
Expand Down Expand Up @@ -74,6 +89,17 @@ if( HAVE_CLOUDSC_C )
CONDITION HAVE_OMP
)

else()
ecbuild_info( "Serialbox not found, disabling C prototype" )
endif()

# Create symlink for the input data
if( HAVE_SERIALBOX )
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/../../data ${CMAKE_CURRENT_BINARY_DIR}/../../../data )
endif()

if( HAVE_HDF5 )
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/../../config-files/input.h5 ${CMAKE_CURRENT_BINARY_DIR}/../../../input.h5 )
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/../../config-files/reference.h5 ${CMAKE_CURRENT_BINARY_DIR}/../../../reference.h5 )
endif()
2 changes: 1 addition & 1 deletion src/cloudsc_c/cloudsc/cloudsc_validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void validate_3d(const char *name, double *v_ref, double *v_field, int nlon,
}


int cloudsc_validate(const int nlon, const int nlev, const int nclv, const int ngptot, const int nproma,
void cloudsc_validate(const int nlon, const int nlev, const int nclv, const int ngptot, const int nproma,
double *plude, double *pcovptot, double *prainfrac_toprfz, double *pfsqlf, double *pfsqif,
double *pfcqlng, double *pfcqnng, double *pfsqrf, double *pfsqsf, double *pfcqrng, double *pfcqsng,
double *pfsqltur, double *pfsqitur, double *pfplsl, double *pfplsn, double *pfhpsl, double *pfhpsn,
Expand Down
2 changes: 1 addition & 1 deletion src/cloudsc_c/cloudsc/cloudsc_validate.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include "load_state.h"

int cloudsc_validate(const int nlon, const int nlev, const int nclv, const int ngptot, const int nproma,
void cloudsc_validate(const int nlon, const int nlev, const int nclv, const int ngptot, const int nproma,
double *plude, double *pcovptot, double *prainfrac_toprfz, double *pfsqlf, double *pfsqif,
double *pfcqlng, double *pfcqnng, double *pfsqrf, double *pfsqsf, double *pfcqrng, double *pfcqsng,
double *pfsqltur, double *pfsqitur, double *pfplsl, double *pfplsn, double *pfhpsl, double *pfhpsn,
Expand Down
Loading
Loading