77#
88# Examples:
99# > ./make_ncep_libs.sh -h
10- # > ./make_ncep_libs.sh -s theia -c intel -d /scratch4/home/USERNAME/NCEPlibs-20180401 -o 1
10+ # > ./make_ncep_libs.sh -s hera -c intel -d /scratch4/home/USERNAME/NCEPlibs-20180401 -o 1
1111# > ./make_ncep_libs.sh -s cheyenne -c pgi -d /glade/p/work/USERNAME/NCEPlibs-20180401 -o 0
1212# > ./make_ncep_libs.sh -s macosx -c gnu -d /usr/local/NCEPlibs-20180401 -o 1
13+ # > ./make_ncep_libs.sh -s cheyenne -c gnu -d /glade/p/work/USERNAME/NCEPlibs-20180401 -o 0 -a sar
1314#
1415# ==========================================================================
1516
1617# Define functions.
17-
1818function fail { [ -n " $1 " ] && printf " \n%s\n" " $1 " ; exit 1; }
1919
2020function usage {
2121 echo " Usage: "
22- echo " $THIS_FILE -s system -c compiler -d installdir -o openmp [-m mpi] [-a compileall] | -h"
23- echo " Where: system [required] can be : ${validsystems[@]} "
24- echo " compiler [required] can be : ${validcompilers[@]} "
25- echo " installdir [required] is the installation destination (must exist)"
26- echo " openmp [required] is an OpenMP build flag and can be ${validopenmpflags[@]} "
27- echo " mpi [optional] is an MPI build flag and can be ${validmpiflags[@]} (default 1; if 0, nemsio is not built and compileall must be 0)"
28- echo " compileall [optional] is a flag to build the full set of libraries (only valid on theia, cheyenne and macosx) and can be ${validcompileallflags[@]} "
22+ echo " $THIS_FILE -s system -c compiler -d installdir -o openmp [-m mpi] [-a application] | -h"
23+ echo " Where: system [required] can be : ${validsystems[@]} "
24+ echo " compiler [required] can be : ${validcompilers[@]} "
25+ echo " installdir [required] is the installation destination (must exist)"
26+ echo " openmp [required] is an OpenMP build flag and can be ${validopenmpflags[@]} "
27+ echo " mpi [optional] is an MPI build flag and can be ${validmpiflags[@]} "
28+ echo " (default 1; if 0, nemsio is not built and application must be 'global')"
29+ echo " application [optional] is a flag to build certain sets of libraries for specific applications"
30+ echo " The default is 'global', the full set of options is: ${validapplicationflags[@]} "
2931 exit 1
3032}
3133
@@ -40,7 +42,7 @@ validsystems=( hera theia jet gaea cheyenne macosx linux )
4042validcompilers=( intel pgi gnu )
4143validopenmpflags=( 0 1 )
4244validmpiflags=( 0 1 )
43- validcompileallflags =( 0 1 )
45+ validapplicationflags =( global sar all )
4446# --------------------------------------------------------------
4547# Parse command line arguments
4648# --------------------------------------------------------------
@@ -51,19 +53,26 @@ while getopts :s:c:d:o:m:a:help opt; do
5153 d) NCEPLIBS_DST_DIR=$OPTARG ;;
5254 o) OPENMP=$OPTARG ;;
5355 m) MPI=$OPTARG ;;
54- a) COMPILEALL =$OPTARG ;;
56+ a) APP =$OPTARG ;;
5557 h) usage ;;
5658 * ) usage ;;
5759 esac
5860done
5961
6062# Check if all mandatory arguments are provided
61- if [ -z $SYSTEM ] ; then usage; fi
62- if [ -z $COMPILER ] ; then usage; fi
63- if [ -z $NCEPLIBS_DST_DIR ] ; then usage; fi
64- if [ -z $OPENMP ] ; then usage; fi
63+ if [ -z $SYSTEM ] ; then echo " ERROR: system argument is required " ; echo " " ; usage; fi
64+ if [ -z $COMPILER ] ; then echo " ERROR: compiler argument is required " ; echo " " ; usage; fi
65+ if [ -z $NCEPLIBS_DST_DIR ] ; then echo " ERROR: installdir argument is required " ; echo " " ; usage; fi
66+ if [ -z $OPENMP ] ; then echo " ERROR: openmp argument is required " ; echo " " ; usage; fi
6567if [ -z $MPI ] ; then MPI=1; fi
66- if [ -z $COMPILEALL ] ; then COMPILEALL=0; fi # COMPILEALL is an optional argument
68+ if [ -z $APP ] ; then APP=0; fi # APP is an optional argument
69+
70+ # For back compatability, allow APP to be 0 (global) or 1 (all)
71+ if [ " $APP " == " 0" ]; then
72+ $APP = " global"
73+ elif [ " $APP " == " 1" ]; then
74+ $APP = " all"
75+ fi
6776
6877# Ensure value ($2) of variable ($1) is contained in list of validvalues ($3)
6978function checkvalid {
@@ -90,12 +99,12 @@ checkvalid SYSTEM ${SYSTEM} ${validsystems[@]}
9099checkvalid COMPILER ${COMPILER} ${validcompilers[@]}
91100checkvalid OPENMP ${OPENMP} ${validopenmpflags[@]}
92101checkvalid MPI ${MPI} ${validmpiflags[@]}
93- checkvalid COMPILEALL ${COMPILEALL } ${validcompileallflags [@]}
102+ checkvalid APP ${APP } ${validapplicationflags [@]}
94103
95- # Consistency check: if MPI is zero, COMPILEALL must be zero, too
104+ # Consistency check: if MPI is zero, APP must be zero, too
96105if [ " $MPI " == " 0" ]; then
97- if [ " $COMPILEALL " == " 1 " ]; then
98- echo " ERROR: Option -a compileall must be zero if MPI is desiabled ."
106+ if [ " $APP " != " global " ]; then
107+ echo " ERROR: Option -a (application) must be 'global' if MPI is disabled ."
99108 exit 1
100109 fi
101110fi
111120# --------------------------------------------------------------
112121# Check that all libraries are available on this platform
113122# --------------------------------------------------------------
114- if [ " $COMPILEALL " == " 1" ]; then
123+ if [ " $APP " == " 1" ]; then
115124 if [ " ${SYSTEM} " != " cheyenne" -a " ${SYSTEM} " != " macosx" -a " ${SYSTEM} " != " theia" -a " ${SYSTEM} " != " hera" ]; then
116- echo " ERROR: Compile all option (-a 1) only supported for 'cheyenne', 'macosx', 'theia' and 'hera' at this time"
125+ echo " ERROR: Compile all option (-a 1) only supported for 'cheyenne', 'macosx', and 'hera' at this time"
126+ exit 1
127+ fi
128+ fi
129+ if [ " $APP " == " upp" ] || [ " $APP " == " sar" ]; then
130+ if [ " ${SYSTEM} " != " cheyenne" -a " ${SYSTEM} " != " macosx" -a " ${SYSTEM} " != " hera" ]; then
131+ echo " ERROR: upp and sar library sets are only supported for 'cheyenne', 'macosx', and 'hera' at this time"
117132 exit 1
118133 fi
119134fi
@@ -170,12 +185,17 @@ cp -v ${MACROS_FILE}.${SYSTEM}.${COMPILER} ${MACROS_FILE}
170185export OPENMP=${OPENMP}
171186rsync -a macros.make Makefile src ${BUILD_DIR}
172187cd ${BUILD_DIR}
173- if [ " $COMPILEALL " == " 1 " ]; then
188+ if [ " $APP " == " all " ]; then
174189 make all || fail " An error occurred building the NCEP libraries"
175190elif [ " $MPI " == " 0" ]; then
176191 make nompi || fail " An error occurred building the NCEP libraries"
192+ elif [ " $APP " == " upp" ]; then
193+ echo " UPP libraries are not yet supported"
194+ fail " An error occurred building the NCEP libraries"
195+ elif [ " $APP " == " sar" ]; then
196+ make sar || fail " An error occurred building the NCEP libraries"
177197else
178- make some || fail " An error occurred building the NCEP libraries"
198+ make global || fail " An error occurred building the NCEP libraries"
179199fi
180200export -n OPENMP
181201
@@ -193,5 +213,9 @@ cp -av ${BUILD_DIR}/include/* ${NCEPLIBS_DST_DIR}/include/
193213cp -av ${BUILD_DIR} /lib* .a ${NCEPLIBS_DST_DIR} /lib/
194214
195215echo
196- echo " To build FV3, set environment variable NCEPLIBS_DIR to ${NCEPLIBS_DST_DIR} "
216+ if [ " $APP " == " upp" ]; then
217+ echo " To build UPP, set environment variable NCEPLIBS_DIR to ${NCEPLIBS_DST_DIR} "
218+ else
219+ echo " To build FV3, set environment variable NCEPLIBS_DIR to ${NCEPLIBS_DST_DIR} "
220+ fi
197221echo
0 commit comments