1 |
#!/bin/csh -f |
2 |
# |
3 |
# $Header: /u/gcmpack/models/MITgcmUV/tools/genmake,v 1.33.2.8 2001/04/05 15:49:51 jamous Exp $ |
4 |
# |
5 |
# Makefile generator for MITgcm UV codes |
6 |
# created by cnh 03/98 |
7 |
# adapted by aja 06/98 |
8 |
# modified by aja 01/00 |
9 |
|
10 |
# Default lists |
11 |
set DISABLE = ( aim ) |
12 |
set ENABLE = ( ) |
13 |
set MODS = ( ) |
14 |
|
15 |
# Grab variables/lists from .genmakerc |
16 |
if (-r .genmakerc) source .genmakerc |
17 |
|
18 |
# Process command-line arguments |
19 |
set allargs=( $argv ) |
20 |
while ($#allargs) |
21 |
set arg = $allargs[1] |
22 |
switch ($arg) |
23 |
case -makefile: |
24 |
set mfile = ( Makefile ) |
25 |
breaksw |
26 |
case -makefile=*: |
27 |
set mfile = ( `echo $arg | sed 's/-makefile=//' `) |
28 |
breaksw |
29 |
case -platform: |
30 |
case -platform=: |
31 |
echo "To change platform you must specify one with -platform=" |
32 |
echo "eg. -platform=sparc or -platform=mips" |
33 |
exit |
34 |
breaksw |
35 |
case -platform*: |
36 |
if ($?platform) then |
37 |
echo Option -platform=dir can only be specified once.; exit 1 |
38 |
endif |
39 |
set platform = ( `echo $arg | sed 's/-platform=//' `) |
40 |
breaksw |
41 |
case -rootdir: |
42 |
case -rootdir=: |
43 |
echo "To specify root directory you must specify one with -rootdir=dir" |
44 |
echo "with NO space eg. -rootdir=../../.. or -rootdir=/usr/people/joe/src" |
45 |
exit |
46 |
breaksw |
47 |
case -rootdir=*: |
48 |
if ($?ROOTDIR) then |
49 |
echo "***" Warning: variable \$ROOTDIR is already set to $ROOTDIR |
50 |
echo "***" Command line \"$arg\" will override this. |
51 |
endif |
52 |
set ROOTDIR = ( `echo $arg | sed 's/-rootdir=//' `) |
53 |
breaksw |
54 |
case -mods: |
55 |
case -mods=: |
56 |
echo "To specify an additional source directory you must specify one with -mods=dir" |
57 |
echo "with NO space eg. -mods=../code or -mods=/usr/people/joe/src" |
58 |
exit |
59 |
breaksw |
60 |
case -mods=*: |
61 |
set MODS = ( $MODS `echo $arg | sed 's/-mods=//' | sed 's/,/ /g' `) |
62 |
breaksw |
63 |
case -disable: |
64 |
case -disable=: |
65 |
echo "To disable packages from compilation use -disable=pkg1,pkg2" |
66 |
echo "with NO spaces eg. -disable=kpp,gmredi or -disable=all (to enable all packages)" |
67 |
exit |
68 |
breaksw |
69 |
case -disable=*: |
70 |
set DISABLE = ( $DISABLE `echo $arg | sed 's/-disable=//' | sed 's/,/ /g' `) |
71 |
breaksw |
72 |
case -enable: |
73 |
case -enable=: |
74 |
echo "To enable packages from compilation use -enable=pkg1,pkg2" |
75 |
echo "with NO spaces eg. -enable=aim or -enable=all (to enable all packages)" |
76 |
echo "-enable overrides -disable, ie. a package listed in both is enabled" |
77 |
exit |
78 |
breaksw |
79 |
case -enable=*: |
80 |
set ENABLE = ( $ENABLE `echo $arg | sed 's/-enable=//' | sed 's/,/ /g' `) |
81 |
breaksw |
82 |
case -mpi: |
83 |
echo "Enabling MPI options" |
84 |
set USEMPI |
85 |
breaksw |
86 |
case -jam: |
87 |
set include_jam_libs |
88 |
echo "Including paths to JAM libraries" |
89 |
breaksw |
90 |
case -help: |
91 |
echo "usage: $0 [-help] [-makefile[=...]] [-platform=...] [-mpi] [-jam] [-disable=pkg1[,pkg2,...]] [-enable=pkg1[,pkg2,...]] [-mods=dir1[,dir2,...]] [-rootdir=dir]" |
92 |
cat << EOF |
93 |
|
94 |
$0 is used to generate the Makefile in the current directory. |
95 |
|
96 |
Typical invocations are: |
97 |
o from "bin": ../tools/genmake |
98 |
o from "verification/expt/code": ../../../tools/genmake |
99 |
o from "verification/expt/input": ../../../tools/genmake -mods=../code |
100 |
o from a scratch directory: ~/mitgcm/tools/genmake -rootdir=~/mitgcm |
101 |
or ~/mitgcm/tools/genmake -rootdir=~/mitgcm -mods=~/mymods |
102 |
|
103 |
Packages (collected modules of code) can be disabled to avoid unnecessary |
104 |
compilation of unused code. For instance if you know you will not |
105 |
use GM/Redi, KPP and OBCS and they are appropriate turned-off in the |
106 |
configuration: |
107 |
.../tools/genmake -disable=gmredi,kpp,obcs |
108 |
|
109 |
If you add some source files you can re-call the previous instance of |
110 |
genmake with "make makefile". |
111 |
|
112 |
genmake also reads the file .genmakerc which can be used to configure |
113 |
options (primarily the command-line options above) for particular experiments. |
114 |
EOF |
115 |
exit |
116 |
breaksw |
117 |
default: |
118 |
echo "Unknown command-line option: " $arg |
119 |
echo $0 "-help to show usage" |
120 |
exit |
121 |
breaksw |
122 |
endsw |
123 |
shift allargs |
124 |
end |
125 |
|
126 |
# Default actions/options |
127 |
|
128 |
# If platform wasn't specified then determine platform type of the host |
129 |
if (! $?platform) then |
130 |
set platform = (`uname`) |
131 |
endif |
132 |
# If name of makefile wasn't specified then use default "Makefile" |
133 |
if (! $?mfile) set mfile = ( Makefile ) |
134 |
|
135 |
set mach = ( `uname -a` ) |
136 |
echo Operating system: $mach |
137 |
|
138 |
# Directories for source, includes, binaries and executables |
139 |
# |
140 |
# If -rootdir wasn't specified then assume script is being run from bin |
141 |
# but if it was supplied then we should place the executable in the build dir |
142 |
if (! $?ROOTDIR) then |
143 |
set pwd=`pwd` |
144 |
if ($pwd:t == bin & -d ../model & -d ../eesupp & -d ../pkg) then |
145 |
set ROOTDIR = ( .. ) |
146 |
endif |
147 |
endif |
148 |
# Scan for logical ROOTDIR |
149 |
if (! $?ROOTDIR) then |
150 |
foreach dr (. .. ../.. ../../.. ../../../.. ../../../../..) |
151 |
if (-d $dr/model & -d $dr/eesupp & -d $dr/pkg) then |
152 |
set ROOTDIR = $dr |
153 |
echo ROOTDIR was not specified. Setting ROOTDIR = \"$ROOTDIR\" |
154 |
break |
155 |
endif |
156 |
end |
157 |
endif |
158 |
if (! $?ROOTDIR) then |
159 |
echo Root directory was not specified and could not be determined. |
160 |
echo Specify the root location of the model source with -rootdir=dir |
161 |
exit 1 |
162 |
endif |
163 |
if (! -d $ROOTDIR) then |
164 |
echo Root directory $ROOTDIR not found.;exit 1 |
165 |
endif |
166 |
# If -mods wasn't specified then we will assume that we can find all the |
167 |
# source code in the standard directories |
168 |
if (! $?MODS) then |
169 |
set SOURCEDIRS = ( ) |
170 |
set INCLUDEDIRS = ( . ) |
171 |
else |
172 |
set SOURCEDIRS = ( $MODS ) |
173 |
set INCLUDEDIRS = ( . $MODS ) |
174 |
endif |
175 |
if (! $?BUILDDIR) set BUILDDIR = ( . ) |
176 |
if (! -d $BUILDDIR) then |
177 |
echo Build directory $BUILDDIR not found.;exit 1 |
178 |
endif |
179 |
if (! $?EXEDIR) then |
180 |
set pwd=`pwd` |
181 |
if ($pwd:t == bin & -d ../exe & $ROOTDIR == ..) then |
182 |
set EXEDIR = ( ../exe ) |
183 |
else |
184 |
set EXEDIR = ( . ) |
185 |
endif |
186 |
endif |
187 |
if (! -d $EXEDIR) then |
188 |
echo Executable directory $EXEDIR not found.;exit 1 |
189 |
endif |
190 |
if (! $?TOOLSDIR) set TOOLSDIR = ( $ROOTDIR/tools ) |
191 |
if (! -d $TOOLSDIR) then |
192 |
echo Tools directory $TOOLSDIR not found.;exit 1 |
193 |
endif |
194 |
if (! $?EXECUTABLE) set EXECUTABLE = ( mitgcmuv ) |
195 |
|
196 |
# We have a special set of source files in eesupp/src which |
197 |
# are generated from some template source files. We'll make them |
198 |
# first so the appear as regular source code |
199 |
if (-r $ROOTDIR/eesupp/src/Makefile) then |
200 |
echo Making source files in eesupp from templates... |
201 |
(cd $ROOTDIR/eesupp/src/; make) >& make_eesupp.errs |
202 |
if ($status == 0) then |
203 |
rm -f make_eesupp.errs |
204 |
else |
205 |
cat make_eesupp.errs |
206 |
exit 2 |
207 |
endif |
208 |
endif |
209 |
|
210 |
# Now scan the standard source code tree |
211 |
foreach dr ($SOURCEDIRS) |
212 |
set adr=$dr |
213 |
if (! -d $adr) then |
214 |
echo mods directory $adr not found.; exit 1 |
215 |
endif |
216 |
echo Adding mods dir: $adr |
217 |
end |
218 |
if (! $?PACKAGES) then |
219 |
set PACKAGES=() |
220 |
foreach pkg (`cd $ROOTDIR/pkg; find . -type d | grep -v CVS | sed 's:\./::' | grep -v "\." | sort`) |
221 |
if (-d $ROOTDIR/pkg/$pkg) set PACKAGES=($PACKAGES $pkg) |
222 |
end |
223 |
endif |
224 |
foreach dr ($PACKAGES) |
225 |
set enable |
226 |
foreach p ($DISABLE) |
227 |
if ($p != 'all' & ! -d $ROOTDIR/pkg/$p) then |
228 |
echo Specified package \"$p\" does not exist. |
229 |
exit 1 |
230 |
endif |
231 |
if ($dr == $p) unset enable |
232 |
if ($p == 'all') unset enable |
233 |
# The following allows entire trees to be disabled |
234 |
if ($dr:h == $p) unset enable |
235 |
if ($dr:h:h == $p) unset enable |
236 |
if ($dr:h:h:h == $p) unset enable |
237 |
if ($dr:h:h:h:h == $p) unset enable |
238 |
end |
239 |
foreach p ($ENABLE) |
240 |
if ($dr == $p) set enable |
241 |
end |
242 |
if ($?enable) then |
243 |
set adr=$ROOTDIR/pkg/$dr |
244 |
if (! -d $adr) then |
245 |
echo Source directory $adr not found.; exit 1 |
246 |
endif |
247 |
echo Adding pkg dir: $adr |
248 |
set SOURCEDIRS = ($SOURCEDIRS $adr) |
249 |
set INCLUDEDIRS = ($INCLUDEDIRS $adr) |
250 |
else |
251 |
echo " *" Package \"$dr\" NOT enabled. |
252 |
endif |
253 |
end |
254 |
if (! $?STANDARDDIRS) set STANDARDDIRS=(eesupp model) |
255 |
foreach dr ($STANDARDDIRS) |
256 |
set adr=$ROOTDIR/$dr/src |
257 |
if (! -d $adr) then |
258 |
echo Source directory $adr not found.; exit 1 |
259 |
endif |
260 |
echo Adding src dir: $adr |
261 |
set SOURCEDIRS = ($SOURCEDIRS $adr) |
262 |
set idr = `echo $adr | sed 's/src/inc/'` |
263 |
set INCLUDEDIRS = ($INCLUDEDIRS $idr) |
264 |
end |
265 |
|
266 |
# This is the generic configuration. |
267 |
# Platform specific options are chosen below |
268 |
set LN = ( 'ln -s' ) |
269 |
set CPP = ( '/lib/cpp -P' ) |
270 |
set KPP = ( ) |
271 |
set FC = ( 'f77' ) |
272 |
set LINK = ( 'f77' ) |
273 |
set DEFINES = ( ) |
274 |
set INCLUDES = ( ) |
275 |
set FFLAGS = ( ) |
276 |
set FOPTIM = ( ) |
277 |
set KFLAGS1 = ( ) |
278 |
set KFLAGS2 = ( ) |
279 |
set LIBS = ( ) |
280 |
set KPPFILES = ( ) |
281 |
set NOOPTFILES = ( ) |
282 |
set NOOPTFLAGS = ( ) |
283 |
set RMFILES = ( ) |
284 |
|
285 |
# We often want to use different compile/link options is using MPI |
286 |
if ($?USEMPI) then |
287 |
set USEMPI = ( '+mpi' ) |
288 |
set DEFINES = ( ${DEFINES} '-DALLOW_USE_MPI -DALWAYS_USE_MPI' ) |
289 |
else |
290 |
set USEMPI |
291 |
# set DEFINES = ( ${DEFINES} '-UALLOW_USE_MPI -UALWAYS_USE_MPI' ) |
292 |
endif |
293 |
|
294 |
# Platform specific options |
295 |
switch ($platform$USEMPI) |
296 |
case OSF1: |
297 |
case OSF1+mpi: |
298 |
echo "Configuring for DEC Alpha" |
299 |
set CPP = ( '/usr/bin/cpp -P' ) |
300 |
set DEFINES = ( ${DEFINES} '-DTARGET_DEC -DWORDLENGTH=1' ) |
301 |
set KPP = ( 'kapf' ) |
302 |
set KPPFILES = ( 'main.F' ) |
303 |
set KFLAGS1 = ( '-scan=132 -noconc -cmp=' ) |
304 |
set FC = ( 'f77' ) |
305 |
set FFLAGS = ( '-convert big_endian -r8 -extend_source -automatic -call_shared -notransform_loops -align dcommons' ) |
306 |
set FOPTIM = ( '-O5 -fast -tune host -inline all' ) |
307 |
set NOOPTFLAGS = ( '-O0' ) |
308 |
set LIBS = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' ) |
309 |
set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F') |
310 |
set RMFILES = ( '*.p.out' ) |
311 |
breaksw |
312 |
case IRIX64+mpi: |
313 |
echo "Configuring for SGI Mips with MPI" |
314 |
set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) |
315 |
set INCLUDES = ( '-I/usr/local/mpi/include' ) |
316 |
set FC = ( 'mpif77' ) |
317 |
set LINK = ( 'mpif77' ) |
318 |
set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' ) |
319 |
set FOPTIM = ( '-O3' ) |
320 |
set RMFILES = ( 'rii_files' ) |
321 |
breaksw |
322 |
case IRIX64: |
323 |
echo "Configuring for SGI Mips" |
324 |
set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) |
325 |
set INCLUDES = ( '-I/usr/local/mpi/include' ) |
326 |
set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4 -r8 -static' ) |
327 |
set FOPTIM = ( '-O3' ) |
328 |
# set NOOPTFLAGS = ( '-O0' ) |
329 |
# set NOOPTFILES = ( 'barrier.F different_multiple.F ' \ |
330 |
# 'external_fields_load.F' ) |
331 |
set RMFILES = ( 'rii_files' ) |
332 |
breaksw |
333 |
case o2: |
334 |
case IRIX: |
335 |
echo "Configuring for SGI O2 running IRIX 6.5" |
336 |
set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) |
337 |
set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' ) |
338 |
set FOPTIM = ( '-O2' ) |
339 |
set NOOPTFLAGS = ( '-O0' ) |
340 |
breaksw |
341 |
case o2+mpi: |
342 |
case IRIX+mpi: |
343 |
echo "Configuring for SGI O2 running IRIX 6.5 with MPI" |
344 |
set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) |
345 |
set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' ) |
346 |
set FOPTIM = ( '-O2' ) |
347 |
set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F' ) |
348 |
set NOOPTFLAGS = ( '-O0' ) |
349 |
set LIBS = ( '-lmpi' ) |
350 |
breaksw |
351 |
case o2k+mpi: |
352 |
echo "Configuring for SGI Origin2000 running IRIX 6.5" |
353 |
set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) |
354 |
set INCLUDES = ( '-I/usr/include' ) |
355 |
set FFLAGS = ( '-n32 -extend_source -bytereclen' ) |
356 |
set FOPTIM = ( '-O2' ) |
357 |
set NOOPTFILES = ( 'calc_mom_rhs.F' ) |
358 |
set NOOPTFLAGS = ( '-O1' ) |
359 |
set LIBS = ( '-lmpi -lscs' ) |
360 |
breaksw |
361 |
case onyx: |
362 |
case onyx+mpi: |
363 |
echo "Configuring for SGI ONYX running IRIX64" |
364 |
set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) |
365 |
set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' ) |
366 |
set FOPTIM = ( '-O2' ) |
367 |
set NOOPTFLAGS = ( '-O0' ) |
368 |
set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F' ) |
369 |
set LIBS = ( '-lmpi' ) |
370 |
breaksw |
371 |
case SunOS: |
372 |
set LN = ( '/usr/bin/ln -s' ) |
373 |
set CPP = ( '/usr/ccs/lib/cpp -P' ) |
374 |
set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4' ) |
375 |
set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar') |
376 |
set FOPTIM = ( '-fast -O3' ) |
377 |
set NOOPTFLAGS = ( '-O0' ) |
378 |
set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F ini_vertical_grid.F') |
379 |
breaksw |
380 |
case SunOS+mpi: |
381 |
set LN = ( '/usr/bin/ln -s' ) |
382 |
set CPP = ( '/usr/ccs/lib/cpp -P' ) |
383 |
set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4' ) |
384 |
set INCLUDES = ( '-I/usr/local/mpi/include' ) |
385 |
set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar') |
386 |
set FOPTIM = ( '-fast -O3' ) |
387 |
set NOOPTFLAGS = ( '-O0' ) |
388 |
set LIBS = ( '-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread' \ |
389 |
'-lsocket -lnsl' ) |
390 |
set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F ini_vertical_grid.F') |
391 |
breaksw |
392 |
case IRIX32: |
393 |
echo "Configuring for SGI ONYX running IRIX64" |
394 |
set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' ) |
395 |
set INCLUDES = ( '-I/usr/include' ) |
396 |
set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' ) |
397 |
set FOPTIM = ( '-O2' ) |
398 |
set NOOPTFLAGS = ( '-O0' ) |
399 |
set NOOPTFILES = ( 'barrier.F different_multiple.F ' \ |
400 |
'external_fields_load.F' ) |
401 |
set LIBS = ( '-lmpi' ) |
402 |
breaksw |
403 |
case HP-UX+mpi: |
404 |
set FC = ( 'mpif77' ) |
405 |
set LINK = ( 'mpif77' ) |
406 |
set INCLUDES = ( '-I/opt/mpi/include' ) |
407 |
case HP-UX: |
408 |
echo "Configuring for HP Exemplar" |
409 |
set CPP = ( '/usr/ccs/lbin/cpp -P' ) |
410 |
set DEFINES = ( ${DEFINES} '-DTARGET_HP -DWORDLENGTH=4' ) |
411 |
set FFLAGS = ( '+es +U77 +Onoautopar +Oexemplar_model' \ |
412 |
'+Okernel_threads' ) |
413 |
set FOPTIM = ( '+O2' ) |
414 |
set NOOPTFLAGS = ( '+O0' ) |
415 |
set NOOPTFILES = ( 'barrier.F different_multiple.F' \ |
416 |
'external_fields_load.F' ) |
417 |
breaksw |
418 |
case Linux+mpi: |
419 |
set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' ) |
420 |
set INCLUDES = ( '-I/usr/local/include' ) |
421 |
case Linux: |
422 |
set LN = ( '/bin/ln -s' ) |
423 |
set CPP = ( '/lib/cpp -traditional -P' ) |
424 |
set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' ) |
425 |
set FC = ( 'g77' ) |
426 |
set FFLAGS = ( '-Wimplicit -Wunused -Wuninitialized' ) |
427 |
set FOPTIM = ( '-O3 -malign-double -funroll-loops ' ) |
428 |
set LINK = ( 'g77' ) |
429 |
breaksw |
430 |
case Linux+pgi+mpi: |
431 |
if ($?include_jam_libs) then |
432 |
set INCLUDES = ( '-I/usr/local/mpich-1.2.1/pgi_fortran_binding/include' ) |
433 |
set LIBS = ( '-L/usr/local/mpich-1.2.1/pgi_fortran_binding/lib/ -lfmpich -lmpich' ) |
434 |
else |
435 |
set INCLUDES = ( '-I/usr/local/include' ) |
436 |
set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' ) |
437 |
endif |
438 |
case Linux+pgi: |
439 |
set LN = ( '/bin/ln -s' ) |
440 |
set CPP = ( '/lib/cpp -traditional -P' ) |
441 |
set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' ) |
442 |
set FC = ( 'pgf77' ) |
443 |
set FFLAGS = ( '-byteswapio -r8 -Mnodclchk -Mextend' ) |
444 |
set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' ) |
445 |
set LINK = ( 'pgf77' ) |
446 |
breaksw |
447 |
case T3E: |
448 |
case sn6312: |
449 |
set CPP = ( '/opt/ctl/bin/cpp -P') |
450 |
set DEFINES = ( ${DEFINES} '-DTARGET_T3E -DWORDLENGTH=4' ) |
451 |
set FC = ( 'f90' ) |
452 |
set LINK = ( 'f90' ) |
453 |
set FFLAGS = ( '-O 2,fusion' ) |
454 |
breaksw |
455 |
case T90: |
456 |
case sn7113: |
457 |
set FC = ( 'f90' ) |
458 |
set LINK = ( 'f90' ) |
459 |
set LN = ( '/bin/ln -s' ) |
460 |
set CPP = ( '/opt/ctl/bin/cpp -N -P' ) |
461 |
set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' ) |
462 |
set FFLAGS = ( '-m3 -Rabc -N 132') |
463 |
set FOPTIM = ( '-O0' ) |
464 |
set NOOPTFLAGS = ( '-O0' ) |
465 |
set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F') |
466 |
breaksw |
467 |
case SV1: |
468 |
case sn3002: |
469 |
set FC = ( 'f90' ) |
470 |
set LINK = ( 'f90' ) |
471 |
set LN = ( '/bin/ln -s' ) |
472 |
set CPP = ( '/opt/ctl/bin/cpp -N -P' ) |
473 |
set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' ) |
474 |
set FFLAGS = ( '-m3 -Rabc -ei -eI -s cf77types -N 132') |
475 |
set FOPTIM = ( '-O0' ) |
476 |
set NOOPTFLAGS = ( '-O0' ) |
477 |
set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F') |
478 |
breaksw |
479 |
default: |
480 |
echo "Error: platform not recognized: uname -p = " $platform$USEMPI |
481 |
exit |
482 |
breaksw |
483 |
endsw |
484 |
|
485 |
############################################################################### |
486 |
## ## |
487 |
## Everything below here should not need to be changed. Platform specific ## |
488 |
## changes and code specific changes should be configured above this line. ## |
489 |
## ## |
490 |
############################################################################### |
491 |
|
492 |
# Convert lists of directories into command-line options |
493 |
foreach inc ($INCLUDEDIRS) |
494 |
set INCLUDES = ($INCLUDES -I$inc) |
495 |
end |
496 |
|
497 |
# Search for source code |
498 |
rm -rf .links.tmp;mkdir .links.tmp |
499 |
echo "# This section creates symbolic links" > srclinks.tmp |
500 |
echo "" >> srclinks.tmp |
501 |
echo -n 'SRCFILES = ' > srclist.inc |
502 |
echo -n 'CSRCFILES = ' > csrclist.inc |
503 |
#echo -n 'HEADERFILES = ' > hlist.inc |
504 |
foreach dr ($SOURCEDIRS) |
505 |
set deplist=( ) |
506 |
foreach srcfile (`cd $dr; ls *.[hcF]`) |
507 |
if (! -r .links.tmp/$srcfile) then |
508 |
if (-f $dr/$srcfile) then |
509 |
switch ($srcfile:e) |
510 |
case F: |
511 |
touch .links.tmp/$srcfile |
512 |
set deplist=($deplist $srcfile) |
513 |
echo ' \' >> srclist.inc |
514 |
echo -n " " $srcfile >> srclist.inc |
515 |
breaksw |
516 |
case c: |
517 |
touch .links.tmp/$srcfile |
518 |
set deplist=($deplist $srcfile) |
519 |
echo ' \' >> csrclist.inc |
520 |
echo -n " " $srcfile >> csrclist.inc |
521 |
breaksw |
522 |
case h: |
523 |
# touch .links.tmp/$srcfile |
524 |
# set deplist=($deplist $srcfile) |
525 |
# echo ' \' >> hlist.inc |
526 |
# echo -n " " $srcfile >> hlist.inc |
527 |
breaksw |
528 |
endsw |
529 |
endif |
530 |
endif |
531 |
end |
532 |
if ($#deplist != 0) then |
533 |
echo "# These files are linked from $dr" >> srclinks.tmp |
534 |
echo $deplist':' >> srclinks.tmp |
535 |
echo ' $(LN) '$dr'/$@ $@' >> srclinks.tmp |
536 |
endif |
537 |
end |
538 |
rm -rf .links.tmp |
539 |
echo "" >> srclist.inc |
540 |
echo "" >> csrclist.inc |
541 |
#echo "" >> hlist.inc |
542 |
|
543 |
set THISHOSTNAME = ( `hostname` ) |
544 |
set THISCWD = ( `pwd` ) |
545 |
set THISDATE = ( `date` ) |
546 |
|
547 |
if (-r $mfile) mv -f $mfile $mfile.bak |
548 |
########################################### |
549 |
## This is the template for the makefile ## |
550 |
########################################### |
551 |
echo Creating makefile: $mfile |
552 |
echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile} |
553 |
echo "# This makefile was generated automatically on" >> ${mfile} |
554 |
echo "# $THISDATE" >> ${mfile} |
555 |
echo "# by the command:" >> ${mfile} |
556 |
echo "# ${0} $argv" >> ${mfile} |
557 |
echo "# executed by:" >> ${mfile} |
558 |
echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> ${mfile} |
559 |
cat >> ${mfile} <<EOF |
560 |
# |
561 |
# BUILDDIR : Directory where object files are written |
562 |
# SOURCEDIRS : Directories containing the source (.F) files |
563 |
# INCLUDEDIRS : Directories containing the header-source (.h) files |
564 |
# EXEDIR : Directory where executable that is generated is written |
565 |
# EXECUTABLE : Full path of executable binary |
566 |
# |
567 |
# CPP : C-preprocessor command |
568 |
# INCLUDES : Directories searched for header files |
569 |
# DEFINES : Macro definitions for CPP |
570 |
# KPP : Special preprocessor command (specific to platform) |
571 |
# KFLAGS : Flags for KPP |
572 |
# FC : Fortran compiler command |
573 |
# FFLAGS : Configuration/debugging options for FC |
574 |
# FOPTIM : Optimization options for FC |
575 |
# LINK : Command for link editor program |
576 |
# LIBS : Library flags /or/ additional optimization/debugging flags |
577 |
|
578 |
ROOTDIR = ${ROOTDIR} |
579 |
BUILDDIR = ${BUILDDIR} |
580 |
SOURCEDIRS = ${SOURCEDIRS} |
581 |
INCLUDEDIRS = ${INCLUDEDIRS} |
582 |
EXEDIR = ${EXEDIR} |
583 |
EXECUTABLE = \$(EXEDIR)/${EXECUTABLE} |
584 |
TOOLSDIR = ${TOOLSDIR} |
585 |
|
586 |
EOF |
587 |
|
588 |
|
589 |
# JAM libraries on Hyades |
590 |
if ($?include_jam_libs) then |
591 |
cat >> ${mfile} <<EOF |
592 |
# extra stuff for Hyades ............................................ |
593 |
HYADES_DIR = /u/u0/cnh/jam-lib/software |
594 |
HYADES_DIR = /u/u0/cnh/jam-lib-twoproc |
595 |
HYADES_DIR = /usr/local/jamlib/current/dual_proc |
596 |
WORK_DIR = \$(HYADES_DIR) |
597 |
DEPOSIT_DIR = linux_bin |
598 |
|
599 |
STARTXOBJDIR = startx_util/\$(DEPOSIT_DIR) |
600 |
STARTXOBJ = \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/startx_timer.o \ |
601 |
\$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/startx_util.o \ |
602 |
\$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/client.o \ |
603 |
\$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/csutil.o |
604 |
|
605 |
JAMOBJDIR = jam/\$(DEPOSIT_DIR) |
606 |
JAMOBJ = \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_init.o \ |
607 |
\$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_kernel.o \ |
608 |
\$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_malloc.o \ |
609 |
\$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_vmalloc.o \ |
610 |
\$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_mutex.o |
611 |
|
612 |
JAMCOBJDIR = jam_collective/\$(DEPOSIT_DIR) |
613 |
JAMCOBJ = \$(WORK_DIR)/jam_collective/\$(DEPOSIT_DIR)/jam_collective.o |
614 |
|
615 |
XLIBS = \$(STARTXOBJ) \$(JAMOBJ) \$(JAMCOBJ) |
616 |
|
617 |
# .................................................................. |
618 |
|
619 |
EOF |
620 |
endif |
621 |
|
622 |
|
623 |
cat >> ${mfile} <<EOF |
624 |
# Unix ln (link) |
625 |
LN = ${LN} |
626 |
# C preprocessor |
627 |
CPP = cat \$< | \$(TOOLSDIR)/set64bitConst.sh | ${CPP} |
628 |
# Special preprocessor (KAP on DECs, FPP on Crays) |
629 |
KPP = ${KPP} |
630 |
# Fortran compiler |
631 |
FC = ${FC} |
632 |
# Link editor |
633 |
LINK = ${LINK} |
634 |
|
635 |
# Defines for CPP |
636 |
DEFINES = ${DEFINES} |
637 |
# Includes for CPP |
638 |
INCLUDES = ${INCLUDES} |
639 |
# Flags for KPP |
640 |
KFLAGS1 = ${KFLAGS1} |
641 |
KFLAGS2 = ${KFLAGS2} |
642 |
# Optim./debug for FC |
643 |
FFLAGS = ${FFLAGS} |
644 |
FOPTIM = ${FOPTIM} |
645 |
# Files that should not be optimized |
646 |
NOOPTFILES = ${NOOPTFILES} |
647 |
NOOPTFLAGS = ${NOOPTFLAGS} |
648 |
# Flags and libraries needed for linking |
649 |
LIBS = ${LIBS} \$(XLIBS) |
650 |
|
651 |
EOF |
652 |
|
653 |
cat srclist.inc >> ${mfile} |
654 |
cat csrclist.inc >> ${mfile} |
655 |
echo 'F77FILES = $(SRCFILES:.F=.f)' >> ${mfile} |
656 |
echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o)' >> ${mfile} |
657 |
|
658 |
rm -f srclist.inc csrclist.inc flist.tmp clist.tmp |
659 |
|
660 |
cat >> ${mfile} <<EOF |
661 |
|
662 |
.SUFFIXES: |
663 |
.SUFFIXES: .o .f .p .F .c |
664 |
|
665 |
all: \$(EXECUTABLE) |
666 |
\$(EXECUTABLE): \$(OBJFILES) |
667 |
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) |
668 |
depend: |
669 |
@make links |
670 |
makedepend -o .f \$(INCLUDES) \$(SRCFILES) |
671 |
|
672 |
links: \$(SRCFILES) |
673 |
|
674 |
small_f: \$(F77FILES) |
675 |
|
676 |
clean: |
677 |
-rm -rf *.o *.f *.p ${RMFILES} |
678 |
Clean: |
679 |
@make clean |
680 |
@make cleanlinks |
681 |
-rm -f Makefile.bak |
682 |
CLEAN: |
683 |
@make Clean |
684 |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
685 |
-find \$(EXEDIR) -name "*.data" -exec rm {} \; |
686 |
-rm -f \$(EXECUTABLE) |
687 |
|
688 |
makefile: |
689 |
${0} $argv |
690 |
cleanlinks: |
691 |
-find . -type l -exec rm {} \; |
692 |
|
693 |
# The normal chain of rules is ( .F - .f - .o ) |
694 |
.F.f: |
695 |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
696 |
.f.o: |
697 |
\$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< |
698 |
|
699 |
# Special exceptions that use the ( .F - .p - .f - .o ) rule-chain |
700 |
.F.p: |
701 |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
702 |
.p.f: |
703 |
\$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< |
704 |
EOF |
705 |
|
706 |
# Make list of "exceptions" that need ".p" files |
707 |
foreach sf ($KPPFILES) |
708 |
set fname=( ${sf:t} ) |
709 |
echo "${fname:r}.f: ${fname:r}.p" >> ${mfile} |
710 |
end |
711 |
foreach sf ($NOOPTFILES) |
712 |
set fname=( ${sf:t} ) |
713 |
echo "${fname:r}.o: ${fname:r}.f" >> ${mfile} |
714 |
echo ' $(FC) $(FFLAGS) $(NOOPTFLAGS) -c $<' >> ${mfile} |
715 |
end |
716 |
echo "" >> ${mfile} |
717 |
|
718 |
# Add rules for links |
719 |
cat srclinks.tmp >> ${mfile} |
720 |
rm -f srclinks.tmp |
721 |
|
722 |
echo "" >> ${mfile} |
723 |
echo "# DO NOT DELETE" >> ${mfile} |
724 |
|
725 |
exit |