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

Annotation of /MITgcm/tools/genmake

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


Revision 1.64 - (hide annotations) (download)
Wed Aug 7 19:48:44 2002 UTC (21 years, 8 months ago) by adcroft
Branch: MAIN
Changes since 1.63: +9 -2 lines
Well, who'd have guessed that SUN ship g77 by default! I'm restricting
the automatic search of compilers to Linux platforms until we do
a general tidy up of genmake.

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

  ViewVC Help
Powered by ViewVC 1.1.22