forked from NOAA-EMC/MOM6-interface
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.sh
executable file
·159 lines (129 loc) · 5.1 KB
/
compile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/sh
sadness() {
echo "$@" 1>&2
exit 8
}
# download MOM6 code
# git clone --recursive https://github.com/NOAA-GFDL/MOM6-examples.git MOM6-examples
#
while [[ "$#" > 0 ]] ; do
if [[ "$1" == "--fms-dir" ]] ; then
FMS_DIR=$2
shift
elif [[ "$1" == "--platform" ]] ; then
platform="$2"
shift
elif [[ "$1" == "--" ]] ; then
shift
break
fi
shift
done
if [[ "${FMS_DIR:-Q}" == Q ]] ; then
export FMS_DIR=$( cd ../FMS/FMS_INSTALL ; pwd -P )
fi
if [[ "${platform:-Q}" == Q ]] ; then
sadness "Please provide --platform"
fi
if [[ -d "$FMS_DIR" ]] ; then
echo "Will use FMS from: $FMS_DIR"
else
sadness "NO FMS!! Set FMS_DIR variable or use --fms-dir"
fi
set -xue
BASEDIR=`pwd`
MACHINE_ID=${platform}
COMPILE_OPTION=${MACHINE_ID}-intel.mk
# Build in debug mode. If DEBUG=Y, enable DEBUG compilation.
# Otherwise, default to REPRO compilation. This flag is
# set in ${ROOTDIR}/coupledFV3_MOM6_CICE_debug.appBuilder file.
DEBUG=${DEBUG:-}
REPRO=${REPRO:-}
if [[ ${DEBUG} == "Y" ]] ; then
DEBUG=1
else
REPRO=1
fi
echo "MOM6 compile.sh ... DEBUG=${DEBUG}, REPRO=${REPRO}"
compile_MOM6_LIB=1
compile_ocean_only=0
compile_MOM6_SIS2=0
###############################################
if [[ ${compile_MOM6_LIB} == 1 ]] ; then
echo "compile MOM6 library ..."
cd $BASEDIR
mkdir -p build/intel/MOM6_LIB/repro
cd build/intel/MOM6_LIB/repro
if [[ -f path_names ]] ; then
rm -f path_names
fi
echo "generating file_paths ..."
../../../../src/mkmf/bin/list_paths ../../../../src/MOM6/src/*/ ../../../../src/MOM6/src/*/*/ ../../../../src/MOM6/config_src/dynamic/ ../../../../src/MOM6/config_src/nuopc_driver/{mom_ocean_model_nuopc.F90,mom_surface_forcing_nuopc.F90}
echo "generating makefile ..."
../../../../src/mkmf/bin/mkmf -t ../../../../src/mkmf/templates/${COMPILE_OPTION} -p lib_ocean.a -o "-I${FMS_DIR}" path_names
echo "compiling MOM6 library..."
if ( ! make NETCDF=4 REPRO=${REPRO} DEBUG=${DEBUG} lib_ocean.a ) ; then
sadness "compiling MOM6 failed"
fi
echo "compiling MOM6 library successful"
# ar rv lib_ocean.a *o
echo "compiling MOM6 library done"
# Install library and module files for NEMSAppbuilder
cd $BASEDIR
mkdir -p exec/${MACHINE_ID}/
# link to the library and module files
ln -s ${BASEDIR}/build/intel/MOM6_LIB/repro exec/${MACHINE_ID}/lib_ocean
fi
###############################################
if [[ ${compile_ocean_only} == 1 ]] ; then
echo "compile ocean only ..."
cd $BASEDIR
mkdir -p build/intel/ocean_only/repro
cd build/intel/ocean_only/repro
if [[ -f path_names ]] ; then
rm -f path_names
fi
echo "generating file_paths ..."
../../../../src/mkmf/bin/list_paths ./ ../../../../src/MOM6/{config_src/dynamic,pkg/CVMix-src/src/shared,config_src/solo_driver,src/{*,*/*}}
echo "generating makefile ..."
../../../../src/mkmf/bin/mkmf -t ../../../../src/mkmf/templates/${COMPILE_OPTION} -o "-I../../shared/repro -I${FMS_DIR}" -p "MOM6 -L${FMS_DIR} -L../../shared/repro -lfms" -c "-Duse_libMPI -Duse_netcdf -DSPMD" path_names
echo "compiling MOM6 ocean only ..."
if ( ! make NETCDF=4 REPRO=1 MOM6 -j ) ; then
sadness "compiling Ocean_only exectuable failed"
fi
echo "compiling Ocean_only exectuable successful"
# echo "generating libocean.a"
# ar rv libocean.a *o
fi
echo "=================================================="
#######################################
if [[ ${compile_MOM6_SIS2} == 1 ]] ; then
echo "compiling MOM6-SIS2 ..."
cd $BASEDIR
mkdir -p build/intel/ice_ocean_SIS2/repro
cd build/intel/ice_ocean_SIS2/repro
if [[ -f path_names ]] ; then
rm -f path_names
fi
echo "generating file_paths ..."
../../../../src/mkmf/bin/list_paths ./ ../../../../src/MOM6/config_src/{dynamic,coupled_driver} ../../../../src/MOM6/src/{*,*/*}/ ../../../../src/{atmos_null,coupler,land_null,ice_ocean_extras,icebergs,SIS2,FMS/coupler,FMS/include}
echo "generating makefile ..."
../../../../src/mkmf/bin/mkmf -t ../../../../src/mkmf/templates/${COMPILE_OPTION} -o '-I../../shared/repro' -p MOM6 -l '-L../../shared/repro -lfms' -c '-Duse_libMPI -Duse_netcdf -DSPMD -DUSE_LOG_DIAG_FIELD_INFO -Duse_AM3_physics -D_USE_LEGACY_LAND_' path_names
echo "compiling MOM6 ocean only ..."
if ( ! make NETCDF=4 REPRO=1 MOM6 -j ) ; then
sadness "compiling MOM6-SIS2 exectuable/lib failed" 1>&2
fi
echo "compiling MOM6-SIS2 exectuable/lib successful"
echo "generating lib_ocean.a"
rm repro
ar rv lib_ocean.a *o
echo "compiling MOM6-SIS2 done"
# Install library and module files for NEMSAppbuilder
cd $BASEDIR
mkdir -p exec/${MACHINE_ID}/
# link to the library and module files
rm -rf exec/${MACHINE_ID}/lib_FMS exec/${MACHINE_ID}/lib_ocean
ln -s ${BASEDIR}/build/intel/shared/repro exec/${MACHINE_ID}/lib_FMS
ln -s ${BASEDIR}/build/intel/ice_ocean_SIS2/repro exec/${MACHINE_ID}/lib_ocean
fi
echo "Next recommended step is to rejoice out of happiness from a successful compile."