From 601037c71d99b1299d83de9e2cfcc5a929a071d3 Mon Sep 17 00:00:00 2001 From: Philippe Blain Date: Thu, 6 Feb 2020 14:12:18 -0700 Subject: [PATCH] machines: add conda environment for macOS and Linux --- configuration/scripts/icepack.batch.csh | 5 +++ .../scripts/machines/Macros.conda_linux | 35 ++++++++++++++++ .../scripts/machines/Macros.conda_macos | 38 +++++++++++++++++ .../scripts/machines/env.conda_linux | 41 +++++++++++++++++++ .../scripts/machines/env.conda_macos | 41 +++++++++++++++++++ .../scripts/machines/environment.yml | 11 +++++ 6 files changed, 171 insertions(+) create mode 100644 configuration/scripts/machines/Macros.conda_linux create mode 100644 configuration/scripts/machines/Macros.conda_macos create mode 100755 configuration/scripts/machines/env.conda_linux create mode 100755 configuration/scripts/machines/env.conda_macos create mode 100644 configuration/scripts/machines/environment.yml diff --git a/configuration/scripts/icepack.batch.csh b/configuration/scripts/icepack.batch.csh index 6d6511491..2aff309f9 100755 --- a/configuration/scripts/icepack.batch.csh +++ b/configuration/scripts/icepack.batch.csh @@ -143,6 +143,11 @@ cat >> ${jobfile} << EOFB # nothing to do EOFB +else if (${ICE_MACHINE} =~ conda*) then +cat >> ${jobfile} << EOFB +# nothing to do +EOFB + else echo "${0} ERROR: ${ICE_MACHINE} unknown" exit -1 diff --git a/configuration/scripts/machines/Macros.conda_linux b/configuration/scripts/machines/Macros.conda_linux new file mode 100644 index 000000000..b6bb9ed69 --- /dev/null +++ b/configuration/scripts/machines/Macros.conda_linux @@ -0,0 +1,35 @@ +#============================================================================== +# Makefile macros for conda environment, GNU/Linux systems +#============================================================================== + +# Preprocessor macros +CPPDEFS := -DFORTRANUNDERSCORE ${ICE_CPPDEFS} + +# Flags for the C compiler +CFLAGS := -c -O2 + +# Flags for the Fortran compiler +FREEFLAGS := -ffree-form +FFLAGS := -fconvert=big-endian -fbacktrace -ffree-line-length-none + +# Additional flags for the Fortran compiler when compiling in debug mode +ifeq ($(ICE_BLDDEBUG), true) + FFLAGS += -O0 -g -fcheck=bounds -finit-real=nan -fimplicit-none -ffpe-trap=invalid,zero,overflow +else + FFLAGS += -O2 +endif + +# C and Fortran compilers +SCC := gcc +SFC := gfortran +CC := $(SCC) +FC := $(SFC) +LD := $(FC) + +# Necessary flag to compile with OpenMP support +ifeq ($(ICE_THREADED), true) + LDFLAGS += -fopenmp + CFLAGS += -fopenmp + FFLAGS += -fopenmp +endif + diff --git a/configuration/scripts/machines/Macros.conda_macos b/configuration/scripts/machines/Macros.conda_macos new file mode 100644 index 000000000..86510c265 --- /dev/null +++ b/configuration/scripts/machines/Macros.conda_macos @@ -0,0 +1,38 @@ +#============================================================================== +# Makefile macros for conda environment, macOS systems +#============================================================================== + +# Preprocessor macros +CPPDEFS := -DFORTRANUNDERSCORE ${ICE_CPPDEFS} + +# Flags for the C compiler +CFLAGS := -c -O2 + +# Flags for the Fortran compiler +FREEFLAGS := -ffree-form +FFLAGS := -fconvert=big-endian -fbacktrace -ffree-line-length-none + +# Additional flags for the Fortran compiler when compiling in debug mode +ifeq ($(ICE_BLDDEBUG), true) + FFLAGS += -O0 -g -fcheck=bounds -finit-real=nan -fimplicit-none -ffpe-trap=invalid,zero,overflow +else + FFLAGS += -O2 +endif + +# C and Fortran compilers +SCC := clang +SFC := gfortran +CC := $(SCC) +FC := $(SFC) +LD := $(FC) + +# Location of the system C header files (required on recent macOS to compile makdep) +CFLAGS_HOST = -isysroot$(shell xcrun --show-sdk-path) + +# Necessary flag to compile with OpenMP support +ifeq ($(ICE_THREADED), true) + LDFLAGS += -fopenmp + CFLAGS += -fopenmp + FFLAGS += -fopenmp +endif + diff --git a/configuration/scripts/machines/env.conda_linux b/configuration/scripts/machines/env.conda_linux new file mode 100755 index 000000000..d677e2023 --- /dev/null +++ b/configuration/scripts/machines/env.conda_linux @@ -0,0 +1,41 @@ +#!/bin/csh -f + +set inp = "undefined" +if ($#argv == 1) then + set inp = $1 +endif + +if ("$inp" != "-nomodules") then + +# Init conda +if ! $?CONDA_EXE then + echo "" + echo "${0}: conda executable not found, see the Icepack documentation for how to initialize your login shell to use conda" + echo "" + exit 1 +endif +source `$CONDA_EXE info --base`/etc/profile.d/conda.csh +# Activate "icepack" conda environment +conda activate icepack +if $status then + echo "" + echo "${0}: 'icepack' conda environment not found, see the Icepack documentation for how to create the conda icepack env" + echo "" + exit 1 +endif + +endif + +setenv ICE_MACHINE_ENVNAME conda +setenv ICE_MACHINE_COMPILER linux +setenv ICE_MACHINE_MAKE make +setenv ICE_MACHINE_WKDIR $HOME/icepack-dirs/runs +setenv ICE_MACHINE_INPUTDATA $HOME/icepack-dirs/input +setenv ICE_MACHINE_BASELINE $HOME/icepack-dirs/baseline +setenv ICE_MACHINE_SUBMIT " " +setenv ICE_MACHINE_TPNODE 4 +setenv ICE_MACHINE_ACCT P0000000 +setenv ICE_MACHINE_QUEUE "debug" +setenv ICE_MACHINE_BLDTHRDS 4 +setenv ICE_MACHINE_QSTAT " " + diff --git a/configuration/scripts/machines/env.conda_macos b/configuration/scripts/machines/env.conda_macos new file mode 100755 index 000000000..0d094d53a --- /dev/null +++ b/configuration/scripts/machines/env.conda_macos @@ -0,0 +1,41 @@ +#!/bin/csh -f + +set inp = "undefined" +if ($#argv == 1) then + set inp = $1 +endif + +if ("$inp" != "-nomodules") then + +# Init conda +if ! $?CONDA_EXE then + echo "" + echo "${0}: conda executable not found, see the Icepack documentation for how to initialize your login shell to use conda" + echo "" + exit 1 +endif +source `$CONDA_EXE info --base`/etc/profile.d/conda.csh +# Activate "icepack" conda environment +conda activate cice +if $status then + echo "" + echo "${0}: 'cice' conda environment not found, see the Icepack documentation for how to create the conda icepack env" + echo "" + exit 1 +endif + +endif + +setenv ICE_MACHINE_ENVNAME conda +setenv ICE_MACHINE_COMPILER macos +setenv ICE_MACHINE_MAKE make +setenv ICE_MACHINE_WKDIR $HOME/icepack-dirs/runs +setenv ICE_MACHINE_INPUTDATA $HOME/icepack-dirs/input +setenv ICE_MACHINE_BASELINE $HOME/icepack-dirs/baseline +setenv ICE_MACHINE_SUBMIT " " +setenv ICE_MACHINE_TPNODE 4 +setenv ICE_MACHINE_ACCT P0000000 +setenv ICE_MACHINE_QUEUE "debug" +setenv ICE_MACHINE_BLDTHRDS 4 +setenv ICE_MACHINE_QSTAT " " + diff --git a/configuration/scripts/machines/environment.yml b/configuration/scripts/machines/environment.yml new file mode 100644 index 000000000..c63ccbf5b --- /dev/null +++ b/configuration/scripts/machines/environment.yml @@ -0,0 +1,11 @@ +name: icepack +channels: + - conda-forge + - nodefaults +dependencies: +# Build dependencies + - compilers + - make +# Python dependencies for building the HTML documentation + - sphinx + - sphinxcontrib-bibtex