diff --git a/.gitignore b/.gitignore index 259148fa..a4e1a415 100644 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,13 @@ *.a *.lib +# intermediate build files +*_INSTALL/ + # Executables *.exe *.out *.app + +# Editor +.idea diff --git a/.gitmodules b/.gitmodules index c21b87e1..53771378 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,24 +1,24 @@ [submodule "ATMESH"] path = ATMESH - url = https://github.com/moghimis/ATMESH + url = https://github.com/noaa-ocs-modeling/ATMESH.git branch = master [submodule "WW3DATA"] path = WW3DATA - url = https://github.com/moghimis/WW3DATA + url = https://github.com/noaa-ocs-modeling/WW3DATA.git branch = master [submodule "WW3"] path = WW3 - url = https://github.com/awest-noaa/WW3.git + url = https://github.com/noaa-ocs-modeling/WW3.git branch = nuopc_unstruc [submodule "NEMS"] path = NEMS - url = https://github.com/moghimis/NEMS + url = https://github.com/noaa-ocs-modeling/NEMS.git branch = develop [submodule "ADCIRC"] path = ADCIRC - url = https://github.com/moghimis/adcirc-cg.git + url = https://github.com/adcirc/adcirc-cg.git branch = master [submodule "NWM"] path = NWM - url = https://github.com/trimbleava/nwm_public_nuopc.git + url = https://github.com/noaa-ocs-modeling/nwm_public_nuopc.git branch = master diff --git a/ADCIRC b/ADCIRC index 59765040..74287374 160000 --- a/ADCIRC +++ b/ADCIRC @@ -1 +1 @@ -Subproject commit 59765040a3716ec51b00266710bc8b1b58c48a4c +Subproject commit 7428737428ff4fb72582526bc1cbcb200e6feb3d diff --git a/ATMESH b/ATMESH index b760156d..da054839 160000 --- a/ATMESH +++ b/ATMESH @@ -1 +1 @@ -Subproject commit b760156d61d9b207d75763d4eb815f93b978c17a +Subproject commit da054839ce8277049413bcdcd84a98952095952c diff --git a/HOWTO b/HOWTO index f58ca9aa..47fb3241 100644 --- a/HOWTO +++ b/HOWTO @@ -1,3 +1,5 @@ +Modified: Panagiotis Velissariou - 12/05/2020 + ================================== Coastal Act Team - 9/13/2019 @@ -591,7 +593,6 @@ build_NWM: $(nwm_mk) env_file=$(NWM_SRCDIR)/setEnvar.sh -esmf_env=$(NWM_SRCDIR)/esmf-impi-env.sh comp_opt=3 # HOW to source env here?? diff --git a/NEMS b/NEMS index 2fdfde2b..7cf93063 160000 --- a/NEMS +++ b/NEMS @@ -1 +1 @@ -Subproject commit 2fdfde2b49b26baccae93cd0da6c2c1c9ab082a4 +Subproject commit 7cf930637f6bc49d1974c354800eb1d25d3ba641 diff --git a/NWM b/NWM index 55e9524e..3bc401d2 160000 --- a/NWM +++ b/NWM @@ -1 +1 @@ -Subproject commit 55e9524efa34b51acb6ebbd30e1fc09d4617cbea +Subproject commit 3bc401d298070515cb6171a585d2d19646afd650 diff --git a/README.md b/README.md index 84cc9ced..11fac621 100644 --- a/README.md +++ b/README.md @@ -1,101 +1,118 @@ -## ADC-WW3-NWM-NEMS - -ADC-WW3-NWM-NEMS is an ESMF application developed as part of the Coastal Act -coupling project to determine wind versus water percentage loss caused by a -Named Storm Event. - -## Cloning - git clone --recursive https://github.com/noaa-ocs-modeling/ADC-WW3-NWM-NEMS.git +# ADC-WW3-NWM-NEMS + +ESMF application for building a NUOPC / NEMS application coupling ADCIRC, ATMESH, WW3 / WW3DATA, and NWM. + +`ADC-WW3-NWM-NEMS` is an ESMF application developed as part of the Coastal Act coupling project to determine wind versus water percentage loss caused by a Named Storm Event. + +```bash +git clone --recursive https://github.com/noaa-ocs-modeling/ADC-WW3-NWM-NEMS +cd ADC-WW3-NWM-NEMS +``` + +## Compilation + +```bash +./build.sh --component "ADCIRC ATMESH WW3DATA" --plat hera --compiler intel --clean -2 +``` + +- `--component` can be any combination of + - `ADCIRC` + - `ATMESH` + - `WW3` / `WW3DATA` + - `NWM` +- `--plat` can be any combination of + - `hera` + - `stampede` + - `wcoss` + - `orion` + - `jet` + - `gaea` + - `cheyenne` + - `linux` + - `macosx` +- `--compiler` can be one of + - `intel` + - `gnu` + - `pgi` +- `--clean` is optional, and can be one of + - ` ` (`make clean` and exit) + - `1` (`make clean` and exit) + - `2` (`make clobber` and exit) + - `-1` (`make clean` and build) + - `-2` (`make clobber` and build) + +#### adding a new platform / compiler to compilation script + +Environment files are stored in `modulefiles/` with the filename `envmodules_.` + +To compile in your own system you should create a similar file, then run `build.sh` to compile. ## Requirements -### Install ParMETIS - -Unstructured WW3 requires an installation of ParMETIS for domain decomposition. Download the code from this [link](http://glaros.dtc.umn.edu/gkhome/metis/parmetis/download) - -To build ParMETIS: - - module purge - - module load intel impi - - setenv CFLAGS -fPIC - - make config cc=mpiicc cxx=mpiicc prefix=/path/to/your/parmetis/ | & tee config.out-rr - - make install | & tee make-install.out-rr - -This adds `libparmetis.a` under `/path/to/your/parmetis/lib/libparmetis.a` - -Set the path to ParMETIS: - - setenv METIS_PATH /path/to/your/parmetis - -### Set module files based on your HPC - -For a list of additional requirements and versions, see: - - modulefiles/hera/ESMF_NUOPC - - -## Compile - -Set the following environment variable: - -- `ROOTDIR`: The directory of your choice where the repository has been cloned - -In the build script `build.sh`, select desired components for which to build the app, e.g.: - - make -f GNUmakefile build COMPONENTS="ADCIRC WW3 ATMESH" - -Execute the build script: - - ./build.sh - +#### installing ParMETIS for WW3 + +Using unstructured WW3 requires an installation of ParMETIS for domain decomposition. + +1. [download the code here](http://glaros.dtc.umn.edu/gkhome/metis/parmetis/download) +2. build ParMETIS + ```bash + module purge + module load intel impi + setenv CFLAGS -fPIC + make config cc=mpiicc cxx=mpiicc prefix=/path/to/your/parmetis/ | & tee config.out-rr + make install | & tee make-install.out-rr + ``` + This adds `libparmetis.a` under `/path/to/your/parmetis/lib/libparmetis.a`. +3. set the path to ParMETIS + ```bash + setenv METIS_PATH /path/to/your/parmetis + ``` ## Collaboration To collaborate and contribute to this repository follow below instructions: -While in github GUI, https://github.com/noaa-ocs-modeling/ADC-WW3-NWM-NEMS.git: - -1) Hit the "Fork" button located on the upper right corner of the GUI in order - to have your own copy of this repository into your own github repository. -2) Your github username displays with a message "Where should we fork ..." . - Click on your username to fork it into your account. -3) You should see the source codes in your own github repository with the same - name as the forked reopsitory. - -Next you should create your local version of your forked repository. -Go to your local directoy and clone the the repository: - -1) git clone --recursive https://github.com//ADC-WW3-NWM-NEMS -2) do your collaboration edition and when finished -3) git add . -4) git commit -m "describe what you changed" -5) git push origin master - to push your changes into your github -6) enter your github username/password if asked - -While in your github repository GUI: - -1) push the "New pull request" button -2) hit the "Create pull request" button -3) the request goes to originated repository, where your changes are reviewed and - merged or rejected. - -### Setup and compilation - -This application contains a module file tailored for the intended computer system. -To compile in your own system you should create a similar file. The setup module -file, is located at modulefile/hera/ESMF_NUOPC. Also, for your convenience there -is a "HOWTO" that explains in detail about the usage of this application. - - -## Cite - -Moghimi, S.; Van der Westhuysen, A.; Abdolali, A.; Myers, E.; Vinogradov, S.; Ma, Z.; Liu, F.; Mehra, A.; Kurkowski, N. Development of an ESMF Based Flexible Coupling Application of ADCIRC and WAVEWATCH III for High Fidelity Coastal Inundation Studies. J. Mar. Sci. Eng. 2020, 8, 308. https://doi.org/10.3390/jmse8050308 - -Development of a Flexible Coupling Framework for Coastal Inundation Studies, 2020 S Moghimi, A van der Westhuysen, A Abdolali, E Myers, S Vinogradov -https://arxiv.org/abs/2003.12652 - -Development of a Flexible Coupling Interface for ADCIRC Model for Coastal Inundation Studies, 2019 Saeed Moghimi, Sergey Vinogradov, Edward P Myers, Yuji Funakoshi, Andre J Van der Westhuysen, Ali Abdolali, Zaizhong Ma, Fei Liu https://repository.library.noaa.gov/view/noaa/20609/ +1. go to https://github.com/noaa-ocs-modeling/ADC-WW3-NWM-NEMS +2. create a fork (click `Fork` on the upper right corner), and fork to your account. +3. clone your forked repository + ```bash + git clone --recursive https://github.com//ADC-WW3-NWM-NEMS + ``` +4. edit the files locally + ```bash + git status + ``` +5. commit changes + ```bash + git commit -a -m "describe what you changed" + ``` +6. push your changes to GitHub + ```bash + git push + ``` +7. enter your GitHub username/password if asked +8. create a pull request with descriptions of changes at + ``` + https://github.com/noaa-ocs-modeling/ADC-WW3-NWM-NEMS/compare/...: + ``` + +## Citations + +``` +Moghimi, S., Van der Westhuysen, A., Abdolali, A., Myers, E., Vinogradov, S., + Ma, Z., Liu, F., Mehra, A., & Kurkowski, N. (2020). Development of an ESMF + Based Flexible Coupling Application of ADCIRC and WAVEWATCH III for High + Fidelity Coastal Inundation Studies. Journal of Marine Science and + Engineering, 8(5), 308. https://doi.org/10.3390/jmse8050308 + +Moghimi, S., Vinogradov, S., Myers, E. P., Funakoshi, Y., Van der Westhuysen, + A. J., Abdolali, A., Ma, Z., & Liu, F. (2019). Development of a Flexible + Coupling Interface for ADCIRC model for Coastal Inundation Studies. NOAA + Technical Memorandum, NOS CS(41). + https://repository.library.noaa.gov/view/noaa/20609/ + +Moghimi, S., Westhuysen, A., Abdolali, A., Myers, E., Vinogradov, S., Ma, Z., + Liu, F., Mehra, A., & Kurkowski, N. (2020). Development of a Flexible + Coupling Framework for Coastal Inundation Studies. + https://arxiv.org/abs/2003.12652 +``` diff --git a/WW3 b/WW3 index 7823bd24..60610eb5 160000 --- a/WW3 +++ b/WW3 @@ -1 +1 @@ -Subproject commit 7823bd245ed98df295ac8b6c437903e131101666 +Subproject commit 60610eb5f7a79b8d8bf41a02f078a691bf0506c8 diff --git a/WW3DATA b/WW3DATA index 8308a380..beda5f2e 160000 --- a/WW3DATA +++ b/WW3DATA @@ -1 +1 @@ -Subproject commit 8308a380f8fc7439748a136e5476476efd751020 +Subproject commit beda5f2eab6bf670991ad970fc064e0a80584f0a diff --git a/build.sh b/build.sh deleted file mode 100755 index 41e309aa..00000000 --- a/build.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -# Description : Script to compile NSEModel NEMS application -# Usage : ./build.sh -# Date : Feb 27, 2020 -# Contact : moghimis@gmail.com - -# Check for env variables -if [ "${ROOTDIR}" == "" ] - then - echo "ERROR - Your ROOTDIR environment variable is not set" - exit 1 -fi -if [ "${METIS_PATH}" == "" ] - then - echo "ERROR - Your METIS_PATH environment variable for WW3 is not set" - exit 1 -else - echo "METIS_PATH set to ${METIS_PATH}" -fi - -# Load modules -source ${ROOTDIR}/modulefiles/hera/ESMF_NUOPC -module list - -echo "Building NEMS app in ${ROOTDIR}/NEMS" -cd ${ROOTDIR}/NEMS - -# Clean up -make -f GNUmakefile distclean_ADCIRC COMPONENTS="ADCIRC" -make -f GNUmakefile distclean_WW3DATA COMPONENTS="WW3DATA" -make -f GNUmakefile distclean_ATMESH COMPONENTS="ATMESH" -make -f GNUmakefile distclean_WW3 COMPONENTS="WW3" -make -f GNUmakefile distclean_NWM COMPONENTS="NWM" -make -f GNUmakefile distclean_NEMS COMPONENTS="ADCIRC WW3 NWM ATMESH" - -# Make coupled NEMS app -#make -f GNUmakefile build COMPONENTS="ADCIRC NWM ATMESH" -#make -f GNUmakefile build COMPONENTS="ADCIRC WW3 ATMESH" -#make -f GNUmakefile build COMPONENTS="ADCIRC ATMESH WW3 NWM" -#make -f GNUmakefile build COMPONENTS="ADCIRC WW3DATA ATMESH" -#make -f GNUmakefile build COMPONENTS="ADCIRC ATMESH NWM" -make -f GNUmakefile build COMPONENTS="ADCIRC WW3DATA ATMESH NWM" diff --git a/build.sh b/build.sh new file mode 120000 index 00000000..7def0452 --- /dev/null +++ b/build.sh @@ -0,0 +1 @@ +scripts/build-v1.1.sh \ No newline at end of file diff --git a/compile-NEMS.x.txt b/compile-NEMS.x.txt new file mode 100644 index 00000000..a3126e4e --- /dev/null +++ b/compile-NEMS.x.txt @@ -0,0 +1,25 @@ +Patch usage: patch -p1 < patch_name + example: patch -p1 < ADC-WW3-NWM-NEMS.patch + to reverse it: + example: patch -p1 -R < ADC-WW3-NWM-NEMS.patch + +1) Run the build.sh script as: + build.sh -h or, build.sh --help + to get the list of all options available to script. + +2) Example: Run the build.sh script as: + build.sh + to use the default settings + +3) Example: Run the build.sh script as: + build.sh -plat stampede -component "ADCIRC ATMESH + to use customized settings + +3) Example: Run the build.sh script as: + build.sh -c --component="ADCIRC ATMESH + to clean a previous compilation using "make clean" + build.sh -c 2 --component="ADCIRC ATMESH + to clean a previous compilation using "make distclean" + +Panagiotis Velissariou - 12/04/2020 + diff --git a/conf/configure.nems.linux.gnu b/conf/configure.nems.linux.gnu new file mode 100644 index 00000000..d1aee7e4 --- /dev/null +++ b/conf/configure.nems.linux.gnu @@ -0,0 +1,56 @@ +## NEMS configuration file +## +## Platform: Generic/Linux +## Compiler: GNU with MPI --- needs fixing + +SHELL = /bin/sh + +################################################################################ +## Include the common configuration parts +include $(TOP)/conf/configure.nems.NUOPC + +################################################################################ +## Other settings + +NETCDF_INC = -I$(NETCDF_INCDIR) +NETCDF_LIB = -L$(NETCDF_LIBDIR) -lnetcdf + +NEMSIO_INC = -I${LIBDIR}/incmod/nemsio +NEMSIO_LIB = -L${LIBDIR} -lnemsio +SYS_LIB = + +EXTLIBS = $(NEMSIO_LIB) \ + $(NETCDF_LIB) \ + $(ESMF_LIB) \ + $(SYS_LIB) -lm + +EXTLIBS_POST = $(NEMSIO_LIB) \ + $(ESMF_LIB) \ + $(NETCDF_LIB) \ + $(SYS_LIB) +### +FC = mpif90 -g -ffree-line-length-none -fno-range-check -fbacktrace +F77 = mpiifort -g -ffree-line-length-none -fno-range-check -fbacktrace +FREE = -free +FIXED = -fixed +R8 = -r8 + +FINCS = $(ESMF_INC) $(NEMSIO_INC) $(NETCDF_INC) +#TRAPS = ??? + +FFLAGS = $(TRAPS) $(FINCS) -fp-model strict + +OPTS_NMM = -g -ffree-line-length-none -fno-range-check -fbacktrace $(FREE) + +FFLAGM_DEBUG = + +FFLAGS_NMM = $(MACROS_NWM) $(OPTS_NMM) $(FFLAGS) + +FPP = -fpp +CPP = cpp -P -traditional +CPPFLAGS = -DENABLE_SMP -DCHNK_RRTM=8 + +AR = ar +ARFLAGS = -r + +RM = rm diff --git a/conf/configure.nems.linux.intel b/conf/configure.nems.linux.intel new file mode 100644 index 00000000..a3229932 --- /dev/null +++ b/conf/configure.nems.linux.intel @@ -0,0 +1,56 @@ +## NEMS configuration file +## +## Platform: Generic/Linux +## Compiler: Intel with IntelMPI + +SHELL = /bin/sh + +################################################################################ +## Include the common configuration parts +include $(TOP)/conf/configure.nems.NUOPC + +################################################################################ +## Other settings + +NETCDF_INC = -I$(NETCDF_INCDIR) +NETCDF_LIB = -L$(NETCDF_LIBDIR) -lnetcdf + +NEMSIO_INC = -I${LIBDIR}/incmod/nemsio +NEMSIO_LIB = -L${LIBDIR} -lnemsio +SYS_LIB = + +EXTLIBS = $(NEMSIO_LIB) \ + $(NETCDF_LIB) \ + $(ESMF_LIB) \ + $(SYS_LIB) -lm + +EXTLIBS_POST = $(NEMSIO_LIB) \ + $(ESMF_LIB) \ + $(NETCDF_LIB) \ + $(SYS_LIB) +### +FC = mpiifort -g -qopenmp -mkl=sequential -align array32byte -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lpthread -qopenmp -convert big_endian -assume byterecl -mkl=sequential +F77 = mpiifort -g -qopenmp -mkl=sequential -align array32byte -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lpthread -qopenmp -convert big_endian -assume byterecl -mkl=sequential +FREE = -free +FIXED = -fixed +R8 = -r8 + +FINCS = $(ESMF_INC) $(NEMSIO_INC) $(NETCDF_INC) +#TRAPS = -g -fno-inline -no-ip -traceback -ftrapuv -fpe0 -ftz -check all -check noarg_temp_created -fp-stack-check + +FFLAGS = $(TRAPS) $(FINCS) -fp-model strict + +OPTS_NMM = -g -fno-inline -no-ip -traceback -ftrapuv -fpe0 -ftz -check all -check noarg_temp_created -fp-stack-check $(FREE) + +FFLAGM_DEBUG = + +FFLAGS_NMM = $(MACROS_NWM) $(OPTS_NMM) $(FFLAGS) + +FPP = -fpp +CPP = cpp -P -traditional +CPPFLAGS = -DENABLE_SMP -DCHNK_RRTM=8 + +AR = ar +ARFLAGS = -r + +RM = rm diff --git a/conf/configure.nems.linux.pgi b/conf/configure.nems.linux.pgi new file mode 100644 index 00000000..81674d2d --- /dev/null +++ b/conf/configure.nems.linux.pgi @@ -0,0 +1,56 @@ +## NEMS configuration file +## +## Platform: Generic/Linux +## Compiler: PGI with MPI --- needs fixing + +SHELL = /bin/sh + +################################################################################ +## Include the common configuration parts +include $(TOP)/conf/configure.nems.NUOPC + +################################################################################ +## Other settings + +NETCDF_INC = -I$(NETCDF_INCDIR) +NETCDF_LIB = -L$(NETCDF_LIBDIR) -lnetcdf + +NEMSIO_INC = -I${LIBDIR}/incmod/nemsio +NEMSIO_LIB = -L${LIBDIR} -lnemsio +SYS_LIB = + +EXTLIBS = $(NEMSIO_LIB) \ + $(NETCDF_LIB) \ + $(ESMF_LIB) \ + $(SYS_LIB) -lm + +EXTLIBS_POST = $(NEMSIO_LIB) \ + $(ESMF_LIB) \ + $(NETCDF_LIB) \ + $(SYS_LIB) +### +FC = mpif90 -g -Mextend -Minform,inform -Mbounds +F77 = mpif90 -g -Mextend -Minform,inform -Mbounds +FREE = -free +FIXED = +R8 = -r8 + +FINCS = $(ESMF_INC) $(NEMSIO_INC) $(NETCDF_INC) +#TRAPS = -g -fno-inline -no-ip -traceback -ftrapuv -fpe0 -ftz -check all -check noarg_temp_created -fp-stack-check + +FFLAGS = $(TRAPS) $(FINCS) -fp-model strict + +OPTS_NMM = -g -Mextend -Minform,inform -Mbounds $(FREE) + +FFLAGM_DEBUG = + +FFLAGS_NMM = $(MACROS_NWM) $(OPTS_NMM) $(FFLAGS) + +FPP = -fpp +CPP = cpp -P -traditional +CPPFLAGS = -DENABLE_SMP -DCHNK_RRTM=8 + +AR = ar +ARFLAGS = -r + +RM = rm diff --git a/conf/configure.nems.ndcrc.intel b/conf/configure.nems.ndcrc.intel new file mode 100644 index 00000000..ce0df05b --- /dev/null +++ b/conf/configure.nems.ndcrc.intel @@ -0,0 +1,61 @@ +## NEMS configuration file +## +## Platform: Hera +## Compiler: Intel with IntelMPI + +SHELL = /bin/sh + +################################################################################ +## Include the common configuration parts +include $(TOP)/conf/configure.nems.NUOPC +#include $(TOP)/conf/configure.ndcrc.NUOPC + + +################################################################################ +## Other settings + +NETCDF_INC = -I$(NETCDF)/include +NETCDF_LIB = -L$(NETCDF)/lib -lnetcdff + +NEMSIO_INC = -I${LIBDIR}/incmod/nemsio +NEMSIO_LIB = -L${LIBDIR} -lnemsio +SYS_LIB = + +EXTLIBS = $(NEMSIO_LIB) \ + $(NETCDF_LIB) \ + $(ESMF_LIB) \ + $(SYS_LIB) -lm + +EXTLIBS_POST = $(NEMSIO_LIB) \ + $(ESMF_LIB) \ + $(NETCDF_LIB) \ + $(SYS_LIB) +### +#FC = mpiifort -g -qopenmp -mkl=sequential -align array32byte -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lpthread -qopenmp -convert big_endian -assume byterecl -mkl=sequential +#F77 = mpiifort -g -qopenmp -mkl=sequential -align array32byte -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lpthread -qopenmp -convert big_endian -assume byterecl -mkl=sequential +FREE = -free +FC = mpif90 -g -qopenmp -mkl=sequential -align array32byte -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lpthread -qopenmp -convert big_endian -assume byterecl -mkl=sequential +F77 = mpif90 -g -qopenmp -mkl=sequential -align array32byte -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lpthread -qopenmp -convert big_endian -assume byterecl -mkl=sequential +FIXED = -fixed +R8 = -r8 +CC = mpicc + +FINCS = $(ESMF_INC) $(NEMSIO_INC) $(NETCDF_INC) +#TRAPS = -g -fno-inline -no-ip -traceback -ftrapuv -fpe0 -ftz -check all -check noarg_temp_created -fp-stack-check + +FFLAGS = $(TRAPS) $(FINCS) -fp-model strict + +OPTS_NMM = -g -fno-inline -no-ip -traceback -ftrapuv -fpe0 -ftz -check all -check noarg_temp_created -fp-stack-check $(FREE) + +FFLAGM_DEBUG = + +FFLAGS_NMM = $(MACROS_NWM) $(OPTS_NMM) $(FFLAGS) + +FPP = -fpp +CPP = cpp -P -traditional +CPPFLAGS = -DENABLE_SMP -DCHNK_RRTM=8 + +AR = ar +ARFLAGS = -r + +RM = rm diff --git a/conf/externals.nems b/conf/externals.nems new file mode 100644 index 00000000..7d3e85ad --- /dev/null +++ b/conf/externals.nems @@ -0,0 +1,2 @@ +# Location of external components + diff --git a/conf/externals.nems.cheyenne b/conf/externals.nems.cheyenne new file mode 100644 index 00000000..9feed939 --- /dev/null +++ b/conf/externals.nems.cheyenne @@ -0,0 +1,26 @@ +# Location of external components + +SATM_DIR= +XATM_DIR= +SLND_DIR= +XLND_DIR= +NOAH_DIR= +NOAHMP_DIR= +SICE_DIR= +XICE_DIR= +CICE_DIR= +SOCN_DIR= +XOCN_DIR= +MOM5_DIR= +HYCOM_DIR= +POM_DIR= +SWAV_DIR= +XWAV_DIR= +WW3_DIR= +SIPM_DIR= +XIPM_DIR= +IPE_DIR= +SHYD_DIR= +XHYD_DIR= +WRFHYDRO_DIR= +LIS_DIR= diff --git a/conf/externals.nems.gaea b/conf/externals.nems.gaea new file mode 100644 index 00000000..9feed939 --- /dev/null +++ b/conf/externals.nems.gaea @@ -0,0 +1,26 @@ +# Location of external components + +SATM_DIR= +XATM_DIR= +SLND_DIR= +XLND_DIR= +NOAH_DIR= +NOAHMP_DIR= +SICE_DIR= +XICE_DIR= +CICE_DIR= +SOCN_DIR= +XOCN_DIR= +MOM5_DIR= +HYCOM_DIR= +POM_DIR= +SWAV_DIR= +XWAV_DIR= +WW3_DIR= +SIPM_DIR= +XIPM_DIR= +IPE_DIR= +SHYD_DIR= +XHYD_DIR= +WRFHYDRO_DIR= +LIS_DIR= diff --git a/conf/externals.nems.hera b/conf/externals.nems.hera index e30e7ff8..9feed939 100755 --- a/conf/externals.nems.hera +++ b/conf/externals.nems.hera @@ -1,4 +1,4 @@ -# Location of external components on Theia +# Location of external components SATM_DIR= XATM_DIR= diff --git a/conf/externals.nems.hera.rej b/conf/externals.nems.hera.rej new file mode 100644 index 00000000..a8f60eee --- /dev/null +++ b/conf/externals.nems.hera.rej @@ -0,0 +1,8 @@ +--- conf/externals.nems.hera 2020-12-04 14:36:35.000000000 -0600 ++++ conf/externals.nems.hera 2020-12-09 22:33:55.670362901 -0600 +@@ -1,4 +1,4 @@ +-# Location of external components on Theia ++# Location of external components + + SATM_DIR= + XATM_DIR= diff --git a/conf/externals.nems.jet b/conf/externals.nems.jet new file mode 100644 index 00000000..9feed939 --- /dev/null +++ b/conf/externals.nems.jet @@ -0,0 +1,26 @@ +# Location of external components + +SATM_DIR= +XATM_DIR= +SLND_DIR= +XLND_DIR= +NOAH_DIR= +NOAHMP_DIR= +SICE_DIR= +XICE_DIR= +CICE_DIR= +SOCN_DIR= +XOCN_DIR= +MOM5_DIR= +HYCOM_DIR= +POM_DIR= +SWAV_DIR= +XWAV_DIR= +WW3_DIR= +SIPM_DIR= +XIPM_DIR= +IPE_DIR= +SHYD_DIR= +XHYD_DIR= +WRFHYDRO_DIR= +LIS_DIR= diff --git a/conf/externals.nems.linux b/conf/externals.nems.linux new file mode 100644 index 00000000..7d3e85ad --- /dev/null +++ b/conf/externals.nems.linux @@ -0,0 +1,2 @@ +# Location of external components + diff --git a/conf/externals.nems.macosx b/conf/externals.nems.macosx new file mode 100644 index 00000000..7d3e85ad --- /dev/null +++ b/conf/externals.nems.macosx @@ -0,0 +1,2 @@ +# Location of external components + diff --git a/conf/externals.nems.orion b/conf/externals.nems.orion new file mode 100644 index 00000000..9feed939 --- /dev/null +++ b/conf/externals.nems.orion @@ -0,0 +1,26 @@ +# Location of external components + +SATM_DIR= +XATM_DIR= +SLND_DIR= +XLND_DIR= +NOAH_DIR= +NOAHMP_DIR= +SICE_DIR= +XICE_DIR= +CICE_DIR= +SOCN_DIR= +XOCN_DIR= +MOM5_DIR= +HYCOM_DIR= +POM_DIR= +SWAV_DIR= +XWAV_DIR= +WW3_DIR= +SIPM_DIR= +XIPM_DIR= +IPE_DIR= +SHYD_DIR= +XHYD_DIR= +WRFHYDRO_DIR= +LIS_DIR= diff --git a/conf/externals.nems.stampede b/conf/externals.nems.stampede new file mode 100644 index 00000000..9feed939 --- /dev/null +++ b/conf/externals.nems.stampede @@ -0,0 +1,26 @@ +# Location of external components + +SATM_DIR= +XATM_DIR= +SLND_DIR= +XLND_DIR= +NOAH_DIR= +NOAHMP_DIR= +SICE_DIR= +XICE_DIR= +CICE_DIR= +SOCN_DIR= +XOCN_DIR= +MOM5_DIR= +HYCOM_DIR= +POM_DIR= +SWAV_DIR= +XWAV_DIR= +WW3_DIR= +SIPM_DIR= +XIPM_DIR= +IPE_DIR= +SHYD_DIR= +XHYD_DIR= +WRFHYDRO_DIR= +LIS_DIR= diff --git a/conf/externals.nems.wcoss b/conf/externals.nems.wcoss new file mode 100644 index 00000000..9feed939 --- /dev/null +++ b/conf/externals.nems.wcoss @@ -0,0 +1,26 @@ +# Location of external components + +SATM_DIR= +XATM_DIR= +SLND_DIR= +XLND_DIR= +NOAH_DIR= +NOAHMP_DIR= +SICE_DIR= +XICE_DIR= +CICE_DIR= +SOCN_DIR= +XOCN_DIR= +MOM5_DIR= +HYCOM_DIR= +POM_DIR= +SWAV_DIR= +XWAV_DIR= +WW3_DIR= +SIPM_DIR= +XIPM_DIR= +IPE_DIR= +SHYD_DIR= +XHYD_DIR= +WRFHYDRO_DIR= +LIS_DIR= diff --git a/modulefiles/PlatformFuncs b/modulefiles/PlatformFuncs new file mode 100644 index 00000000..32316f65 --- /dev/null +++ b/modulefiles/PlatformFuncs @@ -0,0 +1,101 @@ +########################################################################### +### NEMS Build System +### PlatformFuncs :: Utility functions +### +### Author: Panagiotis Velissariou +########################################################################### + +get_env_hdf5() +{ +# if [ "${_found_hdf5:-FALSE}" = "FALSE" ]; then + _found_hdf5=FALSE + if [ -n "${HDF5:+1}" ]; then + HDF5="${HDF5}" + export HDF5HOME="${HDF5}" + HDF5_DIR="${HDF5}" + HDF5_PATH="${HDF5}" + HDF5_ROOT="${HDF5}" + _found_hdf5=TRUE + else + for _var in DIR HOME PATH ROOT + do + _var_val="$(eval "echo \"\$HDF5${_var}\"")" + if [ -n "${_var_val:+1}" ]; then + HDF5="${_var_val}" + export HDF5HOME="${_var_val}" + HDF5_DIR="${_var_val}" + HDF5_PATH="${_var_val}" + HDF5_ROOT="${_var_val}" + _found_hdf5=TRUE + break + else + _var_val="$(eval "echo \"\$HDF5_${_var}\"")" + if [ -n "${_var_val:+1}" ]; then + HDF5="${_var_val}" + export HDF5HOME="${_var_val}" + HDF5_DIR="${_var_val}" + HDF5_PATH="${_var_val}" + HDF5_ROOT="${_var_val}" + _found_hdf5=TRUE + break + fi + fi + done + fi + unset _name _var _var_val +# fi + + return 0 +} + + +get_env_netcdf() +{ +# if [ "${_found_netcdf:-FALSE}" = "FALSE" ]; then + export _found_netcdf=FALSE + for _name in NETCDF NETCDF4 NetCDF NetCDF4 + do + if [ "${_found_netcdf}" = "TRUE" ]; then + break + fi + + _var_val="$(eval "echo \"\$${_name}\"")" + if [ -n "${_var_val:+1}" ]; then + export NETCDF="${_var_val}" + export NETCDFHOME="${_var_val}" + export NETCDF_DIR="${_var_val}" + export NETCDF_PATH="${_var_val}" + export NETCDF_ROOT="${_var_val}" + export _found_netcdf=TRUE + else + for _var in DIR HOME PATH ROOT + do + _var_val="$(eval "echo \"\$${_name}${_var}\"")" + if [ -n "${_var_val:+1}" ]; then + export NETCDF="${_var_val}" + export NETCDFHOME="${_var_val}" + export NETCDF_DIR="${_var_val}" + export NETCDF_PATH="${_var_val}" + export NETCDF_ROOT="${_var_val}" + export _found_netcdf=TRUE + break + else + _var_val="$(eval "echo \"\$${_name}_${_var}\"")" + if [ -n "${_var_val:+1}" ]; then + export NETCDF="${_var_val}" + export NETCDFHOME="${_var_val}" + export NETCDF_DIR="${_var_val}" + export NETCDF_PATH="${_var_val}" + export NETCDF_ROOT="${_var_val}" + export _found_netcdf=TRUE + break + fi + fi + done + fi + done + unset _name _var _var_val +# fi + + return 0 +} diff --git a/modulefiles/envmodules_gnu.cheyenne b/modulefiles/envmodules_gnu.cheyenne new file mode 100644 index 00000000..23899380 --- /dev/null +++ b/modulefiles/envmodules_gnu.cheyenne @@ -0,0 +1,34 @@ +#!/bin/bash-*-Shell-script-modules*- +#---------- +[[ "$0" == "bash" || "$0" == "-bash" ]] && retv=return || retv=exit +echo "$(basename ${BASH_SOURCE[0]}) :: This environment is either not configured or not supported" +echo " Exiting ..." +${retv} 1 +#---------- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load gcc impi +module load szip hdf5 +module load netcdf + +module use /contrib/modulefiles +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_gnu.gaea b/modulefiles/envmodules_gnu.gaea new file mode 100644 index 00000000..b7e83e4a --- /dev/null +++ b/modulefiles/envmodules_gnu.gaea @@ -0,0 +1,28 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load gcc impi +module load szip hdf5 +module load netcdf + +module use /contrib/modulefiles +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_gnu.hera b/modulefiles/envmodules_gnu.hera new file mode 100644 index 00000000..23899380 --- /dev/null +++ b/modulefiles/envmodules_gnu.hera @@ -0,0 +1,34 @@ +#!/bin/bash-*-Shell-script-modules*- +#---------- +[[ "$0" == "bash" || "$0" == "-bash" ]] && retv=return || retv=exit +echo "$(basename ${BASH_SOURCE[0]}) :: This environment is either not configured or not supported" +echo " Exiting ..." +${retv} 1 +#---------- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load gcc impi +module load szip hdf5 +module load netcdf + +module use /contrib/modulefiles +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_gnu.jet b/modulefiles/envmodules_gnu.jet new file mode 100644 index 00000000..23899380 --- /dev/null +++ b/modulefiles/envmodules_gnu.jet @@ -0,0 +1,34 @@ +#!/bin/bash-*-Shell-script-modules*- +#---------- +[[ "$0" == "bash" || "$0" == "-bash" ]] && retv=return || retv=exit +echo "$(basename ${BASH_SOURCE[0]}) :: This environment is either not configured or not supported" +echo " Exiting ..." +${retv} 1 +#---------- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load gcc impi +module load szip hdf5 +module load netcdf + +module use /contrib/modulefiles +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_gnu.linux b/modulefiles/envmodules_gnu.linux new file mode 100644 index 00000000..d8646ca5 --- /dev/null +++ b/modulefiles/envmodules_gnu.linux @@ -0,0 +1,31 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load intel impi +#module load szip hdf5 +module load netcdf + +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. +funcs="$( find . -type f -name "PlatformFuncs" | head -n 1 )" +[ -f "${funcs}" ] && source "${funcs}" +unset funcs + + +get_env_hdf5 +get_env_netcdf + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_gnu.local b/modulefiles/envmodules_gnu.local new file mode 100644 index 00000000..b7e83e4a --- /dev/null +++ b/modulefiles/envmodules_gnu.local @@ -0,0 +1,28 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load gcc impi +module load szip hdf5 +module load netcdf + +module use /contrib/modulefiles +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_gnu.macosx b/modulefiles/envmodules_gnu.macosx new file mode 100644 index 00000000..5cb700e1 --- /dev/null +++ b/modulefiles/envmodules_gnu.macosx @@ -0,0 +1,27 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +#module purge +#module load gcc impi +#module load szip hdf5 +#module load netcdf + +#module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_gnu.orion b/modulefiles/envmodules_gnu.orion new file mode 100644 index 00000000..d90402b3 --- /dev/null +++ b/modulefiles/envmodules_gnu.orion @@ -0,0 +1,27 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load gcc impi +module load szip hdf5 +module load netcdf + +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5_ROOT} +export NETCDFHOME=${NETCDF_ROOT} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDF_INCLUDE_DIRS} +export NETCDF_LIBDIR=${NETCDF_LIBRARY_DIRS} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_gnu.stampede b/modulefiles/envmodules_gnu.stampede new file mode 100644 index 00000000..2cc88d56 --- /dev/null +++ b/modulefiles/envmodules_gnu.stampede @@ -0,0 +1,28 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load gcc impi +module load hdf5 +module load netcdf + +module use /work/07380/panvel/Modules/modulefiles +module load impi-intel/esmf-8.0.1 + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${TACC_HDF5_DIR} +export NETCDFHOME=${TACC_NETCDF_DIR} + +export NETCDF_CONFIG=${TACC_NETCDF_BIN}/nc-config +export NETCDF_INCDIR=${TACC_NETCDF_INC} +export NETCDF_LIBDIR=${TACC_NETCDF_LIB} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_gnu.wcoss b/modulefiles/envmodules_gnu.wcoss new file mode 100644 index 00000000..55c30263 --- /dev/null +++ b/modulefiles/envmodules_gnu.wcoss @@ -0,0 +1,28 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +#module load gcc impi +#module load szip hdf5 +#module load netcdf + +#module use /contrib/modulefiles +#module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_intel.cheyenne b/modulefiles/envmodules_intel.cheyenne new file mode 100644 index 00000000..4358bc8a --- /dev/null +++ b/modulefiles/envmodules_intel.cheyenne @@ -0,0 +1,34 @@ +#!/bin/bash-*-Shell-script-modules*- +#---------- +[[ "$0" == "bash" || "$0" == "-bash" ]] && retv=return || retv=exit +echo "$(basename ${BASH_SOURCE[0]}) :: This environment is either not configured or not supported" +echo " Exiting ..." +${retv} 1 +#---------- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load intel impi +module load szip hdf5 +module load netcdf + +module use /contrib/modulefiles +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_intel.gaea b/modulefiles/envmodules_intel.gaea new file mode 100644 index 00000000..4358bc8a --- /dev/null +++ b/modulefiles/envmodules_intel.gaea @@ -0,0 +1,34 @@ +#!/bin/bash-*-Shell-script-modules*- +#---------- +[[ "$0" == "bash" || "$0" == "-bash" ]] && retv=return || retv=exit +echo "$(basename ${BASH_SOURCE[0]}) :: This environment is either not configured or not supported" +echo " Exiting ..." +${retv} 1 +#---------- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load intel impi +module load szip hdf5 +module load netcdf + +module use /contrib/modulefiles +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_intel.hera b/modulefiles/envmodules_intel.hera new file mode 100644 index 00000000..6f8b0aa5 --- /dev/null +++ b/modulefiles/envmodules_intel.hera @@ -0,0 +1,29 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load intel/18.0.5.274 impi/2018.0.4 +module load szip + +module use /home/emc.nemspara/SOFT-hera/modulefiles +module load hdf5_parallel/1.10.6.release +module load netcdf_parallel/4.7.4.release +module load esmf/8.1.0bs36g + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_intel.jet b/modulefiles/envmodules_intel.jet new file mode 100644 index 00000000..4358bc8a --- /dev/null +++ b/modulefiles/envmodules_intel.jet @@ -0,0 +1,34 @@ +#!/bin/bash-*-Shell-script-modules*- +#---------- +[[ "$0" == "bash" || "$0" == "-bash" ]] && retv=return || retv=exit +echo "$(basename ${BASH_SOURCE[0]}) :: This environment is either not configured or not supported" +echo " Exiting ..." +${retv} 1 +#---------- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load intel impi +module load szip hdf5 +module load netcdf + +module use /contrib/modulefiles +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_intel.linux b/modulefiles/envmodules_intel.linux new file mode 100644 index 00000000..d8646ca5 --- /dev/null +++ b/modulefiles/envmodules_intel.linux @@ -0,0 +1,31 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load intel impi +#module load szip hdf5 +module load netcdf + +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. +funcs="$( find . -type f -name "PlatformFuncs" | head -n 1 )" +[ -f "${funcs}" ] && source "${funcs}" +unset funcs + + +get_env_hdf5 +get_env_netcdf + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_intel.local b/modulefiles/envmodules_intel.local new file mode 100644 index 00000000..6f8b0aa5 --- /dev/null +++ b/modulefiles/envmodules_intel.local @@ -0,0 +1,29 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load intel/18.0.5.274 impi/2018.0.4 +module load szip + +module use /home/emc.nemspara/SOFT-hera/modulefiles +module load hdf5_parallel/1.10.6.release +module load netcdf_parallel/4.7.4.release +module load esmf/8.1.0bs36g + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_intel.macosx b/modulefiles/envmodules_intel.macosx new file mode 100644 index 00000000..3b61d299 --- /dev/null +++ b/modulefiles/envmodules_intel.macosx @@ -0,0 +1,27 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +#module purge +#module load intel impi +#module load szip hdf5 +#module load netcdf + +#module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_intel.orion b/modulefiles/envmodules_intel.orion new file mode 100644 index 00000000..0e915c9f --- /dev/null +++ b/modulefiles/envmodules_intel.orion @@ -0,0 +1,27 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load intel impi +module load szip hdf5 +module load netcdf + +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5_ROOT} +export NETCDFHOME=${NETCDF_ROOT} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDF_INCLUDE_DIRS} +export NETCDF_LIBDIR=${NETCDF_LIBRARY_DIRS} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_intel.stampede b/modulefiles/envmodules_intel.stampede new file mode 100644 index 00000000..e613292e --- /dev/null +++ b/modulefiles/envmodules_intel.stampede @@ -0,0 +1,28 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load intel impi +module load hdf5 +module load netcdf + +module use /work/07380/panvel/Modules/modulefiles +module load impi-intel/esmf-8.0.1 + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${TACC_HDF5_DIR} +export NETCDFHOME=${TACC_NETCDF_DIR} + +export NETCDF_CONFIG=${TACC_NETCDF_BIN}/nc-config +export NETCDF_INCDIR=${TACC_NETCDF_INC} +export NETCDF_LIBDIR=${TACC_NETCDF_LIB} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_intel.wcoss b/modulefiles/envmodules_intel.wcoss new file mode 100644 index 00000000..9f0662ad --- /dev/null +++ b/modulefiles/envmodules_intel.wcoss @@ -0,0 +1,28 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +#module load intel impi +#module load szip hdf5 +#module load netcdf + +#module use /contrib/modulefiles +#module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_pgi.cheyenne b/modulefiles/envmodules_pgi.cheyenne new file mode 100644 index 00000000..ecc1c9f0 --- /dev/null +++ b/modulefiles/envmodules_pgi.cheyenne @@ -0,0 +1,34 @@ +#!/bin/bash-*-Shell-script-modules*- +#---------- +[[ "$0" == "bash" || "$0" == "-bash" ]] && retv=return || retv=exit +echo "$(basename ${BASH_SOURCE[0]}) :: This environment is either not configured or not supported" +echo " Exiting ..." +${retv} 1 +#---------- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load pgi impi +module load szip hdf5 +module load netcdf + +module use /contrib/modulefiles +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_pgi.gaea b/modulefiles/envmodules_pgi.gaea new file mode 100644 index 00000000..b3f09057 --- /dev/null +++ b/modulefiles/envmodules_pgi.gaea @@ -0,0 +1,31 @@ +#!/bin/bash-*-Shell-script-modules*- +#---------- +[[ "$0" == "bash" || "$0" == "-bash" ]] && retv=return || retv=exit +echo "$(basename ${BASH_SOURCE[0]}) :: This environment is either not configured or not supported" +echo " Exiting ..." +${retv} 1 +#---------- + +#################### +### (1) Load all needed environment modules. +module purge +module load pgi impi +module load szip hdf5 +module load netcdf + +module use /contrib/modulefiles +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_pgi.hera b/modulefiles/envmodules_pgi.hera new file mode 100644 index 00000000..ecc1c9f0 --- /dev/null +++ b/modulefiles/envmodules_pgi.hera @@ -0,0 +1,34 @@ +#!/bin/bash-*-Shell-script-modules*- +#---------- +[[ "$0" == "bash" || "$0" == "-bash" ]] && retv=return || retv=exit +echo "$(basename ${BASH_SOURCE[0]}) :: This environment is either not configured or not supported" +echo " Exiting ..." +${retv} 1 +#---------- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load pgi impi +module load szip hdf5 +module load netcdf + +module use /contrib/modulefiles +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_pgi.jet b/modulefiles/envmodules_pgi.jet new file mode 100644 index 00000000..ecc1c9f0 --- /dev/null +++ b/modulefiles/envmodules_pgi.jet @@ -0,0 +1,34 @@ +#!/bin/bash-*-Shell-script-modules*- +#---------- +[[ "$0" == "bash" || "$0" == "-bash" ]] && retv=return || retv=exit +echo "$(basename ${BASH_SOURCE[0]}) :: This environment is either not configured or not supported" +echo " Exiting ..." +${retv} 1 +#---------- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load pgi impi +module load szip hdf5 +module load netcdf + +module use /contrib/modulefiles +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_pgi.linux b/modulefiles/envmodules_pgi.linux new file mode 100644 index 00000000..ca6adc62 --- /dev/null +++ b/modulefiles/envmodules_pgi.linux @@ -0,0 +1,32 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load intel impi +#module load szip hdf5 +module load netcdf + +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. +funcs="$( find . -type f -name "PlatformFuncs" | head -n 1 )" +[ -f "${funcs}" ] && source "${funcs}" +unset funcs + + +get_env_hdf5 +get_env_netcdf + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} + diff --git a/modulefiles/envmodules_pgi.local b/modulefiles/envmodules_pgi.local new file mode 100644 index 00000000..ecc1c9f0 --- /dev/null +++ b/modulefiles/envmodules_pgi.local @@ -0,0 +1,34 @@ +#!/bin/bash-*-Shell-script-modules*- +#---------- +[[ "$0" == "bash" || "$0" == "-bash" ]] && retv=return || retv=exit +echo "$(basename ${BASH_SOURCE[0]}) :: This environment is either not configured or not supported" +echo " Exiting ..." +${retv} 1 +#---------- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load pgi impi +module load szip hdf5 +module load netcdf + +module use /contrib/modulefiles +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_pgi.macosx b/modulefiles/envmodules_pgi.macosx new file mode 100644 index 00000000..e0e25e47 --- /dev/null +++ b/modulefiles/envmodules_pgi.macosx @@ -0,0 +1,27 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +#module purge +#module load pgi impi +#module load szip hdf5 +#module load netcdf + +#module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_pgi.orion b/modulefiles/envmodules_pgi.orion new file mode 100644 index 00000000..437d2940 --- /dev/null +++ b/modulefiles/envmodules_pgi.orion @@ -0,0 +1,27 @@ +#!/bin/bash-*-Shell-script-modules*- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load pgi impi +module load szip hdf5 +module load netcdf + +module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5_ROOT} +export NETCDFHOME=${NETCDF_ROOT} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDF_INCLUDE_DIRS} +export NETCDF_LIBDIR=${NETCDF_LIBRARY_DIRS} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_pgi.stampede b/modulefiles/envmodules_pgi.stampede new file mode 100644 index 00000000..1effcc1e --- /dev/null +++ b/modulefiles/envmodules_pgi.stampede @@ -0,0 +1,34 @@ +#!/bin/bash-*-Shell-script-modules*- +#---------- +[[ "$0" == "bash" || "$0" == "-bash" ]] && retv=return || retv=exit +echo "$(basename ${BASH_SOURCE[0]}) :: This environment is either not configured or not supported" +echo " Exiting ..." +${retv} 1 +#---------- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +module load pgi impi +module load hdf5 +module load netcdf + +module use /work/07380/panvel/Modules/modulefiles +module load impi-intel/esmf-8.0.1 + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${TACC_HDF5_DIR} +export NETCDFHOME=${TACC_NETCDF_DIR} + +export NETCDF_CONFIG=${TACC_NETCDF_BIN}/nc-config +export NETCDF_INCDIR=${TACC_NETCDF_INC} +export NETCDF_LIBDIR=${TACC_NETCDF_LIB} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/envmodules_pgi.wcoss b/modulefiles/envmodules_pgi.wcoss new file mode 100644 index 00000000..93b0c6d4 --- /dev/null +++ b/modulefiles/envmodules_pgi.wcoss @@ -0,0 +1,34 @@ +#!/bin/bash-*-Shell-script-modules*- +#---------- +[[ "$0" == "bash" || "$0" == "-bash" ]] && retv=return || retv=exit +echo "$(basename ${BASH_SOURCE[0]}) :: This environment is either not configured or not supported" +echo " Exiting ..." +${retv} 1 +#---------- + +# This script is responsible for loading modules that are +# compatible with the NUOPC Layer version used in NEMS. + +#################### +### (1) Load all needed environment modules. +module purge +#module load pgi impi +#module load szip hdf5 +#module load netcdf + +#module use /contrib/modulefiles +#module load esmf + + +#################### +### (2) Set some environments varaiables related to the loaded +### modules and required to compile the NEMS application properly. + +export HDF5HOME=${HDF5} +export NETCDFHOME=${NETCDF} + +export NETCDF_CONFIG=${NETCDFHOME:+${NETCDFHOME}/bin/nc-config} +export NETCDF_INCDIR=${NETCDFHOME:+${NETCDFHOME}/include} +export NETCDF_LIBDIR=${NETCDFHOME:+${NETCDFHOME}/lib} + +export ESMFMKFILE=${ESMFMKFILE} diff --git a/modulefiles/hera/ESMF_NUOPC b/modulefiles/hera/ESMF_NUOPC deleted file mode 100644 index 591471f8..00000000 --- a/modulefiles/hera/ESMF_NUOPC +++ /dev/null @@ -1,17 +0,0 @@ -#%Module###################################################################### - -# This script is responsible for loading modules that are compatible with -# the NUOPC Layer version used in NEMS. - -module load intel/18.0.5.274 -module load szip/2.1 -module load hdf5/1.10.4 -module load impi/2018.0.4 -module load netcdf/4.6.1 - -# Environment for ESMF v8.0.0 beta snapshot 48g -module use /home/emc.nemspara/SOFT-hera/modulefiles -module load esmf/8.0.0bs48g -# - -# diff --git a/modulefiles/hera/coastal_app b/modulefiles/hera/coastal_app deleted file mode 100755 index bdb5d3e8..00000000 --- a/modulefiles/hera/coastal_app +++ /dev/null @@ -1,39 +0,0 @@ -#%Module###################################################################### -## -## NEMS coastal_app Prerequisites: hera - -##### rem by saeed ### proc ModulesHelp {} { -##### rem by saeed ### puts stderr "\tcit - loads modules required for building and running FV3 under NEMS on Theia" -##### rem by saeed ### } - -##### rem by saeed ### module-whatis "loads NEMS FV3 prerequisites for Theia" - -# NOTE: the "module purge" and loading of the module command are -# handled by the module-setup.sh (or .csh) script. - -## -## load programming environment -## this typically includes compiler, MPI and job scheduler -## - -module load intel/18.0.5.274 -module load szip/2.1 -module load hdf5/1.10.4 -module load impi/2018.0.4 -module load netcdf/4.6.1 - -#This below library is for esmf 8.0 on Hera, compiled and tested successfully for NWM-NUOPC CAP -#module use /home/emc.nemspara/SOFT-hera/modulefiles - -# for current NEMS -module load esmf/7.1.0r - - -#module use /scratch2/NCEPDEV/nwprod/NCEPLIBS/modulefiles -#module load w3nco/v2.0.6 -#module load w3emc/v2.0.5 - - - - - diff --git a/modulefiles/theia/theia_modules b/modulefiles/theia/theia_modules deleted file mode 100755 index bd3ae7b1..00000000 --- a/modulefiles/theia/theia_modules +++ /dev/null @@ -1,41 +0,0 @@ -#%Module###################################################################### -## -## NEMS FV3 Prerequisites: Theia - -##proc ModulesHelp {} { -## puts stderr "\tcit - loads modules required for building and running FV3 under NEMS on Theia" -##} - -##module-whatis "loads NEMS FV3 prerequisites for Theia" - -# NOTE: the "module purge" and loading of the module command are -# handled by the module-setup.sh (or .csh) script. - -## -## load programming environment -## this typically includes compiler, MPI and job scheduler -## -module load intel/15.1.133 -module load impi/5.0.3.048 -module load hdf5 -module load netcdf/4.3.0 -module load esmf/7.0.2 - -## From old NEMS -#source /etc/profile -#module load intel/14.0.2 impi/4.1.3.048 netcdf/4.3.0 -#module use /scratch4/NCEPDEV/nems/save/Gerhard.Theurich/Modulefiles -#module load esmf/7.0.0 -#module use /scratch4/NCEPDEV/nems/save/Daniel.Rosen/Modulefiles/theia -#module load jasper/1.900.1 gribapi/1.12.3 - -## -## load nwprod libraries -## -module use -a /scratch3/NCEPDEV/nwprod/lib/modulefiles - -#module load bacio/v2.0.1 -#module load sp/v2.0.2 -#module load ip/v2.0.0 -module load w3nco/v2.0.6 -module load w3emc/v2.0.5 diff --git a/scripts/build-v1.0.sh b/scripts/build-v1.0.sh new file mode 100644 index 00000000..ba6f6cb4 --- /dev/null +++ b/scripts/build-v1.0.sh @@ -0,0 +1,214 @@ +#!/bin/bash + +########################################################################### +### Author: Panagiotis Velissariou +### +### Version - 1.0 Fri Dec 04 2020 +########################################################################### + + +###==================== +# Make sure that the current working directory is in the PATH +[[ ! :$PATH: == *:".":* ]] && export PATH="${PATH}:." + + +# Get the directory where the script is located +scrNAME="${BASH_SOURCE[0]}" +if [[ $(uname -s) == Darwin ]]; then +# readonly scrDIR="$(cd "$(dirname "$(greadlink -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P)" + readonly scrDIR="$(cd "$(dirname "$(grealpath -s "${scrNAME}" )" )" && pwd -P)" +else +# readonly scrDIR="$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P)" + readonly scrDIR="$(cd "$(dirname "$(realpath -s "${scrNAME}")" )" && pwd -P)" +fi + +funcs="$( find ${scrDIR} -type f -name "functions_build" | head -n 1 )" +if [ -f "${funcs}" ]; then + source "${funcs}" +else + echo " ### ERROR :: in ${scrNAME}" + echo " Cannot load the required file: ${funcs}" + echo " Exiting now ..." + echo + exit 1 +fi + +unset funcs +###==================== + + +######### +# Call ParseArgs to get the user input. +ParseArgs "${@}" + + +########## +# Set the variables for this script +CLEAN=${MY_CLEAN:-0} + +[ -n "${MY_COMPILER:+1}" ] && COMPILER="$( toLOWER "${MY_COMPILER}" )" + +[ -n "${MY_COMPONENT:+1}" ] && COMPONENT="$( toUPPER "${MY_COMPONENT}" )" + +[ -n "${MY_OS:+1}" ] && OS="$( toLOWER "${MY_OS}" )" + +[ "${MY_PARMAKE:0}" -gt 1 ] && PARMAKE=${MY_PARMAKE} + +[ -n "${MY_PLATFORM:+1}" ] && PLATFORM="$( toLOWER "${MY_PLATFORM}" )" + +[ -n "${MY_VERBOSE:+1}" ] && VERBOSE="$( toLOWER "${MY_VERBOSE}" )" + +modFILE="envmodules${COMPILER:+_${COMPILER}}${PLATFORM:+.${PLATFORM}}" + +# Customize the NEMS.x filename to include the component names +if [ -n "${COMPONENT:+1}" ]; then + compFNAME="$( strTrim "$( toLOWER "${COMPONENT}" )" )" + compFNAME="$( echo "${compFNAME}" | sed 's/ /_/g' )" +fi + +# Export some environment variables for NEMS +export NEMS_COMPILER=${COMPILER} +########## + + +########## +# Get the project directories and perform a basic check on them +readonly nemsDIR="${NEMS_DIR:-${scrDIR}/NEMS}" +if [ ! -f "${nemsDIR}/NEMSAppBuilder" ]; then + echo "The project directory \"${nemsDIR}\" does not appear to contain NEMSAppBuilder." + echo "Is this the correct NEMS directory?" + echo "You might need to set the environment variable NEMS_DIR before running this script." + echo "Exiting ..." + exit 1 +fi + +readonly modDIR="${NEMSMODS_DIR:-${scrDIR}/modulefiles}" +if [ ! -f "${modDIR}/${modFILE}" ]; then + echo "The modulefiles directory \"${modDIR}\" does not appear to contain module: ${modFILE}." + echo "Is this the correct modulefiles directory?" + echo "You might need to set the environment variable NEMSMODS_DIR before running this script." + echo "Exiting ..." + exit 1 +fi +########## + + +########## +# If the user requested to clean the build folder, do the cleaning end exit +if [ ${CLEAN:-0} -ge 1 ]; then + echo "User requested to only clean the project. Cleaning ..." + + pushd ${nemsDIR} >/dev/null 2>&1 + [ ${CLEAN:-0} -eq 1 ] && compileNems clean + [ ${CLEAN:-0} -eq 2 ] && compileNems distclean + popd >/dev/null 2>&1 + + exit 0 +fi +########## + + +########## +# Source the environment module +source ${modDIR}/${modFILE} + +component_ww3="$( echo "${COMPONENT}" | sed 's/ /:/g' )" +if [[ :${component_ww3}: == *:"WW3":* ]]; then + export WW3_CONFOPT="${COMPILER}" + export WW3_COMP="${COMPILER}" + export WWATCH3_NETCDF=NC4 +fi +########## + + +########## +# Get a final user response for the variables +echo +echo "The following variables are defined:" +echo " CLEAN = ${CLEAN}" +echo " COMPILER = ${COMPILER:-Undefined, Supported values are: [${MY_COMPILING_SYTEMS}]}" +echo " NEMS_COMPILER = ${NEMS_COMPILER}" +if [[ :${component_ww3}: == *:"WW3":* ]]; then + echo " WW3_CONFOPT = ${WW3_CONFOPT}" + echo " WW3_COMP = ${WW3_COMP}" + echo " WWATCH3_NETCDF = ${WWATCH3_NETCDF}" +fi +echo " COMPONENTS = ${COMPONENT:-Undefined, Supported values are: [${MY_COMPONENT_LIST}]}" +echo " OS = ${OS}" +echo " PLATFORM = ${PLATFORM}" +echo " VERBOSE = ${VERBOSE}" +echo +echo " HDF5HOME = ${HDF5HOME}" +echo " NETCDFHOME = ${NETCDFHOME}" +echo " NETCDF_INCDIR = ${NETCDF_INCDIR}" +echo " NETCDF_LIBDIR = ${NETCDF_LIBDIR}" +echo +echo " ESMFMKFILE = ${ESMFMKFILE}" +echo + +module list + +echo_response= +while [ -z "${echo_response}" ] ; do + echo -n "Are these values correct? [y/n]: " + read echo_response + echo_response="$( getYesNo "${echo_response}" )" +done + +if [ "${echo_response:-no}" = "no" ]; then + echo + echo "User responded: ${echo_response}" + echo "Exiting now ..." + echo + exit 1 +fi + +unset echo_response +########## + + +############################################################ +### START THE CALCULATIONS +############################################################ + +########## +# Compile the project +compileERR=0 +pushd ${nemsDIR} >/dev/null 2>&1 + case ${CLEAN:-0} in + -1 ) + compileNems clean + compileERR=$? + ;; + -2 ) + compileNems distclean + compileERR=$? + ;; + -3 ) + compileNems noclean + compileERR=$? + ;; + * ) + compileNems clean + compileERR=$? + ;; + esac + + if [ ${compileERR} -eq 0 ]; then + compileNems build + compileERR=$? + fi + + if [ ${compileERR} -eq 0 ]; then + if [ -f exe/NEMS.x ]; then + cp -p exe/NEMS.x exe/NEMS${compFNAME:+-${compFNAME}}.x + fi + fi +popd >/dev/null 2>&1 + +########## +# Install all data, executables, libraries in a common directory +[ ${compileERR:-0} -eq 0 ] && installNems +########## + +exit 0 diff --git a/scripts/build-v1.1.sh b/scripts/build-v1.1.sh new file mode 100644 index 00000000..30f8880e --- /dev/null +++ b/scripts/build-v1.1.sh @@ -0,0 +1,227 @@ +#!/bin/bash + +########################################################################### +### Author: Panagiotis Velissariou +### +### Version - 1.1 +### +### 1.1 Wed Apr 14 2021 +### 1.0 Fri Dec 04 2020 +########################################################################### + + +###==================== +# Make sure that the current working directory is in the PATH +[[ ! :$PATH: == *:".":* ]] && export PATH="${PATH}:." + + +# Get the directory where the script is located +if [[ $(uname -s) == Darwin ]]; then + readonly scrNAME="$( grealpath -s "${BASH_SOURCE[0]}" )" + readonly scrDIR="$(cd "$(dirname "${scrNAME}" )" && pwd -P)" +else + readonly scrNAME="$( realpath -s "${BASH_SOURCE[0]}" )" + readonly scrDIR="$(cd "$(dirname "$(realpath -s "${BASH_SOURCE[0]}")" )" && pwd -P)" +fi + +funcs="$( find ${scrDIR} -type f -name "functions_build" | head -n 1 )" +if [ -f "${funcs}" ]; then + source "${funcs}" +else + echo " ### ERROR :: in ${scrNAME}" + echo " Cannot load the required file: ${funcs}" + echo " Exiting now ..." + echo + exit 1 +fi + +unset funcs +###==================== + + +######### +# Call ParseArgs to get the user input. +ParseArgs "${@}" + + +########## +# Set the variables for this script +CLEAN=${MY_CLEAN:-0} + +[ -n "${MY_COMPILER:+1}" ] && COMPILER="$( toLOWER "${MY_COMPILER}" )" + +[ -n "${MY_COMPONENT:+1}" ] && COMPONENT="$( toUPPER "${MY_COMPONENT}" )" + + +[ -n "${MY_OS:+1}" ] && OS="$( toLOWER "${MY_OS}" )" +if [ -n "${MY_PLATFORM:+1}" ]; then + PLATFORM="$( toLOWER "${MY_PLATFORM}" )" +else + PLATFORM="${OS}" +fi +export NEMS_PLATFORM=${PLATFORM} +export MACHINE_ID=${PLATFORM} + + +[ "${MY_PARMAKE:0}" -gt 1 ] && PARMAKE=${MY_PARMAKE} + +[ -n "${MY_VERBOSE:+1}" ] && VERBOSE="$( toLOWER "${MY_VERBOSE}" )" + +modFILE="envmodules${COMPILER:+_${COMPILER}}${PLATFORM:+.${PLATFORM}}" + +# Customize the NEMS.x filename to include the component names +if [ -n "${COMPONENT:+1}" ]; then + compFNAME="$( strTrim "$( toLOWER "${COMPONENT}" )" )" + compFNAME="$( echo "${compFNAME}" | sed 's/ /_/g' )" +fi + +# Export some environment variables for NEMS +export NEMS_COMPILER=${COMPILER} +########## + + +########## +# Get the project directories and perform a basic check on them +readonly nemsDIR="${NEMS_DIR:-${scrDIR}/NEMS}" +if [ ! -f "${nemsDIR}/NEMSAppBuilder" ]; then + echo "The project directory \"${nemsDIR}\" does not appear to contain NEMSAppBuilder." + echo "Is this the correct NEMS directory?" + echo "You might need to set the environment variable NEMS_DIR before running this script." + echo "Exiting ..." + exit 1 +fi + +readonly modDIR="${NEMSMODS_DIR:-${scrDIR}/modulefiles}" +if [ ! -f "${modDIR}/${modFILE}" ]; then + echo + echo "The modulefiles directory \"${modDIR}\" does not appear to contain the module file: ${modFILE}." + echo "Is this the correct \"modulefiles\" directory?" + echo "You might need to set the environment variable \"NEMSMODS_DIR\" to point to a custom modulefiles directory before running this script." + echo "Exiting ..." + echo + exit 1 +fi +########## + + +########## +# If the user requested to clean the build folder, do the cleaning end exit +if [ ${CLEAN:-0} -ge 1 ]; then + echo "User requested to only clean the project. Cleaning ..." + + pushd ${nemsDIR} >/dev/null 2>&1 + [ ${CLEAN:-0} -eq 1 ] && compileNems clean + [ ${CLEAN:-0} -eq 2 ] && compileNems distclean + popd >/dev/null 2>&1 + + exit 0 +fi +########## + + +########## +# Source the environment module +source ${modDIR}/${modFILE} + +component_ww3="$( echo "${COMPONENT}" | sed 's/ /:/g' )" +if [[ :${component_ww3}: == *:"WW3":* ]]; then + export WW3_CONFOPT="${COMPILER}" + export WW3_COMP="${COMPILER}" + export WWATCH3_NETCDF=NC4 +fi +########## + + +########## +# Get a final user response for the variables +echo +echo "The following variables are defined:" +echo " CLEAN = ${CLEAN}" +echo " COMPILER = ${COMPILER:-Undefined, Supported values are: [${MY_COMPILING_SYTEMS}]}" +echo " NEMS_COMPILER = ${NEMS_COMPILER}" +echo " MODULES FILE = ${modFILE}" +if [[ :${component_ww3}: == *:"WW3":* ]]; then + echo " WW3_CONFOPT = ${WW3_CONFOPT}" + echo " WW3_COMP = ${WW3_COMP}" + echo " WWATCH3_NETCDF = ${WWATCH3_NETCDF}" +fi +echo " COMPONENTS = ${COMPONENT:-Undefined, Supported values are: [${MY_COMPONENT_LIST}]}" +echo " OS = ${OS}" +echo " PLATFORM = ${PLATFORM}" +echo " VERBOSE = ${VERBOSE}" +echo +echo " HDF5HOME = ${HDF5HOME}" +echo " NETCDFHOME = ${NETCDFHOME}" +echo " NETCDF_INCDIR = ${NETCDF_INCDIR}" +echo " NETCDF_LIBDIR = ${NETCDF_LIBDIR}" +echo +echo " ESMFMKFILE = ${ESMFMKFILE}" +echo + +module list + + +echo_response= +while [ -z "${echo_response}" ] ; do + echo -n "Are these values correct? [y/n]: " + read echo_response + echo_response="$( getYesNo "${echo_response}" )" +done + +if [ "${echo_response:-no}" = "no" ]; then + echo + echo "User responded: ${echo_response}" + echo "Exiting now ..." + echo + exit 1 +fi + +unset echo_response +########## + + +############################################################ +### START THE CALCULATIONS +############################################################ + +########## +# Compile the project +compileERR=0 +pushd ${nemsDIR} >/dev/null 2>&1 + case ${CLEAN:-0} in + -1 ) + compileNems clean + compileERR=$? + ;; + -2 ) + compileNems distclean + compileERR=$? + ;; + -3 ) + compileNems noclean + compileERR=$? + ;; + * ) + compileNems clean + compileERR=$? + ;; + esac + + if [ ${compileERR} -eq 0 ]; then + compileNems build + compileERR=$? + fi + + if [ ${compileERR} -eq 0 ]; then + if [ -f exe/NEMS.x ]; then + cp -p exe/NEMS.x exe/NEMS${compFNAME:+-${compFNAME}}.x + fi + fi +popd >/dev/null 2>&1 + +########## +# Install all data, executables, libraries in a common directory +[ ${compileERR:-0} -eq 0 ] && installNems +########## + +exit 0 diff --git a/scripts/functions_build b/scripts/functions_build new file mode 100644 index 00000000..ebb69270 --- /dev/null +++ b/scripts/functions_build @@ -0,0 +1,617 @@ +#!/bin/bash-*-Shell-script-functions*- + +########################################################################### +### Author: Panagiotis Velissariou +### +### Version - 1.0 Fri Dec 04 2020 +########################################################################### + +set +u + +MY_COMPILING_SYTEMS="gnu, intel, pgi" + +MY_ATM_MODS="ATMESH WRF HWRF PAHM" +MY_OCN_MODS="ADCIRC SCHISM FVCOM ROMS" +MY_HYD_MODS="NWM" +MY_WAV_MODS="WW3DATA WW3" + +MY_COMPONENT_LIST="${MY_ATM_MODS} ${MY_OCN_MODS} ${MY_HYD_MODS} ${MY_WAV_MODS} " + +################################################## +### MODELLING SYSTEM BUILD FUNCTIONS +################################################## + +###======================================== +### ParseArgs() +### Usage: ParseArgs args +### Parameters: args = the script options +### Returns: 0 +### Echoes: NONE +### +### Gets the supplied options to the script. +###======================================== +ParseArgs() +{ + local nm_func=$( basename ${BASH_SOURCE[${#BASH_SOURCE[@]}-1]} ) + + local opt_all opt_opt opt_arg opt_chk + + local t_VAR + local ans0 ans ival intN + local all_evars + + all_evars="MY_CLEAN MY_COMPILER MY_COMPONENT MY_OS MY_PARMAKE MY_PLATFORM MY_VERBOSE" + + for ival in ${all_evars}; do unset __${ival}; done + + + __MY_CLEAN=0 + __MY_COMPILER=intel + __MY_COMPONENT="ADCIRC WW3DATA ATMESH" + __MY_OS= + __MY_PARMAKE=1 + __MY_PLATFORM= + __MY_VERBOSE= + + + # ----- + # Process the function options + opt_all=( c clean compiler component j os plat v verbose h help ) + opt_all=":$( echo "${opt_all[@]/#/-} ${opt_all[@]/#/--}" | sed 's/ /:/g' ):" + + unset __OPTION_LIST + while test $# -gt 0; do + case "${1}" in + -[^-]*=* | --[^-]*=* ) + opt_opt="$( toLOWER "$( echo "${1}" | sed 's/=.*//' )" )" + len=$(( ${#opt_opt} + 1 )) + opt_arg="$( strTrim "$( echo "${1:${len}}" )" 2 )" + [ "$( echo "${opt_all}" | egrep -o ":${opt_arg}:" )" ] && \ + opt_arg= + ;; + -[^-]* | --[^-]* ) + opt_opt="$( toLOWER "${1}" )" + opt_chk="$( toLOWER "$( echo "${2}" | sed 's/=.*//' )" )" + if [ "$( echo "${opt_all}" | egrep -o ":${opt_chk}:" )" ]; then + opt_arg= + else + opt_arg="$( strTrim "$( echo "${2}" )" )" + fi + ;; + *) + opt_opt= + opt_arg= + ;; + esac + + case "${opt_opt}" in + -c | --c | -clean | --clean ) + checkFuncOpt "--clean" + if [ $? -eq 0 ]; then + __MY_CLEAN=1 + if [ "X${opt_arg}" != "X" ]; then + if `isInteger "${opt_arg}"` ; then + __MY_CLEAN=$( echo "${opt_arg}" ) + [ ${opt_arg} -le -3 ] && __MY_CLEAN=-3 + [ ${opt_arg} -ge 2 ] && __MY_CLEAN=2 + else + __MY_CLEAN=0 + [ "$( getYesNo "${opt_arg}" )" = "yes" ] && __MY_CLEAN=1 + fi + fi + fi + ;; + -compiler | --compiler ) + checkFuncOpt "--compiler" + if [ $? -eq 0 ]; then + if [ "X${opt_arg}" != "X" ]; then + __MY_COMPILER="$( echo "${opt_arg}" | sed 's/[[:space:]]//g' )" + fi + fi + ;; + -component | --component ) + checkFuncOpt "--component" + if [ $? -eq 0 ]; then + if [ "X${opt_arg}" != "X" ]; then + __MY_COMPONENT="$( strTrim "${opt_arg}" )" + fi + fi + ;; + -j | --j ) + checkFuncOpt "--j" + if [ $? -eq 0 ]; then + if [ "X${opt_arg}" != "X" ]; then + __MY_PARMAKE=1 + t_VAR="$( getPosInteger "${opt_arg}" )" + [ ! -z "${t_VAR}" ] && __MY_PARMAKE=${t_VAR} + fi + fi + ;; + -os | --os ) + checkFuncOpt "--os" + if [ $? -eq 0 ]; then + if [ "X${opt_arg}" != "X" ]; then + __MY_OS="$( echo "${opt_arg}" | sed 's/[[:space:]]//g' )" + fi + fi + ;; + -plat | --plat ) + checkFuncOpt "--plat" + if [ $? -eq 0 ]; then + if [ "X${opt_arg}" != "X" ]; then + __MY_PLATFORM="$( echo "${opt_arg}" | sed 's/[[:space:]]//g' )" + fi + fi + ;; + -v | --v | -verbose | --verbose ) + checkFuncOpt "--verbose" + if [ $? -eq 0 ]; then + __MY_VERBOSE=b + if [ "X${opt_arg}" != "X" ]; then + __MY_VERBOSE="$( echo "$( strTrim "${opt_arg}" 2 )" | sed 's/[[:space:]]/,/g' )" + fi + fi + ;; + -h | -help | --h | --help ) + UsageBuild ${nm_func} + ;; + *) ;; # DEFAULT + esac + shift + opt_opt= + opt_arg= + done + unset __OPTION_LIST + # ----- + + if [ -z "${__MY_OS}" ]; then + case "$(uname -s)" in + Darwin ) __MY_OS="macosx" ;; + Linux ) __MY_OS="linux" ;; + *) __MY_OS="UNDEFINED";; # DEFAULT + esac + fi + + # Export the values of all __* variables. + for ival in ${all_evars} + do + ans0="$( eval "echo \${$(echo ${ival}):-}" )" + ans="$( eval "echo \${$(echo __${ival}):-}" )" + ans=${ans:-${ans0:-}} + + eval "${ival}=\${ans}" + export ${ival} + + unset __${ival} + done + + return 0 +} + +UsageBuild() +{ + local nm="$( basename ${0} )" + + echo + echo "Usage: \"${nm}\" [{-|--}option1{=|space}[option_value1]] [{-|--}option2{=|space}[option_value2]] ..." + echo + + echo " -h|-help|--h|--help" + echo " Show this help screen." + echo + #--- + echo " -c|--c|-clean|--clean [=|space] \"0|1|yes|no\" (OPTIONAL)." + echo " Only clean the already compiled CMake build system." + echo " Default: 0|no." + echo + #--- + echo " -compiler|--compiler [=|space] \"compiling_system\" (OPTIONAL)." + echo " The compiling system to use (${MY_COMPILING_SYTEMS})." + echo " Default: intel." + echo + #--- + echo " -component|--component [=|space] \"component_list\" (OPTIONAL)." + echo " The component(s) to use (${MY_COMPONENT_LIST})." + echo " Default: \"ADCIRC WW3DATA ATMESH\"." + echo + #--- + echo " -j|--j [=|space] \"N\" (OPTIONAL)." + echo " Define the number of make jobs to run simultaneously." + echo " Default: 1." + echo + #--- + echo " -os|--os [=|space] \"OS string\" (OPTIONAL)." + echo " The name of the Operating system." + echo " Supported OSes: linux macosx." + echo " Default: current OS." + echo + #--- + echo " -plat|--plat [=|space] \"platform\" (OPTIONAL)." + echo " The name of the compute HPC platform to consider." + echo " Selecting a platform, environment modules specific to that platform are loaded" + echo " and corresponding environment variables are set." + echo " Supported platforms: cheyenne gaea hera jet orion stampede wcoss." + echo " Default: none." + echo + #--- + echo " -v|--v|-verbose|--verbose [=|space] \"a,b,v,i,j,m,n\" (any combination, OPTIONAL)." + echo " Enable verbosity in the make files during compilation." + echo " a (all) : all types of debugging output are enabled" + echo " n (none) : disable all debugging currently enabled" + echo " b (basic) : basic debugging and whether the build was successful or not" + echo " v (verbose) : a level above basic" + echo " i (implicit) : prints messages describing the implicit rule searches for each target" + echo " j (jobs) : prints messages giving details on the invocation of specific sub-commands" + echo " m (makefile) : enables messages while rebuilding makefiles" + echo " Default:none." + echo + #--- + + exit 0 +} + +###======================================== +### checkFuncOpt() +### Usage: checkFuncOpt opt_name +### Parameters: +### opt_name: The name of the option to a function +### +### Returns : Exits on error +### +### Exports : __OPTION_LIST +### +### Echoes : NONE +### +### checkFuncOpt: Checks if an option to a function is already supplied. +###======================================== +checkFuncOpt() { + local opt_inp opt_list + + [ $# -eq 0 ] && return -1 + + opt_inp="$( strTrim "${1}" 2 )" + opt_inp="$( echo "${opt_inp}" | sed 's/^[-]*//' )" + + opt_list="$( strTrim "${__OPTION_LIST}" 2 )" + [ -n ${opt_list:+1} ] && \ + opt_list=":$( echo "${opt_list}" | sed 's/ /:/g' ):" + + [ "$( echo "${opt_list}" | egrep -o ":${opt_inp}:" )" ] && return 1 + + __OPTION_LIST="${__OPTION_LIST} ${opt_inp}" + export __OPTION_LIST + + return 0 +} + +###======================================== +### isInteger() +### Usage: isInteger var +### Parameters: var +### Returns: 1 if var is not an integer (0 is an integer as well) +### 0 in any other case +### Echoes: NONE +###======================================== +isInteger() +{ + local -i retval=1 + + [ $# -eq 0 ] && return ${retval} + + if [ "${1:-UNDEF}" -eq "${1}" ] 2>/dev/null + then + retval=0 + fi + + return ${retval} +} + +###======================================== +### getInteger() +### Usage: getInteger int +### Parameters: int (int >=0 or, int < 0) +### Returns: 1 if var is not an integer +### 0 in any other case +### Echoes: int, if it is a valid integer (including 0), +### in any other case echoes an empty string +###======================================== +getInteger() +{ + local -i retval=0 + local echoval= minus= + + # strip spaces, '+' signs and '-' signs + # if the first character of the string is '-', set the minus variable + echoval="$( echo "${1}" | sed 's/[[:space:]+]//g' )" + [ "X$( echo "${echoval:0:1}" )" = "X-" ] && minus="-" + echoval="${minus}$( echo "${echoval}" | sed 's/[[:space:]-]//g' )" + + if isInteger ${echoval}; then + echoval="$(echo "scale=0; ${echoval} + 0" | bc -ql 2>/dev/null)" + retval=$? + echoval="${echoval:-0}" + else + echoval= + retval=1 + fi + + echo -n ${echoval} + + return ${retval} +} + +###======================================== +### getPosInteger() +### Usage: getPosInteger posint +### Parameters: posint (posint >= 0) +### Returns: 1 if var is not a positive integer +### 0 in any other case +### Echoes: posint if it is a valid positive integer +### (including 0), in any other case echoes an +### empty string +###======================================== +getPosInteger() +{ + local -i retval=0 + local echoval= + + echoval=$( getInteger "${1}" ) + retval=$? + + if [ ${retval} -ne 0 ] ; then + echoval= + retval=1 + else + if [ ${echoval} -lt 0 ]; then + echoval= + retval=1 + fi + fi + + echo -n ${echoval} + + return ${retval} +} + +###======================================== +### getYesNo() +### Usage: getYesNo value +### Parameters: +### value : The input value (the value of a parameter) +### The value of a bash parameter that is checked +### against TRUE/FALSE. If the value is one of: +### ">=1|y|yes|yea|yeah|yep" +### then the value of parameter is TRUE (answer = yes). +### If the value is one of: +### "<=0|n|no|not|nop|nope" +### then the value of parameter is FALSE (answer = no). +### If the value is empty then the value of parameter +### is FALSE (answer = no) +### +### Returns : NONE +### +### Exports : NONE +### +### Echoes : A "yes" or "no" answer. +### +### getYesNo: Checks if a parameter is assigned a TRUE/FALSE value. +###======================================== +getYesNo() +{ + local param answer + + param="$( echo "${1}" | tr '[:upper:]' '[:lower:]' )" + + if [ "${param}" -eq "${param}" ] 2>/dev/null + then + [ ${param} -le 0 ] && param=0 + [ ${param} -gt 0 ] && param=1 + fi + + case "${param}" in + 1|y|yes|yea|yeah|yep) answer="yes" ;; + 0|n|no|not|nop|nope) answer="no" ;; + *) answer="" ;; # DEFAULT + esac + + echo -n "${answer}" +} + +###======================================== +### toUPPER() +### Usage: toUPPER string +### Parameters: +### string : The string in to convert +### +### Returns : NONE +### +### Exports : NONE +### +### Echoes : The input string converted to an all upper case string +### +### toUPPER: Converts a string to an all upper case string +###======================================== +function toUPPER() +{ + echo "${1}" | tr '[:lower:]' '[:upper:]' +} + +###======================================== +### toLOWER() +### Usage: toLOWER string +### Parameters: +### string : The string in to convert +### +### Returns : NONE +### +### Exports : NONE +### +### Echoes : The input string converted to an all lower case string +### +### toLOWER: Converts a string to an all lower case string +###======================================== +function toLOWER() +{ + echo "${1}" | tr '[:upper:]' '[:lower:]' +} + +###======================================== +### strESC() +### Usage: strESC string +### Parameters: +### string : The input string +### The input string on which this function is applied +### to escape special characters used in bash/sed ... +### +### Returns : NONE +### +### Exports : NONE +### +### Echoes : The modified string with its special characters escaped +### +### strESC: Escapes special characters in a string: "'()/[]*. +###======================================== +strESC() +{ + echo -n "$( echo "${*}" | sed -e "s/[\"\'\(\)\/\*\!]/\\\&/g;s/\[/\\\&/g;s/\]/\\\&/g" )" +} + +strESC1() +{ + echo -n "$( echo "${*}" | sed -e "s/[\&\/\*\!]/\\\&/g;s/\[/\\\&/g;s/\]/\\\&/g" )" +} + +###======================================== +### strTrim() +### Usage: strTrim s1 flag +### Parameters: +### s1 : The input string +### flag : Integer +### A value that controls the action of strTrim. +### If flag is zero or not present, trailing blanks are removed. +### Leading blanks are removed if it is equal to 1. +### Both are removed if it is equal to 2. +### In any other case, trailing blanks are removed. +### +### Returns : NONE +### +### Exports : NONE +### +### Echoes : s1 with all leading and/or trailing +### white spaces removed. +### +### strTrim: Removes all leading and/or trailing white spaces +### from the input string +###======================================== +function strTrim () +{ + local trimFLG="${2:-0}" + local out_str= + + case ${trimFLG} in + 0) out_str="$(echo "${1}" | sed 's/[[:space:]]*$//')" ;; + 1) out_str="$(echo "${1}" | sed 's/^[[:space:]]*//')" ;; + 2) out_str="$(echo "${1}" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" ;; + *) out_str="$(echo "${1}" | sed 's/[[:space:]]*$//')" ;; + esac + + echo -n ${out_str} +} + +compileNems() { + local cmp_type cmp_make cmp_comp cmp_mjob + local err=0 + + [ $# -eq 0 ] && return ${err} + + cmp_type="$( toLOWER "${1}" )" + cmp_make=GNUmakefile + cmp_comp="${COMPONENT:+COMPONENTS=\"${COMPONENT}\"}" + cmp_mjob="${PARMAKE:+-j ${PARMAKE}}" + cmp_verb="${VERBOSE:+--debug=${VERBOSE}}" + + case "${cmp_type}" in + "clean"|"distclean" ) + if [ -f "${cmp_make}" ]; then + echo + echo "compileNems :: Cleaning: make -f ${cmp_make} ${cmp_type} ${cmp_comp}" + eval "make ${cmp_verb} -f ${cmp_make} ${cmp_type} ${cmp_comp}" + err=$? + + if [ "${cmp_type}" == "distclean" ]; then + rm -f NEMS/exe/NEMS-*.x + fi + else + echo "compileNems :: Cleaning: no makefile found: makefile = ${cmp_make}" + err=1 + fi + ;; + "build"|"compile" ) + if [ -f "${cmp_make}" ]; then + echo + echo "compileNems :: Compiling: make ${cmp_mjob} -f ${cmp_make} ${cmp_type} ${cmp_comp}" + eval "make ${cmp_verb} ${cmp_mjob} -f ${cmp_make} ${cmp_type} ${cmp_comp}" + err=$? + else + echo "compileNems :: Compiling: no makefile found: makefile = ${cmp_make}" + err=1 + fi + ;; + * ) err=0 ;; # Do nothing + esac + + return ${err} +} + +installNems() { + local cmp_comp icmp + local instdir + local CPBIN="/bin/cp -fpv" + local RMBIN="/bin/rm -fv" + + instdir="ALLBIN_INSTALL" + + cmp_comp="${COMPONENT}" + + [ ! -d "${instdir}" ] && mkdir -p ${instdir} + + for icmp in ${cmp_comp} + do + indir="${icmp}_INSTALL" + + if [ -d ${indir} ]; then + echo + echo " --- Installing from: ${indir} to ${instdir} ---" + ${CPBIN} ${indir}/* ${instdir}/ + fi + + ###### Extra ADCIRC files + if [ "${icmp}" == "ADCIRC" ]; then + echo + echo " --- Installing from: ${icmp} to ${instdir} ---" + for iprog in adcprep + do + prog="$( find ${icmp} -type f -name ${iprog} | head -1 )" + if [ -n "${prog:+1}" ]; then + ${CPBIN} ${prog} ${instdir}/ + fi + done + fi + ###### + done + + ###### Install the NEMS/exe/NEMS* files + echo + echo " --- Installing from: NEMS/exe to ${instdir} ---" + for iprog in NEMS/exe/NEMS-*.x + do + if [ -f "${iprog}" ]; then + ${CPBIN} ${iprog} ${instdir}/ + fi + done + + ###### Remove un-needed files from instdir + echo + echo " --- Removing files that are not needed from: ${instdir} ---" + ${RMBIN} ${instdir}/*.mk ${instdir}/*.mod +} diff --git a/scripts/functions_build-v1.0 b/scripts/functions_build-v1.0 new file mode 100644 index 00000000..05111ddc --- /dev/null +++ b/scripts/functions_build-v1.0 @@ -0,0 +1,611 @@ +#!/bin/bash-*-Shell-script-functions*- + +########################################################################### +### Author: Panagiotis Velissariou +### +### Version - 1.0 Fri Dec 04 2020 +########################################################################### + +set +u + +MY_COMPILING_SYTEMS="gnu, intel, pgi" +MY_COMPONENT_LIST="ADCIRC WW3DATA WW3 NWM ATMESH" + +################################################## +### MODELLING SYSTEM BUILD FUNCTIONS +################################################## + +###======================================== +### ParseArgs() +### Usage: ParseArgs args +### Parameters: args = the script options +### Returns: 0 +### Echoes: NONE +### +### Gets the supplied options to the script. +###======================================== +ParseArgs() +{ + local nm_func=$( basename ${BASH_SOURCE[${#BASH_SOURCE[@]}-1]} ) + + local opt_all opt_opt opt_arg opt_chk + + local t_VAR + local ans0 ans ival intN + local all_evars + + all_evars="MY_CLEAN MY_COMPILER MY_COMPONENT MY_OS MY_PARMAKE MY_PLATFORM MY_VERBOSE" + + for ival in ${all_evars}; do unset __${ival}; done + + + __MY_CLEAN=0 + __MY_COMPILER=intel + __MY_COMPONENT="ADCIRC WW3DATA ATMESH" + __MY_OS= + __MY_PARMAKE=1 + __MY_PLATFORM= + __MY_VERBOSE= + + + # ----- + # Process the function options + opt_all=( c clean compiler component j os plat v verbose h help ) + opt_all=":$( echo "${opt_all[@]/#/-} ${opt_all[@]/#/--}" | sed 's/ /:/g' ):" + + unset __OPTION_LIST + while test $# -gt 0; do + case "${1}" in + -[^-]*=* | --[^-]*=* ) + opt_opt="$( toLOWER "$( echo "${1}" | sed 's/=.*//' )" )" + len=$(( ${#opt_opt} + 1 )) + opt_arg="$( strTrim "$( echo "${1:${len}}" )" 2 )" + [ "$( echo "${opt_all}" | egrep -o ":${opt_arg}:" )" ] && \ + opt_arg= + ;; + -[^-]* | --[^-]* ) + opt_opt="$( toLOWER "${1}" )" + opt_chk="$( toLOWER "$( echo "${2}" | sed 's/=.*//' )" )" + if [ "$( echo "${opt_all}" | egrep -o ":${opt_chk}:" )" ]; then + opt_arg= + else + opt_arg="$( strTrim "$( echo "${2}" )" )" + fi + ;; + *) + opt_opt= + opt_arg= + ;; + esac + + case "${opt_opt}" in + -c | --c | -clean | --clean ) + checkFuncOpt "--clean" + if [ $? -eq 0 ]; then + __MY_CLEAN=1 + if [ "X${opt_arg}" != "X" ]; then + if `isInteger "${opt_arg}"` ; then + __MY_CLEAN=$( echo "${opt_arg}" ) + [ ${opt_arg} -le -3 ] && __MY_CLEAN=-3 + [ ${opt_arg} -ge 2 ] && __MY_CLEAN=2 + else + __MY_CLEAN=0 + [ "$( getYesNo "${opt_arg}" )" = "yes" ] && __MY_CLEAN=1 + fi + fi + fi + ;; + -compiler | --compiler ) + checkFuncOpt "--compiler" + if [ $? -eq 0 ]; then + if [ "X${opt_arg}" != "X" ]; then + __MY_COMPILER="$( echo "${opt_arg}" | sed 's/[[:space:]]//g' )" + fi + fi + ;; + -component | --component ) + checkFuncOpt "--component" + if [ $? -eq 0 ]; then + if [ "X${opt_arg}" != "X" ]; then + __MY_COMPONENT="$( strTrim "${opt_arg}" )" + fi + fi + ;; + -j | --j ) + checkFuncOpt "--j" + if [ $? -eq 0 ]; then + if [ "X${opt_arg}" != "X" ]; then + __MY_PARMAKE=1 + t_VAR="$( getPosInteger "${opt_arg}" )" + [ ! -z "${t_VAR}" ] && __MY_PARMAKE=${t_VAR} + fi + fi + ;; + -os | --os ) + checkFuncOpt "--os" + if [ $? -eq 0 ]; then + if [ "X${opt_arg}" != "X" ]; then + __MY_OS="$( echo "${opt_arg}" | sed 's/[[:space:]]//g' )" + fi + fi + ;; + -plat | --plat ) + checkFuncOpt "--plat" + if [ $? -eq 0 ]; then + if [ "X${opt_arg}" != "X" ]; then + __MY_PLATFORM="$( echo "${opt_arg}" | sed 's/[[:space:]]//g' )" + fi + fi + ;; + -v | --v | -verbose | --verbose ) + checkFuncOpt "--verbose" + if [ $? -eq 0 ]; then + __MY_VERBOSE=b + if [ "X${opt_arg}" != "X" ]; then + __MY_VERBOSE="$( echo "$( strTrim "${opt_arg}" 2 )" | sed 's/[[:space:]]/,/g' )" + fi + fi + ;; + -h | -help | --h | --help ) + UsageBuild ${nm_func} + ;; + *) ;; # DEFAULT + esac + shift + opt_opt= + opt_arg= + done + unset __OPTION_LIST + # ----- + + if [ -z "${__MY_OS}" ]; then + case "$(uname -s)" in + Darwin ) __MY_OS="macosx" ;; + Linux ) __MY_OS="linux" ;; + *) __MY_OS="UNDEFINED";; # DEFAULT + esac + fi + + # Export the values of all __* variables. + for ival in ${all_evars} + do + ans0="$( eval "echo \${$(echo ${ival}):-}" )" + ans="$( eval "echo \${$(echo __${ival}):-}" )" + ans=${ans:-${ans0:-}} + + eval "${ival}=\${ans}" + export ${ival} + + unset __${ival} + done + + return 0 +} + +UsageBuild() +{ + local nm="$( basename ${0} )" + + echo + echo "Usage: \"${nm}\" [{-|--}option1{=|space}[option_value1]] [{-|--}option2{=|space}[option_value2]] ..." + echo + + echo " -h|-help|--h|--help" + echo " Show this help screen." + echo + #--- + echo " -c|--c|-clean|--clean [=|space] \"0|1|yes|no\" (OPTIONAL)." + echo " Only clean the already compiled CMake build system." + echo " Default: 0|no." + echo + #--- + echo " -compiler|--compiler [=|space] \"compiling_system\" (OPTIONAL)." + echo " The compiling system to use (${MY_COMPILING_SYTEMS})." + echo " Default: intel." + echo + #--- + echo " -component|--component [=|space] \"component_list\" (OPTIONAL)." + echo " The component(s) to use (${MY_COMPONENT_LIST})." + echo " Default: \"ADCIRC WW3DATA ATMESH\"." + echo + #--- + echo " -j|--j [=|space] \"N\" (OPTIONAL)." + echo " Define the number of make jobs to run simultaneously." + echo " Default: 1." + echo + #--- + echo " -os|--os [=|space] \"OS string\" (OPTIONAL)." + echo " The name of the Operating system." + echo " Supported OSes: linux macosx." + echo " Default: current OS." + echo + #--- + echo " -plat|--plat [=|space] \"platform\" (OPTIONAL)." + echo " The name of the compute HPC platform to consider." + echo " Selecting a platform, environment modules specific to that platform are loaded" + echo " and corresponding environment variables are set." + echo " Supported platforms: cheyenne gaea hera jet orion stampede wcoss." + echo " Default: none." + echo + #--- + echo " -v|--v|-verbose|--verbose [=|space] \"a,b,v,i,j,m,n\" (any combination, OPTIONAL)." + echo " Enable verbosity in the make files during compilation." + echo " a (all) : all types of debugging output are enabled" + echo " n (none) : disable all debugging currently enabled" + echo " b (basic) : basic debugging and whether the build was successful or not" + echo " v (verbose) : a level above basic" + echo " i (implicit) : prints messages describing the implicit rule searches for each target" + echo " j (jobs) : prints messages giving details on the invocation of specific sub-commands" + echo " m (makefile) : enables messages while rebuilding makefiles" + echo " Default:none." + echo + #--- + + exit 0 +} + +###======================================== +### checkFuncOpt() +### Usage: checkFuncOpt opt_name +### Parameters: +### opt_name: The name of the option to a function +### +### Returns : Exits on error +### +### Exports : __OPTION_LIST +### +### Echoes : NONE +### +### checkFuncOpt: Checks if an option to a function is already supplied. +###======================================== +checkFuncOpt() { + local opt_inp opt_list + + [ $# -eq 0 ] && return -1 + + opt_inp="$( strTrim "${1}" 2 )" + opt_inp="$( echo "${opt_inp}" | sed 's/^[-]*//' )" + + opt_list="$( strTrim "${__OPTION_LIST}" 2 )" + [ -n ${opt_list:+1} ] && \ + opt_list=":$( echo "${opt_list}" | sed 's/ /:/g' ):" + + [ "$( echo "${opt_list}" | egrep -o ":${opt_inp}:" )" ] && return 1 + + __OPTION_LIST="${__OPTION_LIST} ${opt_inp}" + export __OPTION_LIST + + return 0 +} + +###======================================== +### isInteger() +### Usage: isInteger var +### Parameters: var +### Returns: 1 if var is not an integer (0 is an integer as well) +### 0 in any other case +### Echoes: NONE +###======================================== +isInteger() +{ + local -i retval=1 + + [ $# -eq 0 ] && return ${retval} + + if [ "${1:-UNDEF}" -eq "${1}" ] 2>/dev/null + then + retval=0 + fi + + return ${retval} +} + +###======================================== +### getInteger() +### Usage: getInteger int +### Parameters: int (int >=0 or, int < 0) +### Returns: 1 if var is not an integer +### 0 in any other case +### Echoes: int, if it is a valid integer (including 0), +### in any other case echoes an empty string +###======================================== +getInteger() +{ + local -i retval=0 + local echoval= minus= + + # strip spaces, '+' signs and '-' signs + # if the first character of the string is '-', set the minus variable + echoval="$( echo "${1}" | sed 's/[[:space:]+]//g' )" + [ "X$( echo "${echoval:0:1}" )" = "X-" ] && minus="-" + echoval="${minus}$( echo "${echoval}" | sed 's/[[:space:]-]//g' )" + + if isInteger ${echoval}; then + echoval="$(echo "scale=0; ${echoval} + 0" | bc -ql 2>/dev/null)" + retval=$? + echoval="${echoval:-0}" + else + echoval= + retval=1 + fi + + echo -n ${echoval} + + return ${retval} +} + +###======================================== +### getPosInteger() +### Usage: getPosInteger posint +### Parameters: posint (posint >= 0) +### Returns: 1 if var is not a positive integer +### 0 in any other case +### Echoes: posint if it is a valid positive integer +### (including 0), in any other case echoes an +### empty string +###======================================== +getPosInteger() +{ + local -i retval=0 + local echoval= + + echoval=$( getInteger "${1}" ) + retval=$? + + if [ ${retval} -ne 0 ] ; then + echoval= + retval=1 + else + if [ ${echoval} -lt 0 ]; then + echoval= + retval=1 + fi + fi + + echo -n ${echoval} + + return ${retval} +} + +###======================================== +### getYesNo() +### Usage: getYesNo value +### Parameters: +### value : The input value (the value of a parameter) +### The value of a bash parameter that is checked +### against TRUE/FALSE. If the value is one of: +### ">=1|y|yes|yea|yeah|yep" +### then the value of parameter is TRUE (answer = yes). +### If the value is one of: +### "<=0|n|no|not|nop|nope" +### then the value of parameter is FALSE (answer = no). +### If the value is empty then the value of parameter +### is FALSE (answer = no) +### +### Returns : NONE +### +### Exports : NONE +### +### Echoes : A "yes" or "no" answer. +### +### getYesNo: Checks if a parameter is assigned a TRUE/FALSE value. +###======================================== +getYesNo() +{ + local param answer + + param="$( echo "${1}" | tr '[:upper:]' '[:lower:]' )" + + if [ "${param}" -eq "${param}" ] 2>/dev/null + then + [ ${param} -le 0 ] && param=0 + [ ${param} -gt 0 ] && param=1 + fi + + case "${param}" in + 1|y|yes|yea|yeah|yep) answer="yes" ;; + 0|n|no|not|nop|nope) answer="no" ;; + *) answer="" ;; # DEFAULT + esac + + echo -n "${answer}" +} + +###======================================== +### toUPPER() +### Usage: toUPPER string +### Parameters: +### string : The string in to convert +### +### Returns : NONE +### +### Exports : NONE +### +### Echoes : The input string converted to an all upper case string +### +### toUPPER: Converts a string to an all upper case string +###======================================== +function toUPPER() +{ + echo "${1}" | tr '[:lower:]' '[:upper:]' +} + +###======================================== +### toLOWER() +### Usage: toLOWER string +### Parameters: +### string : The string in to convert +### +### Returns : NONE +### +### Exports : NONE +### +### Echoes : The input string converted to an all lower case string +### +### toLOWER: Converts a string to an all lower case string +###======================================== +function toLOWER() +{ + echo "${1}" | tr '[:upper:]' '[:lower:]' +} + +###======================================== +### strESC() +### Usage: strESC string +### Parameters: +### string : The input string +### The input string on which this function is applied +### to escape special characters used in bash/sed ... +### +### Returns : NONE +### +### Exports : NONE +### +### Echoes : The modified string with its special characters escaped +### +### strESC: Escapes special characters in a string: "'()/[]*. +###======================================== +strESC() +{ + echo -n "$( echo "${*}" | sed -e "s/[\"\'\(\)\/\*\!]/\\\&/g;s/\[/\\\&/g;s/\]/\\\&/g" )" +} + +strESC1() +{ + echo -n "$( echo "${*}" | sed -e "s/[\&\/\*\!]/\\\&/g;s/\[/\\\&/g;s/\]/\\\&/g" )" +} + +###======================================== +### strTrim() +### Usage: strTrim s1 flag +### Parameters: +### s1 : The input string +### flag : Integer +### A value that controls the action of strTrim. +### If flag is zero or not present, trailing blanks are removed. +### Leading blanks are removed if it is equal to 1. +### Both are removed if it is equal to 2. +### In any other case, trailing blanks are removed. +### +### Returns : NONE +### +### Exports : NONE +### +### Echoes : s1 with all leading and/or trailing +### white spaces removed. +### +### strTrim: Removes all leading and/or trailing white spaces +### from the input string +###======================================== +function strTrim () +{ + local trimFLG="${2:-0}" + local out_str= + + case ${trimFLG} in + 0) out_str="$(echo "${1}" | sed 's/[[:space:]]*$//')" ;; + 1) out_str="$(echo "${1}" | sed 's/^[[:space:]]*//')" ;; + 2) out_str="$(echo "${1}" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" ;; + *) out_str="$(echo "${1}" | sed 's/[[:space:]]*$//')" ;; + esac + + echo -n ${out_str} +} + +compileNems() { + local cmp_type cmp_make cmp_comp cmp_mjob + local err=0 + + [ $# -eq 0 ] && return ${err} + + cmp_type="$( toLOWER "${1}" )" + cmp_make=GNUmakefile + cmp_comp="${COMPONENT:+COMPONENTS=\"${COMPONENT}\"}" + cmp_mjob="${PARMAKE:+-j ${PARMAKE}}" + cmp_verb="${VERBOSE:+--debug=${VERBOSE}}" + + case "${cmp_type}" in + "clean"|"distclean" ) + if [ -f "${cmp_make}" ]; then + echo + echo "compileNems :: Cleaning: make -f ${cmp_make} ${cmp_type} ${cmp_comp}" + eval "make ${cmp_verb} -f ${cmp_make} ${cmp_type} ${cmp_comp}" + err=$? + + if [ "${cmp_type}" == "distclean" ]; then + rm -f NEMS/exe/NEMS-*.x + fi + else + echo "compileNems :: Cleaning: no makefile found: makefile = ${cmp_make}" + err=1 + fi + ;; + "build"|"compile" ) + if [ -f "${cmp_make}" ]; then + echo + echo "compileNems :: Compiling: make ${cmp_mjob} -f ${cmp_make} ${cmp_type} ${cmp_comp}" + eval "make ${cmp_verb} ${cmp_mjob} -f ${cmp_make} ${cmp_type} ${cmp_comp}" + err=$? + else + echo "compileNems :: Compiling: no makefile found: makefile = ${cmp_make}" + err=1 + fi + ;; + * ) err=0 ;; # Do nothing + esac + + return ${err} +} + +installNems() { + local cmp_comp icmp + local instdir + local CPBIN="/bin/cp -fpv" + local RMBIN="/bin/rm -fv" + + instdir="ALLBIN_INSTALL" + + cmp_comp="${COMPONENT}" + + [ ! -d "${instdir}" ] && mkdir -p ${instdir} + + for icmp in ${cmp_comp} + do + indir="${icmp}_INSTALL" + + if [ -d ${indir} ]; then + echo + echo " --- Installing from: ${indir} to ${instdir} ---" + ${CPBIN} ${indir}/* ${instdir}/ + fi + + ###### Extra ADCIRC files + if [ "${icmp}" == "ADCIRC" ]; then + echo + echo " --- Installing from: ${icmp} to ${instdir} ---" + for iprog in adcprep + do + prog="$( find ${icmp} -type f -name ${iprog} | head -1 )" + if [ -n "${prog:+1}" ]; then + ${CPBIN} ${prog} ${instdir}/ + fi + done + fi + ###### + done + + ###### Install the NEMS/exe/NEMS* files + echo + echo " --- Installing from: NEMS/exe to ${instdir} ---" + for iprog in NEMS/exe/NEMS-*.x + do + if [ -f "${iprog}" ]; then + ${CPBIN} ${iprog} ${instdir}/ + fi + done + + ###### Remove un-needed files from instdir + echo + echo " --- Removing files that are not needed from: ${instdir} ---" + ${RMBIN} ${instdir}/*.mk ${instdir}/*.mod +} diff --git a/scripts/functions_build.del b/scripts/functions_build.del new file mode 100644 index 00000000..ebb69270 --- /dev/null +++ b/scripts/functions_build.del @@ -0,0 +1,617 @@ +#!/bin/bash-*-Shell-script-functions*- + +########################################################################### +### Author: Panagiotis Velissariou +### +### Version - 1.0 Fri Dec 04 2020 +########################################################################### + +set +u + +MY_COMPILING_SYTEMS="gnu, intel, pgi" + +MY_ATM_MODS="ATMESH WRF HWRF PAHM" +MY_OCN_MODS="ADCIRC SCHISM FVCOM ROMS" +MY_HYD_MODS="NWM" +MY_WAV_MODS="WW3DATA WW3" + +MY_COMPONENT_LIST="${MY_ATM_MODS} ${MY_OCN_MODS} ${MY_HYD_MODS} ${MY_WAV_MODS} " + +################################################## +### MODELLING SYSTEM BUILD FUNCTIONS +################################################## + +###======================================== +### ParseArgs() +### Usage: ParseArgs args +### Parameters: args = the script options +### Returns: 0 +### Echoes: NONE +### +### Gets the supplied options to the script. +###======================================== +ParseArgs() +{ + local nm_func=$( basename ${BASH_SOURCE[${#BASH_SOURCE[@]}-1]} ) + + local opt_all opt_opt opt_arg opt_chk + + local t_VAR + local ans0 ans ival intN + local all_evars + + all_evars="MY_CLEAN MY_COMPILER MY_COMPONENT MY_OS MY_PARMAKE MY_PLATFORM MY_VERBOSE" + + for ival in ${all_evars}; do unset __${ival}; done + + + __MY_CLEAN=0 + __MY_COMPILER=intel + __MY_COMPONENT="ADCIRC WW3DATA ATMESH" + __MY_OS= + __MY_PARMAKE=1 + __MY_PLATFORM= + __MY_VERBOSE= + + + # ----- + # Process the function options + opt_all=( c clean compiler component j os plat v verbose h help ) + opt_all=":$( echo "${opt_all[@]/#/-} ${opt_all[@]/#/--}" | sed 's/ /:/g' ):" + + unset __OPTION_LIST + while test $# -gt 0; do + case "${1}" in + -[^-]*=* | --[^-]*=* ) + opt_opt="$( toLOWER "$( echo "${1}" | sed 's/=.*//' )" )" + len=$(( ${#opt_opt} + 1 )) + opt_arg="$( strTrim "$( echo "${1:${len}}" )" 2 )" + [ "$( echo "${opt_all}" | egrep -o ":${opt_arg}:" )" ] && \ + opt_arg= + ;; + -[^-]* | --[^-]* ) + opt_opt="$( toLOWER "${1}" )" + opt_chk="$( toLOWER "$( echo "${2}" | sed 's/=.*//' )" )" + if [ "$( echo "${opt_all}" | egrep -o ":${opt_chk}:" )" ]; then + opt_arg= + else + opt_arg="$( strTrim "$( echo "${2}" )" )" + fi + ;; + *) + opt_opt= + opt_arg= + ;; + esac + + case "${opt_opt}" in + -c | --c | -clean | --clean ) + checkFuncOpt "--clean" + if [ $? -eq 0 ]; then + __MY_CLEAN=1 + if [ "X${opt_arg}" != "X" ]; then + if `isInteger "${opt_arg}"` ; then + __MY_CLEAN=$( echo "${opt_arg}" ) + [ ${opt_arg} -le -3 ] && __MY_CLEAN=-3 + [ ${opt_arg} -ge 2 ] && __MY_CLEAN=2 + else + __MY_CLEAN=0 + [ "$( getYesNo "${opt_arg}" )" = "yes" ] && __MY_CLEAN=1 + fi + fi + fi + ;; + -compiler | --compiler ) + checkFuncOpt "--compiler" + if [ $? -eq 0 ]; then + if [ "X${opt_arg}" != "X" ]; then + __MY_COMPILER="$( echo "${opt_arg}" | sed 's/[[:space:]]//g' )" + fi + fi + ;; + -component | --component ) + checkFuncOpt "--component" + if [ $? -eq 0 ]; then + if [ "X${opt_arg}" != "X" ]; then + __MY_COMPONENT="$( strTrim "${opt_arg}" )" + fi + fi + ;; + -j | --j ) + checkFuncOpt "--j" + if [ $? -eq 0 ]; then + if [ "X${opt_arg}" != "X" ]; then + __MY_PARMAKE=1 + t_VAR="$( getPosInteger "${opt_arg}" )" + [ ! -z "${t_VAR}" ] && __MY_PARMAKE=${t_VAR} + fi + fi + ;; + -os | --os ) + checkFuncOpt "--os" + if [ $? -eq 0 ]; then + if [ "X${opt_arg}" != "X" ]; then + __MY_OS="$( echo "${opt_arg}" | sed 's/[[:space:]]//g' )" + fi + fi + ;; + -plat | --plat ) + checkFuncOpt "--plat" + if [ $? -eq 0 ]; then + if [ "X${opt_arg}" != "X" ]; then + __MY_PLATFORM="$( echo "${opt_arg}" | sed 's/[[:space:]]//g' )" + fi + fi + ;; + -v | --v | -verbose | --verbose ) + checkFuncOpt "--verbose" + if [ $? -eq 0 ]; then + __MY_VERBOSE=b + if [ "X${opt_arg}" != "X" ]; then + __MY_VERBOSE="$( echo "$( strTrim "${opt_arg}" 2 )" | sed 's/[[:space:]]/,/g' )" + fi + fi + ;; + -h | -help | --h | --help ) + UsageBuild ${nm_func} + ;; + *) ;; # DEFAULT + esac + shift + opt_opt= + opt_arg= + done + unset __OPTION_LIST + # ----- + + if [ -z "${__MY_OS}" ]; then + case "$(uname -s)" in + Darwin ) __MY_OS="macosx" ;; + Linux ) __MY_OS="linux" ;; + *) __MY_OS="UNDEFINED";; # DEFAULT + esac + fi + + # Export the values of all __* variables. + for ival in ${all_evars} + do + ans0="$( eval "echo \${$(echo ${ival}):-}" )" + ans="$( eval "echo \${$(echo __${ival}):-}" )" + ans=${ans:-${ans0:-}} + + eval "${ival}=\${ans}" + export ${ival} + + unset __${ival} + done + + return 0 +} + +UsageBuild() +{ + local nm="$( basename ${0} )" + + echo + echo "Usage: \"${nm}\" [{-|--}option1{=|space}[option_value1]] [{-|--}option2{=|space}[option_value2]] ..." + echo + + echo " -h|-help|--h|--help" + echo " Show this help screen." + echo + #--- + echo " -c|--c|-clean|--clean [=|space] \"0|1|yes|no\" (OPTIONAL)." + echo " Only clean the already compiled CMake build system." + echo " Default: 0|no." + echo + #--- + echo " -compiler|--compiler [=|space] \"compiling_system\" (OPTIONAL)." + echo " The compiling system to use (${MY_COMPILING_SYTEMS})." + echo " Default: intel." + echo + #--- + echo " -component|--component [=|space] \"component_list\" (OPTIONAL)." + echo " The component(s) to use (${MY_COMPONENT_LIST})." + echo " Default: \"ADCIRC WW3DATA ATMESH\"." + echo + #--- + echo " -j|--j [=|space] \"N\" (OPTIONAL)." + echo " Define the number of make jobs to run simultaneously." + echo " Default: 1." + echo + #--- + echo " -os|--os [=|space] \"OS string\" (OPTIONAL)." + echo " The name of the Operating system." + echo " Supported OSes: linux macosx." + echo " Default: current OS." + echo + #--- + echo " -plat|--plat [=|space] \"platform\" (OPTIONAL)." + echo " The name of the compute HPC platform to consider." + echo " Selecting a platform, environment modules specific to that platform are loaded" + echo " and corresponding environment variables are set." + echo " Supported platforms: cheyenne gaea hera jet orion stampede wcoss." + echo " Default: none." + echo + #--- + echo " -v|--v|-verbose|--verbose [=|space] \"a,b,v,i,j,m,n\" (any combination, OPTIONAL)." + echo " Enable verbosity in the make files during compilation." + echo " a (all) : all types of debugging output are enabled" + echo " n (none) : disable all debugging currently enabled" + echo " b (basic) : basic debugging and whether the build was successful or not" + echo " v (verbose) : a level above basic" + echo " i (implicit) : prints messages describing the implicit rule searches for each target" + echo " j (jobs) : prints messages giving details on the invocation of specific sub-commands" + echo " m (makefile) : enables messages while rebuilding makefiles" + echo " Default:none." + echo + #--- + + exit 0 +} + +###======================================== +### checkFuncOpt() +### Usage: checkFuncOpt opt_name +### Parameters: +### opt_name: The name of the option to a function +### +### Returns : Exits on error +### +### Exports : __OPTION_LIST +### +### Echoes : NONE +### +### checkFuncOpt: Checks if an option to a function is already supplied. +###======================================== +checkFuncOpt() { + local opt_inp opt_list + + [ $# -eq 0 ] && return -1 + + opt_inp="$( strTrim "${1}" 2 )" + opt_inp="$( echo "${opt_inp}" | sed 's/^[-]*//' )" + + opt_list="$( strTrim "${__OPTION_LIST}" 2 )" + [ -n ${opt_list:+1} ] && \ + opt_list=":$( echo "${opt_list}" | sed 's/ /:/g' ):" + + [ "$( echo "${opt_list}" | egrep -o ":${opt_inp}:" )" ] && return 1 + + __OPTION_LIST="${__OPTION_LIST} ${opt_inp}" + export __OPTION_LIST + + return 0 +} + +###======================================== +### isInteger() +### Usage: isInteger var +### Parameters: var +### Returns: 1 if var is not an integer (0 is an integer as well) +### 0 in any other case +### Echoes: NONE +###======================================== +isInteger() +{ + local -i retval=1 + + [ $# -eq 0 ] && return ${retval} + + if [ "${1:-UNDEF}" -eq "${1}" ] 2>/dev/null + then + retval=0 + fi + + return ${retval} +} + +###======================================== +### getInteger() +### Usage: getInteger int +### Parameters: int (int >=0 or, int < 0) +### Returns: 1 if var is not an integer +### 0 in any other case +### Echoes: int, if it is a valid integer (including 0), +### in any other case echoes an empty string +###======================================== +getInteger() +{ + local -i retval=0 + local echoval= minus= + + # strip spaces, '+' signs and '-' signs + # if the first character of the string is '-', set the minus variable + echoval="$( echo "${1}" | sed 's/[[:space:]+]//g' )" + [ "X$( echo "${echoval:0:1}" )" = "X-" ] && minus="-" + echoval="${minus}$( echo "${echoval}" | sed 's/[[:space:]-]//g' )" + + if isInteger ${echoval}; then + echoval="$(echo "scale=0; ${echoval} + 0" | bc -ql 2>/dev/null)" + retval=$? + echoval="${echoval:-0}" + else + echoval= + retval=1 + fi + + echo -n ${echoval} + + return ${retval} +} + +###======================================== +### getPosInteger() +### Usage: getPosInteger posint +### Parameters: posint (posint >= 0) +### Returns: 1 if var is not a positive integer +### 0 in any other case +### Echoes: posint if it is a valid positive integer +### (including 0), in any other case echoes an +### empty string +###======================================== +getPosInteger() +{ + local -i retval=0 + local echoval= + + echoval=$( getInteger "${1}" ) + retval=$? + + if [ ${retval} -ne 0 ] ; then + echoval= + retval=1 + else + if [ ${echoval} -lt 0 ]; then + echoval= + retval=1 + fi + fi + + echo -n ${echoval} + + return ${retval} +} + +###======================================== +### getYesNo() +### Usage: getYesNo value +### Parameters: +### value : The input value (the value of a parameter) +### The value of a bash parameter that is checked +### against TRUE/FALSE. If the value is one of: +### ">=1|y|yes|yea|yeah|yep" +### then the value of parameter is TRUE (answer = yes). +### If the value is one of: +### "<=0|n|no|not|nop|nope" +### then the value of parameter is FALSE (answer = no). +### If the value is empty then the value of parameter +### is FALSE (answer = no) +### +### Returns : NONE +### +### Exports : NONE +### +### Echoes : A "yes" or "no" answer. +### +### getYesNo: Checks if a parameter is assigned a TRUE/FALSE value. +###======================================== +getYesNo() +{ + local param answer + + param="$( echo "${1}" | tr '[:upper:]' '[:lower:]' )" + + if [ "${param}" -eq "${param}" ] 2>/dev/null + then + [ ${param} -le 0 ] && param=0 + [ ${param} -gt 0 ] && param=1 + fi + + case "${param}" in + 1|y|yes|yea|yeah|yep) answer="yes" ;; + 0|n|no|not|nop|nope) answer="no" ;; + *) answer="" ;; # DEFAULT + esac + + echo -n "${answer}" +} + +###======================================== +### toUPPER() +### Usage: toUPPER string +### Parameters: +### string : The string in to convert +### +### Returns : NONE +### +### Exports : NONE +### +### Echoes : The input string converted to an all upper case string +### +### toUPPER: Converts a string to an all upper case string +###======================================== +function toUPPER() +{ + echo "${1}" | tr '[:lower:]' '[:upper:]' +} + +###======================================== +### toLOWER() +### Usage: toLOWER string +### Parameters: +### string : The string in to convert +### +### Returns : NONE +### +### Exports : NONE +### +### Echoes : The input string converted to an all lower case string +### +### toLOWER: Converts a string to an all lower case string +###======================================== +function toLOWER() +{ + echo "${1}" | tr '[:upper:]' '[:lower:]' +} + +###======================================== +### strESC() +### Usage: strESC string +### Parameters: +### string : The input string +### The input string on which this function is applied +### to escape special characters used in bash/sed ... +### +### Returns : NONE +### +### Exports : NONE +### +### Echoes : The modified string with its special characters escaped +### +### strESC: Escapes special characters in a string: "'()/[]*. +###======================================== +strESC() +{ + echo -n "$( echo "${*}" | sed -e "s/[\"\'\(\)\/\*\!]/\\\&/g;s/\[/\\\&/g;s/\]/\\\&/g" )" +} + +strESC1() +{ + echo -n "$( echo "${*}" | sed -e "s/[\&\/\*\!]/\\\&/g;s/\[/\\\&/g;s/\]/\\\&/g" )" +} + +###======================================== +### strTrim() +### Usage: strTrim s1 flag +### Parameters: +### s1 : The input string +### flag : Integer +### A value that controls the action of strTrim. +### If flag is zero or not present, trailing blanks are removed. +### Leading blanks are removed if it is equal to 1. +### Both are removed if it is equal to 2. +### In any other case, trailing blanks are removed. +### +### Returns : NONE +### +### Exports : NONE +### +### Echoes : s1 with all leading and/or trailing +### white spaces removed. +### +### strTrim: Removes all leading and/or trailing white spaces +### from the input string +###======================================== +function strTrim () +{ + local trimFLG="${2:-0}" + local out_str= + + case ${trimFLG} in + 0) out_str="$(echo "${1}" | sed 's/[[:space:]]*$//')" ;; + 1) out_str="$(echo "${1}" | sed 's/^[[:space:]]*//')" ;; + 2) out_str="$(echo "${1}" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" ;; + *) out_str="$(echo "${1}" | sed 's/[[:space:]]*$//')" ;; + esac + + echo -n ${out_str} +} + +compileNems() { + local cmp_type cmp_make cmp_comp cmp_mjob + local err=0 + + [ $# -eq 0 ] && return ${err} + + cmp_type="$( toLOWER "${1}" )" + cmp_make=GNUmakefile + cmp_comp="${COMPONENT:+COMPONENTS=\"${COMPONENT}\"}" + cmp_mjob="${PARMAKE:+-j ${PARMAKE}}" + cmp_verb="${VERBOSE:+--debug=${VERBOSE}}" + + case "${cmp_type}" in + "clean"|"distclean" ) + if [ -f "${cmp_make}" ]; then + echo + echo "compileNems :: Cleaning: make -f ${cmp_make} ${cmp_type} ${cmp_comp}" + eval "make ${cmp_verb} -f ${cmp_make} ${cmp_type} ${cmp_comp}" + err=$? + + if [ "${cmp_type}" == "distclean" ]; then + rm -f NEMS/exe/NEMS-*.x + fi + else + echo "compileNems :: Cleaning: no makefile found: makefile = ${cmp_make}" + err=1 + fi + ;; + "build"|"compile" ) + if [ -f "${cmp_make}" ]; then + echo + echo "compileNems :: Compiling: make ${cmp_mjob} -f ${cmp_make} ${cmp_type} ${cmp_comp}" + eval "make ${cmp_verb} ${cmp_mjob} -f ${cmp_make} ${cmp_type} ${cmp_comp}" + err=$? + else + echo "compileNems :: Compiling: no makefile found: makefile = ${cmp_make}" + err=1 + fi + ;; + * ) err=0 ;; # Do nothing + esac + + return ${err} +} + +installNems() { + local cmp_comp icmp + local instdir + local CPBIN="/bin/cp -fpv" + local RMBIN="/bin/rm -fv" + + instdir="ALLBIN_INSTALL" + + cmp_comp="${COMPONENT}" + + [ ! -d "${instdir}" ] && mkdir -p ${instdir} + + for icmp in ${cmp_comp} + do + indir="${icmp}_INSTALL" + + if [ -d ${indir} ]; then + echo + echo " --- Installing from: ${indir} to ${instdir} ---" + ${CPBIN} ${indir}/* ${instdir}/ + fi + + ###### Extra ADCIRC files + if [ "${icmp}" == "ADCIRC" ]; then + echo + echo " --- Installing from: ${icmp} to ${instdir} ---" + for iprog in adcprep + do + prog="$( find ${icmp} -type f -name ${iprog} | head -1 )" + if [ -n "${prog:+1}" ]; then + ${CPBIN} ${prog} ${instdir}/ + fi + done + fi + ###### + done + + ###### Install the NEMS/exe/NEMS* files + echo + echo " --- Installing from: NEMS/exe to ${instdir} ---" + for iprog in NEMS/exe/NEMS-*.x + do + if [ -f "${iprog}" ]; then + ${CPBIN} ${iprog} ${instdir}/ + fi + done + + ###### Remove un-needed files from instdir + echo + echo " --- Removing files that are not needed from: ${instdir} ---" + ${RMBIN} ${instdir}/*.mk ${instdir}/*.mod +}