Skip to content
This repository was archived by the owner on Apr 8, 2021. It is now read-only.

Commit 9e8cf86

Browse files
authored
Rearrange how '-a' flag works for make script (#8)
Improving how the -a flag works. Instead of the old, clunky compile "some" or "all" (with 0 or 1, 0 being default), users can specify the application they need the libraries for. Options are global (the old default, -a 0), sar (the old -a 1), upp (a new implementation, still incomplete but will be done at the end of this larger effort), and all (all libraries) Kept in the ability to use the old flags (0 or 1) for back-compatability but these are no longer documented.
1 parent 3da51e1 commit 9e8cf86

File tree

2 files changed

+82
-40
lines changed

2 files changed

+82
-40
lines changed

Makefile

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,39 @@
33
include ./macros.make
44

55
# DH* move nemsio to end of all list
6-
nompi:
7-
$(MAKE) $(GMAKEMINUSJ) -C src/bacio/v2.0.1/src
8-
$(MAKE) $(GMAKEMINUSJ) -C src/ip/v3.0.0/sorc
9-
$(MAKE) $(MAKEMINUSJ) -C src/sp/v2.0.2/src
10-
$(MAKE) $(MAKEMINUSJ) -C src/sigio/v2.0.1/src
11-
$(MAKE) $(MAKEMINUSJ) -C src/w3emc/v2.2.0/src # Depends on sigio 2.0.1
12-
$(MAKE) $(MAKEMINUSJ) -C src/w3nco/v2.0.6/src
13-
14-
some: nompi
15-
$(MAKE) $(MAKEMINUSJ) -C src/nemsio/v2.2.3/src
16-
17-
all: some
18-
$(MAKE) $(MAKEMINUSJ) -C src/landsfcutil/v2.1.0/src
19-
$(MAKE) $(MAKEMINUSJ) -C src/sfcio/v1.0.0/src
20-
$(MAKE) $(MAKEMINUSJ) -C src/nemsiogfs/v2.0.1/src # Depends on nemsio 2.0.1
6+
nompi: core
7+
8+
core:
9+
$(MAKE) $(GMAKEMINUSJ) -C src/bacio/v2.0.1/src # GLOBAL,SAR,UPP
10+
$(MAKE) $(GMAKEMINUSJ) -C src/ip/v3.0.0/sorc # GLOBAL,SAR,UPP
11+
$(MAKE) $(MAKEMINUSJ) -C src/sp/v2.0.2/src # GLOBAL,SAR,UPP
12+
$(MAKE) $(MAKEMINUSJ) -C src/sigio/v2.0.1/src # GLOBAL,SAR,UPP
13+
$(MAKE) $(MAKEMINUSJ) -C src/w3emc/v2.2.0/src # GLOBAL,SAR,UPP; Depends on sigio 2.0.1
14+
$(MAKE) $(MAKEMINUSJ) -C src/w3nco/v2.0.6/src # GLOBAL,SAR,UPP
15+
16+
# nemsio gets separate stanza since it does not support serial build
17+
nemsio:
18+
$(MAKE) $(MAKEMINUSJ) -C src/nemsio/v2.2.3/src # GLOBAL,SAR,UPP
19+
20+
# sfcio gets separate stanza since it is used by both SAR and UPP
21+
sfcio:
22+
$(MAKE) $(MAKEMINUSJ) -C src/sfcio/v1.0.0/src # SAR,UPP
23+
24+
# Makerule for libraries needed for Stand-Alone Regional (SAR) FV3
25+
sar: core nemsio sfcio sarlibs
26+
sarlibs:
27+
$(MAKE) $(MAKEMINUSJ) -C src/landsfcutil/v2.1.0/src # SAR
28+
$(MAKE) $(MAKEMINUSJ) -C src/nemsiogfs/v2.0.1/src # SAR; Depends on nemsio 2.0.1
29+
30+
# Makerule for the Unified Post-Processor (UPP)
31+
upp: core nemsio sfcio upplibs
32+
upplibs:
33+
34+
# Makerule for original (global) libraries
35+
global: core nemsio
36+
37+
# Makerule for building all libraries
38+
all: core nemsio sfcio sarlibs upplibs
2139

2240
clean:
2341
$(MAKE) -C src/bacio/v2.0.1/src clean

make_ncep_libs.sh

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,27 @@
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-
1818
function fail { [ -n "$1" ] && printf "\n%s\n" "$1"; exit 1; }
1919

2020
function 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 )
4042
validcompilers=( intel pgi gnu )
4143
validopenmpflags=( 0 1 )
4244
validmpiflags=( 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
5860
done
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
6567
if [ -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)
6978
function checkvalid {
@@ -90,12 +99,12 @@ checkvalid SYSTEM ${SYSTEM} ${validsystems[@]}
9099
checkvalid COMPILER ${COMPILER} ${validcompilers[@]}
91100
checkvalid OPENMP ${OPENMP} ${validopenmpflags[@]}
92101
checkvalid 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
96105
if [ "$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
101110
fi
@@ -111,9 +120,15 @@ fi
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
119134
fi
@@ -170,12 +185,17 @@ cp -v ${MACROS_FILE}.${SYSTEM}.${COMPILER} ${MACROS_FILE}
170185
export OPENMP=${OPENMP}
171186
rsync -a macros.make Makefile src ${BUILD_DIR}
172187
cd ${BUILD_DIR}
173-
if [ "$COMPILEALL" == "1" ]; then
188+
if [ "$APP" == "all" ]; then
174189
make all || fail "An error occurred building the NCEP libraries"
175190
elif [ "$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"
177197
else
178-
make some || fail "An error occurred building the NCEP libraries"
198+
make global || fail "An error occurred building the NCEP libraries"
179199
fi
180200
export -n OPENMP
181201

@@ -193,5 +213,9 @@ cp -av ${BUILD_DIR}/include/* ${NCEPLIBS_DST_DIR}/include/
193213
cp -av ${BUILD_DIR}/lib*.a ${NCEPLIBS_DST_DIR}/lib/
194214

195215
echo
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
197221
echo

0 commit comments

Comments
 (0)