1 |
cnh |
1.1 |
#!/bin/csh -f |
2 |
|
|
# |
3 |
adcroft |
1.22.2.4 |
# $Header: /u/gcmpack/models/MITgcmUV/tools/genmake,v 1.22.2.3 2001/01/25 17:56:33 adcroft Exp $ |
4 |
cnh |
1.1 |
# |
5 |
|
|
# Makefile generator for MITgcm UV codes |
6 |
|
|
# created by cnh 03/98 |
7 |
|
|
# adapted by aja 06/98 |
8 |
|
|
|
9 |
|
|
# Process command-line arguments |
10 |
|
|
set allargs=( $argv ) |
11 |
|
|
while ($#allargs) |
12 |
|
|
set arg = $allargs[1] |
13 |
|
|
switch ($arg) |
14 |
adcroft |
1.9 |
case -makefile: |
15 |
|
|
set mfile = ( Makefile ) |
16 |
|
|
breaksw |
17 |
|
|
case -makefile=*: |
18 |
|
|
set mfile = ( `echo $arg | sed 's/-makefile=//' `) |
19 |
cnh |
1.1 |
breaksw |
20 |
|
|
case -platform: |
21 |
|
|
case -platform=: |
22 |
|
|
echo "To change platform you must specify one with -platform=" |
23 |
|
|
echo "eg. -platform=sparc or -platform=mips" |
24 |
|
|
exit |
25 |
|
|
breaksw |
26 |
|
|
case -platform*: |
27 |
|
|
set platform = ( `echo $arg | sed 's/-platform=//' `) |
28 |
|
|
breaksw |
29 |
adcroft |
1.22.2.1 |
case -rootdir=*: |
30 |
|
|
set ROOTDIR = ( `echo $arg | sed 's/-rootdir=//' `) |
31 |
|
|
breaksw |
32 |
|
|
case -mymods=*: |
33 |
|
|
set MYMODS = ( `echo $arg | sed 's/-mymods=//' `) |
34 |
|
|
breaksw |
35 |
cnh |
1.1 |
case -mpi: |
36 |
|
|
echo "Enabling MPI options" |
37 |
|
|
set USEMPI |
38 |
|
|
breaksw |
39 |
adcroft |
1.12 |
case -jam: |
40 |
|
|
set include_jam_libs |
41 |
|
|
echo "Including paths to JAM libraries" |
42 |
|
|
breaksw |
43 |
cnh |
1.1 |
case -help: |
44 |
|
|
echo "usage: $0 [-help] [-makefile[=...]] [-platform=...] [-mpi]" |
45 |
|
|
exit |
46 |
|
|
breaksw |
47 |
|
|
default: |
48 |
|
|
echo "Unknown command-line option: " $arg |
49 |
|
|
echo $0 "-help to show usage" |
50 |
|
|
exit |
51 |
|
|
breaksw |
52 |
|
|
endsw |
53 |
|
|
shift allargs |
54 |
|
|
end |
55 |
cnh |
1.6 |
|
56 |
adcroft |
1.22.2.1 |
# Default actions/options |
57 |
|
|
|
58 |
|
|
# If platform wasn't specified then determine platform type of the host |
59 |
cnh |
1.6 |
if ($?platform == 0) then |
60 |
|
|
set platform = (`uname`) |
61 |
|
|
endif |
62 |
adcroft |
1.22.2.1 |
# If name of makefile wasn't specified then use default "Makefile" |
63 |
|
|
if ($?mfile == 0) set mfile = ( Makefile ) |
64 |
|
|
|
65 |
cnh |
1.1 |
set mach = ( `uname -a` ) |
66 |
|
|
echo Operating system: $mach |
67 |
|
|
|
68 |
adcroft |
1.22.2.1 |
|
69 |
cnh |
1.1 |
# Directories for source, includes, binaries and executables |
70 |
|
|
# Note |
71 |
|
|
# o If you prefer/need everything under a single directory |
72 |
|
|
# copy everything in ../eesupp/src, ../model/src, |
73 |
|
|
# ../eesupp/inc and ../model/inc into a directory and then |
74 |
|
|
# edit the paths below to ./ |
75 |
adcroft |
1.22.2.1 |
# |
76 |
|
|
# If -rootdir wasn't specified then assume script is being run from bin |
77 |
|
|
# but if it was supplied then we should place the executable in the build dir |
78 |
|
|
if ($?ROOTDIR == 0) then |
79 |
|
|
set ROOTDIR = ( .. ) |
80 |
|
|
else |
81 |
|
|
if ($?EXEDIR == 0) set EXEDIR = ( ./ ) |
82 |
|
|
endif |
83 |
|
|
if ($?MYMODS == 0) then |
84 |
|
|
set SOURCEDIRS = ( $ROOTDIR/{eesupp,model,diags}/src/ $ROOTDIR/pkg/[a-z]*/ ) |
85 |
|
|
set INCLUDEDIRS = ( ./ $ROOTDIR/{eesupp,model,diags}/inc/ $ROOTDIR/pkg/[a-z]*/ ) |
86 |
|
|
else |
87 |
adcroft |
1.22.2.3 |
set SOURCEDIRS = ( $MYMODS/ $ROOTDIR/{eesupp,model,diags}/src/ $ROOTDIR/pkg/[a-z]*/ ) |
88 |
adcroft |
1.22.2.1 |
set INCLUDEDIRS = ( ./ $MYMODS/ $ROOTDIR/{eesupp,model,diags}/inc/ $ROOTDIR/pkg/[a-z]*/ ) |
89 |
|
|
endif |
90 |
|
|
if ($?BUILDDIR == 0) set BUILDDIR = ( ./ ) |
91 |
|
|
if ($?EXEDIR == 0) set EXEDIR = ( $ROOTDIR/exe/ ) |
92 |
|
|
if ($?EXECUTABLE == 0) set EXECUTABLE = ( mitgcmuv ) |
93 |
|
|
if ($?TOOLSDIR == 0) set TOOLSDIR = ( $ROOTDIR/tools/ ) |
94 |
cnh |
1.1 |
|
95 |
|
|
# This is the generic configuration. |
96 |
|
|
# Platform specific options are chosen below |
97 |
adcroft |
1.22.2.1 |
set LN = ( 'ln -s' ) |
98 |
cnh |
1.1 |
set CPP = ( '/lib/cpp -P' ) |
99 |
|
|
set KPP = ( ) |
100 |
|
|
set FC = ( 'f77' ) |
101 |
|
|
set LINK = ( 'f77' ) |
102 |
|
|
set DEFINES = ( ) |
103 |
|
|
set INCLUDES = ( ) |
104 |
|
|
set FFLAGS = ( ) |
105 |
|
|
set FOPTIM = ( ) |
106 |
|
|
set KFLAGS1 = ( ) |
107 |
|
|
set KFLAGS2 = ( ) |
108 |
|
|
set LIBS = ( ) |
109 |
|
|
set KPPFILES = ( ) |
110 |
|
|
set NOOPTFILES = ( ) |
111 |
|
|
set NOOPTFLAGS = ( ) |
112 |
|
|
set RMFILES = ( ) |
113 |
|
|
|
114 |
|
|
# We often want to use different compile/link options is using MPI |
115 |
|
|
if ($?USEMPI) then |
116 |
|
|
set USEMPI = ( '+mpi' ) |
117 |
|
|
set DEFINES = ( ${DEFINES} '-DALLOW_USE_MPI -DALWAYS_USE_MPI' ) |
118 |
|
|
else |
119 |
|
|
set USEMPI |
120 |
|
|
# set DEFINES = ( ${DEFINES} '-UALLOW_USE_MPI -UALWAYS_USE_MPI' ) |
121 |
|
|
endif |
122 |
|
|
|
123 |
|
|
# Platform specific options |
124 |
|
|
switch ($platform$USEMPI) |
125 |
cnh |
1.6 |
case OSF1: |
126 |
|
|
case OSF1+mpi: |
127 |
cnh |
1.1 |
echo "Configuring for DEC Alpha" |
128 |
|
|
set CPP = ( '/usr/bin/cpp -P' ) |
129 |
adcroft |
1.10 |
set DEFINES = ( ${DEFINES} '-DTARGET_DEC -DWORDLENGTH=1' ) |
130 |
cnh |
1.1 |
set KPP = ( 'kapf' ) |
131 |
cnh |
1.4 |
set KPPFILES = ( 'main.F' ) |
132 |
cnh |
1.1 |
set KFLAGS1 = ( '-scan=132 -noconc -cmp=' ) |
133 |
|
|
set FC = ( 'f77' ) |
134 |
adcroft |
1.2 |
set FFLAGS = ( '-convert big_endian -r8 -extend_source -u -automatic -call_shared -notransform_loops -align dcommons' ) |
135 |
cnh |
1.1 |
set FOPTIM = ( '-O5 -fast -tune host -inline all' ) |
136 |
|
|
set NOOPTFLAGS = ( '-O0' ) |
137 |
|
|
set LIBS = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' ) |
138 |
heimbach |
1.20 |
set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F') |
139 |
cnh |
1.1 |
set RMFILES = ( '*.p.out' ) |
140 |
|
|
breaksw |
141 |
cnh |
1.6 |
case IRIX64+mpi: |
142 |
cnh |
1.1 |
echo "Configuring for SGI Mips with MPI" |
143 |
adcroft |
1.11 |
set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) |
144 |
cnh |
1.1 |
set INCLUDES = ( '-I/usr/local/mpi/include' ) |
145 |
|
|
set FC = ( 'mpif77' ) |
146 |
|
|
set LINK = ( 'mpif77' ) |
147 |
adcroft |
1.11 |
set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' ) |
148 |
cnh |
1.1 |
set FOPTIM = ( '-O3' ) |
149 |
|
|
set RMFILES = ( 'rii_files' ) |
150 |
|
|
breaksw |
151 |
cnh |
1.6 |
case IRIX64: |
152 |
cnh |
1.1 |
echo "Configuring for SGI Mips" |
153 |
adcroft |
1.11 |
set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) |
154 |
cnh |
1.1 |
set INCLUDES = ( '-I/usr/local/mpi/include' ) |
155 |
|
|
set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4' ) |
156 |
adcroft |
1.11 |
set FOPTIM = ( '-O3' ) |
157 |
|
|
# set NOOPTFLAGS = ( '-O0' ) |
158 |
|
|
# set NOOPTFILES = ( 'barrier.F different_multiple.F ' \ |
159 |
heimbach |
1.20 |
# 'external_fields_load.F' ) |
160 |
cnh |
1.1 |
set RMFILES = ( 'rii_files' ) |
161 |
|
|
breaksw |
162 |
heimbach |
1.20 |
case o2: |
163 |
|
|
case IRIX: |
164 |
|
|
echo "Configuring for SGI O2 running IRIX 6.5" |
165 |
|
|
set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) |
166 |
|
|
set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' ) |
167 |
|
|
set FOPTIM = ( '-O2' ) |
168 |
|
|
set NOOPTFLAGS = ( '-O0' ) |
169 |
|
|
breaksw |
170 |
|
|
case o2+mpi: |
171 |
|
|
case IRIX+mpi: |
172 |
|
|
echo "Configuring for SGI O2 running IRIX 6.5 with MPI" |
173 |
|
|
set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) |
174 |
|
|
set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' ) |
175 |
|
|
set FOPTIM = ( '-O2' ) |
176 |
|
|
set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F' ) |
177 |
|
|
set NOOPTFLAGS = ( '-O0' ) |
178 |
|
|
set LIBS = ( '-lmpi' ) |
179 |
|
|
breaksw |
180 |
|
|
case o2k+mpi: |
181 |
|
|
echo "Configuring for SGI Origin2000 running IRIX 6.5" |
182 |
|
|
set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) |
183 |
|
|
set INCLUDES = ( '-I/usr/include' ) |
184 |
|
|
set FFLAGS = ( '-n32 -extend_source -bytereclen' ) |
185 |
|
|
set FOPTIM = ( '-O2' ) |
186 |
|
|
set NOOPTFILES = ( 'calc_mom_rhs.F' ) |
187 |
|
|
set NOOPTFLAGS = ( '-O1' ) |
188 |
|
|
set LIBS = ( '-lmpi -lscs' ) |
189 |
|
|
breaksw |
190 |
|
|
case onyx: |
191 |
|
|
case onyx+mpi: |
192 |
|
|
echo "Configuring for SGI ONYX running IRIX64" |
193 |
|
|
set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) |
194 |
|
|
set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' ) |
195 |
|
|
set FOPTIM = ( '-O2' ) |
196 |
|
|
set NOOPTFLAGS = ( '-O0' ) |
197 |
|
|
set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F' ) |
198 |
|
|
set LIBS = ( '-lmpi' ) |
199 |
|
|
breaksw |
200 |
cnh |
1.6 |
case SunOS: |
201 |
adcroft |
1.22.2.1 |
set LN = ( '/usr/bin/ln -s' ) |
202 |
cnh |
1.6 |
set CPP = ( '/usr/ccs/lib/cpp -P' ) |
203 |
adcroft |
1.11 |
set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4' ) |
204 |
cnh |
1.6 |
set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar') |
205 |
heimbach |
1.20 |
set FOPTIM = ( '-fast -O3' ) |
206 |
cnh |
1.6 |
set NOOPTFLAGS = ( '-O0' ) |
207 |
heimbach |
1.20 |
set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F ini_vertical_grid.F') |
208 |
cnh |
1.6 |
breaksw |
209 |
|
|
case SunOS+mpi: |
210 |
adcroft |
1.22.2.1 |
set LN = ( '/usr/bin/ln -s' ) |
211 |
cnh |
1.1 |
set CPP = ( '/usr/ccs/lib/cpp -P' ) |
212 |
adcroft |
1.11 |
set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4' ) |
213 |
cnh |
1.1 |
set INCLUDES = ( '-I/usr/local/mpi/include' ) |
214 |
|
|
set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar') |
215 |
heimbach |
1.20 |
set FOPTIM = ( '-fast -O3' ) |
216 |
cnh |
1.1 |
set NOOPTFLAGS = ( '-O0' ) |
217 |
|
|
set LIBS = ( '-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread' \ |
218 |
cnh |
1.6 |
'-lsocket -lnsl' ) |
219 |
heimbach |
1.20 |
set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F ini_vertical_grid.F') |
220 |
cnh |
1.3 |
breaksw |
221 |
cnh |
1.6 |
case IRIX32: |
222 |
cnh |
1.3 |
echo "Configuring for SGI ONYX running IRIX64" |
223 |
adcroft |
1.11 |
set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) |
224 |
cnh |
1.3 |
set INCLUDES = ( '-I/usr/include' ) |
225 |
|
|
set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' ) |
226 |
|
|
set FOPTIM = ( '-O2' ) |
227 |
|
|
set NOOPTFLAGS = ( '-O0' ) |
228 |
|
|
set NOOPTFILES = ( 'barrier.F different_multiple.F ' \ |
229 |
heimbach |
1.20 |
'external_fields_load.F' ) |
230 |
cnh |
1.3 |
set LIBS = ( '-lmpi' ) |
231 |
|
|
breaksw |
232 |
adcroft |
1.11 |
case HP-UX+mpi: |
233 |
|
|
set FC = ( 'mpif77' ) |
234 |
|
|
set LINK = ( 'mpif77' ) |
235 |
|
|
set INCLUDES = ( '-I/opt/mpi/include' ) |
236 |
cnh |
1.6 |
case HP-UX: |
237 |
cnh |
1.3 |
echo "Configuring for HP Exemplar" |
238 |
|
|
set CPP = ( '/usr/ccs/lbin/cpp -P' ) |
239 |
adcroft |
1.11 |
set DEFINES = ( ${DEFINES} '-DTARGET_HP -DWORDLENGTH=4' ) |
240 |
cnh |
1.3 |
set FFLAGS = ( '+es +U77 +Onoautopar +Oexemplar_model' \ |
241 |
|
|
'+Okernel_threads' ) |
242 |
|
|
set FOPTIM = ( '+O2' ) |
243 |
cnh |
1.6 |
set NOOPTFLAGS = ( '+O0' ) |
244 |
cnh |
1.3 |
set NOOPTFILES = ( 'barrier.F different_multiple.F' \ |
245 |
heimbach |
1.20 |
'external_fields_load.F' ) |
246 |
cnh |
1.1 |
breaksw |
247 |
adcroft |
1.9 |
case Linux+mpi: |
248 |
|
|
set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' ) |
249 |
adcroft |
1.14 |
set INCLUDES = ( '-I/usr/local/include' ) |
250 |
cnh |
1.6 |
case Linux: |
251 |
adcroft |
1.22.2.1 |
set LN = ( '/bin/ln -s' ) |
252 |
adcroft |
1.14 |
set CPP = ( '/lib/cpp -traditional -P' ) |
253 |
adcroft |
1.11 |
set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' ) |
254 |
cnh |
1.6 |
set FC = ( 'g77' ) |
255 |
adcroft |
1.14 |
set FFLAGS = ( '-Wimplicit -Wunused -Wuninitialized' ) |
256 |
|
|
set FOPTIM = ( '-O3 -malign-double -funroll-loops ' ) |
257 |
cnh |
1.6 |
set LINK = ( 'g77' ) |
258 |
|
|
breaksw |
259 |
adcroft |
1.14 |
case Linux+pgi+mpi: |
260 |
adcroft |
1.15 |
if ($?include_jam_libs) then |
261 |
|
|
set INCLUDES = ( '-I/usr/local//mpich-cnh-install/include' ) |
262 |
|
|
set LIBS = ( '-L/usr/local/mpich-cnh-install/lib/LINUX/ch_p4/ -lfmpich -lmpich' ) |
263 |
|
|
else |
264 |
|
|
set INCLUDES = ( '-I/usr/local/include' ) |
265 |
|
|
set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' ) |
266 |
|
|
endif |
267 |
cnh |
1.6 |
case Linux+pgi: |
268 |
adcroft |
1.22.2.1 |
set LN = ( '/bin/ln -s' ) |
269 |
adcroft |
1.14 |
set CPP = ( '/lib/cpp -traditional -P' ) |
270 |
adcroft |
1.10 |
set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' ) |
271 |
cnh |
1.6 |
set FC = ( 'pgf77' ) |
272 |
|
|
set FFLAGS = ( '-byteswapio' ) |
273 |
|
|
set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' ) |
274 |
|
|
set LINK = ( 'pgf77' ) |
275 |
adcroft |
1.13 |
breaksw |
276 |
|
|
case T3E: |
277 |
|
|
case sn6312: |
278 |
|
|
set CPP = ( '/opt/ctl/bin/cpp -P') |
279 |
|
|
set DEFINES = ( ${DEFINES} '-DTARGET_T3E -DWORDLENGTH=4' ) |
280 |
|
|
set FC = ( 'f90' ) |
281 |
|
|
set LINK = ( 'f90' ) |
282 |
|
|
set FFLAGS = ( '-O 2,fusion' ) |
283 |
heimbach |
1.18 |
breaksw |
284 |
|
|
case T90: |
285 |
|
|
case sn7113: |
286 |
|
|
set FC = ( 'f90' ) |
287 |
|
|
set LINK = ( 'f90' ) |
288 |
adcroft |
1.22.2.1 |
set LN = ( '/bin/ln -s' ) |
289 |
heimbach |
1.19 |
set CPP = ( '/opt/ctl/bin/cpp -N -P' ) |
290 |
|
|
set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' ) |
291 |
|
|
set FFLAGS = ( '-m3 -Rabc -N 132') |
292 |
heimbach |
1.18 |
set FOPTIM = ( '-O0' ) |
293 |
|
|
set NOOPTFLAGS = ( '-O0' ) |
294 |
heimbach |
1.20 |
set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F') |
295 |
heimbach |
1.18 |
breaksw |
296 |
|
|
case SV1: |
297 |
|
|
case sn3002: |
298 |
|
|
set FC = ( 'f90' ) |
299 |
|
|
set LINK = ( 'f90' ) |
300 |
adcroft |
1.22.2.1 |
set LN = ( '/bin/ln -s' ) |
301 |
heimbach |
1.19 |
set CPP = ( '/opt/ctl/bin/cpp -N -P' ) |
302 |
|
|
set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' ) |
303 |
|
|
set FFLAGS = ( '-m3 -Rabc -ei -eI -s cf77types -N 132') |
304 |
heimbach |
1.18 |
set FOPTIM = ( '-O0' ) |
305 |
|
|
set NOOPTFLAGS = ( '-O0' ) |
306 |
heimbach |
1.20 |
set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F') |
307 |
cnh |
1.6 |
breaksw |
308 |
cnh |
1.1 |
default: |
309 |
|
|
echo "Error: platform not recognized: uname -p = " $platform$USEMPI |
310 |
|
|
exit |
311 |
|
|
breaksw |
312 |
|
|
endsw |
313 |
|
|
|
314 |
|
|
############################################################################### |
315 |
|
|
## ## |
316 |
|
|
## Everything below here should not need to be changed. Platform specific ## |
317 |
|
|
## changes and code specific changes should be configured above this line. ## |
318 |
|
|
## ## |
319 |
|
|
############################################################################### |
320 |
|
|
|
321 |
|
|
# Convert lists of directories into command-line options |
322 |
|
|
foreach inc ($INCLUDEDIRS) |
323 |
|
|
set INCLUDES = ($INCLUDES -I$inc) |
324 |
|
|
end |
325 |
adcroft |
1.22.2.3 |
|
326 |
|
|
# Search for source code |
327 |
|
|
rm -rf .links.tmp;mkdir .links.tmp |
328 |
|
|
echo "# This section creates symbolic links" > srclinks.tmp |
329 |
|
|
echo "" >> srclinks.tmp |
330 |
|
|
echo -n 'SRCFILES = ' > srclist.inc |
331 |
|
|
echo -n 'CSRCFILES = ' > csrclist.inc |
332 |
|
|
#echo -n 'HEADERFILES = ' > hlist.inc |
333 |
cnh |
1.1 |
foreach dr ($SOURCEDIRS) |
334 |
adcroft |
1.22.2.3 |
set deplist=( ) |
335 |
|
|
foreach srcfile (`cd $dr; ls *.[hcF]`) |
336 |
|
|
if (! -r .links.tmp/$srcfile) then |
337 |
|
|
if (-f $dr/$srcfile) then |
338 |
|
|
switch ($srcfile:e) |
339 |
|
|
case F: |
340 |
|
|
touch .links.tmp/$srcfile |
341 |
|
|
set deplist=($deplist $srcfile) |
342 |
|
|
echo ' \' >> srclist.inc |
343 |
|
|
echo -n " " $srcfile >> srclist.inc |
344 |
|
|
breaksw |
345 |
|
|
case c: |
346 |
|
|
touch .links.tmp/$srcfile |
347 |
|
|
set deplist=($deplist $srcfile) |
348 |
|
|
echo ' \' >> csrclist.inc |
349 |
|
|
echo -n " " $srcfile >> csrclist.inc |
350 |
|
|
breaksw |
351 |
|
|
case h: |
352 |
|
|
# touch .links.tmp/$srcfile |
353 |
|
|
# set deplist=($deplist $srcfile) |
354 |
|
|
# echo ' \' >> hlist.inc |
355 |
|
|
# echo -n " " $srcfile >> hlist.inc |
356 |
|
|
breaksw |
357 |
|
|
endsw |
358 |
|
|
endif |
359 |
|
|
endif |
360 |
|
|
end |
361 |
|
|
if ($#deplist != 0) then |
362 |
|
|
echo "# These files are linked from $dr" >> srclinks.tmp |
363 |
|
|
echo $deplist':' >> srclinks.tmp |
364 |
|
|
echo '\t$(LN) '$dr'$@ $@' >> srclinks.tmp |
365 |
|
|
endif |
366 |
cnh |
1.1 |
end |
367 |
adcroft |
1.22.2.3 |
rm -rf .links.tmp |
368 |
|
|
echo "" >> srclist.inc |
369 |
|
|
echo "" >> csrclist.inc |
370 |
|
|
#echo "" >> hlist.inc |
371 |
cnh |
1.1 |
|
372 |
|
|
set THISHOSTNAME = ( `hostname` ) |
373 |
|
|
set THISCWD = ( `pwd` ) |
374 |
|
|
set THISDATE = ( `date` ) |
375 |
|
|
|
376 |
|
|
########################################### |
377 |
|
|
## This is the template for the makefile ## |
378 |
|
|
########################################### |
379 |
|
|
echo Creating makefile: $mfile |
380 |
|
|
echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile} |
381 |
adcroft |
1.22.2.4 |
echo "# This makefile was generated automatically on" >> ${mfile} |
382 |
cnh |
1.1 |
echo "# $THISDATE" >> ${mfile} |
383 |
|
|
echo "# by the command:" >> ${mfile} |
384 |
|
|
echo "# ${0} $argv" >> ${mfile} |
385 |
|
|
echo "# executed by:" >> ${mfile} |
386 |
|
|
echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> ${mfile} |
387 |
|
|
cat >> ${mfile} <<EOF |
388 |
|
|
# |
389 |
|
|
# BUILDDIR : Directory where object files are written |
390 |
|
|
# SOURCEDIRS : Directories containing the source (.F) files |
391 |
|
|
# INCLUDEDIRS : Directories containing the header-source (.h) files |
392 |
|
|
# EXEDIR : Directory where executable that is generated is written |
393 |
|
|
# EXECUTABLE : Full path of executable binary |
394 |
|
|
# |
395 |
|
|
# CPP : C-preprocessor command |
396 |
|
|
# INCLUDES : Directories searched for header files |
397 |
|
|
# DEFINES : Macro definitions for CPP |
398 |
|
|
# KPP : Special preprocessor command (specific to platform) |
399 |
|
|
# KFLAGS : Flags for KPP |
400 |
|
|
# FC : Fortran compiler command |
401 |
|
|
# FFLAGS : Configuration/debugging options for FC |
402 |
|
|
# FOPTIM : Optimization options for FC |
403 |
|
|
# LINK : Command for link editor program |
404 |
|
|
# LIBS : Library flags /or/ additional optimization/debugging flags |
405 |
|
|
|
406 |
adcroft |
1.22.2.1 |
ROOTDIR = ${ROOTDIR} |
407 |
|
|
BUILDDIR = ${BUILDDIR} |
408 |
|
|
SOURCEDIRS = ${SOURCEDIRS} |
409 |
cnh |
1.1 |
INCLUDEDIRS = ${INCLUDEDIRS} |
410 |
adcroft |
1.22.2.1 |
EXEDIR = ${EXEDIR} |
411 |
|
|
EXECUTABLE = \$(EXEDIR)${EXECUTABLE} |
412 |
|
|
TOOLSDIR = ${TOOLSDIR} |
413 |
cnh |
1.1 |
|
414 |
adcroft |
1.12 |
EOF |
415 |
|
|
|
416 |
|
|
|
417 |
|
|
# JAM libraries on Hyades |
418 |
|
|
if ($?include_jam_libs) then |
419 |
|
|
cat >> ${mfile} <<EOF |
420 |
|
|
# extra stuff for Hyades ............................................ |
421 |
|
|
HYADES_DIR = /u/u0/cnh/jam-lib/software |
422 |
adcroft |
1.16 |
HYADES_DIR = /u/u0/cnh/jam-lib-twoproc |
423 |
adcroft |
1.12 |
WORK_DIR = \$(HYADES_DIR) |
424 |
|
|
DEPOSIT_DIR = linux_bin |
425 |
|
|
|
426 |
|
|
STARTXOBJDIR = startx_util/\$(DEPOSIT_DIR) |
427 |
|
|
STARTXOBJ = \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/startx_timer.o \ |
428 |
|
|
\$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/startx_util.o \ |
429 |
|
|
\$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/client.o \ |
430 |
|
|
\$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/csutil.o |
431 |
|
|
|
432 |
|
|
JAMOBJDIR = jam/\$(DEPOSIT_DIR) |
433 |
|
|
JAMOBJ = \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_init.o \ |
434 |
|
|
\$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_kernel.o \ |
435 |
|
|
\$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_malloc.o \ |
436 |
|
|
\$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_vmalloc.o \ |
437 |
|
|
\$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_mutex.o |
438 |
|
|
|
439 |
|
|
JAMCOBJDIR = jam_collective/\$(DEPOSIT_DIR) |
440 |
|
|
JAMCOBJ = \$(WORK_DIR)/jam_collective/\$(DEPOSIT_DIR)/jam_collective.o |
441 |
|
|
|
442 |
|
|
XLIBS = \$(STARTXOBJ) \$(JAMOBJ) \$(JAMCOBJ) |
443 |
|
|
|
444 |
|
|
# .................................................................. |
445 |
|
|
|
446 |
|
|
EOF |
447 |
|
|
endif |
448 |
|
|
|
449 |
|
|
|
450 |
|
|
cat >> ${mfile} <<EOF |
451 |
cnh |
1.1 |
# Unix ln (link) |
452 |
|
|
LN = ${LN} |
453 |
|
|
# C preprocessor |
454 |
adcroft |
1.22.2.1 |
CPP = cat \$< | \$(TOOLSDIR)/set64bitConst.sh | ${CPP} |
455 |
cnh |
1.1 |
# Special preprocessor (KAP on DECs, FPP on Crays) |
456 |
|
|
KPP = ${KPP} |
457 |
|
|
# Fortran compiler |
458 |
|
|
FC = ${FC} |
459 |
|
|
# Link editor |
460 |
|
|
LINK = ${LINK} |
461 |
|
|
|
462 |
|
|
# Defines for CPP |
463 |
|
|
DEFINES = ${DEFINES} |
464 |
|
|
# Includes for CPP |
465 |
|
|
INCLUDES = ${INCLUDES} |
466 |
|
|
# Flags for KPP |
467 |
|
|
KFLAGS1 = ${KFLAGS1} |
468 |
|
|
KFLAGS2 = ${KFLAGS2} |
469 |
|
|
# Optim./debug for FC |
470 |
|
|
FFLAGS = ${FFLAGS} |
471 |
|
|
FOPTIM = ${FOPTIM} |
472 |
|
|
# Files that should not be optimized |
473 |
|
|
NOOPTFILES = ${NOOPTFILES} |
474 |
|
|
NOOPTFLAGS = ${NOOPTFLAGS} |
475 |
|
|
# Flags and libraries needed for linking |
476 |
adcroft |
1.15 |
LIBS = ${LIBS} \$(XLIBS) |
477 |
cnh |
1.1 |
|
478 |
|
|
EOF |
479 |
|
|
|
480 |
heimbach |
1.19 |
cat srclist.inc >> ${mfile} |
481 |
|
|
cat csrclist.inc >> ${mfile} |
482 |
|
|
echo 'F77FILES = $(SRCFILES:.F=.f)' >> ${mfile} |
483 |
|
|
echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o)' >> ${mfile} |
484 |
|
|
|
485 |
adcroft |
1.22.2.3 |
rm -f srclist.inc csrclist.inc flist.tmp clist.tmp |
486 |
cnh |
1.1 |
|
487 |
|
|
cat >> ${mfile} <<EOF |
488 |
|
|
|
489 |
|
|
.SUFFIXES: |
490 |
cnh |
1.5 |
.SUFFIXES: .o .f .p .F .c |
491 |
cnh |
1.1 |
|
492 |
|
|
all: \$(EXECUTABLE) |
493 |
|
|
\$(EXECUTABLE): \$(OBJFILES) |
494 |
|
|
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) |
495 |
|
|
depend: |
496 |
|
|
@make links |
497 |
|
|
makedepend -o .f \$(INCLUDES) \$(SRCFILES) |
498 |
adcroft |
1.22.2.3 |
links: \$(SRCFILES) |
499 |
heimbach |
1.19 |
|
500 |
|
|
small_f: \$(F77FILES) |
501 |
|
|
|
502 |
cnh |
1.1 |
clean: |
503 |
|
|
-rm -rf *.o *.f *.p ${RMFILES} |
504 |
cnh |
1.6 |
Clean: |
505 |
|
|
@make clean |
506 |
adcroft |
1.8 |
-find . -type l -exec rm {} \; |
507 |
|
|
-rm Makefile.bak |
508 |
adcroft |
1.12 |
CLEAN: |
509 |
|
|
@make Clean |
510 |
adcroft |
1.22.2.1 |
-find \$(ROOTDIR)/verification/*/input/ -name "*.meta" -exec rm {} \; |
511 |
|
|
-find \$(ROOTDIR)/verification/*/input/ -name "*.data" -exec rm {} \; |
512 |
adcroft |
1.12 |
-rm \$(EXECUTABLE) |
513 |
cnh |
1.1 |
|
514 |
|
|
# The normal chain of rules is ( .F - .f - .o ) |
515 |
|
|
.F.f: |
516 |
cnh |
1.6 |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
517 |
cnh |
1.1 |
.f.o: |
518 |
|
|
\$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< |
519 |
|
|
|
520 |
|
|
# Special exceptions that use the ( .F - .p - .f - .o ) rule-chain |
521 |
|
|
.F.p: |
522 |
cnh |
1.6 |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
523 |
cnh |
1.1 |
.p.f: |
524 |
|
|
\$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< |
525 |
|
|
EOF |
526 |
|
|
|
527 |
|
|
# Make list of "exceptions" that need ".p" files |
528 |
|
|
foreach sf ($KPPFILES) |
529 |
|
|
set fname=( ${sf:t} ) |
530 |
|
|
echo "${fname:r}.f: ${fname:r}.p" >> ${mfile} |
531 |
|
|
end |
532 |
|
|
foreach sf ($NOOPTFILES) |
533 |
|
|
set fname=( ${sf:t} ) |
534 |
|
|
echo "${fname:r}.o: ${fname:r}.f" >> ${mfile} |
535 |
|
|
echo ' $(FC) $(FFLAGS) $(NOOPTFLAGS) -c $<' >> ${mfile} |
536 |
|
|
end |
537 |
adcroft |
1.22.2.1 |
echo "" >> ${mfile} |
538 |
|
|
|
539 |
adcroft |
1.22.2.3 |
# Add rules for links |
540 |
|
|
cat srclinks.tmp >> ${mfile} |
541 |
|
|
rm -f srclinks.tmp |
542 |
adcroft |
1.22.2.1 |
|
543 |
|
|
echo "" >> ${mfile} |
544 |
cnh |
1.1 |
echo "# DO NOT DELETE" >> ${mfile} |
545 |
|
|
|
546 |
|
|
exit |