/[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.42 - (hide annotations) (download)
Tue Aug 14 14:27:10 2001 UTC (22 years, 7 months ago) by adcroft
Branch: MAIN
Changes since 1.41: +5 -5 lines
Fixed problem which infinite links; header files ended up linked to
themselves because the ./ directory was the first in the INCLUDEDIRS
list. Now INCLUDES has -I. in it and ./ is at end of search path.

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

  ViewVC Help
Powered by ViewVC 1.1.22