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