/[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.39 - (hide annotations) (download)
Tue Jul 31 15:22:12 2001 UTC (22 years, 8 months ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint40pre5
Changes since 1.38: +8 -7 lines
Removed KAP stuff for DEC's since most people don't have it
and we weren't using it anyway.

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

  ViewVC Help
Powered by ViewVC 1.1.22