/[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.63 - (show annotations) (download)
Wed Aug 7 19:27:27 2002 UTC (21 years, 8 months ago) by adcroft
Branch: MAIN
Changes since 1.62: +80 -13 lines
o added new option -cpp=... which defines a CPP macro on the cpp command line
o added -fc=...  which specifies the $FC variable
o made the platform target "Linux*" now searches for ifc, g77, pgf77, f77 etc
  in the $PATH and select the appropriate options. This should be done for
  all platforms but I can't remember my passwords on anything except Linux
  boxes....

1 #!/bin/csh -f
2 #
3 # $Header: /u/gcmpack/models/MITgcmUV/tools/genmake,v 1.62 2002/03/04 17:26:41 adcroft 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 )
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 | 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 default:
296 breaksw
297 endsw
298 endif
299 end
300 if (! $?STANDARDDIRS) set STANDARDDIRS=(eesupp model)
301 foreach dr ($STANDARDDIRS)
302 set adr=$ROOTDIR/$dr/src
303 if (! -d $adr) then
304 echo Source directory $adr not found.; exit 1
305 endif
306 echo Adding src dir: $adr
307 set SOURCEDIRS = ($SOURCEDIRS $adr)
308 set idr = `echo $adr | sed 's/src/inc/'`
309 set INCLUDEDIRS = ($INCLUDEDIRS $idr)
310 end
311
312 # Find possible compilers
313 if ($?FC) then
314 echo "$FC was specified as the compiler"
315 else
316 echo " "
317 set likelysuspects=(ifc g77 pgf77 f77 f90 f95)
318 foreach fc ($likelysuspects)
319 set foundfc=`which $fc |& cat - `
320 if (-x $foundfc[1]) then
321 if ($?possiblefc) then
322 set possiblefc=($possiblefc $fc)
323 else
324 set possiblefc=$fc
325 endif
326 endif
327 end
328 if ($?possiblefc) then
329 set FC=$possiblefc[1]
330 echo Found these compilers: $possiblefc. Using \"$FC\" as the compiler
331 else
332 echo "No compiler found\!"
333 echo I tried looking for \"$likelysuspects\" in your \$PATH but found none
334 exit 13
335 endif
336 endif
337
338 # This is the generic configuration.
339 # Platform specific options are chosen below
340 set LN = ( 'ln -s' )
341 set CPP = ( '/lib/cpp -P' )
342 set S64 = ( '$(TOOLSDIR)/set64bitConst.sh' )
343 set KPP = ( )
344 #set FC = ( 'f77' )
345 set LINK = $FC
346 set MAKEDEPEND = ( 'makedepend' )
347 set INCLUDES = ( -I. )
348 set FFLAGS = ( )
349 set FOPTIM = ( )
350 set CFLAGS = ( )
351 set KFLAGS1 = ( )
352 set KFLAGS2 = ( )
353 set LIBS = ( )
354 set KPPFILES = ( )
355 set NOOPTFILES = ( )
356 set NOOPTFLAGS = ( )
357 set RMFILES = ( )
358
359 # We often want to use different compile/link options is using MPI
360 if ($?USEMPI) then
361 set USEMPI = ( '+mpi' )
362 set DEFINES = ( ${DEFINES} '-DALLOW_USE_MPI -DALWAYS_USE_MPI' )
363 else
364 set USEMPI
365 # set DEFINES = ( ${DEFINES} '-UALLOW_USE_MPI -UALWAYS_USE_MPI' )
366 endif
367
368 # Platform specific options
369 switch ($platform$USEMPI)
370 case OSF1+mpi:
371 echo "Configuring for DEC Alpha with MPI"
372 set LIBS = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' )
373 case OSF1:
374 echo "Configuring for DEC Alpha"
375 set CPP = ( '/usr/bin/cpp -P' )
376 set DEFINES = ( ${DEFINES} '-DTARGET_DEC -DWORDLENGTH=1' )
377 set KPP = ( )
378 set KPPFILES = ( )
379 set KFLAGS1 = ( )
380 set FC = ( 'f77' )
381 set FFLAGS = ( '-convert big_endian -r8 -extend_source -automatic -call_shared -notransform_loops -align dcommons' )
382 set FOPTIM = ( '-O5 -fast -tune host -inline all' )
383 set NOOPTFLAGS = ( '-O0' )
384 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')
385 set RMFILES = ( '*.p.out' )
386 breaksw
387 case IRIX64+mpi:
388 echo "Configuring for SGI Mips with MPI"
389 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
390 set INCLUDES = ( '-I/usr/local/mpi/include' )
391 set FC = ( 'mpif77' )
392 set LINK = ( 'mpif77' )
393 set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' )
394 set FOPTIM = ( '-O3' )
395 set RMFILES = ( 'rii_files' )
396 breaksw
397 case IRIX64:
398 echo "Configuring for SGI Mips"
399 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
400 set INCLUDES = ( '-I/usr/local/mpi/include' )
401 set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4 -r8 -static' )
402 set FOPTIM = ( '-O3' )
403 # set NOOPTFLAGS = ( '-O0' )
404 # set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
405 # 'external_fields_load.F' )
406 set RMFILES = ( 'rii_files' )
407 breaksw
408 case o2:
409 case IRIX:
410 echo "Configuring for SGI O2 running IRIX 6.5"
411 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
412 set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' )
413 set FOPTIM = ( '-O2' )
414 set NOOPTFLAGS = ( '-O0' )
415 breaksw
416 case o2+mpi:
417 case IRIX+mpi:
418 echo "Configuring for SGI O2 running IRIX 6.5 with MPI"
419 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
420 set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' )
421 set FOPTIM = ( '-O2' )
422 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F' )
423 set NOOPTFLAGS = ( '-O0' )
424 set LIBS = ( '-lmpi' )
425 breaksw
426 case o2k+mpi:
427 echo "Configuring for SGI Origin2000 running IRIX 6.5"
428 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
429 set INCLUDES = ( '-I/usr/include' )
430 set FFLAGS = ( '-n32 -extend_source -bytereclen' )
431 set FOPTIM = ( '-O2' )
432 set NOOPTFILES = ( 'calc_mom_rhs.F' )
433 set NOOPTFLAGS = ( '-O1' )
434 set LIBS = ( '-lmpi -lscs' )
435 breaksw
436 case onyx:
437 case onyx+mpi:
438 echo "Configuring for SGI ONYX running IRIX64"
439 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
440 set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' )
441 set FOPTIM = ( '-O2' )
442 set NOOPTFLAGS = ( '-O0' )
443 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F' )
444 set LIBS = ( '-lmpi' )
445 breaksw
446 case SunOS:
447 set LN = ( '/usr/bin/ln -s' )
448 set CPP = ( '/usr/ccs/lib/cpp -P' )
449 set MAKEDEPEND = ( ${TOOLSDIR}/xmakedepend )
450 set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4 -D_d=E' )
451 set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar -xtypemap=real:64,double:64,integer:32 -fsimple=0' )
452 set FOPTIM = ( '-dalign -O3 -xarch=v9' )
453 set CFLAGS = ( '-dalign -O3 -xarch=v9' )
454 set NOOPTFLAGS = ( '-dalign -O0 -xarch=v9' )
455 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 ')
456 breaksw
457 case SunOS+mpi:
458 set LN = ( '/usr/bin/ln -s' )
459 set CPP = ( '/usr/ccs/lib/cpp -P' )
460 set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4 -D_d=E' )
461 set INCLUDES = ( '-I/usr/local/mpi/include' )
462 set LIBS = ( '-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread' \
463 set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar -xtypemap=real:64,double:64,integer:32 -fsimple=0' )
464 set FOPTIM = ( '-dalign -O3 -xarch=v9' )
465 set NOOPTFLAGS = ( '-dalign -O0 -xarch=v9' )
466 '-lsocket -lnsl' )
467 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')
468 breaksw
469 case IRIX32:
470 echo "Configuring for SGI ONYX running IRIX64"
471 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
472 set INCLUDES = ( '-I/usr/include' )
473 set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' )
474 set FOPTIM = ( '-O2' )
475 set NOOPTFLAGS = ( '-O0' )
476 set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
477 'external_fields_load.F' )
478 set LIBS = ( '-lmpi' )
479 breaksw
480 case HP-UX+mpi:
481 set FC = ( 'mpif77' )
482 set LINK = ( 'mpif77' )
483 set INCLUDES = ( '-I/opt/mpi/include' )
484 case HP-UX:
485 echo "Configuring for HP Exemplar"
486 set CPP = ( '/usr/ccs/lbin/cpp -P' )
487 set DEFINES = ( ${DEFINES} '-DTARGET_HP -DWORDLENGTH=4' )
488 set FFLAGS = ( '+es +U77 +Onoautopar +Oexemplar_model' \
489 '+Okernel_threads' )
490 set FOPTIM = ( '+O2' )
491 set NOOPTFLAGS = ( '+O0' )
492 set NOOPTFILES = ( 'barrier.F different_multiple.F' \
493 'external_fields_load.F' )
494 breaksw
495 case Linux-alpha+mpi:
496 echo "Configuring with MPI"
497 set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
498 set INCLUDES = ( '-I/usr/local/include' )
499 case Linux-alpha:
500 echo "Configuring for " $platform
501 set LN = ( '/bin/ln -s' )
502 set CPP = ( '/lib/cpp -traditional -P' )
503 set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' )
504 set FC = ( 'g77' )
505 set FFLAGS = ( ' ' )
506 if ($?IEEE) set FFLAGS = ( $FFLAGS '-ffloat-store' )
507 set FOPTIM = ( '-ffast-math -fexpensive-optimizations -fomit-frame-pointer -O3' )
508 set LINK = ( 'g77' )
509 breaksw
510 case Linux*+pgi+mpi:
511 if ($?include_jam_libs) then
512 set INCLUDES = ( '-I/usr/local/mpich-1.2.1/pgi_fortran_binding/include' )
513 set LIBS = ( '-L/usr/local/mpich-1.2.1/pgi_fortran_binding/lib/ -lfmpich -lmpich' )
514 else
515 set INCLUDES = ( '-I/usr/local/include' )
516 set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
517 endif
518 case Linux*+pgi:
519 echo "Configuring for " $platform
520 set LN = ( '/bin/ln -s' )
521 set CPP = ( '/lib/cpp -traditional -P' )
522 set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' )
523 set FC = ( 'pgf77' )
524 set FFLAGS = ( '-byteswapio -r8 -Mnodclchk -Mextend' )
525 set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
526 set LINK = ( 'pgf77' )
527 breaksw
528 case Linux*+mpi:
529 set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
530 set INCLUDES = ( '-I/usr/local/include' )
531 case Linux*:
532 echo "Configuring for " $platform
533 set LN = ( '/bin/ln -s' )
534 set CPP = ( '/lib/cpp -traditional -P' )
535 switch ($FC)
536 case g77:
537 set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' )
538 set FFLAGS = ( '-Wimplicit -Wunused -Wuninitialized' )
539 if ($?IEEE) set FFLAGS = ( $FFLAGS '-ffloat-store' )
540 set FOPTIM = ( '-O3 -malign-double -funroll-loops' )
541 breaksw
542 case pgf77:
543 set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' )
544 set FC = ( 'pgf77' )
545 set FFLAGS = ( '-byteswapio -r8 -Mnodclchk -Mextend' )
546 set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
547 breaksw
548 case ifc:
549 set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' )
550 set FFLAGS = ( '-132 -r8 -i4 -w95 -W0 -WB' )
551 if ($?IEEE) set FFLAGS = ( $FFLAGS '-mp' )
552 set FOPTIM = ( '-O3 -align' )
553 #P3 set FOPTIM = ( $FOPTIM '-tpp6 -xWKM' )
554 #P4 set FOPTIM = ( $FOPTIM '-tpp7 -xWKM' )
555 set LIBS = ( '-lPEPCF90' )
556 breaksw
557 default:
558 echo Error: Linux compiler not recognized: \$FC=$FC
559 exit
560 breaksw
561 endsw
562 breaksw
563 case T3E:
564 case sn6312:
565 echo "Configuring for T3E"
566 set CPP = ( '/opt/ctl/bin/cpp -P')
567 set DEFINES = ( ${DEFINES} '-DTARGET_T3E -DWORDLENGTH=4' )
568 set FC = ( 'f90' )
569 set LINK = ( 'f90' )
570 set FFLAGS = ( '-O 2,fusion' )
571 breaksw
572 case T90:
573 case sn7113:
574 echo "Configuring for T90"
575 set FC = ( 'f90' )
576 set LINK = ( 'f90' )
577 set LN = ( '/bin/ln -s' )
578 set CPP = ( '/opt/ctl/bin/cpp -N -P' )
579 set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' )
580 set FFLAGS = ( '-m3 -Rabc -N 132')
581 set FOPTIM = ( '-O0' )
582 set NOOPTFLAGS = ( '-O0' )
583 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')
584 breaksw
585 case SV1:
586 case sn3002:
587 set FC = ( 'f90' )
588 set LINK = ( 'f90' )
589 set LN = ( '/bin/ln -s' )
590 set CPP = ( '/opt/ctl/bin/cpp -N -P' )
591 set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' )
592 set FFLAGS = ( '-m3 -Rabc -ei -eI -s cf77types -N 132')
593 set FOPTIM = ( '-O0' )
594 set NOOPTFLAGS = ( '-O0' )
595 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')
596 breaksw
597 case SP3:
598 # originally from A. Biastoch, SIO.
599 echo "Configuring for IBM SP POWER3"
600 set SOURCEDIRS = ( ./ $SOURCEDIRS )
601 set LN = ( 'ln -s' )
602 set DEFINES = ( ${DEFINES} '-DTARGET_PWR3 -DTARGET_SGI -DWORDLENGTH=4' )
603 set INCLUDES = ( '-I/usr/lpp/ppe.poe/include' )
604 # set CPP = ( '/lib/cpp' )
605 set FC = ( 'mpxlf95' )
606 set LINK = ( 'mpxlf95' )
607 set FLAGS = ( '-O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \
608 '-bmaxdata:0x80000000 -bloadmap:mitgcmuv.map' )
609 set FFLAGS = ( '-qfixed=132 -O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \
610 '-bmaxdata:0x80000000 ' )
611 set LDFLAGS = ( '-O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \
612 '-bmaxdata:0x80000000' )
613 set LIBS = ( ' -L/usr/local/apps/mass -lmass' )
614 # set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4' )
615 # set FOPTIM = ( '-O3' )
616 # set NOOPTFLAGS = ( '-O0' )
617 # set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
618 # 'external_fields_load.F' )
619 set RMFILES = ( 'rii_files' )
620 breaksw
621 default:
622 echo "Error: platform not recognized: uname -p = " $platform$USEMPI
623 exit
624 breaksw
625 endsw
626
627 ###############################################################################
628 ## ##
629 ## Everything below here should not need to be changed. Platform specific ##
630 ## changes and code specific changes should be configured above this line. ##
631 ## ##
632 ###############################################################################
633
634 # Convert lists of directories into command-line options
635 foreach inc ($INCLUDEDIRS)
636 set INCLUDES = ($INCLUDES -I$inc)
637 end
638
639 # Search for source code
640 rm -rf .links.tmp;mkdir .links.tmp
641 echo "# This section creates symbolic links" > srclinks.tmp
642 echo "" >> srclinks.tmp
643 echo -n 'SRCFILES = ' > srclist.inc
644 echo -n 'CSRCFILES = ' > csrclist.inc
645 echo -n 'HEADERFILES = ' > hlist.inc
646 foreach dr ($SOURCEDIRS $INCLUDEDIRS .)
647 set deplist=( )
648 foreach srcfile (`cd $dr; ls *.[hcF]`)
649 if (! -r .links.tmp/$srcfile) then
650 if (-f $dr/$srcfile) then
651 switch ($srcfile:e)
652 case F:
653 touch .links.tmp/$srcfile
654 set deplist=($deplist $srcfile)
655 echo ' \' >> srclist.inc
656 echo -n " " $srcfile >> srclist.inc
657 breaksw
658 case c:
659 touch .links.tmp/$srcfile
660 set deplist=($deplist $srcfile)
661 echo ' \' >> csrclist.inc
662 echo -n " " $srcfile >> csrclist.inc
663 breaksw
664 case h:
665 touch .links.tmp/$srcfile
666 set deplist=($deplist $srcfile)
667 echo ' \' >> hlist.inc
668 echo -n " " $srcfile >> hlist.inc
669 breaksw
670 endsw
671 endif
672 endif
673 end
674 if ($#deplist != 0) then
675 echo "# These files are linked from $dr" >> srclinks.tmp
676 echo $deplist':' >> srclinks.tmp
677 echo ' $(LN) '$dr'/$@ $@' >> srclinks.tmp
678 endif
679 end
680 rm -rf .links.tmp
681 echo "" >> srclist.inc
682 echo "" >> csrclist.inc
683 echo "" >> hlist.inc
684
685 set THISHOSTNAME = ( `hostname` )
686 set THISCWD = ( `pwd` )
687 set THISDATE = ( `date` )
688
689 if (-r $mfile) mv -f $mfile $mfile.bak
690 ###########################################
691 ## This is the template for the makefile ##
692 ###########################################
693 echo Creating makefile: $mfile
694 echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile}
695 echo "# This makefile was generated automatically on" >> ${mfile}
696 echo "# $THISDATE" >> ${mfile}
697 echo "# by the command:" >> ${mfile}
698 echo "# ${0} $argv" >> ${mfile}
699 echo "# executed by:" >> ${mfile}
700 echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> ${mfile}
701 cat >> ${mfile} <<EOF
702 #
703 # BUILDDIR : Directory where object files are written
704 # SOURCEDIRS : Directories containing the source (.F) files
705 # INCLUDEDIRS : Directories containing the header-source (.h) files
706 # EXEDIR : Directory where executable that is generated is written
707 # EXECUTABLE : Full path of executable binary
708 #
709 # CPP : C-preprocessor command
710 # INCLUDES : Directories searched for header files
711 # DEFINES : Macro definitions for CPP
712 # MAKEDEPEND : Dependency generator
713 # KPP : Special preprocessor command (specific to platform)
714 # KFLAGS : Flags for KPP
715 # FC : Fortran compiler command
716 # FFLAGS : Configuration/debugging options for FC
717 # FOPTIM : Optimization options for FC
718 # LINK : Command for link editor program
719 # LIBS : Library flags /or/ additional optimization/debugging flags
720
721 ROOTDIR = ${ROOTDIR}
722 BUILDDIR = ${BUILDDIR}
723 SOURCEDIRS = ${SOURCEDIRS}
724 INCLUDEDIRS = ${INCLUDEDIRS}
725 EXEDIR = ${EXEDIR}
726 EXECUTABLE = \$(EXEDIR)/${EXECUTABLE}
727 TOOLSDIR = ${TOOLSDIR}
728
729 EOF
730
731
732 # JAM libraries on Hyades
733 if ($?include_jam_libs) then
734 cat >> ${mfile} <<EOF
735 # extra stuff for Hyades ............................................
736 HYADES_DIR = /u/u0/cnh/jam-lib/software
737 HYADES_DIR = /u/u0/cnh/jam-lib-twoproc
738 HYADES_DIR = /usr/local/jamlib/current/dual_proc
739 WORK_DIR = \$(HYADES_DIR)
740 DEPOSIT_DIR = linux_bin
741
742 STARTXOBJDIR = startx_util/\$(DEPOSIT_DIR)
743 STARTXOBJ = \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/startx_timer.o \
744 \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/startx_util.o \
745 \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/client.o \
746 \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/csutil.o
747
748 JAMOBJDIR = jam/\$(DEPOSIT_DIR)
749 JAMOBJ = \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_init.o \
750 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_kernel.o \
751 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_malloc.o \
752 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_vmalloc.o \
753 \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_mutex.o
754
755 JAMCOBJDIR = jam_collective/\$(DEPOSIT_DIR)
756 JAMCOBJ = \$(WORK_DIR)/jam_collective/\$(DEPOSIT_DIR)/jam_collective.o
757
758 XLIBS = \$(STARTXOBJ) \$(JAMOBJ) \$(JAMCOBJ)
759
760 # ..................................................................
761
762 EOF
763 endif
764
765
766 cat >> ${mfile} <<EOF
767 # Unix ln (link)
768 LN = ${LN}
769 # C preprocessor
770 CPP = cat \$< | ${S64} | ${CPP}
771 # Dependency generator
772 MAKEDEPEND = ${MAKEDEPEND}
773 # Special preprocessor (KAP on DECs, FPP on Crays)
774 KPP = ${KPP}
775 # Fortran compiler
776 FC = ${FC}
777 # Link editor
778 LINK = ${LINK}
779
780 # Defines for CPP
781 DEFINES = ${DEFINES}
782 # Includes for CPP
783 INCLUDES = ${INCLUDES}
784 # Flags for KPP
785 KFLAGS1 = ${KFLAGS1}
786 KFLAGS2 = ${KFLAGS2}
787 # Optim./debug for FC
788 FFLAGS = ${FFLAGS}
789 FOPTIM = ${FOPTIM}
790 # Flags for CC
791 CFLAGS = ${CFLAGS}
792 # Files that should not be optimized
793 NOOPTFILES = ${NOOPTFILES}
794 NOOPTFLAGS = ${NOOPTFLAGS}
795 # Flags and libraries needed for linking
796 LIBS = ${LIBS} \$(XLIBS)
797
798 EOF
799
800 cat srclist.inc >> ${mfile}
801 cat csrclist.inc >> ${mfile}
802 cat hlist.inc >> ${mfile}
803 echo 'F77FILES = $(SRCFILES:.F=.f)' >> ${mfile}
804 echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o)' >> ${mfile}
805
806 rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp
807
808 cat >> ${mfile} <<EOF
809
810 .SUFFIXES:
811 .SUFFIXES: .o .f .p .F .c
812
813 all: \$(EXECUTABLE)
814 \$(EXECUTABLE): \$(OBJFILES)
815 \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
816 depend:
817 @make links
818 \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
819
820 links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES)
821
822 small_f: \$(F77FILES)
823
824 output.txt: \$(EXECUTABLE)
825 @printf 'running ... '
826 @\$(EXECUTABLE) > \$@
827
828 clean:
829 -rm -rf *.o *.f *.p ${RMFILES} work.{pc,pcl}
830 Clean:
831 @make clean
832 @make cleanlinks
833 -rm -f Makefile.bak
834 CLEAN:
835 @make Clean
836 -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
837 -find \$(EXEDIR) -name "*.data" -exec rm {} \;
838 -rm -f \$(EXECUTABLE)
839
840 makefile:
841 ${0} $argv
842 cleanlinks:
843 -find . -type l -exec rm {} \;
844
845 # The normal chain of rules is ( .F - .f - .o )
846 .F.f:
847 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
848 .f.o:
849 \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
850 .c.o:
851 \$(CC) \$(CFLAGS) -c \$<
852
853 # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain
854 .F.p:
855 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
856 .p.f:
857 \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
858 EOF
859
860 # Make list of "exceptions" that need ".p" files
861 foreach sf ($KPPFILES)
862 set fname=( ${sf:t} )
863 echo "${fname:r}.f: ${fname:r}.p" >> ${mfile}
864 end
865 foreach sf ($NOOPTFILES)
866 set fname=( ${sf:t} )
867 echo "${fname:r}.o: ${fname:r}.f" >> ${mfile}
868 echo ' $(FC) $(FFLAGS) $(NOOPTFLAGS) -c $<' >> ${mfile}
869 end
870 echo "" >> ${mfile}
871
872 # Add rules for links
873 cat srclinks.tmp >> ${mfile}
874 rm -f srclinks.tmp
875
876 echo "" >> ${mfile}
877 echo "# DO NOT DELETE" >> ${mfile}
878
879 exit

  ViewVC Help
Powered by ViewVC 1.1.22