/[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.45 - (hide annotations) (download)
Fri Aug 17 16:40:45 2001 UTC (22 years, 7 months ago) by adcroft
Branch: MAIN
Changes since 1.44: +4 -2 lines
Added new target to help testscript deal with the -quick option.

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

  ViewVC Help
Powered by ViewVC 1.1.22