/[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.56.4.4 - (hide annotations) (download)
Thu Apr 4 11:12:40 2002 UTC (22 years ago) by heimbach
Branch: ecco-branch
CVS Tags: ecco_c44_e23, ecco_c44_e26, ecco_c44_e24, ecco_c44_e25, icebear3, icebear2, ecco_ice2, ecco_ice1, ecco_c44_e22
Branch point for: c24_e25_ice
Changes since 1.56.4.3: +17 -10 lines
genmake with MAKEDEPEND variable was still missing in ecco-branch

1 cnh 1.1 #!/bin/csh -f
2     #
3 heimbach 1.56.4.4 # $Header: /u/gcmpack/MITgcm/tools/genmake,v 1.62 2002/03/04 17:26:41 adcroft Exp $
4 adcroft 1.48 # $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.56.4.1 set DISABLE = ( aim autodiff cal cost ctrl ecco exf grdchk flt )
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.40 case -ieee:
82     set IEEE
83     breaksw
84 adcroft 1.23 case -enable=*:
85 adcroft 1.24 set ENABLE = ( $ENABLE `echo $arg | sed 's/-enable=//' | sed 's/,/ /g' `)
86 adcroft 1.23 breaksw
87 cnh 1.1 case -mpi:
88     echo "Enabling MPI options"
89     set USEMPI
90     breaksw
91 adcroft 1.12 case -jam:
92     set include_jam_libs
93     echo "Including paths to JAM libraries"
94     breaksw
95 cnh 1.1 case -help:
96 adcroft 1.35 echo "usage: $0 [-help] [-makefile[=...]] [-platform=...] [-mpi] [-jam] [-disable=pkg1[,pkg2,...]] [-enable=pkg1[,pkg2,...]] [-mods=dir1[,dir2,...]] [-rootdir=dir]"
97     cat << EOF
98    
99     $0 is used to generate the Makefile in the current directory.
100    
101     Typical invocations are:
102     o from "bin": ../tools/genmake
103     o from "verification/expt/code": ../../../tools/genmake
104     o from "verification/expt/input": ../../../tools/genmake -mods=../code
105     o from a scratch directory: ~/mitgcm/tools/genmake -rootdir=~/mitgcm
106     or ~/mitgcm/tools/genmake -rootdir=~/mitgcm -mods=~/mymods
107    
108     Packages (collected modules of code) can be disabled to avoid unnecessary
109     compilation of unused code. For instance if you know you will not
110     use GM/Redi, KPP and OBCS and they are appropriate turned-off in the
111     configuration:
112     .../tools/genmake -disable=gmredi,kpp,obcs
113    
114     If you add some source files you can re-call the previous instance of
115     genmake with "make makefile".
116    
117     genmake also reads the file .genmakerc which can be used to configure
118     options (primarily the command-line options above) for particular experiments.
119     EOF
120 cnh 1.1 exit
121     breaksw
122     default:
123     echo "Unknown command-line option: " $arg
124     echo $0 "-help to show usage"
125     exit
126     breaksw
127     endsw
128     shift allargs
129     end
130 cnh 1.6
131 adcroft 1.23 # Default actions/options
132    
133     # If platform wasn't specified then determine platform type of the host
134     if (! $?platform) then
135 cnh 1.6 set platform = (`uname`)
136 adcroft 1.55 # This let's us distinguish between different Linux platforms
137     if ($platform == Linux) then
138     set machine = (`uname -m`)
139     set platform = ($platform'-'$machine)
140     endif
141 cnh 1.6 endif
142 adcroft 1.23 # If name of makefile wasn't specified then use default "Makefile"
143     if (! $?mfile) set mfile = ( Makefile )
144    
145 cnh 1.1 set mach = ( `uname -a` )
146     echo Operating system: $mach
147    
148     # Directories for source, includes, binaries and executables
149 adcroft 1.23 #
150     # If -rootdir wasn't specified then assume script is being run from bin
151     # but if it was supplied then we should place the executable in the build dir
152     if (! $?ROOTDIR) then
153 adcroft 1.26 set pwd=`pwd`
154 adcroft 1.29 if ($pwd:t == bin & -d ../model & -d ../eesupp & -d ../pkg) then
155     set ROOTDIR = ( .. )
156 adcroft 1.26 endif
157     endif
158     # Scan for logical ROOTDIR
159     if (! $?ROOTDIR) then
160     foreach dr (. .. ../.. ../../.. ../../../.. ../../../../..)
161     if (-d $dr/model & -d $dr/eesupp & -d $dr/pkg) then
162     set ROOTDIR = $dr
163     echo ROOTDIR was not specified. Setting ROOTDIR = \"$ROOTDIR\"
164     break
165     endif
166     end
167     endif
168     if (! $?ROOTDIR) then
169     echo Root directory was not specified and could not be determined.
170     echo Specify the root location of the model source with -rootdir=dir
171     exit 1
172 adcroft 1.23 endif
173     if (! -d $ROOTDIR) then
174     echo Root directory $ROOTDIR not found.;exit 1
175     endif
176     # If -mods wasn't specified then we will assume that we can find all the
177     # source code in the standard directories
178     if (! $?MODS) then
179     set SOURCEDIRS = ( )
180 adcroft 1.42 set INCLUDEDIRS = ( )
181 adcroft 1.23 else
182     set SOURCEDIRS = ( $MODS )
183 adcroft 1.42 set INCLUDEDIRS = ( $MODS )
184 adcroft 1.23 endif
185     if (! $?BUILDDIR) set BUILDDIR = ( . )
186     if (! -d $BUILDDIR) then
187     echo Build directory $BUILDDIR not found.;exit 1
188 adcroft 1.29 endif
189     if (! $?EXEDIR) then
190     set pwd=`pwd`
191     if ($pwd:t == bin & -d ../exe & $ROOTDIR == ..) then
192     set EXEDIR = ( ../exe )
193     else
194     set EXEDIR = ( . )
195     endif
196 adcroft 1.23 endif
197     if (! -d $EXEDIR) then
198     echo Executable directory $EXEDIR not found.;exit 1
199     endif
200     if (! $?TOOLSDIR) set TOOLSDIR = ( $ROOTDIR/tools )
201     if (! -d $TOOLSDIR) then
202     echo Tools directory $TOOLSDIR not found.;exit 1
203     endif
204     if (! $?EXECUTABLE) set EXECUTABLE = ( mitgcmuv )
205    
206 adcroft 1.35 # We have a special set of source files in eesupp/src which
207     # are generated from some template source files. We'll make them
208     # first so the appear as regular source code
209     if (-r $ROOTDIR/eesupp/src/Makefile) then
210     echo Making source files in eesupp from templates...
211     (cd $ROOTDIR/eesupp/src/; make) >& make_eesupp.errs
212     if ($status == 0) then
213     rm -f make_eesupp.errs
214     else
215     cat make_eesupp.errs
216     exit 2
217     endif
218     endif
219    
220 adcroft 1.23 # Now scan the standard source code tree
221     foreach dr ($SOURCEDIRS)
222     set adr=$dr
223     if (! -d $adr) then
224     echo mods directory $adr not found.; exit 1
225     endif
226 adcroft 1.35 echo Adding mods dir: $adr
227 adcroft 1.23 end
228     if (! $?PACKAGES) then
229 adcroft 1.35 set PACKAGES=()
230     foreach pkg (`cd $ROOTDIR/pkg; find . -type d | grep -v CVS | sed 's:\./::' | grep -v "\." | sort`)
231     if (-d $ROOTDIR/pkg/$pkg) set PACKAGES=($PACKAGES $pkg)
232     end
233 adcroft 1.23 endif
234     foreach dr ($PACKAGES)
235     set enable
236     foreach p ($DISABLE)
237 adcroft 1.31 if ($p != 'all' & ! -d $ROOTDIR/pkg/$p) then
238 adcroft 1.30 echo Specified package \"$p\" does not exist.
239     exit 1
240     endif
241 adcroft 1.23 if ($dr == $p) unset enable
242     if ($p == 'all') unset enable
243 adcroft 1.35 # The following allows entire trees to be disabled
244     if ($dr:h == $p) unset enable
245     if ($dr:h:h == $p) unset enable
246     if ($dr:h:h:h == $p) unset enable
247     if ($dr:h:h:h:h == $p) unset enable
248 adcroft 1.23 end
249     foreach p ($ENABLE)
250     if ($dr == $p) set enable
251     end
252     if ($?enable) then
253     set adr=$ROOTDIR/pkg/$dr
254     if (! -d $adr) then
255     echo Source directory $adr not found.; exit 1
256     endif
257 adcroft 1.35 echo Adding pkg dir: $adr
258 adcroft 1.23 set SOURCEDIRS = ($SOURCEDIRS $adr)
259     set INCLUDEDIRS = ($INCLUDEDIRS $adr)
260     else
261 adcroft 1.35 echo " *" Package \"$dr\" NOT enabled.
262 adcroft 1.44 switch ($dr)
263     case mom_fluxform:
264     set DEFINES = ($DEFINES '-DDISABLE_MOM_FLUXFORM'); breaksw
265     case mom_vecinv:
266 adcroft 1.50 set DEFINES = ($DEFINES '-DDISABLE_MOM_VECINV'); breaksw
267 adcroft 1.54 case generic_advdiff:
268     set DEFINES = ($DEFINES '-DDISABLE_GENERIC_ADVDIFF'); breaksw
269 adcroft 1.44 default:
270     breaksw
271     endsw
272 adcroft 1.23 endif
273 adcroft 1.30 end
274 jmc 1.33 if (! $?STANDARDDIRS) set STANDARDDIRS=(eesupp model)
275 adcroft 1.30 foreach dr ($STANDARDDIRS)
276     set adr=$ROOTDIR/$dr/src
277     if (! -d $adr) then
278     echo Source directory $adr not found.; exit 1
279     endif
280 adcroft 1.35 echo Adding src dir: $adr
281 adcroft 1.30 set SOURCEDIRS = ($SOURCEDIRS $adr)
282     set idr = `echo $adr | sed 's/src/inc/'`
283     set INCLUDEDIRS = ($INCLUDEDIRS $idr)
284 adcroft 1.23 end
285 cnh 1.1
286     # This is the generic configuration.
287     # Platform specific options are chosen below
288 adcroft 1.23 set LN = ( 'ln -s' )
289 cnh 1.1 set CPP = ( '/lib/cpp -P' )
290 cnh 1.53 set S64 = ( '$(TOOLSDIR)/set64bitConst.sh' )
291 cnh 1.1 set KPP = ( )
292     set FC = ( 'f77' )
293     set LINK = ( 'f77' )
294 heimbach 1.56.4.4 set MAKEDEPEND = ( 'makedepend' )
295 adcroft 1.42 set INCLUDES = ( -I. )
296 cnh 1.1 set FFLAGS = ( )
297     set FOPTIM = ( )
298 adcroft 1.51 set CFLAGS = ( )
299 cnh 1.1 set KFLAGS1 = ( )
300     set KFLAGS2 = ( )
301     set LIBS = ( )
302     set KPPFILES = ( )
303     set NOOPTFILES = ( )
304     set NOOPTFLAGS = ( )
305     set RMFILES = ( )
306    
307     # We often want to use different compile/link options is using MPI
308     if ($?USEMPI) then
309     set USEMPI = ( '+mpi' )
310     set DEFINES = ( ${DEFINES} '-DALLOW_USE_MPI -DALWAYS_USE_MPI' )
311     else
312     set USEMPI
313     # set DEFINES = ( ${DEFINES} '-UALLOW_USE_MPI -UALWAYS_USE_MPI' )
314     endif
315    
316     # Platform specific options
317     switch ($platform$USEMPI)
318 adcroft 1.39 case OSF1+mpi:
319     echo "Configuring for DEC Alpha with MPI"
320     set LIBS = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' )
321 cnh 1.6 case OSF1:
322 cnh 1.1 echo "Configuring for DEC Alpha"
323     set CPP = ( '/usr/bin/cpp -P' )
324 adcroft 1.10 set DEFINES = ( ${DEFINES} '-DTARGET_DEC -DWORDLENGTH=1' )
325 adcroft 1.39 set KPP = ( )
326     set KPPFILES = ( )
327     set KFLAGS1 = ( )
328 cnh 1.1 set FC = ( 'f77' )
329 cnh 1.25 set FFLAGS = ( '-convert big_endian -r8 -extend_source -automatic -call_shared -notransform_loops -align dcommons' )
330 cnh 1.1 set FOPTIM = ( '-O5 -fast -tune host -inline all' )
331     set NOOPTFLAGS = ( '-O0' )
332 heimbach 1.20 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')
333 cnh 1.1 set RMFILES = ( '*.p.out' )
334     breaksw
335 cnh 1.6 case IRIX64+mpi:
336 cnh 1.1 echo "Configuring for SGI Mips with MPI"
337 adcroft 1.11 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
338 cnh 1.1 set INCLUDES = ( '-I/usr/local/mpi/include' )
339     set FC = ( 'mpif77' )
340     set LINK = ( 'mpif77' )
341 adcroft 1.11 set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' )
342 cnh 1.1 set FOPTIM = ( '-O3' )
343     set RMFILES = ( 'rii_files' )
344     breaksw
345 cnh 1.6 case IRIX64:
346 cnh 1.1 echo "Configuring for SGI Mips"
347 adcroft 1.11 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
348 cnh 1.1 set INCLUDES = ( '-I/usr/local/mpi/include' )
349 adcroft 1.35 set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4 -r8 -static' )
350 adcroft 1.11 set FOPTIM = ( '-O3' )
351     # set NOOPTFLAGS = ( '-O0' )
352     # set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
353 heimbach 1.20 # 'external_fields_load.F' )
354 cnh 1.1 set RMFILES = ( 'rii_files' )
355     breaksw
356 heimbach 1.20 case o2:
357     case IRIX:
358     echo "Configuring for SGI O2 running IRIX 6.5"
359     set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
360     set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' )
361     set FOPTIM = ( '-O2' )
362     set NOOPTFLAGS = ( '-O0' )
363     breaksw
364     case o2+mpi:
365     case IRIX+mpi:
366     echo "Configuring for SGI O2 running IRIX 6.5 with MPI"
367     set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
368     set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' )
369     set FOPTIM = ( '-O2' )
370     set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F' )
371     set NOOPTFLAGS = ( '-O0' )
372     set LIBS = ( '-lmpi' )
373     breaksw
374     case o2k+mpi:
375     echo "Configuring for SGI Origin2000 running IRIX 6.5"
376     set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
377     set INCLUDES = ( '-I/usr/include' )
378     set FFLAGS = ( '-n32 -extend_source -bytereclen' )
379     set FOPTIM = ( '-O2' )
380     set NOOPTFILES = ( 'calc_mom_rhs.F' )
381     set NOOPTFLAGS = ( '-O1' )
382     set LIBS = ( '-lmpi -lscs' )
383     breaksw
384     case onyx:
385     case onyx+mpi:
386     echo "Configuring for SGI ONYX running IRIX64"
387     set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
388     set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' )
389     set FOPTIM = ( '-O2' )
390     set NOOPTFLAGS = ( '-O0' )
391     set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F' )
392     set LIBS = ( '-lmpi' )
393     breaksw
394 cnh 1.6 case SunOS:
395 adcroft 1.23 set LN = ( '/usr/bin/ln -s' )
396 cnh 1.6 set CPP = ( '/usr/ccs/lib/cpp -P' )
397 heimbach 1.56.4.4 set MAKEDEPEND = ( ${TOOLSDIR}/xmakedepend )
398 cnh 1.52 set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4 -D_d=E' )
399 heimbach 1.56.4.3 set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar -xtypemap=real:64,double:64,integer:32 -fsimple=0' )
400 heimbach 1.56.4.4 set FOPTIM = ( '-dalign -O1 -xarch=v9' )
401     set CFLAGS = ( '-dalign -O1 -xarch=v9' )
402 adcroft 1.51 set NOOPTFLAGS = ( '-dalign -O0 -xarch=v9' )
403     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 ')
404 cnh 1.6 breaksw
405     case SunOS+mpi:
406 adcroft 1.23 set LN = ( '/usr/bin/ln -s' )
407 cnh 1.1 set CPP = ( '/usr/ccs/lib/cpp -P' )
408 cnh 1.52 set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4 -D_d=E' )
409 cnh 1.1 set INCLUDES = ( '-I/usr/local/mpi/include' )
410     set LIBS = ( '-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread' \
411 heimbach 1.56.4.3 set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar -xtypemap=real:64,double:64,integer:32 -fsimple=0' )
412 adcroft 1.51 set FOPTIM = ( '-dalign -O3 -xarch=v9' )
413     set NOOPTFLAGS = ( '-dalign -O0 -xarch=v9' )
414 cnh 1.6 '-lsocket -lnsl' )
415 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')
416 cnh 1.3 breaksw
417 cnh 1.6 case IRIX32:
418 cnh 1.3 echo "Configuring for SGI ONYX running IRIX64"
419 adcroft 1.11 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
420 cnh 1.3 set INCLUDES = ( '-I/usr/include' )
421     set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' )
422     set FOPTIM = ( '-O2' )
423     set NOOPTFLAGS = ( '-O0' )
424     set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
425 heimbach 1.20 'external_fields_load.F' )
426 cnh 1.3 set LIBS = ( '-lmpi' )
427     breaksw
428 adcroft 1.11 case HP-UX+mpi:
429     set FC = ( 'mpif77' )
430     set LINK = ( 'mpif77' )
431     set INCLUDES = ( '-I/opt/mpi/include' )
432 cnh 1.6 case HP-UX:
433 cnh 1.3 echo "Configuring for HP Exemplar"
434     set CPP = ( '/usr/ccs/lbin/cpp -P' )
435 adcroft 1.11 set DEFINES = ( ${DEFINES} '-DTARGET_HP -DWORDLENGTH=4' )
436 cnh 1.3 set FFLAGS = ( '+es +U77 +Onoautopar +Oexemplar_model' \
437     '+Okernel_threads' )
438     set FOPTIM = ( '+O2' )
439 cnh 1.6 set NOOPTFLAGS = ( '+O0' )
440 cnh 1.3 set NOOPTFILES = ( 'barrier.F different_multiple.F' \
441 heimbach 1.20 'external_fields_load.F' )
442 cnh 1.1 breaksw
443 adcroft 1.55 case Linux-alpha+mpi:
444     echo "Configuring with MPI"
445     set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
446     set INCLUDES = ( '-I/usr/local/include' )
447     case Linux-alpha:
448     echo "Configuring for " $platform
449     set LN = ( '/bin/ln -s' )
450     set CPP = ( '/lib/cpp -traditional -P' )
451     set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' )
452     set FC = ( 'g77' )
453     set FFLAGS = ( ' ' )
454     if ($?IEEE) set FFLAGS = ( $FFLAGS '-ffloat-store' )
455     set FOPTIM = ( '-ffast-math -fexpensive-optimizations -fomit-frame-pointer -O3' )
456     set LINK = ( 'g77' )
457     breaksw
458     case Linux*+pgi+mpi:
459 adcroft 1.15 if ($?include_jam_libs) then
460 adcroft 1.35 set INCLUDES = ( '-I/usr/local/mpich-1.2.1/pgi_fortran_binding/include' )
461     set LIBS = ( '-L/usr/local/mpich-1.2.1/pgi_fortran_binding/lib/ -lfmpich -lmpich' )
462 adcroft 1.15 else
463     set INCLUDES = ( '-I/usr/local/include' )
464     set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
465     endif
466 heimbach 1.56.4.4 case atlas:
467     if ($?include_jam_libs) then
468     set INCLUDES = ( '-I/usr/local/mpich-cnh-install/include' )
469     set LIBS = ( '-L/usr/local/mpich-cnh-install/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
470     else
471     set INCLUDES = ( '-I/usr/mpich/pghpf/include' )
472     endif
473 adcroft 1.55 case Linux*+pgi:
474     echo "Configuring for " $platform
475 adcroft 1.23 set LN = ( '/bin/ln -s' )
476 adcroft 1.14 set CPP = ( '/lib/cpp -traditional -P' )
477 adcroft 1.10 set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' )
478 cnh 1.6 set FC = ( 'pgf77' )
479 adcroft 1.23 set FFLAGS = ( '-byteswapio -r8 -Mnodclchk -Mextend' )
480 cnh 1.6 set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
481     set LINK = ( 'pgf77' )
482 adcroft 1.56 breaksw
483     case Linux*+mpi:
484     set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
485     set INCLUDES = ( '-I/usr/local/include' )
486     case Linux*:
487     echo "Configuring for " $platform
488     set LN = ( '/bin/ln -s' )
489     set CPP = ( '/lib/cpp -traditional -P' )
490     set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' )
491     set FC = ( 'g77' )
492     set FFLAGS = ( '-Wimplicit -Wunused -Wuninitialized' )
493     if ($?IEEE) set FFLAGS = ( $FFLAGS '-ffloat-store' )
494     set FOPTIM = ( '-O3 -malign-double -funroll-loops' )
495     set LINK = ( 'g77' )
496 adcroft 1.13 breaksw
497     case T3E:
498     case sn6312:
499 adcroft 1.55 echo "Configuring for T3E"
500 adcroft 1.13 set CPP = ( '/opt/ctl/bin/cpp -P')
501     set DEFINES = ( ${DEFINES} '-DTARGET_T3E -DWORDLENGTH=4' )
502     set FC = ( 'f90' )
503     set LINK = ( 'f90' )
504     set FFLAGS = ( '-O 2,fusion' )
505 heimbach 1.18 breaksw
506     case T90:
507     case sn7113:
508 adcroft 1.55 echo "Configuring for T90"
509 heimbach 1.18 set FC = ( 'f90' )
510     set LINK = ( 'f90' )
511 adcroft 1.23 set LN = ( '/bin/ln -s' )
512 heimbach 1.19 set CPP = ( '/opt/ctl/bin/cpp -N -P' )
513     set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' )
514     set FFLAGS = ( '-m3 -Rabc -N 132')
515 heimbach 1.18 set FOPTIM = ( '-O0' )
516     set NOOPTFLAGS = ( '-O0' )
517 heimbach 1.20 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')
518 heimbach 1.18 breaksw
519     case SV1:
520     case sn3002:
521     set FC = ( 'f90' )
522     set LINK = ( 'f90' )
523 adcroft 1.23 set LN = ( '/bin/ln -s' )
524 heimbach 1.19 set CPP = ( '/opt/ctl/bin/cpp -N -P' )
525     set DEFINES = ( ${DEFINES} '-DTARGET_CRAY_VECTOR -DWORDLENGTH=4' )
526     set FFLAGS = ( '-m3 -Rabc -ei -eI -s cf77types -N 132')
527 heimbach 1.18 set FOPTIM = ( '-O0' )
528     set NOOPTFLAGS = ( '-O0' )
529 heimbach 1.20 set NOOPTFILES = ( 'barrier.F different_multiple.F external_fields_load.F')
530 heimbach 1.56.4.1 breaksw
531     case SP3:
532     # originally from A. Biastoch, SIO.
533     echo "Configuring for IBM SP POWER3"
534     set SOURCEDIRS = ( ./ $SOURCEDIRS )
535     set LN = ( 'ln -s' )
536     set DEFINES = ( ${DEFINES} '-DTARGET_PWR3 -DTARGET_SGI -DWORDLENGTH=4' )
537     set INCLUDES = ( '-I/usr/lpp/ppe.poe/include' )
538     # set CPP = ( '/lib/cpp' )
539     set FC = ( 'mpxlf95' )
540     set LINK = ( 'mpxlf95' )
541     set FLAGS = ( '-O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \
542     '-bmaxdata:0x80000000 -bloadmap:mitgcmuv.map' )
543     set FFLAGS = ( '-qfixed=132 -O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \
544     '-bmaxdata:0x80000000 ' )
545     set LDFLAGS = ( '-O3 -qarch=pwr3 -qtune=pwr3 -qcache=auto -qmaxmem=-1' \
546     '-bmaxdata:0x80000000' )
547 heimbach 1.56.4.4 set LIBS = ( ' -L/usr/local/apps/mass -lmass' )
548 heimbach 1.56.4.1 set RMFILES = ( 'rii_files' )
549 cnh 1.6 breaksw
550 cnh 1.1 default:
551     echo "Error: platform not recognized: uname -p = " $platform$USEMPI
552     exit
553     breaksw
554     endsw
555    
556     ###############################################################################
557     ## ##
558     ## Everything below here should not need to be changed. Platform specific ##
559     ## changes and code specific changes should be configured above this line. ##
560     ## ##
561     ###############################################################################
562    
563     # Convert lists of directories into command-line options
564     foreach inc ($INCLUDEDIRS)
565     set INCLUDES = ($INCLUDES -I$inc)
566     end
567 adcroft 1.23
568     # Search for source code
569     rm -rf .links.tmp;mkdir .links.tmp
570     echo "# This section creates symbolic links" > srclinks.tmp
571     echo "" >> srclinks.tmp
572     echo -n 'SRCFILES = ' > srclist.inc
573     echo -n 'CSRCFILES = ' > csrclist.inc
574 adcroft 1.41 echo -n 'HEADERFILES = ' > hlist.inc
575 adcroft 1.42 foreach dr ($SOURCEDIRS $INCLUDEDIRS .)
576 adcroft 1.23 set deplist=( )
577     foreach srcfile (`cd $dr; ls *.[hcF]`)
578     if (! -r .links.tmp/$srcfile) then
579     if (-f $dr/$srcfile) then
580     switch ($srcfile:e)
581     case F:
582     touch .links.tmp/$srcfile
583     set deplist=($deplist $srcfile)
584     echo ' \' >> srclist.inc
585     echo -n " " $srcfile >> srclist.inc
586     breaksw
587     case c:
588     touch .links.tmp/$srcfile
589     set deplist=($deplist $srcfile)
590     echo ' \' >> csrclist.inc
591     echo -n " " $srcfile >> csrclist.inc
592     breaksw
593     case h:
594 adcroft 1.41 touch .links.tmp/$srcfile
595     set deplist=($deplist $srcfile)
596     echo ' \' >> hlist.inc
597     echo -n " " $srcfile >> hlist.inc
598 adcroft 1.23 breaksw
599     endsw
600     endif
601     endif
602     end
603     if ($#deplist != 0) then
604     echo "# These files are linked from $dr" >> srclinks.tmp
605     echo $deplist':' >> srclinks.tmp
606     echo ' $(LN) '$dr'/$@ $@' >> srclinks.tmp
607     endif
608 cnh 1.1 end
609 adcroft 1.23 rm -rf .links.tmp
610     echo "" >> srclist.inc
611     echo "" >> csrclist.inc
612 adcroft 1.41 echo "" >> hlist.inc
613 cnh 1.1
614     set THISHOSTNAME = ( `hostname` )
615     set THISCWD = ( `pwd` )
616     set THISDATE = ( `date` )
617    
618 adcroft 1.23 if (-r $mfile) mv -f $mfile $mfile.bak
619 cnh 1.1 ###########################################
620     ## This is the template for the makefile ##
621     ###########################################
622     echo Creating makefile: $mfile
623     echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile}
624 adcroft 1.23 echo "# This makefile was generated automatically on" >> ${mfile}
625 cnh 1.1 echo "# $THISDATE" >> ${mfile}
626     echo "# by the command:" >> ${mfile}
627     echo "# ${0} $argv" >> ${mfile}
628     echo "# executed by:" >> ${mfile}
629     echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> ${mfile}
630     cat >> ${mfile} <<EOF
631     #
632     # BUILDDIR : Directory where object files are written
633     # SOURCEDIRS : Directories containing the source (.F) files
634     # INCLUDEDIRS : Directories containing the header-source (.h) files
635     # EXEDIR : Directory where executable that is generated is written
636     # EXECUTABLE : Full path of executable binary
637     #
638     # CPP : C-preprocessor command
639     # INCLUDES : Directories searched for header files
640     # DEFINES : Macro definitions for CPP
641 heimbach 1.56.4.4 # MAKEDEPEND : Dependency generator
642 cnh 1.1 # KPP : Special preprocessor command (specific to platform)
643     # KFLAGS : Flags for KPP
644     # FC : Fortran compiler command
645     # FFLAGS : Configuration/debugging options for FC
646     # FOPTIM : Optimization options for FC
647     # LINK : Command for link editor program
648     # LIBS : Library flags /or/ additional optimization/debugging flags
649    
650 adcroft 1.23 ROOTDIR = ${ROOTDIR}
651     BUILDDIR = ${BUILDDIR}
652     SOURCEDIRS = ${SOURCEDIRS}
653 cnh 1.1 INCLUDEDIRS = ${INCLUDEDIRS}
654 adcroft 1.23 EXEDIR = ${EXEDIR}
655     EXECUTABLE = \$(EXEDIR)/${EXECUTABLE}
656     TOOLSDIR = ${TOOLSDIR}
657 cnh 1.1
658 adcroft 1.12 EOF
659    
660    
661     # JAM libraries on Hyades
662     if ($?include_jam_libs) then
663     cat >> ${mfile} <<EOF
664     # extra stuff for Hyades ............................................
665     HYADES_DIR = /u/u0/cnh/jam-lib/software
666 adcroft 1.16 HYADES_DIR = /u/u0/cnh/jam-lib-twoproc
667 adcroft 1.35 HYADES_DIR = /usr/local/jamlib/current/dual_proc
668 adcroft 1.12 WORK_DIR = \$(HYADES_DIR)
669     DEPOSIT_DIR = linux_bin
670    
671     STARTXOBJDIR = startx_util/\$(DEPOSIT_DIR)
672     STARTXOBJ = \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/startx_timer.o \
673     \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/startx_util.o \
674     \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/client.o \
675     \$(WORK_DIR)/startx_util/\$(DEPOSIT_DIR)/csutil.o
676    
677     JAMOBJDIR = jam/\$(DEPOSIT_DIR)
678     JAMOBJ = \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_init.o \
679     \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_kernel.o \
680     \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_malloc.o \
681     \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_vmalloc.o \
682     \$(WORK_DIR)/jam/\$(DEPOSIT_DIR)/jam_mutex.o
683    
684     JAMCOBJDIR = jam_collective/\$(DEPOSIT_DIR)
685     JAMCOBJ = \$(WORK_DIR)/jam_collective/\$(DEPOSIT_DIR)/jam_collective.o
686    
687     XLIBS = \$(STARTXOBJ) \$(JAMOBJ) \$(JAMCOBJ)
688    
689     # ..................................................................
690    
691     EOF
692     endif
693    
694    
695     cat >> ${mfile} <<EOF
696 cnh 1.1 # Unix ln (link)
697     LN = ${LN}
698     # C preprocessor
699 cnh 1.52 CPP = cat \$< | ${S64} | ${CPP}
700 heimbach 1.56.4.4 # Dependency generator
701     MAKEDEPEND = ${MAKEDEPEND}
702 cnh 1.1 # Special preprocessor (KAP on DECs, FPP on Crays)
703     KPP = ${KPP}
704     # Fortran compiler
705     FC = ${FC}
706     # Link editor
707     LINK = ${LINK}
708    
709     # Defines for CPP
710     DEFINES = ${DEFINES}
711     # Includes for CPP
712     INCLUDES = ${INCLUDES}
713     # Flags for KPP
714     KFLAGS1 = ${KFLAGS1}
715     KFLAGS2 = ${KFLAGS2}
716     # Optim./debug for FC
717     FFLAGS = ${FFLAGS}
718     FOPTIM = ${FOPTIM}
719 adcroft 1.51 # Flags for CC
720     CFLAGS = ${CFLAGS}
721 cnh 1.1 # Files that should not be optimized
722     NOOPTFILES = ${NOOPTFILES}
723     NOOPTFLAGS = ${NOOPTFLAGS}
724     # Flags and libraries needed for linking
725 adcroft 1.15 LIBS = ${LIBS} \$(XLIBS)
726 cnh 1.1
727     EOF
728    
729 heimbach 1.19 cat srclist.inc >> ${mfile}
730     cat csrclist.inc >> ${mfile}
731 adcroft 1.41 cat hlist.inc >> ${mfile}
732 heimbach 1.19 echo 'F77FILES = $(SRCFILES:.F=.f)' >> ${mfile}
733     echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o)' >> ${mfile}
734    
735 adcroft 1.43 rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp
736 cnh 1.1
737     cat >> ${mfile} <<EOF
738    
739     .SUFFIXES:
740 cnh 1.5 .SUFFIXES: .o .f .p .F .c
741 cnh 1.1
742     all: \$(EXECUTABLE)
743     \$(EXECUTABLE): \$(OBJFILES)
744     \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
745     depend:
746     @make links
747 heimbach 1.56.4.4 \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
748 adcroft 1.32
749 adcroft 1.41 links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES)
750 heimbach 1.46
751     small_f: \$(F77FILES)
752 heimbach 1.19
753 adcroft 1.45 output.txt: \$(EXECUTABLE)
754 adcroft 1.48 @printf 'running ... '
755 adcroft 1.45 @\$(EXECUTABLE) > \$@
756 heimbach 1.19
757 cnh 1.1 clean:
758     -rm -rf *.o *.f *.p ${RMFILES}
759 cnh 1.6 Clean:
760     @make clean
761 adcroft 1.32 @make cleanlinks
762 adcroft 1.23 -rm -f Makefile.bak
763 adcroft 1.12 CLEAN:
764     @make Clean
765 adcroft 1.28 -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
766     -find \$(EXEDIR) -name "*.data" -exec rm {} \;
767 adcroft 1.23 -rm -f \$(EXECUTABLE)
768 adcroft 1.32
769     makefile:
770     ${0} $argv
771     cleanlinks:
772     -find . -type l -exec rm {} \;
773 cnh 1.1
774     # The normal chain of rules is ( .F - .f - .o )
775     .F.f:
776 cnh 1.6 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
777 cnh 1.1 .f.o:
778     \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
779 adcroft 1.51 .c.o:
780     \$(CC) \$(CFLAGS) -c \$<
781 cnh 1.1
782     # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain
783     .F.p:
784 cnh 1.6 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
785 cnh 1.1 .p.f:
786     \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
787     EOF
788    
789     # Make list of "exceptions" that need ".p" files
790     foreach sf ($KPPFILES)
791     set fname=( ${sf:t} )
792     echo "${fname:r}.f: ${fname:r}.p" >> ${mfile}
793     end
794     foreach sf ($NOOPTFILES)
795     set fname=( ${sf:t} )
796     echo "${fname:r}.o: ${fname:r}.f" >> ${mfile}
797     echo ' $(FC) $(FFLAGS) $(NOOPTFLAGS) -c $<' >> ${mfile}
798     end
799 adcroft 1.23 echo "" >> ${mfile}
800    
801     # Add rules for links
802     cat srclinks.tmp >> ${mfile}
803     rm -f srclinks.tmp
804    
805     echo "" >> ${mfile}
806 cnh 1.1 echo "# DO NOT DELETE" >> ${mfile}
807    
808     exit

  ViewVC Help
Powered by ViewVC 1.1.22