/[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.76 - (show annotations) (download)
Wed Mar 19 23:25:53 2003 UTC (17 years, 11 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint50c_post, checkpoint50d_pre, checkpoint50d_post, checkpoint50c_pre, checkpoint50b_pre, checkpoint50b_post, checkpoint50a_post, checkpoint50e_pre
Changes since 1.75: +4 -3 lines
 NOOPTFILES & NOOPTFLAGS not reset if already defined (.e.g in .genmakerc)

1 #!/bin/csh -f
2 #
3 # $Header: /u/gcmpack/MITgcm/tools/genmake,v 1.75 2003/02/28 02:52:49 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 set DISABLE = ( aim autodiff cal cost ctrl ecco exf grdchk flt ptracers seaice therm_seaice bulk_force)
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
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 IRIX32:
511 echo "Configuring for SGI ONYX running IRIX64"
512 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
513 set INCLUDES = ( '-I/usr/include' )
514 set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' )
515 set FOPTIM = ( '-O2' )
516 set NOOPTFLAGS = ( '-O0' )
517 set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
518 'external_fields_load.F' )
519 set LIBS = ( '-lmpi' )
520 breaksw
521 case HP-UX+mpi:
522 set FC = ( 'mpif77' )
523 set LINK = ( 'mpif77' )
524 set INCLUDES = ( '-I/opt/mpi/include' )
525 case HP-UX:
526 echo "Configuring for HP Exemplar"
527 set CPP = ( '/usr/ccs/lbin/cpp -P' )
528 set DEFINES = ( ${DEFINES} '-DTARGET_HP -DWORDLENGTH=4' )
529 set FFLAGS = ( '+es +U77 +Onoautopar +Oexemplar_model' \
530 '+Okernel_threads' )
531 set FOPTIM = ( '+O2' )
532 set NOOPTFLAGS = ( '+O0' )
533 set NOOPTFILES = ( 'barrier.F different_multiple.F' \
534 'external_fields_load.F' )
535 breaksw
536 case Linux-alpha+mpi:
537 echo "Configuring with MPI"
538 set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
539 set INCLUDES = ( '-I/usr/local/include' )
540 case Linux-alpha:
541 echo "Configuring for " $platform
542 set LN = ( '/bin/ln -s' )
543 set CPP = ( '/lib/cpp -traditional -P' )
544 set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' )
545 set FC = ( 'g77' )
546 set FFLAGS = ( ' ' )
547 if ($?IEEE) set FFLAGS = ( $FFLAGS '-ffloat-store' )
548 set FOPTIM = ( '-ffast-math -fexpensive-optimizations -fomit-frame-pointer -O3' )
549 set LINK = ( 'g77' )
550 breaksw
551 case Linux*+pgi+mpi:
552 if ($?include_jam_libs) then
553 set INCLUDES = ( '-I/usr/local/mpich-1.2.1/pgi_fortran_binding/include' )
554 set LIBS = ( '-L/usr/local/mpich-1.2.1/pgi_fortran_binding/lib/ -lfmpich -lmpich' )
555 else
556 set INCLUDES = ( '-I/usr/local/include' )
557 set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
558 endif
559 case Linux*+pgi:
560 echo "Configuring for " $platform
561 set LN = ( '/bin/ln -s' )
562 set CPP = ( '/lib/cpp -traditional -P' )
563 set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' )
564 set FC = ( 'pgf77' )
565 set FFLAGS = ( '-byteswapio -r8 -Mnodclchk -Mextend' )
566 set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
567 set LINK = ( 'pgf77' )
568 breaksw
569 case Linux*+mpi:
570 set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
571 set INCLUDES = ( '-I/usr/local/include' )
572 case Linux*:
573 echo "Configuring for " $platform
574 set LN = ( '/bin/ln -s' )
575 set CPP = ( '/lib/cpp -traditional -P' )
576 switch ($FC)
577 case g77:
578 set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' )
579 set FFLAGS = ( '-Wimplicit -Wunused -Wuninitialized' )
580 if ($?IEEE) set FFLAGS = ( $FFLAGS '-ffloat-store' )
581 set FOPTIM = ( '-O3 -malign-double -funroll-loops' )
582 set NOOPTFLAGS = ( '-O0' )
583 breaksw
584 case pgf77:
585 set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' )
586 set FC = ( 'pgf77' )
587 set FFLAGS = ( '-byteswapio -r8 -Mnodclchk -Mextend' )
588 set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
589 breaksw
590 case ifc:
591 set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' )
592 set FFLAGS = ( '-132 -r8 -i4 -w95 -W0 -WB' )
593 if ($?IEEE) set FFLAGS = ( $FFLAGS '-mp' )
594 set FOPTIM = ( '-O3 -align' )
595 #P3 set FOPTIM = ( $FOPTIM '-tpp6 -xWKM' )
596 #P4 set FOPTIM = ( $FOPTIM '-tpp7 -xWKM' )
597 set LIBS = ( '-lPEPCF90' )
598 breaksw
599 default:
600 echo Error: Linux compiler not recognized: \$FC=$FC
601 exit
602 breaksw
603 endsw
604 breaksw
605 case T3E:
606 case sn6312:
607 echo "Configuring for T3E"
608 set CPP = ( '/opt/ctl/bin/cpp -P')
609 set DEFINES = ( ${DEFINES} '-DTARGET_T3E -DWORDLENGTH=4' )
610 set FC = ( 'f90' )
611 set LINK = ( 'f90' )
612 set FFLAGS = ( '-O 2,fusion' )
613 breaksw
614 case T90:
615 case sn7113:
616 echo "Configuring for T90"
617 set FC = ( 'f90' )
618 set LINK = ( 'f90' )
619 set LN = ( '/bin/ln -s' )
620 set CPP = ( '/opt/ctl/bin/cpp -N -P' )
621 set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' )
622 set FFLAGS = ( '-m3 -Rabc -N 132')
623 set FOPTIM = ( '-O0' )
624 set NOOPTFLAGS = ( '-O0' )
625 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')
626 breaksw
627 case SV1:
628 case sn3002:
629 set FC = ( 'f90' )
630 set LINK = ( 'f90' )
631 set LN = ( '/bin/ln -s' )
632 set CPP = ( '/opt/ctl/bin/cpp -N -P' )
633 set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' )
634 set FFLAGS = ( '-m3 -Rabc -ei -eI -s cf77types -N 132')
635 set FOPTIM = ( '-O0' )
636 set NOOPTFLAGS = ( '-O0' )
637 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')
638 breaksw
639 case cg01+pgi:
640 set LN = ( '/bin/ln -s' )
641 set CPP = ( '/lib/cpp -traditional -P' )
642 set INCLUDES = ( '-I/usr/local/pkg/mpi/mpi-1.2.4..8a-gm-1.5/pgi/include' )
643 set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' )
644 set FC = ( '/usr/local/pkg/mpi/mpi-1.2.4..8a-gm-1.5/pgi/bin/mpif77' )
645 set FFLAGS = ( '-byteswapio -r8 -Mnodclchk -Mextend' )
646 # set LIBS = ( '-L/home/cnh/src/gm-1.4/libgm')
647 set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
648 set LINK = ( '/usr/local/pkg/mpi/mpi-1.2.4..8a-gm-1.5/pgi/bin/mpif77' )
649 breaksw
650 case SP3:
651 # originally from A. Biastoch, SIO.
652 # e.g. horizon.npaci.edu
653 echo "Configuring for IBM SP POWER3"
654 set SOURCEDIRS = ( ./ $SOURCEDIRS )
655 set LN = ( 'ln -s' )
656 set DEFINES = ( ${DEFINES} '-DTARGET_PWR3 -DTARGET_SGI -DWORDLENGTH=4' )
657 set INCLUDES = ( '-I/usr/lpp/ppe.poe/include' )
658 # set CPP = ( '/lib/cpp' )
659 set FC = ( 'mpxlf95' )
660 set LINK = ( 'mpxlf95' )
661 set FLAGS = ( '-O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \
662 '-bmaxdata:0x80000000 -bloadmap:mitgcmuv.map' )
663 set FFLAGS = ( '-qfixed=132 -O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \
664 '-bmaxdata:0x80000000 ' )
665 set LDFLAGS = ( '-O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \
666 '-bmaxdata:0x80000000' )
667 set LIBS = ( ' -L/usr/local/apps/mass -lmass' )
668 # set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4' )
669 # set FOPTIM = ( '-O3' )
670 # set NOOPTFLAGS = ( '-O0' )
671 # set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
672 # 'external_fields_load.F' )
673 set RMFILES = ( 'rii_files' )
674 breaksw
675 case SP4:
676 #ph: e.g. bluesky.ucar.edu, marcellus.navo.hpc.mil
677 echo "Configuring for IBM SP POWER4"
678 set SOURCEDIRS = ( ./ $SOURCEDIRS )
679 set LN = ( 'ln -s' )
680 set DEFINES = ( ${DEFINES} '-DTARGET_PWR3 -DTARGET_SGI -DWORDLENGTH=4' )
681 set INCLUDES = ( '-I/usr/lpp/ppe.poe/include' )
682 # set CPP = ( '/lib/cpp' )
683 set FC = ( 'mpxlf95' )
684 set LINK = ( 'mpxlf95' )
685 set FLAGS = ( '-O3 -qarch=pwr4 -qtune=pwr4 -qcache=auto -qmaxmem=-1' \
686 '-bmaxdata:0x80000000 -bloadmap:mitgcmuv.map' )
687 set FFLAGS = ( '-qfixed=132 -O3 -qarch=pwr4 -qtune=pwr4 -qcache=auto -qmaxmem=-1' \
688 '-bmaxdata:0x80000000 ' )
689 set LDFLAGS = ( '-O3 -qarch=pwr4 -qtune=pwr4 -qcache=auto -qmaxmem=-1' \
690 '-bmaxdata:0x80000000' )
691 set LIBS = ( ' -L/usr/local/apps/mass -lmass' )
692 # set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4' )
693 # set FOPTIM = ( '-O3' )
694 # set NOOPTFLAGS = ( '-O0' )
695 # set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
696 # 'external_fields_load.F' )
697 set RMFILES = ( 'rii_files' )
698 breaksw
699 default:
700 echo "Error: platform not recognized: uname -p = " $platform$USEMPI
701 exit
702 breaksw
703 endsw
704
705 ###############################################################################
706 ## ##
707 ## Everything below here should not need to be changed. Platform specific ##
708 ## changes and code specific changes should be configured above this line. ##
709 ## ##
710 ###############################################################################
711
712 # Convert lists of directories into command-line options
713 foreach inc ($INCLUDEDIRS)
714 set INCLUDES = ($INCLUDES -I$inc)
715 end
716
717 # Search for source code
718 rm -rf .links.tmp;mkdir .links.tmp
719 echo "# This section creates symbolic links" > srclinks.tmp
720 echo "" >> srclinks.tmp
721 echo -n 'SRCFILES = ' > srclist.inc
722 echo -n 'CSRCFILES = ' > csrclist.inc
723 echo -n 'HEADERFILES = ' > hlist.inc
724 foreach dr ($SOURCEDIRS $INCLUDEDIRS .)
725 set deplist=( )
726 foreach srcfile (`cd $dr; ls *.[hcF]`)
727 if (! -r .links.tmp/$srcfile) then
728 if (-f $dr/$srcfile) then
729 switch ($srcfile:e)
730 case F:
731 touch .links.tmp/$srcfile
732 set deplist=($deplist $srcfile)
733 echo ' \' >> srclist.inc
734 echo -n " " $srcfile >> srclist.inc
735 breaksw
736 case c:
737 touch .links.tmp/$srcfile
738 set deplist=($deplist $srcfile)
739 echo ' \' >> csrclist.inc
740 echo -n " " $srcfile >> csrclist.inc
741 breaksw
742 case h:
743 touch .links.tmp/$srcfile
744 set deplist=($deplist $srcfile)
745 echo ' \' >> hlist.inc
746 echo -n " " $srcfile >> hlist.inc
747 breaksw
748 endsw
749 endif
750 endif
751 end
752 if ($#deplist != 0) then
753 echo "# These files are linked from $dr" >> srclinks.tmp
754 echo $deplist':' >> srclinks.tmp
755 echo ' $(LN) '$dr'/$@ $@' >> srclinks.tmp
756 endif
757 end
758 rm -rf .links.tmp
759 echo "" >> srclist.inc
760 echo "" >> csrclist.inc
761 echo "" >> hlist.inc
762
763 set THISHOSTNAME = ( `hostname` )
764 set THISCWD = ( `pwd` )
765 set THISDATE = ( `date` )
766
767 if (-r $mfile) mv -f $mfile $mfile.bak
768 ###########################################
769 ## This is the template for the makefile ##
770 ###########################################
771 echo Creating makefile: $mfile
772 echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile}
773 echo "# This makefile was generated automatically on" >> ${mfile}
774 echo "# $THISDATE" >> ${mfile}
775 echo "# by the command:" >> ${mfile}
776 echo "# ${0} $argv" >> ${mfile}
777 echo "# executed by:" >> ${mfile}
778 echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> ${mfile}
779 cat >> ${mfile} <<EOF
780 #
781 # BUILDDIR : Directory where object files are written
782 # SOURCEDIRS : Directories containing the source (.F) files
783 # INCLUDEDIRS : Directories containing the header-source (.h) files
784 # EXEDIR : Directory where executable that is generated is written
785 # EXECUTABLE : Full path of executable binary
786 #
787 # CPP : C-preprocessor command
788 # INCLUDES : Directories searched for header files
789 # DEFINES : Macro definitions for CPP
790 # MAKEDEPEND : Dependency generator
791 # KPP : Special preprocessor command (specific to platform)
792 # KFLAGS : Flags for KPP
793 # FC : Fortran compiler command
794 # FFLAGS : Configuration/debugging options for FC
795 # FOPTIM : Optimization options for FC
796 # LINK : Command for link editor program
797 # LIBS : Library flags /or/ additional optimization/debugging flags
798
799 ROOTDIR = ${ROOTDIR}
800 BUILDDIR = ${BUILDDIR}
801 SOURCEDIRS = ${SOURCEDIRS}
802 INCLUDEDIRS = ${INCLUDEDIRS}
803 EXEDIR = ${EXEDIR}
804 EXECUTABLE = \$(EXEDIR)/${EXECUTABLE}
805 TOOLSDIR = ${TOOLSDIR}
806
807 EOF
808
809
810 # JAM libraries on Hyades
811 if ($?include_jam_libs) then
812 cat >> ${mfile} <<EOF
813 # extra stuff for Hyades ............................................
814 HYADES_DIR = /u/u0/cnh/jam-lib/software
815 HYADES_DIR = /u/u0/cnh/jam-lib-twoproc
816 HYADES_DIR = /usr/local/jamlib/current/dual_proc
817 WORK_DIR = \$(HYADES_DIR)
818 DEPOSIT_DIR = linux_bin
819
820 STARTXOBJDIR = startx_util/\$(DEPOSIT_DIR)
821 STARTXOBJ = \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/startx_timer.o \
822 \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/startx_util.o \
823 \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/client.o \
824 \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/csutil.o
825
826 JAMOBJDIR = jam/\$(DEPOSIT_DIR)
827 JAMOBJ = \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_init.o \
828 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_kernel.o \
829 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_malloc.o \
830 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_vmalloc.o \
831 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_mutex.o
832
833 JAMCOBJDIR = jam_collective/\$(DEPOSIT_DIR)
834 JAMCOBJ = \$(WORK_DIR)/jam_collective/\$(DEPOSIT_DIR)/jam_collective.o
835
836 XLIBS = \$(STARTXOBJ) \$(JAMOBJ) \$(JAMCOBJ)
837
838 # ..................................................................
839
840 EOF
841 endif
842
843
844 cat >> ${mfile} <<EOF
845 # Unix ln (link)
846 LN = ${LN}
847 # C preprocessor
848 CPP = cat \$< | ${S64} | ${CPP}
849 # Dependency generator
850 MAKEDEPEND = ${MAKEDEPEND}
851 # Special preprocessor (KAP on DECs, FPP on Crays)
852 KPP = ${KPP}
853 # Fortran compiler
854 FC = ${FC}
855 # Link editor
856 LINK = ${LINK}
857
858 # Defines for CPP
859 DEFINES = ${DEFINES}
860 # Includes for CPP
861 INCLUDES = ${INCLUDES}
862 # Flags for KPP
863 KFLAGS1 = ${KFLAGS1}
864 KFLAGS2 = ${KFLAGS2}
865 # Optim./debug for FC
866 FFLAGS = ${FFLAGS}
867 FOPTIM = ${FOPTIM}
868 # Flags for CC
869 CFLAGS = ${CFLAGS}
870 # Files that should not be optimized
871 NOOPTFILES = ${NOOPTFILES}
872 NOOPTFLAGS = ${NOOPTFLAGS}
873 # Flags and libraries needed for linking
874 LIBS = ${LIBS} \$(XLIBS)
875
876 EOF
877
878 cat srclist.inc >> ${mfile}
879 cat csrclist.inc >> ${mfile}
880 cat hlist.inc >> ${mfile}
881 echo 'F77FILES = $(SRCFILES:.F=.f)' >> ${mfile}
882 echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o)' >> ${mfile}
883
884 rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp
885
886 cat >> ${mfile} <<EOF
887
888 .SUFFIXES:
889 .SUFFIXES: .o .f .p .F .c
890
891 all: \$(EXECUTABLE)
892 \$(EXECUTABLE): \$(OBJFILES)
893 \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
894 depend:
895 @make links
896 \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
897
898 links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES)
899
900 small_f: \$(F77FILES)
901
902 output.txt: \$(EXECUTABLE)
903 @printf 'running ... '
904 @\$(EXECUTABLE) > \$@
905
906 clean:
907 -rm -rf *.o *.f *.p ${RMFILES} work.{pc,pcl}
908 Clean:
909 @make clean
910 @make cleanlinks
911 -rm -f Makefile.bak
912 CLEAN:
913 @make Clean
914 -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
915 -find \$(EXEDIR) -name "*.data" -exec rm {} \;
916 -rm -f \$(EXECUTABLE)
917
918 makefile:
919 ${0} $argv
920 cleanlinks:
921 -find . -type l -exec rm {} \;
922
923 # The normal chain of rules is ( .F - .f - .o )
924 .F.f:
925 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
926 .f.o:
927 \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
928 .c.o:
929 \$(CC) \$(CFLAGS) -c \$<
930
931 # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain
932 .F.p:
933 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
934 .p.f:
935 \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
936 EOF
937
938 # Make list of "exceptions" that need ".p" files
939 foreach sf ($KPPFILES)
940 set fname=( ${sf:t} )
941 echo "${fname:r}.f: ${fname:r}.p" >> ${mfile}
942 end
943 foreach sf ($NOOPTFILES)
944 set fname=( ${sf:t} )
945 echo "${fname:r}.o: ${fname:r}.f" >> ${mfile}
946 echo ' $(FC) $(FFLAGS) $(NOOPTFLAGS) -c $<' >> ${mfile}
947 end
948 echo "" >> ${mfile}
949
950 # Add rules for links
951 cat srclinks.tmp >> ${mfile}
952 rm -f srclinks.tmp
953
954 echo "" >> ${mfile}
955 echo "# DO NOT DELETE" >> ${mfile}
956
957 exit

  ViewVC Help
Powered by ViewVC 1.1.22