NCAR / micm

A model-independent chemistry module for atmosphere models
https://ncar.github.io/micm/
Apache License 2.0
5 stars 5 forks source link

Initial attempt for supporting presets. #549

Closed mwaxmonsky closed 2 months ago

mwaxmonsky commented 4 months ago

Adds preset file and now to target derecho a100 gpu, we can simply run cmake --preset=derecho-gpu with the following output:

-- CMake build configuration for micm(Release) 3.5.0
-- Found EnvModules: /glade/u/apps/casper/23.10/spack/opt/spack/lmod/8.7.24/gcc/7.5.0/m4jx/lmod/lmod/libexec/lmod  

Lmod is automatically replacing "intel/2023.2.1" with "nvhpc/23.7".

Due to MODULEPATH changes, the following have been reloaded:
  1) hdf5/1.12.2     2) ncarcompilers/1.0.0     3) netcdf/4.9.2     4) openmpi/4.1.6

-- Currently loaded modules: ncarenv/23.10;nvhpc/23.7;ncarcompilers/1.0.0;hdf5/1.12.2;netcdf/4.9.2;gcc-toolchain/12.2.0;cmake/3.26.3
-- The C compiler identification is NVHPC 23.7.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /glade/u/apps/casper/23.10/spack/opt/spack/ncarcompilers/1.0.0/nvhpc/23.7/pw2i/bin/nvc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
mwaxmonsky commented 2 months ago

Closing this as this is not possible at this time.

Currently, the CMake documentation states to not use this to load build time requirements (https://cmake.org/cmake/help/latest/module/FindEnvModules.html). After some testing, there is the ability to add the module load/unload ... commands to the ALL target that will be called before each target during the make ... phase, but this has two problems: 1) Each target Makefile is hardcoded to use /bin/sh (https://github.com/Kitware/CMake/blob/de8911120eea6aa8df5e156bce2643c819e7c10f/Source/cmLocalUnixMakefileGenerator3.cxx#L658) which does not throw an error when calling . /path/to/lmod/init/sh but does throw an error when calling module load ... saying module command not found. 2) Even if we could migrate to setting /bin/bash in the Makefile's, each target is made in a unique shell session and the Makefiles would have to be modified to share environments so the module load ...'s could be propagated through the targets which is non-trivial and would require manual changes to Makefiles after the configure step if it's possible at all.