Skip to content

Commit

Permalink
Manage Environments - simplify Make (#38)
Browse files Browse the repository at this point in the history
* environment configuration Spice

* move from Makefile to Env

* propagate Makefile requirements to env definitions

---------

Co-authored-by: mo-marqh <[email protected]>
  • Loading branch information
mo-marqh and mo-marqh authored Dec 2, 2024
1 parent 5f31386 commit 897d50e
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 153 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/buildTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
10 changes: 7 additions & 3 deletions archerEnv
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand All @@ -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

Expand Down
20 changes: 20 additions & 0 deletions azspiceEnv
Original file line number Diff line number Diff line change
@@ -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
13 changes: 7 additions & 6 deletions desktopEnv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions jasminEnv
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
#
Expand Down
32 changes: 4 additions & 28 deletions xios_examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 4 additions & 28 deletions xios_examples/context_test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 4 additions & 28 deletions xios_examples/packing_scale_offset/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 5 additions & 28 deletions xios_examples/split_file_test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -55,4 +32,4 @@ run:

# cleanup
clean:
rm -f *.exe *.o *.mod *.MOD *.out *.err *.nc
rm -f *.exe *.o *.mod *.MOD *.out *.err *.nc
32 changes: 4 additions & 28 deletions xios_examples/write_domain_parallel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 897d50e

Please sign in to comment.