From 897d50e4fd594912e6872392beaf44c00ed437fd Mon Sep 17 00:00:00 2001 From: mo-marqh <87382490+mo-marqh@users.noreply.github.com> Date: Mon, 2 Dec 2024 18:16:08 +0000 Subject: [PATCH] Manage Environments - simplify Make (#38) * environment configuration Spice * move from Makefile to Env * propagate Makefile requirements to env definitions --------- Co-authored-by: mo-marqh --- .github/workflows/buildTest.yml | 6 ++-- archerEnv | 10 ++++-- azspiceEnv | 20 ++++++++++++ desktopEnv | 13 ++++---- jasminEnv | 11 +++++-- xios_examples/Makefile | 32 +++---------------- xios_examples/context_test/Makefile | 32 +++---------------- xios_examples/packing_scale_offset/Makefile | 32 +++---------------- xios_examples/split_file_test/Makefile | 33 +++----------------- xios_examples/write_domain_parallel/Makefile | 32 +++---------------- 10 files changed, 68 insertions(+), 153 deletions(-) create mode 100644 azspiceEnv diff --git a/.github/workflows/buildTest.yml b/.github/workflows/buildTest.yml index 17dd232..523f8d3 100644 --- a/.github/workflows/buildTest.yml +++ b/.github/workflows/buildTest.yml @@ -44,11 +44,13 @@ jobs: cd ../.. - name: run resample example run: | - . arch/arch-GCC_LINUX_APT.env - . arch/arch-GCC_LINUX_APT.path export XIOS_BINDIR=$PWD/XIOS/bin export XIOS_INCDIR=$PWD/XIOS/inc export XIOS_LIBDIR=$PWD/XIOS/lib + export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/netcdf/mpi/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH + export LDFLAGS="-L$XIOS_LIBDIR -lxios $(pkg-config --libs netcdf) $(pkg-config --libs netcdf-fortran) -lstdc++" + export FCFLAGS="-g -I$XIOS_INCDIR $(pkg-config --cflags-only-I netcdf) $(pkg-config --cflags-only-I netcdf-fortran)" + export FC=mpif90 export MVER=${{ matrix.version }} export MPI_FLAVOUR='openmpi' diff --git a/archerEnv b/archerEnv index 0c9a899..119b62e 100644 --- a/archerEnv +++ b/archerEnv @@ -8,9 +8,6 @@ module load cray-netcdf-hdf5parallel module load cray-python module load netcdf4 -export NETCDF_LIBDIR=-L$NETCDF_DIR/lib -export NETCDF_INCDIR=-I$NETCDF_DIR/include/ - # set XIOS build to XIOS3 marqh build, if not already set : ${XIOS_DIR=/work/n02/n02/marqh/metofficegit/tcd-XIOS3-extras} @@ -19,6 +16,13 @@ export XIOS_INCDIR=$XIOS_DIR/inc export XIOS_LIBDIR=$XIOS_DIR/lib export XIOS_BINDIR=$XIOS_DIR/bin +# ensure netcdf is on the LD path & flags +export LD_LIBRARY_PATH=$NETCDF_LIBDIR:$LD_LIBRARY_PATH +export LDFLAGS="-L$XIOS_LIBDIR -lxios -L$NETCDF_DIR/lib -lnetcdf -lnetcdff -lstdc++" + +export FCFLAGS="-g -I$XIOS_INCDIR -I$$NETCDF_DIR/include" +export FC=mpif90 + # set env variable for run switching (mpiexec / srun) and iodef patching (transport) export PLATFORM=Archer2 diff --git a/azspiceEnv b/azspiceEnv new file mode 100644 index 0000000..6f7932d --- /dev/null +++ b/azspiceEnv @@ -0,0 +1,20 @@ +# this environment management script needs to be sourced in order to provide +# equivalent functionality on the MO AZ Spice linux desktop to the Github CI environment. +# `. azspiceEnv` + +# load Azure Spice Spack xios module +module load xios + +# provide specific sub_paths for the demonstration build +export XIOS_INCDIR=$XIOS_ROOT/include +export XIOS_LIBDIR=$XIOS_ROOT/lib +export XIOS_BINDIR=$XIOS_ROOT/bin + +# ensure netcdf is on the LD path & flags +export LD_LIBRARY_PATH=${NETCDFF_ROOT}/lib:$LD_LIBRARY_PATH +export LDFLAGS="-L$XIOS_LIBDIR -lxios $(pkg-config --libs netcdf) $(pkg-config --libs netcdf-fortran) -lstdc++" + +export FCFLAGS="-g -I$XIOS_INCDIR $(pkg-config --cflags-only-I netcdf) $(pkg-config --cflags-only-I netcdf-fortran)" +export FC=mpif90 + +export MVER=XIOS/trunk@2252 diff --git a/desktopEnv b/desktopEnv index 94ce5b8..a098a3f 100644 --- a/desktopEnv +++ b/desktopEnv @@ -10,17 +10,18 @@ module use /data/users/lfric/software/modulefiles.rhel7 module load environment/lfric/gcc -# provide explit path set to the arch script for netCDF linking -export NETCDF_LIB_DIRS=$NETCDF_4_8_1_ROOT/lib:$NETCDF_4_8_1_ROOT/lib64 -export NETCDF_INC_DIRS=$NETCDF_4_8_1_ROOT/include - -. arch/arch-GCC_LINUX_APT.path - # provide explicit paths to all XIOS components export XIOS_INCDIR=$XIOS_R2252_2_ROOT/include export XIOS_LIBDIR=$XIOS_R2252_2_ROOT/lib export XIOS_BINDIR=$XIOS_R2252_2_ROOT/bin +# ensure netcdf is on the LD path & flags +export LD_LIBRARY_PATH=$NETCDF_4_8_1_ROOT/lib:$NETCDF_4_8_1_ROOT/lib64:$LD_LIBRARY_PATH +export LDFLAGS="-L$XIOS_LIBDIR -lxios -L$NETCDF_4_8_1_ROOT/lib -lnetcdf -L$NETCDF_4_8_1_ROOT/lib64 -lnetcdff -lstdc++" + +export FCFLAGS="-g -I$XIOS_INCDIR -I$NETCDF_4_8_1_ROOT/include" +export FC=mpif90 + # use an extend LFRic Python environment # that includes netCDF4-python built w.r.t. the LFRIC # netCDF diff --git a/jasminEnv b/jasminEnv index ab2b6a9..83a1cdb 100644 --- a/jasminEnv +++ b/jasminEnv @@ -5,8 +5,8 @@ module load jaspy/3.11 # need at least version 3.11 for parallel netcdf support # provide explit path set to the arch script for netCDF linking -export NETCDF_LIBDIR=-L$(nc-config --libdir) -export NETCDF_INCDIR=-I$(nc-config --includedir) +export NETCDF_LIBDIR=$(nc-config --libdir) +export NETCDF_INCDIR=$(nc-config --includedir) # set XIOS build to XIOS2 trunk revision 2628, if not already set : ${XIOS_DIR=/home/users/jcole/software/xios_trunk_r2628} @@ -16,6 +16,13 @@ export XIOS_INCDIR=$XIOS_DIR/inc export XIOS_LIBDIR=$XIOS_DIR/lib export XIOS_BINDIR=$XIOS_DIR/bin +# ensure netcdf is on the LD path & flags +export LD_LIBRARY_PATH=$NETCDF_LIBDIR:$LD_LIBRARY_PATH +export LDFLAGS="-L$XIOS_LIBDIR -lxios -L$NETCDF_LIBDIR -lnetcdf -lnetcdff -lstdc++" + +export FCFLAGS="-g -I$XIOS_INCDIR -I$NETCDF_INCDIR" +export FC=mpif90 + # set env variable for run switching (mpiexec / srun) and iodef patching (transport) export PLATFORM=Jasmin # diff --git a/xios_examples/Makefile b/xios_examples/Makefile index c787035..e347966 100644 --- a/xios_examples/Makefile +++ b/xios_examples/Makefile @@ -7,36 +7,12 @@ # # Environment Variables expected by this MakeFile: # -# NETCDF_LIBDIR: the directories for the netCDF lib files -# encoded as a -L string, e.g. -# "-L/dir1 -L/dir2" -# NETCDF_INCDIR: the directories for the netCDF include files -# encoded as a -I string, e.g. -# "-I/dir3 -I/dir4" -# (note, this is for consistency with the XIOS build process -# required for the CI build machine. -# this is not required for other directories) -# -# XIOS_INCDIR: The directory for XIOS include files -# XIOS_LIBDIR: The directory for XIOS lib files +# FC: mpif90 +# FCFLAGS: -g & include files for netcdf & xios +# LD_FLAGS: for xios, netcdf, netcdff, stfc++ +# LD_LIBRARY_PATH: for netCDF & XIOS libs # XIOS_BINDIR: The directory for XIOS binary files -FCFLAGS = -g - -FC = mpif90 # compiler driver for MPI programs - -# compiler flag, includes -FCFLAGS += -I$(XIOS_INCDIR) $(NETCDF_INCDIR) - -# loader flags -LDFLAGS = \ - -L$(XIOS_LIBDIR) \ - $(NETCDF_LIBDIR) \ - -lxios \ - -lnetcdf \ - -lnetcdff \ - -lstdc++ - .PHONY: all, clean, run all: resample diff --git a/xios_examples/context_test/Makefile b/xios_examples/context_test/Makefile index e8677c3..62fc539 100644 --- a/xios_examples/context_test/Makefile +++ b/xios_examples/context_test/Makefile @@ -7,36 +7,12 @@ # # Environment Variables expected by this MakeFile: # -# NETCDF_LIBDIR: the directories for the netCDF lib files -# encoded as a -L string, e.g. -# "-L/dir1 -L/dir2" -# NETCDF_INCDIR: the directories for the netCDF include files -# encoded as a -I string, e.g. -# "-I/dir3 -I/dir4" -# (note, this is for consistency with the XIOS build process -# required for the CI build machine. -# this is not required for other directories) -# -# XIOS_INCDIR: The directory for XIOS include files -# XIOS_LIBDIR: The directory for XIOS lib files +# FC: mpif90 +# FCFLAGS: -g & include files for netcdf & xios +# LD_FLAGS: for xios, netcdf, netcdff, stfc++ +# LD_LIBRARY_PATH: for netCDF & XIOS libs # XIOS_BINDIR: The directory for XIOS binary files -FCFLAGS = -g - -FC = mpif90 # compiler driver for MPI programs - -# compiler flag, includes -FCFLAGS += -I$(XIOS_INCDIR) $(NETCDF_INCDIR) - -# loader flags -LDFLAGS = \ - -L$(XIOS_LIBDIR) \ - $(NETCDF_LIBDIR) \ - -lxios \ - -lnetcdf \ - -lnetcdff \ - -lstdc++ - .PHONY: all, clean, run OBJ = custom_type_mod.o context_def_mod.o diff --git a/xios_examples/packing_scale_offset/Makefile b/xios_examples/packing_scale_offset/Makefile index d0f4a3e..4bbef1f 100644 --- a/xios_examples/packing_scale_offset/Makefile +++ b/xios_examples/packing_scale_offset/Makefile @@ -7,36 +7,12 @@ # # Environment Variables expected by this MakeFile: # -# NETCDF_LIBDIR: the directories for the netCDF lib files -# encoded as a -L string, e.g. -# "-L/dir1 -L/dir2" -# NETCDF_INCDIR: the directories for the netCDF include files -# encoded as a -I string, e.g. -# "-I/dir3 -I/dir4" -# (note, this is for consistency with the XIOS build process -# required for the CI build machine. -# this is not required for other directories) -# -# XIOS_INCDIR: The directory for XIOS include files -# XIOS_LIBDIR: The directory for XIOS lib files +# FC: mpif90 +# FCFLAGS: -g & include files for netcdf & xios +# LD_FLAGS: for xios, netcdf, netcdff, stfc++ +# LD_LIBRARY_PATH: for netCDF & XIOS libs # XIOS_BINDIR: The directory for XIOS binary files -FCFLAGS = -g - -FC = mpif90 # compiler driver for MPI programs - -# compiler flag, includes -FCFLAGS += -I$(XIOS_INCDIR) $(NETCDF_INCDIR) - -# loader flags -LDFLAGS = \ - -L$(XIOS_LIBDIR) \ - $(NETCDF_LIBDIR) \ - -lxios \ - -lnetcdf \ - -lnetcdff \ - -lstdc++ - .PHONY: all, clean, run all: pack diff --git a/xios_examples/split_file_test/Makefile b/xios_examples/split_file_test/Makefile index be2e996..fefed47 100644 --- a/xios_examples/split_file_test/Makefile +++ b/xios_examples/split_file_test/Makefile @@ -7,35 +7,12 @@ # # Environment Variables expected by this MakeFile: # -# NETCDF_LIBDIR: the directories for the netCDF lib files -# encoded as a -L string, e.g. -# "-L/dir1 -L/dir2" -# NETCDF_INCDIR: the directories for the netCDF include files -# encoded as a -I string, e.g. -# "-I/dir3 -I/dir4" -# (note, this is for consistency with the XIOS build process -# required for the CI build machine. -# this is not required for other directories) -# -# XIOS_INCDIR: The directory for XIOS include files -# XIOS_LIBDIR: The directory for XIOS lib files +# FC: mpif90 +# FCFLAGS: -g & include files for netcdf & xios +# LD_FLAGS: for xios, netcdf, netcdff, stfc++ +# LD_LIBRARY_PATH: for netCDF & XIOS libs # XIOS_BINDIR: The directory for XIOS binary files -FCFLAGS = -g - -FC = mpif90 # compiler driver for MPI programs - -# compiler flag, includes -FCFLAGS += -I$(XIOS_INCDIR) $(NETCDF_INCDIR) - -# loader flags -LDFLAGS = \ - -L$(XIOS_LIBDIR) \ - $(NETCDF_LIBDIR) \ - -lxios \ - -lnetcdf \ - -lnetcdff \ - -lstdc++ .PHONY: all, clean, run @@ -55,4 +32,4 @@ run: # cleanup clean: - rm -f *.exe *.o *.mod *.MOD *.out *.err *.nc \ No newline at end of file + rm -f *.exe *.o *.mod *.MOD *.out *.err *.nc diff --git a/xios_examples/write_domain_parallel/Makefile b/xios_examples/write_domain_parallel/Makefile index 30d7c7f..30682bf 100644 --- a/xios_examples/write_domain_parallel/Makefile +++ b/xios_examples/write_domain_parallel/Makefile @@ -7,36 +7,12 @@ # # Environment Variables expected by this MakeFile: # -# NETCDF_LIBDIR: the directories for the netCDF lib files -# encoded as a -L string, e.g. -# "-L/dir1 -L/dir2" -# NETCDF_INCDIR: the directories for the netCDF include files -# encoded as a -I string, e.g. -# "-I/dir3 -I/dir4" -# (note, this is for consistency with the XIOS build process -# required for the CI build machine. -# this is not required for other directories) -# -# XIOS_INCDIR: The directory for XIOS include files -# XIOS_LIBDIR: The directory for XIOS lib files +# FC: mpif90 +# FCFLAGS: -g & include files for netcdf & xios +# LD_FLAGS: for xios, netcdf, netcdff, stfc++ +# LD_LIBRARY_PATH: for netCDF & XIOS libs # XIOS_BINDIR: The directory for XIOS binary files -FCFLAGS = -g - -FC = mpif90 # compiler driver for MPI programs - -# compiler flag, includes -FCFLAGS += -I$(XIOS_INCDIR) $(NETCDF_INCDIR) - -# loader flags -LDFLAGS = \ - -L$(XIOS_LIBDIR) \ - $(NETCDF_LIBDIR) \ - -lxios \ - -lnetcdf \ - -lnetcdff \ - -lstdc++ - all: write_parallel # fortran compilation