Skip to content

Commit

Permalink
Merge branch 'jgfouca/sharedlib_no_makefile' into next (PR E3SM-Proje…
Browse files Browse the repository at this point in the history
…ct#5997)

PIO: Remove dependence on CIME/Tools/Makefile

We need to remove all dependencies on CIME/Tools/Makefile so we can
change our macros to use cmake-style names for things. PIO/Scorpio was
the first thing I picked.

The situation with spio was strange. It was using CIME/Tools/Makefile
to call CMake. It translated the Makefile-style settings to Cmake
using a lot of extra code in the Makefile to set up CMAKE_OPTS.

We change the python wrapper build script, buildlib.spio, to instead
just set up the cmake options in python, allowing us to skip the
CIME/Tools/Makefile.

On top of removing the dependency, I think this makes the overall spio
build a lot easier to understand, although it was a bit tedious
pulling things out of the macros.

Once the macros are in proper cmake-stype, I think we could just pass
them directly to scorpio's CMake build via -C and things will be even
simpler.

[BFB]
  • Loading branch information
jgfouca committed Oct 20, 2023
2 parents ff07d40 + 464321f commit 15fa673
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 139 deletions.
2 changes: 1 addition & 1 deletion .circleci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ rc=$?
if [ $rc -ne 0 ]; then
print_bldlog "e3sm"
print_bldlog "csm_share"
print_bldlog "pio"
print_bldlog "spio"
print_bldlog "mct"
print_bldlog "gptl"
exit $rc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ endif()
set(PIO_FILESYSTEM_HINTS "gpfs")
string(APPEND CXX_LIBS " -lstdc++")

SET(CMAKE_C_COMPILER "cc" CACHE STRING "")
SET(CMAKE_Fortran_COMPILER "ftn" CACHE STRING "")
SET(CMAKE_CXX_COMPILER "hipcc" CACHE STRING "")
set(CMAKE_C_COMPILER "cc")
set(CMAKE_Fortran_COMPILER "ftn")
set(CMAKE_CXX_COMPILER "hipcc")

string(APPEND CXXFLAGS " -I${MPICH_DIR}/include")
string(APPEND LDFLAGS " -L${MPICH_DIR}/lib -lmpi -L/opt/cray/pe/mpich/8.1.16/gtl/lib -lmpi_gtl_hsa")
Expand Down
8 changes: 0 additions & 8 deletions cime_config/machines/cmake_macros/nag_cascade.cmake

This file was deleted.

19 changes: 0 additions & 19 deletions cime_config/machines/cmake_macros/pathscale.cmake

This file was deleted.

38 changes: 19 additions & 19 deletions cime_config/machines/config_machines.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@
<environment_variables mpilib="!mpi-serial">
<env name="NETCDF_PATH">/usr/local/packages/netcdf-parallel</env>
<env name="PNETCDF_PATH">/usr/local/packages/pnetcdf</env>
<env name="HDF5_PATH">/usr/local/packages/hdf5-parallel</env>
<env name="HDF5_ROOT">/usr/local/packages/hdf5-parallel</env>
<env name="PATH">/usr/local/packages/cmake/bin:/usr/local/packages/mpich/bin:/usr/local/packages/hdf5-parallel/bin:/usr/local/packages/netcdf-parallel/bin:/usr/local/packages/pnetcdf/bin:$ENV{PATH}</env>
<env name="LD_LIBRARY_PATH">/usr/local/packages/mpich/lib:/usr/local/packages/szip/lib:/usr/local/packages/hdf5-parallel/lib:/usr/local/packages/netcdf-parallel/lib:/usr/local/packages/pnetcdf/lib</env>
</environment_variables>
Expand Down Expand Up @@ -1617,7 +1617,7 @@
<!-- We currently don't have a soft env for mpich 3.3.2 built with gcc 8.2.0 -->
<env name="PATH">/soft/apps/packages/climate/mpich/3.3.2/gcc-8.2.0/bin:/soft/apps/packages/climate/cmake/3.18.4/bin:/soft/apps/packages/climate/gmake/bin:$ENV{PATH}</env>
<!-- We currently don't have a soft env for parallel hdf5 built with mpich 3.3.2 and gcc 8.2.0 -->
<env name="HDF5_PATH">/soft/apps/packages/climate/hdf5/1.8.16-parallel/mpich-3.3.2/gcc-8.2.0</env>
<env name="HDF5_ROOT">/soft/apps/packages/climate/hdf5/1.8.16-parallel/mpich-3.3.2/gcc-8.2.0</env>
<!-- We currently don't have a soft env for netcdf parallel built with mpich 3.3.2 and gcc 8.2.0 -->
<env name="NETCDF_PATH">/soft/apps/packages/climate/netcdf/4.4.1c-4.2cxx-4.4.4f-parallel/mpich-3.3.2/gcc-8.2.0</env>
<!-- We currently don't have a soft env for pnetcdf built with mpich 3.3.2 and gcc 8.2.0 -->
Expand All @@ -1626,9 +1626,9 @@
<environment_variables mpilib="openmpi">
<!-- We currently don't have a soft env for openmpi 2.1.5, zlib, szip, hdf5, NetCDF and PnetCDF libraries -->
<env name="PATH">/soft/apps/packages/climate/openmpi/2.1.5/gcc-8.2.0/bin:/soft/apps/packages/climate/cmake/3.18.4/bin:/soft/apps/packages/climate/gmake/bin:$ENV{PATH}</env>
<env name="ZLIB_PATH">/soft/apps/packages/climate/zlib/1.2.11/gcc-8.2.0-static</env>
<env name="SZIP_PATH">/soft/apps/packages/climate/szip/2.1/gcc-8.2.0-static</env>
<env name="HDF5_PATH">/soft/apps/packages/climate/hdf5/1.8.12-parallel/openmpi-2.1.5/gcc-8.2.0-static</env>
<env name="ZLIB_ROOT">/soft/apps/packages/climate/zlib/1.2.11/gcc-8.2.0-static</env>
<env name="SZIP_ROOT">/soft/apps/packages/climate/szip/2.1/gcc-8.2.0-static</env>
<env name="HDF5_ROOT">/soft/apps/packages/climate/hdf5/1.8.12-parallel/openmpi-2.1.5/gcc-8.2.0-static</env>
<env name="NETCDF_PATH">/soft/apps/packages/climate/netcdf/4.7.4c-4.3.1cxx-4.4.4f-parallel/openmpi-2.1.5/gcc-8.2.0-static-hdf5-1.8.12-pnetcdf-1.12.0</env>
<env name="PNETCDF_PATH">/soft/apps/packages/climate/pnetcdf/1.12.0/openmpi-2.1.5/gcc-8.2.0</env>
</environment_variables>
Expand Down Expand Up @@ -1705,17 +1705,17 @@
<!-- We currently don't have modules for HDF5, NetCDF & PnetCDF -->
<env name="LD_LIBRARY_PATH">/nfs/gce/projects/climate/software/mpich/3.4.2/gcc-11.1.0/lib:$ENV{LD_LIBRARY_PATH}</env>
<env name="PATH">/nfs/gce/projects/climate/software/mpich/3.4.2/gcc-11.1.0/bin:$ENV{PATH}</env>
<env name="ZLIB_PATH">/nfs/gce/software/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/zlib-1.2.11-smoyzzo</env>
<env name="HDF5_PATH">/nfs/gce/projects/climate/software/hdf5/1.12.1/mpich-3.4.2/gcc-11.1.0</env>
<env name="ZLIB_ROOT">/nfs/gce/software/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/zlib-1.2.11-smoyzzo</env>
<env name="HDF5_ROOT">/nfs/gce/projects/climate/software/hdf5/1.12.1/mpich-3.4.2/gcc-11.1.0</env>
<env name="NETCDF_PATH">/nfs/gce/projects/climate/software/netcdf/4.8.0c-4.3.1cxx-4.5.3f-parallel/mpich-3.4.2/gcc-11.1.0</env>
<env name="PNETCDF_PATH">/nfs/gce/projects/climate/software/pnetcdf/1.12.2/mpich-3.4.2/gcc-11.1.0</env>
</environment_variables>
<environment_variables mpilib="openmpi">
<!-- We currently don't have modules for HDF5, NetCDF & PnetCDF -->
<env name="LD_LIBRARY_PATH">/nfs/gce/projects/climate/software/openmpi/4.1.3/gcc-11.1.0/lib:$ENV{LD_LIBRARY_PATH}</env>
<env name="PATH">/nfs/gce/projects/climate/software/openmpi/4.1.3/gcc-11.1.0/bin:$ENV{PATH}</env>
<env name="ZLIB_PATH">/nfs/gce/software/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/zlib-1.2.11-smoyzzo</env>
<env name="HDF5_PATH">/nfs/gce/projects/climate/software/hdf5/1.12.1/openmpi-4.1.3/gcc-11.1.0</env>
<env name="ZLIB_ROOT">/nfs/gce/software/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/zlib-1.2.11-smoyzzo</env>
<env name="HDF5_ROOT">/nfs/gce/projects/climate/software/hdf5/1.12.1/openmpi-4.1.3/gcc-11.1.0</env>
<env name="NETCDF_PATH">/nfs/gce/projects/climate/software/netcdf/4.8.0c-4.3.1cxx-4.5.3f-parallel/openmpi-4.1.3/gcc-11.1.0</env>
<env name="PNETCDF_PATH">/nfs/gce/projects/climate/software/pnetcdf/1.12.2/openmpi-4.1.3/gcc-11.1.0</env>
</environment_variables>
Expand Down Expand Up @@ -1792,17 +1792,17 @@
<!-- We currently don't have modules for HDF5, NetCDF & PnetCDF -->
<env name="LD_LIBRARY_PATH">/nfs/gce/projects/climate/software/linux-ubuntu20.04-x86_64/mpich/4.0/gcc-11.1.0/lib:$ENV{LD_LIBRARY_PATH}</env>
<env name="PATH">/nfs/gce/projects/climate/software/linux-ubuntu20.04-x86_64/mpich/4.0/gcc-11.1.0/bin:$ENV{PATH}</env>
<env name="ZLIB_PATH">/nfs/gce/software/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/zlib-1.2.11-p7dmb5p</env>
<env name="HDF5_PATH">/nfs/gce/projects/climate/software/linux-ubuntu20.04-x86_64/hdf5/1.12.1/mpich-4.0/gcc-11.1.0</env>
<env name="ZLIB_ROOT">/nfs/gce/software/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/zlib-1.2.11-p7dmb5p</env>
<env name="HDF5_ROOT">/nfs/gce/projects/climate/software/linux-ubuntu20.04-x86_64/hdf5/1.12.1/mpich-4.0/gcc-11.1.0</env>
<env name="NETCDF_PATH">/nfs/gce/projects/climate/software/linux-ubuntu20.04-x86_64/netcdf/4.8.0c-4.3.1cxx-4.5.3f-parallel/mpich-4.0/gcc-11.1.0</env>
<env name="PNETCDF_PATH">/nfs/gce/projects/climate/software/linux-ubuntu20.04-x86_64/pnetcdf/1.12.2/mpich-4.0/gcc-11.1.0</env>
</environment_variables>
<environment_variables mpilib="openmpi">
<!-- We currently don't have modules for HDF5, NetCDF & PnetCDF -->
<env name="LD_LIBRARY_PATH">/nfs/gce/projects/climate/software/linux-ubuntu20.04-x86_64/openmpi/4.1.3/gcc-11.1.0/lib:$ENV{LD_LIBRARY_PATH}</env>
<env name="PATH">/nfs/gce/projects/climate/software/linux-ubuntu20.04-x86_64/openmpi/4.1.3/gcc-11.1.0/bin:$ENV{PATH}</env>
<env name="ZLIB_PATH">/nfs/gce/software/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/zlib-1.2.11-p7dmb5p</env>
<env name="HDF5_PATH">/nfs/gce/projects/climate/software/linux-ubuntu20.04-x86_64/hdf5/1.12.1/openmpi-4.1.3/gcc-11.1.0</env>
<env name="ZLIB_ROOT">/nfs/gce/software/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-9.3.0/zlib-1.2.11-p7dmb5p</env>
<env name="HDF5_ROOT">/nfs/gce/projects/climate/software/linux-ubuntu20.04-x86_64/hdf5/1.12.1/openmpi-4.1.3/gcc-11.1.0</env>
<env name="NETCDF_PATH">/nfs/gce/projects/climate/software/linux-ubuntu20.04-x86_64/netcdf/4.8.0c-4.3.1cxx-4.5.3f-parallel/openmpi-4.1.3/gcc-11.1.0</env>
<env name="PNETCDF_PATH">/nfs/gce/projects/climate/software/linux-ubuntu20.04-x86_64/pnetcdf/1.12.2/openmpi-4.1.3/gcc-11.1.0</env>
</environment_variables>
Expand Down Expand Up @@ -2456,7 +2456,7 @@
<env name="PNETCDF_PATH">$SHELL{dirname $(dirname $(which pnetcdf_version))}</env>
</environment_variables>
<environment_variables compiler="gnu">
<env name="HDF5_PATH">$SHELL{which h5dump | xargs dirname | xargs dirname}</env>
<env name="HDF5_ROOT">$SHELL{which h5dump | xargs dirname | xargs dirname}</env>
</environment_variables>
<environment_variables SMP_PRESENT="TRUE">
<env name="OMP_STACKSIZE">128M</env>
Expand Down Expand Up @@ -3375,7 +3375,7 @@
<TEST_TPUT_TOLERANCE>0.05</TEST_TPUT_TOLERANCE>
<MAX_GB_OLD_TEST_DATA>0</MAX_GB_OLD_TEST_DATA>
<environment_variables>
<env name="HDF5_PATH">$SHELL{dirname $(dirname $(which h5diff))}</env>
<env name="HDF5_ROOT">$SHELL{dirname $(dirname $(which h5diff))}</env>
<env name="NETCDF_C_PATH">$SHELL{dirname $(dirname $(which nc-config))}</env>
<env name="NETCDF_FORTRAN_PATH">$SHELL{dirname $(dirname $(which nf-config))}</env>
<env name="MKL_PATH">$ENV{MKLROOT}</env>
Expand Down Expand Up @@ -4207,7 +4207,7 @@
<env name="LAPACK_ROOT">$ENV{OLCF_NETLIB_LAPACK_ROOT}</env>
<env name="BLA_VENDOR">Generic</env>
<env name="ESSL_PATH">$ENV{OLCF_ESSL_ROOT}</env>
<env name="HDF5_PATH">$ENV{OLCF_HDF5_ROOT}</env>
<env name="HDF5_ROOT">$ENV{OLCF_HDF5_ROOT}</env>
<env name="PNETCDF_PATH">$ENV{OLCF_PARALLEL_NETCDF_ROOT}</env>
<env name="PGI_ACC_POOL_ALLOC">0</env>
<env name="SMPIARGS"> </env>
Expand Down Expand Up @@ -4383,7 +4383,7 @@
<env name="LAPACK_ROOT">$ENV{OLCF_NETLIB_LAPACK_ROOT}</env>
<env name="BLA_VENDOR">Generic</env>
<env name="ESSL_PATH">$ENV{OLCF_ESSL_ROOT}</env>
<env name="HDF5_PATH">$ENV{OLCF_HDF5_ROOT}</env>
<env name="HDF5_ROOT">$ENV{OLCF_HDF5_ROOT}</env>
<env name="PGI_ACC_POOL_ALLOC">0</env>
<env name="SMPIARGS"> </env>
</environment_variables>
Expand Down Expand Up @@ -4642,7 +4642,7 @@
<TEST_TPUT_TOLERANCE>0.2</TEST_TPUT_TOLERANCE>
<TEST_MEMLEAK_TOLERANCE>0.20</TEST_MEMLEAK_TOLERANCE>
<environment_variables compiler="gnu">
<env name="HDF5_PATH">$SHELL{dirname $(dirname $(which h5diff))}</env>
<env name="HDF5_ROOT">$SHELL{dirname $(dirname $(which h5diff))}</env>
<env name="NETCDF_C_PATH">$SHELL{dirname $(dirname $(which nc-config))}</env>
<env name="NETCDF_FORTRAN_PATH">$SHELL{dirname $(dirname $(which nf-config))}</env>
<env name="PNETCDF_PATH">$SHELL{dirname $(dirname $(which pnetcdf-config))}</env>
Expand Down Expand Up @@ -4732,7 +4732,7 @@
<TEST_TPUT_TOLERANCE>0.2</TEST_TPUT_TOLERANCE>
<TEST_MEMLEAK_TOLERANCE>0.20</TEST_MEMLEAK_TOLERANCE>
<environment_variables compiler="gnu">
<env name="HDF5_PATH">$SHELL{dirname $(dirname $(which h5diff))}</env>
<env name="HDF5_ROOT">$SHELL{dirname $(dirname $(which h5diff))}</env>
<env name="NETCDF_C_PATH">$SHELL{dirname $(dirname $(which nc-config))}</env>
<env name="NETCDF_FORTRAN_PATH">$SHELL{dirname $(dirname $(which nf-config))}</env>
<env name="PNETCDF_PATH">$SHELL{dirname $(dirname $(which pnetcdf-config))}</env>
Expand Down
8 changes: 8 additions & 0 deletions components/cmake/modules/FindPIO.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ endif()
list(APPEND PIOLIBS "${INSTALL_SHAREDPATH}/lib/libgptl.a")

find_package(NETCDF REQUIRED)
# Check if scorpio has hdf5 enabled
if (DEFINED ENV{HDF5_ROOT})
find_package(HDF5 REQUIRED COMPONENTS C HL)
endif()

# Not all machines/PIO installations use ADIOS but, for now,
# we can assume that an MPI case with ADIOS2_ROOT set is probably
Expand All @@ -46,6 +50,10 @@ else()
list(APPEND PIOLIBS MPI::MPI_C MPI::MPI_Fortran)
endif()

if (DEFINED ENV{HDF5_ROOT})
list(APPEND PIOLIBS ${HDF5_HL_LIBRARIES} ${HDF5_LIBRARIES})
endif()

# Create the interface library, and set target properties
add_library(spio INTERFACE)
target_link_libraries(spio INTERFACE ${PIOLIBS})
Loading

0 comments on commit 15fa673

Please sign in to comment.