-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.sh
executable file
·166 lines (137 loc) · 5.03 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
160
161
162
163
164
165
166
#!/bin/csh -f
# download MOM6 code
# git clone --recursive https://github.com/NOAA-GFDL/MOM6-examples.git MOM6-examples
#
set argv=(`getopt -u -o h -l platform: -- $*`)
while ("$argv[1]" != "--")
switch ($argv[1])
case --platform:
set platform = $argv[2]; shift argv; breaksw
endsw
shift argv
end
shift argv
set BASEDIR=`pwd`
set MACHINE_ID=${platform}
set COMPILE_OPTION=${MACHINE_ID}-intel.mk
set compile_FMS=1
set compile_MOM6_LIB=0
set compile_ocean_only=0
set compile_MOM6_SIS2=1
###############################
if ( ${compile_FMS} == 1 ) then
echo "compile FMS library ..."
cd $BASEDIR
mkdir -p build/intel/shared/repro
cd build/intel/shared/repro
if ( -f path_names ) then
rm -f path_names
endif
echo "generating file_paths ..."
../../../../src/mkmf/bin/list_paths ../../../../src/FMS
echo "generating makefile ..."
../../../../src/mkmf/bin/mkmf -t ../../../../src/mkmf/templates/${COMPILE_OPTION} -p libfms.a -c "-Duse_libMPI -Duse_netCDF -DSPMD" path_names
echo "compiling FMS library..."
make NETCDF=4 REPRO=1 libfms.a -j
set result=$?
if ( $result != 0 ) then
echo "compiling FMS failed"
exit 8
else
echo "compiling FMS library successful"
endif
cp libfms.a lib_FMS.a
endif
echo "====================================================="
###############################################
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
endif
echo "generating file_paths ..."
../../../../src/mkmf/bin/list_paths ../../../../src/MOM6/src/*/ ../../../../src/MOM6/src/*/*/ ../../../../src/MOM6/config_src/dynamic_symmetric/ ../../../../src/MOM6/config_src/coupled_driver/
echo "generating makefile ..."
../../../../src/mkmf/bin/mkmf -t ../../../../src/mkmf/templates/${COMPILE_OPTION} -p lib_ocean.a -o '-I../../shared/repro' path_names
echo "compiling MOM6 library..."
make NETCDF=4 REPRO=1 lib_ocean.a
set result=$?
if ( $result != 0 ) then
echo "compiling MOM6 failed"
exit 8
else
echo "compiling MOM6 library successful"
endif
# 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
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/MOM6_LIB/repro exec/${MACHINE_ID}/lib_ocean
endif
###############################################
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
endif
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' -p 'MOM6 -L../../shared/repro -lfms' -c "-Duse_libMPI -Duse_netcdf -DSPMD" path_names
echo "compiling MOM6 ocean only ..."
make NETCDF=4 REPRO=1 MOM6 -j
set result=$?
if ( $result != 0 ) then
echo "compiling Ocean_only exectuable failed"
exit 8
else
echo "compiling Ocean_only exectuable successful"
endif
# echo "generating libocean.a"
# ar rv libocean.a *o
endif
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
endif
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 ..."
make NETCDF=4 REPRO=1 MOM6 -j
set result=$?
if ( $result != 0 ) then
echo "compiling MOM6-SIS2 exectuable/lib failed"
exit 8
else
echo "compiling MOM6-SIS2 exectuable/lib successful"
endif
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
endif