/[MITgcm]/MITgcm/tools/genmake
ViewVC logotype

Contents of /MITgcm/tools/genmake

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.83 - (show annotations) (download)
Wed Sep 17 18:24:51 2003 UTC (19 years, 4 months ago) by dimitri
Branch: MAIN
CVS Tags: branchpoint-genmake2, checkpoint51f_post
Branch point for: branch-genmake2
Changes since 1.82: +14 -1 lines
added "preliminary" support for SGI Altix in tools/genmake

1 #!/bin/csh -f
2 #
3 # $Header: /usr/local/gcmpack/MITgcm/tools/genmake,v 1.82 2003/06/27 01:59:09 heimbach Exp $
4 # $Name: $
5 #
6 # Makefile generator for MITgcm UV codes
7 # created by cnh 03/98
8 # adapted by aja 06/98
9 # modified by aja 01/00
10
11 # Default lists
12 if (! $?DISABLE) set DISABLE = ( aim aim_v23 autodiff cal cost ctrl ecco exf grdchk flt land ptracers seaice therm_seaice bulk_force dic gchem )
13 if (! $?ENABLE) set ENABLE = ( )
14 if (! $?DEFINES) set DEFINES = ( )
15 if (! $?MODS) set MODS = ( )
16
17 # Grab variables/lists from .genmakerc
18 if (-r .genmakerc) source .genmakerc
19
20 # Process command-line arguments
21 set allargs=( $argv )
22 while ($#allargs)
23 set arg = $allargs[1]
24 switch ($arg)
25 case -makefile:
26 set mfile = ( Makefile )
27 breaksw
28 case -makefile=*:
29 set mfile = ( `echo $arg | sed 's/-makefile=//' `)
30 breaksw
31 case -platform:
32 case -platform=:
33 echo "To change platform you must specify one with -platform="
34 echo "eg. -platform=sparc or -platform=mips"
35 exit
36 breaksw
37 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=//' `)
42 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 -enable=*:
82 set ENABLE = ( $ENABLE `echo $arg | sed 's/-enable=//' | sed 's/,/ /g' `)
83 breaksw
84 case -cpp:
85 case -cpp=:
86 echo "To define CPP macros use -cpp=arg"
87 exit
88 breaksw
89 case -cpp=*:
90 set DEFINES = ( $DEFINES `echo $arg | sed 's/-cpp=//' | sed 's/,/ /g' `)
91 breaksw
92 case -ieee:
93 set IEEE
94 breaksw
95 case -mpi:
96 echo "Enabling MPI options"
97 set USEMPI
98 breaksw
99 case -jam:
100 set include_jam_libs
101 echo "Including paths to JAM libraries"
102 breaksw
103 case -fc:
104 case -fc=:
105 echo "To change the compiler (\$FC) you must specify one with -fc="
106 echo "eg. -fc=f90 or -fc=g77"
107 exit
108 breaksw
109 case -fc*:
110 if ($?FC) then
111 echo Option -fc=... can only be specified once.; exit 1
112 endif
113 set FC = ( `echo $arg | sed 's/-fc=//' `)
114 breaksw
115 case -help:
116 echo "usage: $0 [-help] [-makefile[=...]] [-platform=...] [-mpi] [-jam] [-disable=pkg1[,pkg2,...]] [-enable=pkg1[,pkg2,...]] [-mods=dir1[,dir2,...]] [-rootdir=dir]"
117 cat << EOF
118
119 $0 is used to generate the Makefile in the current directory.
120
121 Typical invocations are:
122 o from "bin": ../tools/genmake
123 o from "verification/expt/code": ../../../tools/genmake
124 o from "verification/expt/input": ../../../tools/genmake -mods=../code
125 o from a scratch directory: ~/mitgcm/tools/genmake -rootdir=~/mitgcm
126 or ~/mitgcm/tools/genmake -rootdir=~/mitgcm -mods=~/mymods
127
128 Packages (collected modules of code) can be disabled to avoid unnecessary
129 compilation of unused code. For instance if you know you will not
130 use GM/Redi, KPP and OBCS and they are appropriate turned-off in the
131 configuration:
132 .../tools/genmake -disable=gmredi,kpp,obcs
133
134 If you add some source files you can re-call the previous instance of
135 genmake with "make makefile".
136
137 genmake also reads the file .genmakerc which can be used to configure
138 options (primarily the command-line options above) for particular experiments.
139 EOF
140 exit
141 breaksw
142 default:
143 echo "Unknown command-line option: " $arg
144 echo $0 "-help to show usage"
145 exit
146 breaksw
147 endsw
148 shift allargs
149 end
150
151 # Default actions/options
152
153 # If platform wasn't specified then determine platform type of the host
154 if (! $?platform) then
155 set platform = (`uname`)
156 # This let's us distinguish between different Linux platforms
157 if ($platform == Linux) then
158 set machine = (`uname -m`)
159 set platform = ($platform'-'$machine)
160 endif
161 endif
162 # If name of makefile wasn't specified then use default "Makefile"
163 if (! $?mfile) set mfile = ( Makefile )
164
165 set mach = ( `uname -a` )
166 echo Operating system: $mach
167
168 # Directories for source, includes, binaries and executables
169 #
170 # If -rootdir wasn't specified then assume script is being run from bin
171 # but if it was supplied then we should place the executable in the build dir
172 if (! $?ROOTDIR) then
173 set pwd=`pwd`
174 if ($pwd:t == bin & -d ../model & -d ../eesupp & -d ../pkg) then
175 set ROOTDIR = ( .. )
176 endif
177 endif
178 # Scan for logical ROOTDIR
179 if (! $?ROOTDIR) then
180 foreach dr (. .. ../.. ../../.. ../../../.. ../../../../..)
181 if (-d $dr/model & -d $dr/eesupp & -d $dr/pkg) then
182 set ROOTDIR = $dr
183 echo ROOTDIR was not specified. Setting ROOTDIR = \"$ROOTDIR\"
184 break
185 endif
186 end
187 endif
188 if (! $?ROOTDIR) then
189 echo Root directory was not specified and could not be determined.
190 echo Specify the root location of the model source with -rootdir=dir
191 exit 1
192 endif
193 if (! -d $ROOTDIR) then
194 echo Root directory $ROOTDIR not found.;exit 1
195 endif
196 # If -mods wasn't specified then we will assume that we can find all the
197 # source code in the standard directories
198 if (! $?MODS) then
199 set SOURCEDIRS = ( )
200 set INCLUDEDIRS = ( )
201 else
202 set SOURCEDIRS = ( $MODS )
203 set INCLUDEDIRS = ( $MODS )
204 endif
205 if (! $?BUILDDIR) set BUILDDIR = ( . )
206 if (! -d $BUILDDIR) then
207 echo Build directory $BUILDDIR not found.;exit 1
208 endif
209 if (! $?EXEDIR) then
210 set pwd=`pwd`
211 if ($pwd:t == bin & -d ../exe & $ROOTDIR == ..) then
212 set EXEDIR = ( ../exe )
213 else
214 set EXEDIR = ( . )
215 endif
216 endif
217 if (! -d $EXEDIR) then
218 echo Executable directory $EXEDIR not found.;exit 1
219 endif
220 if (! $?TOOLSDIR) set TOOLSDIR = ( $ROOTDIR/tools )
221 if (! -d $TOOLSDIR) then
222 echo Tools directory $TOOLSDIR not found.;exit 1
223 endif
224 if (! $?EXECUTABLE) set EXECUTABLE = ( mitgcmuv )
225
226 # We have a special set of source files in eesupp/src which
227 # are generated from some template source files. We'll make them
228 # first so the appear as regular source code
229 if (-r $ROOTDIR/eesupp/src/Makefile) then
230 echo Making source files in eesupp from templates...
231 (cd $ROOTDIR/eesupp/src/; make) >& make_eesupp.errs
232 if ($status == 0) then
233 rm -f make_eesupp.errs
234 else
235 cat make_eesupp.errs
236 exit 2
237 endif
238 endif
239
240 # Now scan the standard source code tree
241 foreach dr ($SOURCEDIRS)
242 set adr=$dr
243 if (! -d $adr) then
244 echo mods directory $adr not found.; exit 1
245 endif
246 echo Adding mods dir: $adr
247 end
248 if (! $?PACKAGES) then
249 set PACKAGES=()
250 foreach pkg (`cd $ROOTDIR/pkg; find . -type d -print | grep -v CVS | sed 's:\./::' | grep -v "\." | sort`)
251 if (-d $ROOTDIR/pkg/$pkg) set PACKAGES=($PACKAGES $pkg)
252 end
253 endif
254 foreach dr ($PACKAGES)
255 set enable
256 foreach p ($DISABLE)
257 if ($p != 'all' & ! -d $ROOTDIR/pkg/$p) then
258 echo Specified package \"$p\" does not exist.
259 exit 1
260 endif
261 if ($dr == $p) unset enable
262 if ($p == 'all') unset enable
263 # The following allows entire trees to be disabled
264 if ($dr:h == $p) unset enable
265 if ($dr:h:h == $p) unset enable
266 if ($dr:h:h:h == $p) unset enable
267 if ($dr:h:h:h:h == $p) unset enable
268 end
269 foreach p ($ENABLE)
270 if ($dr == $p) set enable
271 end
272 if ($?enable) then
273 set adr=$ROOTDIR/pkg/$dr
274 if (! -d $adr) then
275 echo Source directory $adr not found.; exit 1
276 endif
277 echo Adding pkg dir: $adr
278 set SOURCEDIRS = ($SOURCEDIRS $adr)
279 set INCLUDEDIRS = ($INCLUDEDIRS $adr)
280 switch ($dr)
281 case ptracers:
282 set DEFINES = ($DEFINES '-DALLOW_PTRACERS'); breaksw
283 default:
284 breaksw
285 endsw
286 else
287 echo " *" Package \"$dr\" NOT enabled.
288 switch ($dr)
289 case mom_fluxform:
290 set DEFINES = ($DEFINES '-DDISABLE_MOM_FLUXFORM'); breaksw
291 case mom_vecinv:
292 set DEFINES = ($DEFINES '-DDISABLE_MOM_VECINV'); breaksw
293 case generic_advdiff:
294 set DEFINES = ($DEFINES '-DDISABLE_GENERIC_ADVDIFF'); breaksw
295 case debug:
296 set DEFINES = ($DEFINES '-DDISABLE_DEBUGMODE'); breaksw
297 default:
298 breaksw
299 endsw
300 endif
301 end
302 if (! $?STANDARDDIRS) set STANDARDDIRS=(eesupp model)
303 foreach dr ($STANDARDDIRS)
304 set adr=$ROOTDIR/$dr/src
305 if (! -d $adr) then
306 echo Source directory $adr not found.; exit 1
307 endif
308 echo Adding src dir: $adr
309 set SOURCEDIRS = ($SOURCEDIRS $adr)
310 set idr = `echo $adr | sed 's/src/inc/'`
311 set INCLUDEDIRS = ($INCLUDEDIRS $idr)
312 end
313
314 # Find possible compilers
315 if ($?FC) then
316 echo "$FC was specified as the compiler"
317 else
318 echo " "
319 switch ($platform)
320 case Linux*:
321 set likelysuspects=(g77 ifc pgf77 f77 f90 f95)
322 breaksw
323 default:
324 set likelysuspects=(f77)
325 breaksw
326 endsw
327 foreach fc ($likelysuspects)
328 set foundfc=`which $fc |& cat - `
329 if (-x $foundfc[1]) then
330 if ($?possiblefc) then
331 set possiblefc=($possiblefc $fc)
332 else
333 set possiblefc=$fc
334 endif
335 endif
336 end
337 if ($?possiblefc) then
338 set FC=$possiblefc[1]
339 echo Found these compilers: $possiblefc. Using \"$FC\" as the compiler
340 else
341 echo "No compiler found\!"
342 echo I tried looking for \"$likelysuspects\" in your \$PATH but found none
343 echo I will continue anyway and see what happens.
344 set FC = ( 'f77' )
345 # exit 13
346 endif
347 endif
348
349 # This is the generic configuration.
350 # Platform specific options are chosen below
351 set LN = ( 'ln -s' )
352 set CPP = ( '/lib/cpp -P' )
353 set S64 = ( '$(TOOLSDIR)/set64bitConst.sh' )
354 set KPP = ( )
355 #set FC = ( 'f77' )
356 set LINK = $FC
357 set MAKEDEPEND = ( 'makedepend' )
358 set INCLUDES = ( -I. )
359 set FFLAGS = ( )
360 set FOPTIM = ( )
361 set CFLAGS = ( )
362 set KFLAGS1 = ( )
363 set KFLAGS2 = ( )
364 set LIBS = ( )
365 set KPPFILES = ( )
366 if (! $?NOOPTFILES ) set NOOPTFILES = ( )
367 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = ( )
368 set RMFILES = ( )
369
370 # We often want to use different compile/link options is using MPI
371 if ($?USEMPI) then
372 set USEMPI = ( '+mpi' )
373 set DEFINES = ( ${DEFINES} '-DALLOW_USE_MPI -DALWAYS_USE_MPI' )
374 else
375 set USEMPI
376 # set DEFINES = ( ${DEFINES} '-UALLOW_USE_MPI -UALWAYS_USE_MPI' )
377 endif
378
379 # Platform specific options
380 switch ($platform$USEMPI)
381 case OSF1+mpi:
382 #ph: e.g. halem.gsfc.nasa.gov
383 echo "Configuring for DEC Alpha with MPI"
384 set LIBS = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' )
385 #ph: -lkmp_osfp10 not needed on some/many platforms
386 case OSF1:
387 echo "Configuring for DEC Alpha"
388 set CPP = ( '/usr/bin/cpp -P' )
389 set DEFINES = ( ${DEFINES} '-DTARGET_DEC -DWORDLENGTH=1' )
390 set MAKEDEPEND = ( mkdep -f depend.out )
391 #ph: makedepend not available on some/many DEC Alpha's; use mkdep instead
392 set KPP = ( )
393 set KPPFILES = ( )
394 set KFLAGS1 = ( )
395 set FC = ( 'f77' )
396 set FFLAGS = ( '-convert big_endian -r8 -extend_source -automatic -call_shared -notransform_loops -align dcommons' )
397 set FOPTIM = ( '-O5 -fast -tune host -inline all' )
398 #ph: -O5 probably too aggressive in conjunction with adjoint code
399 set NOOPTFLAGS = ( '-O0' )
400 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')
401 set RMFILES = ( '*.p.out' )
402 breaksw
403 case IRIX64+mpi:
404 echo "Configuring for SGI Mips with MPI"
405 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
406 set INCLUDES = ( '-I/usr/local/mpi/include' )
407 set FC = ( 'mpif77' )
408 set LINK = ( 'mpif77' )
409 set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' )
410 set FOPTIM = ( '-O3' )
411 set RMFILES = ( 'rii_files' )
412 breaksw
413 case IRIX64:
414 echo "Configuring for SGI Mips"
415 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
416 set INCLUDES = ( '-I/usr/local/mpi/include' )
417 set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4 -r8 -static' )
418 set FOPTIM = ( '-O3' )
419 if ($?IEEE) set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4 -static' )
420 if ($?IEEE) set FOPTIM = ( '-O0 -OPT:IEEE_arithmetic=1 -OPT:IEEE_NaN_inf=ON' )
421 set RMFILES = ( 'rii_files' )
422 breaksw
423 case o2:
424 case IRIX:
425 echo "Configuring for SGI O2 running IRIX 6.5"
426 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
427 set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' )
428 set FOPTIM = ( '-O2' )
429 set NOOPTFLAGS = ( '-O0' )
430 breaksw
431 case o2+mpi:
432 case IRIX+mpi:
433 echo "Configuring for SGI O2 running IRIX 6.5 with MPI"
434 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
435 set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' )
436 set FOPTIM = ( '-O2' )
437 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F' )
438 set NOOPTFLAGS = ( '-O0' )
439 set LIBS = ( '-lmpi' )
440 breaksw
441 case o2k+mpi:
442 echo "Configuring for SGI Origin2000 running IRIX 6.5"
443 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
444 set INCLUDES = ( '-I/usr/include' )
445 set FFLAGS = ( '-n32 -extend_source -bytereclen' )
446 set FOPTIM = ( '-O3 -OPT:Olimit=0:roundoff=3:div_split=ON:alias=typed' )
447 set LIBS = ( '-lmpi -lscs' )
448 breaksw
449 case o2k_noopt:
450 case o2k_noopt+mpi:
451 echo "Configuring for SGI Origin2000 running IRIX 6.5"
452 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
453 set INCLUDES = ( '-I/usr/include' )
454 set FFLAGS = ( '-n32 -extend_source -bytereclen' )
455 set FOPTIM = ( '-O0' )
456 set LIBS = ( '-lmpi' )
457 breaksw
458 case ames_dbg+mpi:
459 echo "Configuring for SGI Origin2000 running IRIX 6.5"
460 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
461 set INCLUDES = ( '-I/usr/include -I/opt/mpt/1.6.1.beta/usr/include' )
462 set FFLAGS = ( '-n32 -extend_source -bytereclen' )
463 set LIBS = ( '-lmpi -lscs' )
464 set FC = ( 'f90' )
465 set LINK = ( 'f90' )
466 breaksw
467 case ames_opt+mpi:
468 echo "Configuring for SGI Origin2000 running IRIX 6.5"
469 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
470 set INCLUDES = ( '-I/usr/include -I/opt/mpt/1.6.1.beta/usr/include' )
471 set FFLAGS = ( '-n32 -extend_source -bytereclen' )
472 set FOPTIM = ( '-O3 -OPT:Olimit=0:roundoff=3:div_split=ON:alias=typed' )
473 set LIBS = ( '-lmpi -lscs' )
474 set FC = ( 'f90' )
475 set LINK = ( 'f90' )
476 breaksw
477 case onyx:
478 case onyx+mpi:
479 echo "Configuring for SGI ONYX running IRIX64"
480 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
481 set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' )
482 set FOPTIM = ( '-O2' )
483 set NOOPTFLAGS = ( '-O0' )
484 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F' )
485 set LIBS = ( '-lmpi' )
486 breaksw
487 case SunOS:
488 set LN = ( '/usr/bin/ln -s' )
489 set CPP = ( '/usr/ccs/lib/cpp -P' )
490 set MAKEDEPEND = ( ${TOOLSDIR}/xmakedepend )
491 set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4 -D_d=E' )
492 set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar -xtypemap=real:64,double:64,integer:32 -fsimple=0' )
493 set FOPTIM = ( '-dalign -O3 -xarch=v9' )
494 set CFLAGS = ( '-dalign -O3 -xarch=v9' )
495 set NOOPTFLAGS = ( '-dalign -O0 -xarch=v9' )
496 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 ')
497 breaksw
498 case SunOS+mpi:
499 set LN = ( '/usr/bin/ln -s' )
500 set CPP = ( '/usr/ccs/lib/cpp -P' )
501 set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4 -D_d=E' )
502 set INCLUDES = ( '-I/usr/local/mpi/include' )
503 set LIBS = ( '-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread' \
504 set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar -xtypemap=real:64,double:64,integer:32 -fsimple=0' )
505 set FOPTIM = ( '-dalign -O3 -xarch=v9' )
506 set NOOPTFLAGS = ( '-dalign -O0 -xarch=v9' )
507 '-lsocket -lnsl' )
508 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')
509 breaksw
510 case SunFire+mpi:
511 set FC = ( 'mpf77' )
512 set LINK = ( 'mpf77' )
513 set LN = ( '/usr/bin/ln -s' )
514 set CPP = ( '/usr/ccs/lib/cpp -P' )
515 set MAKEDEPEND = ( ${TOOLSDIR}/xmakedepend )
516 set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4' )
517 set INCLUDES = ( '-I/opt/SUNWhpc/include' )
518 set LIBS = ( '-lmpi -lthread -lsocket -lnsl' )
519 set FFLAGS = ( '-e -u -noautopar ' \
520 '-xtypemap=real:64,double:64,integer:32 -fsimple=0' )
521 set FOPTIM = ( '-dalign -O4 -xarch=native' )
522 set CFLAGS = ( '-dalign -xO4 -xarch=native' )
523 set NOOPTFLAGS = ( '-dalign -O0 -xarch=native' )
524 breaksw
525 case IRIX32:
526 echo "Configuring for SGI ONYX running IRIX64"
527 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
528 set INCLUDES = ( '-I/usr/include' )
529 set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' )
530 set FOPTIM = ( '-O2' )
531 set NOOPTFLAGS = ( '-O0' )
532 set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
533 'external_fields_load.F' )
534 set LIBS = ( '-lmpi' )
535 breaksw
536 case HP-UX+mpi:
537 set FC = ( 'mpif77' )
538 set LINK = ( 'mpif77' )
539 set INCLUDES = ( '-I/opt/mpi/include' )
540 case HP-UX:
541 echo "Configuring for HP Exemplar"
542 set CPP = ( '/usr/ccs/lbin/cpp -P' )
543 set DEFINES = ( ${DEFINES} '-DTARGET_HP -DWORDLENGTH=4' )
544 set FFLAGS = ( '+es +U77 +Onoautopar +Oexemplar_model' \
545 '+Okernel_threads' )
546 set FOPTIM = ( '+O2' )
547 set NOOPTFLAGS = ( '+O0' )
548 set NOOPTFILES = ( 'barrier.F different_multiple.F' \
549 'external_fields_load.F' )
550 breaksw
551 case Linux-ia64+mpi:
552 echo "Configuring with MPI"
553 case Linux-ia64:
554 echo "Configuring for " $platform
555 set LN = ( '/bin/ln -s' )
556 set CPP = ( '/lib/cpp -traditional -P' )
557 set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' )
558 set FC = ( 'efc' )
559 set FFLAGS = ( '-WB -Vaxlib -u -w' )
560 set FOPTIM = ( '-O2 ' )
561 set LINK = ( 'efc' )
562 set LIBS = ( '-lmpi -lscs -lpthread' )
563 breaksw
564 case Linux-alpha+mpi:
565 echo "Configuring with MPI"
566 set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
567 set INCLUDES = ( '-I/usr/local/include' )
568 case Linux-alpha:
569 echo "Configuring for " $platform
570 set LN = ( '/bin/ln -s' )
571 set CPP = ( '/lib/cpp -traditional -P' )
572 set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' )
573 set FC = ( 'g77' )
574 set FFLAGS = ( ' ' )
575 if ($?IEEE) set FFLAGS = ( $FFLAGS '-ffloat-store' )
576 set FOPTIM = ( '-ffast-math -fexpensive-optimizations -fomit-frame-pointer -O3' )
577 set LINK = ( 'g77' )
578 breaksw
579 case Linux*+pgi+mpi:
580 if ($?include_jam_libs) then
581 set INCLUDES = ( '-I/usr/local/mpich-1.2.1/pgi_fortran_binding/include' )
582 set LIBS = ( '-L/usr/local/mpich-1.2.1/pgi_fortran_binding/lib/ -lfmpich -lmpich' )
583 else
584 set INCLUDES = ( '-I/usr/local/include' )
585 set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
586 endif
587 case Linux*+pgi:
588 echo "Configuring for " $platform
589 set LN = ( '/bin/ln -s' )
590 set CPP = ( '/lib/cpp -traditional -P' )
591 set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' )
592 set FC = ( 'pgf77' )
593 set FFLAGS = ( '-byteswapio -r8 -Mnodclchk -Mextend' )
594 set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
595 set LINK = ( 'pgf77' )
596 breaksw
597 case Linux*+mpi:
598 set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
599 set INCLUDES = ( '-I/usr/local/include' )
600 case Linux*:
601 echo "Configuring for " $platform
602 set LN = ( '/bin/ln -s' )
603 set CPP = ( '/lib/cpp -traditional -P' )
604 switch ($FC)
605 case g77:
606 set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' )
607 set FFLAGS = ( '-Wimplicit -Wunused -Wuninitialized' )
608 if ($?IEEE) set FFLAGS = ( $FFLAGS '-ffloat-store' )
609 set FOPTIM = ( '-O3 -malign-double -funroll-loops' )
610 set NOOPTFLAGS = ( '-O0' )
611 breaksw
612 case pgf77:
613 set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' )
614 set FC = ( 'pgf77' )
615 set FFLAGS = ( '-byteswapio -r8 -Mnodclchk -Mextend' )
616 set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
617 breaksw
618 case ifc:
619 set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' )
620 set FFLAGS = ( '-132 -r8 -i4 -w95 -W0 -WB' )
621 if ($?IEEE) set FFLAGS = ( $FFLAGS '-mp' )
622 set FOPTIM = ( '-O3 -align' )
623 #P3 set FOPTIM = ( $FOPTIM '-tpp6 -xWKM' )
624 #P4 set FOPTIM = ( $FOPTIM '-tpp7 -xWKM' )
625 set LIBS = ( '-lPEPCF90' )
626 breaksw
627 default:
628 echo Error: Linux compiler not recognized: \$FC=$FC
629 exit
630 breaksw
631 endsw
632 breaksw
633 case T3E:
634 case sn6312:
635 echo "Configuring for T3E"
636 set CPP = ( '/opt/ctl/bin/cpp -P')
637 set DEFINES = ( ${DEFINES} '-DTARGET_T3E -DWORDLENGTH=4' )
638 set FC = ( 'f90' )
639 set LINK = ( 'f90' )
640 set FFLAGS = ( '-O 2,fusion' )
641 breaksw
642 case T90:
643 case sn7113:
644 echo "Configuring for T90"
645 set FC = ( 'f90' )
646 set LINK = ( 'f90' )
647 set LN = ( '/bin/ln -s' )
648 set CPP = ( '/opt/ctl/bin/cpp -N -P' )
649 set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' )
650 set FFLAGS = ( '-m3 -Rabc -N 132')
651 set FOPTIM = ( '-O0' )
652 set NOOPTFLAGS = ( '-O0' )
653 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')
654 breaksw
655 case SV1:
656 case sn3002:
657 set FC = ( 'f90' )
658 set LINK = ( 'f90' )
659 set LN = ( '/bin/ln -s' )
660 set CPP = ( '/opt/ctl/bin/cpp -N -P' )
661 set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' )
662 set FFLAGS = ( '-m3 -Rabc -ei -eI -s cf77types -N 132')
663 set FOPTIM = ( '-O0' )
664 set NOOPTFLAGS = ( '-O0' )
665 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')
666 breaksw
667 case cg01+pgi:
668 set LN = ( '/bin/ln -s' )
669 set CPP = ( '/lib/cpp -traditional -P' )
670 set INCLUDES = ( '-I/usr/local/pkg/mpi/mpi-1.2.4..8a-gm-1.5/pgi/include' )
671 set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' )
672 set FC = ( '/usr/local/pkg/mpi/mpi-1.2.4..8a-gm-1.5/pgi/bin/mpif77' )
673 set FFLAGS = ( '-byteswapio -r8 -Mnodclchk -Mextend' )
674 # set LIBS = ( '-L/home/cnh/src/gm-1.4/libgm')
675 set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
676 set LINK = ( '/usr/local/pkg/mpi/mpi-1.2.4..8a-gm-1.5/pgi/bin/mpif77' )
677 breaksw
678 case SP3:
679 # originally from A. Biastoch, SIO.
680 # e.g. horizon.npaci.edu
681 echo "Configuring for IBM SP POWER3"
682 set SOURCEDIRS = ( ./ $SOURCEDIRS )
683 set LN = ( 'ln -s' )
684 set DEFINES = ( ${DEFINES} '-DTARGET_PWR3 -DTARGET_SGI -DWORDLENGTH=4' )
685 set INCLUDES = ( '-I/usr/lpp/ppe.poe/include' )
686 # set CPP = ( '/lib/cpp' )
687 set FC = ( 'mpxlf95' )
688 set LINK = ( 'mpxlf95' )
689 set FLAGS = ( '-O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \
690 '-bmaxdata:0x80000000 -bloadmap:mitgcmuv.map' )
691 set FFLAGS = ( '-qfixed=132 -O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \
692 '-bmaxdata:0x80000000 ' )
693 set LDFLAGS = ( '-O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \
694 '-bmaxdata:0x80000000' )
695 set LIBS = ( ' -L/usr/local/apps/mass -lmass' )
696 # set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4' )
697 # set FOPTIM = ( '-O3' )
698 # set NOOPTFLAGS = ( '-O0' )
699 # set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
700 # 'external_fields_load.F' )
701 set RMFILES = ( 'rii_files' )
702 breaksw
703 case SP4:
704 #ph: e.g. bluesky.ucar.edu, marcellus.navo.hpc.mil
705 echo "Configuring for IBM SP POWER4"
706 set SOURCEDIRS = ( ./ $SOURCEDIRS )
707 set LN = ( 'ln -s' )
708 set DEFINES = ( ${DEFINES} '-DTARGET_PWR3 -DTARGET_SGI -DWORDLENGTH=4' )
709 set INCLUDES = ( '-I/usr/lpp/ppe.poe/include' )
710 # set CPP = ( '/lib/cpp' )
711 set FC = ( 'mpxlf95' )
712 set LINK = ( 'mpxlf95' )
713 set FLAGS = ( '-O3 -qarch=pwr4 -qtune=pwr4 -qcache=auto -qmaxmem=-1' \
714 '-bmaxdata:0x80000000 -bloadmap:mitgcmuv.map' )
715 set FFLAGS = ( '-qfixed=132 -O3 -qarch=pwr4 -qtune=pwr4 -qcache=auto -qmaxmem=-1' \
716 '-bmaxdata:0x80000000 ' )
717 set LDFLAGS = ( '-O3 -qarch=pwr4 -qtune=pwr4 -qcache=auto -qmaxmem=-1' \
718 '-bmaxdata:0x80000000' )
719 set LIBS = ( ' -L/usr/local/apps/mass -lmass' )
720 # set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4' )
721 # set FOPTIM = ( '-O3' )
722 # set NOOPTFLAGS = ( '-O0' )
723 # set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
724 # 'external_fields_load.F' )
725 set RMFILES = ( 'rii_files' )
726 breaksw
727 case aer-linux-cluster+mpi
728 echo "Configuring for " $platform
729 set LN = ( '/bin/ln -s' )
730 set CPP = ( '/lib/cpp -traditional -P' )
731 set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' )
732 set FC = ( '/opt/mpich/bin/mpif77' )
733 set LINK = ( '/opt/mpich/bin/mpif77' )
734 set FFLAGS = ( '-byteswapio -r8 -Mnodclchk -Mextend' )
735 set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
736 set LIBS = ( '-L/opt/mpich/lib/ -lfmpich -lmpich' )
737 set INCLUDES = ( '-I/opt/mpich/include' )
738 breaksw
739 default:
740 echo "Error: platform not recognized: uname -p = " $platform$USEMPI
741 exit
742 breaksw
743 endsw
744
745 ###############################################################################
746 ## ##
747 ## Everything below here should not need to be changed. Platform specific ##
748 ## changes and code specific changes should be configured above this line. ##
749 ## ##
750 ###############################################################################
751
752 # Convert lists of directories into command-line options
753 foreach inc ($INCLUDEDIRS)
754 set INCLUDES = ($INCLUDES -I$inc)
755 end
756
757 # Search for source code
758 rm -rf .links.tmp;mkdir .links.tmp
759 echo "# This section creates symbolic links" > srclinks.tmp
760 echo "" >> srclinks.tmp
761 echo -n 'SRCFILES = ' > srclist.inc
762 echo -n 'CSRCFILES = ' > csrclist.inc
763 echo -n 'HEADERFILES = ' > hlist.inc
764 foreach dr ($SOURCEDIRS $INCLUDEDIRS .)
765 set deplist=( )
766 foreach srcfile (`cd $dr; ls *.[hcF]`)
767 if (! -r .links.tmp/$srcfile) then
768 if (-f $dr/$srcfile) then
769 switch ($srcfile:e)
770 case F:
771 touch .links.tmp/$srcfile
772 set deplist=($deplist $srcfile)
773 echo ' \' >> srclist.inc
774 echo -n " " $srcfile >> srclist.inc
775 breaksw
776 case c:
777 touch .links.tmp/$srcfile
778 set deplist=($deplist $srcfile)
779 echo ' \' >> csrclist.inc
780 echo -n " " $srcfile >> csrclist.inc
781 breaksw
782 case h:
783 touch .links.tmp/$srcfile
784 set deplist=($deplist $srcfile)
785 echo ' \' >> hlist.inc
786 echo -n " " $srcfile >> hlist.inc
787 breaksw
788 endsw
789 endif
790 endif
791 end
792 if ($#deplist != 0) then
793 echo "# These files are linked from $dr" >> srclinks.tmp
794 echo $deplist':' >> srclinks.tmp
795 echo ' $(LN) '$dr'/$@ $@' >> srclinks.tmp
796 endif
797 end
798 rm -rf .links.tmp
799 echo "" >> srclist.inc
800 echo "" >> csrclist.inc
801 echo "" >> hlist.inc
802
803 set THISHOSTNAME = ( `hostname` )
804 set THISCWD = ( `pwd` )
805 set THISDATE = ( `date` )
806
807 if (-r $mfile) mv -f $mfile $mfile.bak
808 ###########################################
809 ## This is the template for the makefile ##
810 ###########################################
811 echo Creating makefile: $mfile
812 echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile}
813 echo "# This makefile was generated automatically on" >> ${mfile}
814 echo "# $THISDATE" >> ${mfile}
815 echo "# by the command:" >> ${mfile}
816 echo "# ${0} $argv" >> ${mfile}
817 echo "# executed by:" >> ${mfile}
818 echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> ${mfile}
819 cat >> ${mfile} <<EOF
820 #
821 # BUILDDIR : Directory where object files are written
822 # SOURCEDIRS : Directories containing the source (.F) files
823 # INCLUDEDIRS : Directories containing the header-source (.h) files
824 # EXEDIR : Directory where executable that is generated is written
825 # EXECUTABLE : Full path of executable binary
826 #
827 # CPP : C-preprocessor command
828 # INCLUDES : Directories searched for header files
829 # DEFINES : Macro definitions for CPP
830 # MAKEDEPEND : Dependency generator
831 # KPP : Special preprocessor command (specific to platform)
832 # KFLAGS : Flags for KPP
833 # FC : Fortran compiler command
834 # FFLAGS : Configuration/debugging options for FC
835 # FOPTIM : Optimization options for FC
836 # LINK : Command for link editor program
837 # LIBS : Library flags /or/ additional optimization/debugging flags
838
839 ROOTDIR = ${ROOTDIR}
840 BUILDDIR = ${BUILDDIR}
841 SOURCEDIRS = ${SOURCEDIRS}
842 INCLUDEDIRS = ${INCLUDEDIRS}
843 EXEDIR = ${EXEDIR}
844 EXECUTABLE = \$(EXEDIR)/${EXECUTABLE}
845 TOOLSDIR = ${TOOLSDIR}
846
847 EOF
848
849
850 # JAM libraries on Hyades
851 if ($?include_jam_libs) then
852 cat >> ${mfile} <<EOF
853 # extra stuff for Hyades ............................................
854 HYADES_DIR = /u/u0/cnh/jam-lib/software
855 HYADES_DIR = /u/u0/cnh/jam-lib-twoproc
856 HYADES_DIR = /usr/local/jamlib/current/dual_proc
857 WORK_DIR = \$(HYADES_DIR)
858 DEPOSIT_DIR = linux_bin
859
860 STARTXOBJDIR = startx_util/\$(DEPOSIT_DIR)
861 STARTXOBJ = \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/startx_timer.o \
862 \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/startx_util.o \
863 \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/client.o \
864 \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/csutil.o
865
866 JAMOBJDIR = jam/\$(DEPOSIT_DIR)
867 JAMOBJ = \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_init.o \
868 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_kernel.o \
869 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_malloc.o \
870 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_vmalloc.o \
871 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_mutex.o
872
873 JAMCOBJDIR = jam_collective/\$(DEPOSIT_DIR)
874 JAMCOBJ = \$(WORK_DIR)/jam_collective/\$(DEPOSIT_DIR)/jam_collective.o
875
876 XLIBS = \$(STARTXOBJ) \$(JAMOBJ) \$(JAMCOBJ)
877
878 # ..................................................................
879
880 EOF
881 endif
882
883
884 cat >> ${mfile} <<EOF
885 # Unix ln (link)
886 LN = ${LN}
887 # C preprocessor
888 CPP = cat \$< | ${S64} | ${CPP}
889 # Dependency generator
890 MAKEDEPEND = ${MAKEDEPEND}
891 # Special preprocessor (KAP on DECs, FPP on Crays)
892 KPP = ${KPP}
893 # Fortran compiler
894 FC = ${FC}
895 # Link editor
896 LINK = ${LINK}
897
898 # Defines for CPP
899 DEFINES = ${DEFINES}
900 # Includes for CPP
901 INCLUDES = ${INCLUDES}
902 # Flags for KPP
903 KFLAGS1 = ${KFLAGS1}
904 KFLAGS2 = ${KFLAGS2}
905 # Optim./debug for FC
906 FFLAGS = ${FFLAGS}
907 FOPTIM = ${FOPTIM}
908 # Flags for CC
909 CFLAGS = ${CFLAGS}
910 # Files that should not be optimized
911 NOOPTFILES = ${NOOPTFILES}
912 NOOPTFLAGS = ${NOOPTFLAGS}
913 # Flags and libraries needed for linking
914 LIBS = ${LIBS} \$(XLIBS)
915
916 EOF
917
918 cat srclist.inc >> ${mfile}
919 cat csrclist.inc >> ${mfile}
920 cat hlist.inc >> ${mfile}
921 echo 'F77FILES = $(SRCFILES:.F=.f)' >> ${mfile}
922 echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o)' >> ${mfile}
923
924 rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp
925
926 cat >> ${mfile} <<EOF
927
928 .SUFFIXES:
929 .SUFFIXES: .o .f .p .F .c
930
931 all: \$(EXECUTABLE)
932 \$(EXECUTABLE): \$(OBJFILES)
933 \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
934 depend:
935 @make links
936 \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
937
938 links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES)
939
940 small_f: \$(F77FILES)
941
942 output.txt: \$(EXECUTABLE)
943 @printf 'running ... '
944 @\$(EXECUTABLE) > \$@
945
946 clean:
947 -rm -rf *.o *.f *.p ${RMFILES} work.{pc,pcl}
948 Clean:
949 @make clean
950 @make cleanlinks
951 -rm -f Makefile.bak
952 CLEAN:
953 @make Clean
954 -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
955 -find \$(EXEDIR) -name "*.data" -exec rm {} \;
956 -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
957 -rm -f \$(EXECUTABLE)
958
959 makefile:
960 ${0} $argv
961 cleanlinks:
962 -find . -type l -exec rm {} \;
963
964 # The normal chain of rules is ( .F - .f - .o )
965 .F.f:
966 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
967 .f.o:
968 \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
969 .c.o:
970 \$(CC) \$(CFLAGS) -c \$<
971
972 # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain
973 .F.p:
974 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
975 .p.f:
976 \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
977 EOF
978
979 # Make list of "exceptions" that need ".p" files
980 foreach sf ($KPPFILES)
981 set fname=( ${sf:t} )
982 echo "${fname:r}.f: ${fname:r}.p" >> ${mfile}
983 end
984 foreach sf ($NOOPTFILES)
985 set fname=( ${sf:t} )
986 echo "${fname:r}.o: ${fname:r}.f" >> ${mfile}
987 echo ' $(FC) $(FFLAGS) $(NOOPTFLAGS) -c $<' >> ${mfile}
988 end
989 echo "" >> ${mfile}
990
991 # Add rules for links
992 cat srclinks.tmp >> ${mfile}
993 rm -f srclinks.tmp
994
995 echo "" >> ${mfile}
996 echo "# DO NOT DELETE" >> ${mfile}
997
998 exit

  ViewVC Help
Powered by ViewVC 1.1.22