Skip to content

Use absolute paths to subdirectories#27

Merged
Cameron Bateman (cameronbateman-mo) merged 1 commit into
MetOffice:mainfrom
t00sa:spack-cmake-fixes
May 12, 2026
Merged

Use absolute paths to subdirectories#27
Cameron Bateman (cameronbateman-mo) merged 1 commit into
MetOffice:mainfrom
t00sa:spack-cmake-fixes

Conversation

@t00sa
Copy link
Copy Markdown
Collaborator

PR Summary

Code Reviewer: Cameron Bateman (@cameronbateman-mo)

Change the shumlib CMake macros to use full paths via the built in CMAKE_CURRENT_SOURCE_DIR variable. This is needed to avoid problems with spack, which seems to run cmake from directory other than the base of the shumlib clone - at least when running from a version cloned directly from github.

These changes have been tested interactively from within a clone of the shumlib repository and using spack.

Code Quality Checklist

(Some checks are automatically carried out via the CI pipeline)

  • I have performed a self-review of my own code
  • My code follows the project's style guidelines
  • Comments have been included that aid undertanding and enhance the
    readability of the code
  • My changes generate no new warnings

Testing

  • I have tested this change locally, using the rose-stem suite
  • If any tests fail (rose-stem or CI) the reason is understood and
    acceptable (eg. kgo changes)
  • I have added tests to cover new functionality as appropriate (eg. system
    tests, unit tests, etc.)

Interactive Build

vdi> cmake --preset debug-gcc
Preset CMake variables:

  CMAKE_BUILD_TYPE="Debug"
  CMAKE_C_COMPILER="gcc"
  CMAKE_C_FLAGS_INIT="-g -Wall -Wextra -Werror -Wformat=2 -Winit-self -Wfloat-equal -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wconversion -Wlogical-op -Wstrict-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Woverlength-strings -Wshadow -Wall -Wextra -Wpedantic -fdiagnostics-show-option"
  CMAKE_Fortran_COMPILER="gfortran"
  CMAKE_Fortran_FLAGS_INIT="-g -std=f2018 -pedantic -pedantic-errors -fno-range-check -Wall -Wextra -Werror -Wno-compare-reals -Wconversion -Wno-unused-dummy-argument -Wno-c-binding-type -fdiagnostics-show-option"

-- The C compiler identification is GNU 11.5.0
-- The Fortran compiler identification is GNU 11.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc - 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
-- Found OpenMP_C: -fopenmp (found suitable version "4.5", minimum required is "3.0") 
-- Found OpenMP_Fortran: -fopenmp (Required is at least version "3.0") 
-- Found OpenMP: TRUE (found suitable version "4.5", minimum required is "3.0")  
-- Adding shublib sub-libraries to shum
-- Creating shumlib version functions
-- Creating shumlib regression tests
-- Configuring done (1.0s)
-- Generating done (0.0s)
-- Build files have been written to: /var/tmp/persistent/Development/shumlib/build/debug
vdi> cmake --build --preset debug-gcc
[  1%] Building Fortran object CMakeFiles/shum.dir/f_shum_byteswap_version_mod.f90.o
[  3%] Building Fortran object CMakeFiles/shum.dir/f_shum_constants_version_mod.f90.o
[  4%] Building Fortran object CMakeFiles/shum.dir/f_shum_data_conv_version_mod.f90.o
[  6%] Building Fortran object CMakeFiles/shum.dir/f_shum_fieldsfile_class_version_mod.f90.o
[  8%] Building Fortran object CMakeFiles/shum.dir/f_shum_fieldsfile_version_mod.f90.o
[  9%] Building Fortran object CMakeFiles/shum.dir/f_shum_horizontal_field_interp_version_mod.f90.o
[ 11%] Building Fortran object CMakeFiles/shum.dir/f_shum_kinds_version_mod.f90.o
[ 12%] Building Fortran object CMakeFiles/shum.dir/f_shum_latlon_eq_grids_version_mod.f90.o
[ 14%] Building Fortran object CMakeFiles/shum.dir/f_shum_number_tools_version_mod.f90.o
[ 16%] Building Fortran object CMakeFiles/shum.dir/f_shum_spiral_search_version_mod.f90.o
[ 17%] Building Fortran object CMakeFiles/shum.dir/f_shum_string_conv_version_mod.f90.o
[ 19%] Building Fortran object CMakeFiles/shum.dir/f_shum_thread_utils_version_mod.f90.o
[ 20%] Building Fortran object CMakeFiles/shum.dir/f_shum_wgdos_packing_version_mod.f90.o
[ 22%] Building Fortran object CMakeFiles/shum.dir/shum_string_conv/src/f_shum_string_conv.f90.o
[ 24%] Building Fortran object CMakeFiles/shum.dir/shum_byteswap/src/f_shum_byteswap.f90.o
[ 25%] Building Fortran object CMakeFiles/shum.dir/shum_constants/src/f_shum_chemistry_constants_mod.f90.o
[ 27%] Building Fortran object CMakeFiles/shum.dir/shum_constants/src/f_shum_conversions_mod.f90.o
[ 29%] Building Fortran object CMakeFiles/shum.dir/shum_constants/src/f_shum_planet_earth_constants_mod.f90.o
[ 30%] Building Fortran object CMakeFiles/shum.dir/shum_constants/src/f_shum_rel_mol_mass_mod.f90.o
[ 32%] Building Fortran object CMakeFiles/shum.dir/shum_constants/src/f_shum_water_constants_mod.f90.o
[ 33%] Building Fortran object CMakeFiles/shum.dir/shum_constants/src/f_shum_ztables.f90.o
[ 35%] Building Fortran object CMakeFiles/shum.dir/shum_data_conv/src/f_shum_data_conv.f90.o
[ 37%] Building Fortran object CMakeFiles/shum.dir/shum_fieldsfile/src/f_shum_fixed_length_header_indices.f90.o
[ 38%] Building Fortran object CMakeFiles/shum.dir/shum_fieldsfile/src/f_shum_lookup_indices.f90.o
[ 40%] Building Fortran object CMakeFiles/shum.dir/shum_fieldsfile/src/f_shum_fieldsfile.f90.o
[ 41%] Building Fortran object CMakeFiles/shum.dir/shum_fieldsfile/src/f_shum_stashmaster.f90.o
[ 43%] Building Fortran object CMakeFiles/shum.dir/shum_fieldsfile_class/src/f_shum_ff_status.f90.o
[ 45%] Building Fortran object CMakeFiles/shum.dir/shum_fieldsfile_class/src/f_shum_field.f90.o
[ 46%] Building Fortran object CMakeFiles/shum.dir/shum_wgdos_packing/src/f_shum_wgdos_packing.f90.o
[ 48%] Building Fortran object CMakeFiles/shum.dir/shum_fieldsfile_class/src/f_shum_file.f90.o
[ 50%] Building Fortran object CMakeFiles/shum.dir/shum_number_tools/src/f_shum_is_denormal.F90.o
[ 51%] Building Fortran object CMakeFiles/shum.dir/shum_horizontal_field_interp/src/f_shum_horizontal_field_interp.f90.o
[ 53%] Building Fortran object CMakeFiles/shum.dir/shum_kinds/src/f_shum_kinds.F90.o
[ 54%] Building Fortran object CMakeFiles/shum.dir/shum_latlon_eq_grids/src/f_shum_latlon_eq_grids.f90.o
[ 56%] Building Fortran object CMakeFiles/shum.dir/shum_number_tools/src/f_shum_is_inf.F90.o
[ 58%] Building Fortran object CMakeFiles/shum.dir/shum_number_tools/src/f_shum_is_nan.F90.o
[ 59%] Building Fortran object CMakeFiles/shum.dir/shum_spiral_search/src/f_shum_spiral_search.f90.o
[ 61%] Building Fortran object CMakeFiles/shum.dir/shum_spiral_search/src/c_shum_spiral_search.f90.o
[ 62%] Building Fortran object CMakeFiles/shum.dir/shum_thread_utils/src/f_shum_thread_utils.f90.o
[ 64%] Building Fortran object CMakeFiles/shum.dir/shum_wgdos_packing/src/c_shum_wgdos_packing.f90.o
[ 66%] Building C object CMakeFiles/shum.dir/shum_byteswap/src/c_shum_byteswap.c.o
[ 67%] Building C object CMakeFiles/shum.dir/shum_data_conv/src/c_shum_data_conv.c.o
[ 69%] Building C object CMakeFiles/shum.dir/common/src/shumlib_version.c.o
[ 70%] Linking Fortran shared library libshum.so
[ 70%] Built target shum
[ 72%] Building Fortran object CMakeFiles/fruit.dir/fruit/fruit.f90.o
[ 74%] Linking Fortran shared library libfruit.so
[ 74%] Built target fruit
[ 75%] Building Fortran object CMakeFiles/shumlib-tests.dir/shum_byteswap/test/fruit_test_shum_byteswap.f90.o
[ 77%] Building Fortran object CMakeFiles/shumlib-tests.dir/shum_constants/test/fruit_test_shum_constants.f90.o
[ 79%] Building Fortran object CMakeFiles/shumlib-tests.dir/shum_fieldsfile/test/fruit_test_shum_fieldsfile.f90.o
[ 80%] Building Fortran object CMakeFiles/shumlib-tests.dir/shum_fieldsfile_class/test/fruit_test_shum_fieldsfile_class.f90.o
[ 82%] Building Fortran object CMakeFiles/shumlib-tests.dir/shum_horizontal_field_interp/test/fruit_test_shum_horizontal_field_interp.f90.o
[ 83%] Building Fortran object CMakeFiles/shumlib-tests.dir/shum_kinds/test/fruit_test_shum_kinds.f90.o
[ 85%] Building Fortran object CMakeFiles/shumlib-tests.dir/shum_latlon_eq_grids/test/fruit_test_shum_latlon_eq_grids.f90.o
[ 87%] Building Fortran object CMakeFiles/shumlib-tests.dir/shum_number_tools/test/fruit_test_shum_number_tools.F90.o
[ 88%] Building Fortran object CMakeFiles/shumlib-tests.dir/shum_spiral_search/test/fruit_test_shum_spiral_search.f90.o
[ 90%] Building Fortran object CMakeFiles/shumlib-tests.dir/shum_string_conv/test/fruit_test_shum_string_conv.f90.o
[ 91%] Building Fortran object CMakeFiles/shumlib-tests.dir/shum_thread_utils/test/fruit_test_shum_thread_utils.f90.o
[ 93%] Building Fortran object CMakeFiles/shumlib-tests.dir/shum_wgdos_packing/test/fruit_test_shum_wgdos_packing.f90.o
[ 95%] Building C object CMakeFiles/shumlib-tests.dir/shum_number_tools/test/c_fruit_test_shum_number_tools.c.o
[ 96%] Building C object CMakeFiles/shumlib-tests.dir/shum_thread_utils/test/c_fruit_test_shum_thread_utils.c.o
[ 98%] Building Fortran object CMakeFiles/shumlib-tests.dir/fruit_driver.f90.o
[100%] Linking Fortran executable shumlib-tests
[100%] Built target shumlib-tests
vdi>

Spack Build

vdi> spack install
==> Concretized 1 spec
 -   khmxoki  shumlib@develop~denormal~fthreads~ieee~ipo~nan+openmp+test build_system=cmake build_type=Release commit=6e6f3fcb70fac832162424730a96e7d1fd8cd217 generator=make platform=linux os=rhel9 target=zen2 %c,cxx,fortran=gcc@12.2.0
[e]  zftv5rf      ^cmake@3.26.5~doc+ncurses+ownlibs~qtgui build_system=generic build_type=Release platform=linux os=rhel9 target=x86_64 
[+]  d27unkz      ^compiler-wrapper@1.0 build_system=generic platform=linux os=rhel9 target=zen2 
[e]  zasrmws      ^gcc@12.2.0~binutils+bootstrap~graphite~mold~nvptx~piclibs~profiled~strip build_system=autotools build_type=RelWithDebInfo languages:='c,c++,fortran' platform=linux os=rhel9 target=x86_64 
[+]  ty4ddjn      ^gcc-runtime@12.2.0 build_system=generic platform=linux os=rhel9 target=zen2 
[e]  45if5qv      ^glibc@2.34 build_system=autotools platform=linux os=rhel9 target=x86_64 
[e]  yhwkdvc      ^gmake@4.3~guile build_system=generic platform=linux os=rhel9 target=x86_64 

[+] /usr (external cmake-3.26.5-zftv5rfobd6e5wrw5bubdfvowhu3745m)
[+] $SPACK_INSTALL_ROOT/releases/2026-05-07/install/linux-zen2/compiler-wrapper-1.0-d27unkzhpyaq5qhiv3vcsuid3cztwzaw
[+] /data/apps/spack/compilers/install/linux-rhel9-zen2/gcc-11.5.0/gcc-12.2.0-wwyf7gjcun7i6usswde5fnjsyfpsph33 (external gcc-12.2.0-zasrmwszlnmtweskeqzsihgnb6y5qzw4)
[+] /usr (external glibc-2.34-45if5qvlpeyfsyucmcqxopqyyd7vqatq)
[+] /usr (external gmake-4.3-yhwkdvcgeokexlsc5pgdhldaa6tmz2pq)
[+] $SPACK_INSTALL_ROOT/releases/2026-05-07/install/linux-zen2/gcc-runtime-12.2.0-ty4ddjn45eft5ymyyu4wtwe35lig5iea
==> No binary for shumlib-develop-khmxokivmem3dycptei4bciud3zhd2yl found: installing from source
==> Installing shumlib-develop-khmxokivmem3dycptei4bciud3zhd2yl [7/7]
==> Using cached archive: /var/tmp/persistent/Software/Spack/spack-1.1.1/var/spack/cache/_source-cache/git/t00sa/shumlib.git/6e6f3fcb70fac832162424730a96e7d1fd8cd217.tar.gz
==> Warning: Using download cache instead of version control
  The required sources are normally checked out from a version control system, but have been archived in download cache: file:///var/tmp/persistent/Software/Spack/spack-1.1.1/var/spack/cache/_source-cache/git/t00sa/shumlib.git/6e6f3fcb70fac832162424730a96e7d1fd8cd217.tar.gz. Spack lacks a tree hash to verify the integrity of this archive. Make sure your download cache is in a secure location.
==> No patches needed for shumlib
==> shumlib: Executing phase: 'cmake'
==> shumlib: Executing phase: 'build'
==> shumlib: Executing phase: 'install'
==> shumlib: Successfully installed shumlib-develop-khmxokivmem3dycptei4bciud3zhd2yl
  Stage: 0.05s.  Cmake: 1.86s.  Build: 10.14s.  Install: 0.17s.  Post-install: 0.07s.  Total: 12.39s
[+] $SPACK_INSTALL_ROOT/releases/2026-05-07/install/linux-zen2/shumlib-develop-khmxokivmem3dycptei4bciud3zhd2yl
==> Updating view at $SPACK_INSTALL_ROOT/releases/2026-05-07/envs/meto-azspice/shumtest/.spack-env/view
vdi>

Security Considerations

  • This change does not introduce security vulnerabilities
  • I have reviewed the code for potential security issues
  • Sensitive data is properly handled (if applicable)
  • Authentication and authorisation are properly implemented (if applicable)

Performance Impact

  • Performance of the code has been considered and, if applicable, suitable
    performance measurements have been conducted

AI Assistance and Attribution

  • Some of the content of this change has been produced with the assistance
    of Generative AI tool name (e.g., Met Office Github Copilot Enterprise,
    Github Copilot Personal, ChatGPT GPT-4, etc) and I have followed the
    Simulation Systems AI policy(including attribution labels)

Documentation

  • Where appropriate I have updated documentation related to this change and
    confirmed that it builds correctly

Code Review

  • All dependencies have been resolved
  • Related Issues have been properly linked and addressed
  • CLA compliance has been confirmed
  • Code quality standards have been met
  • Tests are adequate and have passed
  • Documentation is complete and accurate
  • Security considerations have been addressed
  • Performance impact is acceptable

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good changes, approved.

@cameronbateman-mo Cameron Bateman (cameronbateman-mo) merged commit 8ea9961 into MetOffice:main May 12, 2026
7 checks passed
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.

4 participants