/[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.69 - (hide annotations) (download)
Tue Nov 12 20:45:41 2002 UTC (21 years, 4 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint46n_post, checkpoint47
Changes since 1.68: +2 -2 lines
Merging from release1_p8 branch:
Adding package parameters and hooks for new seaice package.

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

  ViewVC Help
Powered by ViewVC 1.1.22