/[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.65 - (show annotations) (download)
Wed Aug 7 19:57:48 2002 UTC (21 years, 8 months ago) by adcroft
Branch: MAIN
Changes since 1.64: +4 -2 lines
Damn, I hate SUNs.

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

  ViewVC Help
Powered by ViewVC 1.1.22