/[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.11 - (hide annotations) (download)
Fri May 7 18:12:29 1999 UTC (24 years, 10 months ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint22, checkpoint24, checkpoint23, checkpoint21
Changes since 1.10: +21 -21 lines
Set value for WORDLENGTH on all platforms in genmake.

1 cnh 1.1 #!/bin/csh -f
2     #
3 adcroft 1.11 # $Header: /u/gcmpack/models/MITgcmUV/tools/genmake,v 1.10 1999/05/05 18:32:35 adcroft Exp $
4 cnh 1.1 #
5     # Makefile generator for MITgcm UV codes
6     # created by cnh 03/98
7     # adapted by aja 06/98
8    
9     # Process command-line arguments
10     set allargs=( $argv )
11     while ($#allargs)
12     set arg = $allargs[1]
13     switch ($arg)
14 adcroft 1.9 case -makefile:
15     set mfile = ( Makefile )
16     breaksw
17     case -makefile=*:
18     set mfile = ( `echo $arg | sed 's/-makefile=//' `)
19 cnh 1.1 breaksw
20     case -platform:
21     case -platform=:
22     echo "To change platform you must specify one with -platform="
23     echo "eg. -platform=sparc or -platform=mips"
24     exit
25     breaksw
26     case -platform*:
27     set platform = ( `echo $arg | sed 's/-platform=//' `)
28     breaksw
29     case -mpi:
30     echo "Enabling MPI options"
31     set USEMPI
32     breaksw
33     case -help:
34     echo "usage: $0 [-help] [-makefile[=...]] [-platform=...] [-mpi]"
35     exit
36     breaksw
37     default:
38     echo "Unknown command-line option: " $arg
39     echo $0 "-help to show usage"
40     exit
41     breaksw
42     endsw
43     shift allargs
44     end
45 cnh 1.6
46     if ($?platform == 0) then
47     set platform = (`uname`)
48     endif
49 cnh 1.1 if ($?mfile == 0) set mfile = ( Makefile.$platform )
50     set mach = ( `uname -a` )
51     echo Operating system: $mach
52    
53     # Directories for source, includes, binaries and executables
54     # Note
55     # o If you prefer/need everything under a single directory
56     # copy everything in ../eesupp/src, ../model/src,
57     # ../eesupp/inc and ../model/inc into a directory and then
58     # edit the paths below to ./
59     set SOURCEDIRS = ( ../eesupp/src/ ../model/src/ ../diags/src/)
60     set INCLUDEDIRS = ( ../eesupp/inc/ ../model/inc/ ../diags/inc/)
61     set BUILDDIR = ( ../bin/ )
62     set EXEDIR = ( ../exe/ )
63     set EXECUTABLE = ( mitgcmuv )
64    
65     # This is the generic configuration.
66     # Platform specific options are chosen below
67     set LN = ( 'ln -sf' )
68     set CPP = ( '/lib/cpp -P' )
69     set KPP = ( )
70     set FC = ( 'f77' )
71     set LINK = ( 'f77' )
72     set DEFINES = ( )
73     set INCLUDES = ( )
74     set FFLAGS = ( )
75     set FOPTIM = ( )
76     set KFLAGS1 = ( )
77     set KFLAGS2 = ( )
78     set LIBS = ( )
79     set KPPFILES = ( )
80     set NOOPTFILES = ( )
81     set NOOPTFLAGS = ( )
82     set RMFILES = ( )
83    
84     # We often want to use different compile/link options is using MPI
85     if ($?USEMPI) then
86     set USEMPI = ( '+mpi' )
87     set DEFINES = ( ${DEFINES} '-DALLOW_USE_MPI -DALWAYS_USE_MPI' )
88     else
89     set USEMPI
90     # set DEFINES = ( ${DEFINES} '-UALLOW_USE_MPI -UALWAYS_USE_MPI' )
91     endif
92    
93     # Platform specific options
94     switch ($platform$USEMPI)
95 cnh 1.6 case OSF1:
96     case OSF1+mpi:
97 cnh 1.1 echo "Configuring for DEC Alpha"
98     set CPP = ( '/usr/bin/cpp -P' )
99 adcroft 1.10 set DEFINES = ( ${DEFINES} '-DTARGET_DEC -DWORDLENGTH=1' )
100 cnh 1.1 set KPP = ( 'kapf' )
101 cnh 1.4 set KPPFILES = ( 'main.F' )
102 cnh 1.1 set KFLAGS1 = ( '-scan=132 -noconc -cmp=' )
103     set FC = ( 'f77' )
104 adcroft 1.2 set FFLAGS = ( '-convert big_endian -r8 -extend_source -u -automatic -call_shared -notransform_loops -align dcommons' )
105 cnh 1.1 set FOPTIM = ( '-O5 -fast -tune host -inline all' )
106     set NOOPTFLAGS = ( '-O0' )
107     set LIBS = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' )
108     set NOOPTFILES = ( 'barrier.F different_multiple.F load_external_fields.F')
109     set RMFILES = ( '*.p.out' )
110     breaksw
111 cnh 1.6 case IRIX64+mpi:
112 cnh 1.1 echo "Configuring for SGI Mips with MPI"
113 adcroft 1.11 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
114 cnh 1.1 set INCLUDES = ( '-I/usr/local/mpi/include' )
115     set FC = ( 'mpif77' )
116     set LINK = ( 'mpif77' )
117 adcroft 1.11 set FFLAGS = ( '-extend_source -bytereclen -r10000 -mips4' )
118 cnh 1.1 set FOPTIM = ( '-O3' )
119     set RMFILES = ( 'rii_files' )
120     breaksw
121 cnh 1.6 case IRIX64:
122 cnh 1.1 echo "Configuring for SGI Mips"
123 adcroft 1.11 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
124 cnh 1.1 set INCLUDES = ( '-I/usr/local/mpi/include' )
125     set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4' )
126 adcroft 1.11 set FOPTIM = ( '-O3' )
127     # set NOOPTFLAGS = ( '-O0' )
128     # set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
129     # 'load_external_fields.F' )
130 cnh 1.1 set RMFILES = ( 'rii_files' )
131     breaksw
132 cnh 1.6 case SunOS:
133     set LN = ( '/usr/bin/ln -fs' )
134     set CPP = ( '/usr/ccs/lib/cpp -P' )
135 adcroft 1.11 set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4' )
136 cnh 1.6 set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar')
137 adcroft 1.11 set FOPTIM = ( '-fast -O4' )
138 cnh 1.6 set NOOPTFLAGS = ( '-O0' )
139 adcroft 1.11 set NOOPTFILES = ( 'barrier.F different_multiple.F load_external_fields.F ini_vertical_grid.F')
140 cnh 1.6 breaksw
141     case SunOS+mpi:
142 cnh 1.1 set LN = ( '/usr/bin/ln -fs' )
143     set CPP = ( '/usr/ccs/lib/cpp -P' )
144 adcroft 1.11 set DEFINES = ( ${DEFINES} '-DTARGET_SUN -DWORDLENGTH=4' )
145 cnh 1.1 set INCLUDES = ( '-I/usr/local/mpi/include' )
146     set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar')
147 adcroft 1.11 set FOPTIM = ( '-fast -O4' )
148 cnh 1.1 set NOOPTFLAGS = ( '-O0' )
149     set LIBS = ( '-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread' \
150 cnh 1.6 '-lsocket -lnsl' )
151 adcroft 1.11 set NOOPTFILES = ( 'barrier.F different_multiple.F load_external_fields.F ini_vertical_grid.F')
152 cnh 1.3 breaksw
153 cnh 1.6 case IRIX32:
154 cnh 1.3 echo "Configuring for SGI ONYX running IRIX64"
155 adcroft 1.11 set DEFINES = ( ${DEFINES} '-DTARGET_SGI -DWORDLENGTH=4' )
156 cnh 1.3 set INCLUDES = ( '-I/usr/include' )
157     set FFLAGS = ( '-extend_source -bytereclen -r10000 -64' )
158     set FOPTIM = ( '-O2' )
159     set NOOPTFLAGS = ( '-O0' )
160     set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
161     'load_external_fields.F' )
162     set LIBS = ( '-lmpi' )
163     breaksw
164 adcroft 1.11 case HP-UX+mpi:
165     set FC = ( 'mpif77' )
166     set LINK = ( 'mpif77' )
167     set INCLUDES = ( '-I/opt/mpi/include' )
168 cnh 1.6 case HP-UX:
169 cnh 1.3 echo "Configuring for HP Exemplar"
170     set CPP = ( '/usr/ccs/lbin/cpp -P' )
171 adcroft 1.11 set DEFINES = ( ${DEFINES} '-DTARGET_HP -DWORDLENGTH=4' )
172 cnh 1.3 set FFLAGS = ( '+es +U77 +Onoautopar +Oexemplar_model' \
173     '+Okernel_threads' )
174     set FOPTIM = ( '+O2' )
175 cnh 1.6 set NOOPTFLAGS = ( '+O0' )
176 cnh 1.3 set NOOPTFILES = ( 'barrier.F different_multiple.F' \
177     'load_external_fields.F' )
178 cnh 1.1 breaksw
179 adcroft 1.9 case Linux+mpi:
180     set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich' )
181 cnh 1.6 case Linux:
182     set LN = ( '/bin/ln -fs' )
183 cnh 1.7 set CPP = ( '/usr/lib/gcc-lib/i386-redhat-linux/2.7.2.3/cpp -traditional -P' )
184 adcroft 1.11 set DEFINES = ( ${DEFINES} '-D_BYTESWAPIO -DWORDLENGTH=4' )
185 cnh 1.6 set INCLUDES = ( '-I/usr/local/include' )
186     set FC = ( 'g77' )
187     set FFLAGS = ( ' ' )
188 adcroft 1.9 set FOPTIM = ( '-O3 -funroll-loops ' )
189 cnh 1.6 set LINK = ( 'g77' )
190     breaksw
191     case Linux+pgi:
192     set LN = ( '/bin/ln -fs' )
193     set CPP = ( '/usr/lib/gcc-lib/i386-redhat-linux/2.7.2.3/cpp -P' )
194 adcroft 1.10 set DEFINES = ( ${DEFINES} '-DWORDLENGTH=4' )
195 cnh 1.6 set INCLUDES = ( '-I/usr/local/include' )
196     set FC = ( 'pgf77' )
197     set FFLAGS = ( '-byteswapio' )
198     set FOPTIM = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
199     set LINK = ( 'pgf77' )
200     set LIBS = ( '-L/usr/local/lib/LINUX/ch_p4/ -lfmpich -lmpich -Kieee' )
201     breaksw
202 cnh 1.1 default:
203     echo "Error: platform not recognized: uname -p = " $platform$USEMPI
204     exit
205     breaksw
206     endsw
207    
208     ###############################################################################
209     ## ##
210     ## Everything below here should not need to be changed. Platform specific ##
211     ## changes and code specific changes should be configured above this line. ##
212     ## ##
213     ###############################################################################
214    
215     # Create list of files
216 cnh 1.5 set flist = `ls -1 ${SOURCEDIRS} | grep '.*\.[F]$'`
217 cnh 1.1 if ( $#flist ) then
218     echo -n "SRCFILES = " > srclist.inc
219     echo -n "F77FILES = " > f77list.inc
220     echo -n "OBJFILES = " > objlist.inc
221     foreach ff ( ${flist} )
222     set fname = ( ${ff:t} )
223     echo ' \' >> srclist.inc
224     echo -n " " ${fname:r}.F >> srclist.inc
225     echo ' \' >> f77list.inc
226     echo -n " " ${fname:r}.f >> f77list.inc
227     echo ' \' >> objlist.inc
228     echo -n " " ${fname:r}.o >> objlist.inc
229     end
230     else
231     echo No source files found...\!
232     exit
233     endif
234 cnh 1.5 set flist = `ls -1 ${SOURCEDIRS} | grep '.*\.[c]$'`
235     if ( $#flist ) then
236     foreach ff ( ${flist} )
237     set fname = ( ${ff:t} )
238     echo ' \' >> objlist.inc
239     echo -n " " ${fname:r}.o >> objlist.inc
240     endif
241     echo " " >> srclist.inc
242     echo " " >> f77list.inc
243     echo " " >> objlist.inc
244 cnh 1.1
245     # Convert lists of directories into command-line options
246     foreach inc ($INCLUDEDIRS)
247     set INCLUDES = ($INCLUDES -I$inc)
248     end
249     set SRCSTARS = ( )
250     foreach dr ($SOURCEDIRS)
251 cnh 1.6 set SRCSTARS = ("${SRCSTARS}" $dr\*.\[Fc\] )
252 cnh 1.1 end
253    
254     set THISHOSTNAME = ( `hostname` )
255     set THISCWD = ( `pwd` )
256     set THISDATE = ( `date` )
257    
258     ###########################################
259     ## This is the template for the makefile ##
260     ###########################################
261     echo Creating makefile: $mfile
262     echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile}
263     echo "# This makefile was generated automatically pn" >> ${mfile}
264     echo "# $THISDATE" >> ${mfile}
265     echo "# by the command:" >> ${mfile}
266     echo "# ${0} $argv" >> ${mfile}
267     echo "# executed by:" >> ${mfile}
268     echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> ${mfile}
269     cat >> ${mfile} <<EOF
270     #
271     # BUILDDIR : Directory where object files are written
272     # SOURCEDIRS : Directories containing the source (.F) files
273     # INCLUDEDIRS : Directories containing the header-source (.h) files
274     # EXEDIR : Directory where executable that is generated is written
275     # EXECUTABLE : Full path of executable binary
276     #
277     # CPP : C-preprocessor command
278     # INCLUDES : Directories searched for header files
279     # DEFINES : Macro definitions for CPP
280     # KPP : Special preprocessor command (specific to platform)
281     # KFLAGS : Flags for KPP
282     # FC : Fortran compiler command
283     # FFLAGS : Configuration/debugging options for FC
284     # FOPTIM : Optimization options for FC
285     # LINK : Command for link editor program
286     # LIBS : Library flags /or/ additional optimization/debugging flags
287    
288     BUILDDIR = ${BUILDDIR}
289     SOURCEDIRS = ${SOURCEDIRS}
290     INCLUDEDIRS = ${INCLUDEDIRS}
291     EXEDIR = ${EXEDIR}
292     EXECUTABLE = \$(EXEDIR)${EXECUTABLE}
293    
294     # Unix ln (link)
295     LN = ${LN}
296     # C preprocessor
297 cnh 1.6 CPP = cat \$< | ../tools/set64bitConst.sh | ${CPP}
298 cnh 1.1 # Special preprocessor (KAP on DECs, FPP on Crays)
299     KPP = ${KPP}
300     # Fortran compiler
301     FC = ${FC}
302     # Link editor
303     LINK = ${LINK}
304    
305     # Defines for CPP
306     DEFINES = ${DEFINES}
307     # Includes for CPP
308     INCLUDES = ${INCLUDES}
309     # Flags for KPP
310     KFLAGS1 = ${KFLAGS1}
311     KFLAGS2 = ${KFLAGS2}
312     # Optim./debug for FC
313     FFLAGS = ${FFLAGS}
314     FOPTIM = ${FOPTIM}
315     # Files that should not be optimized
316     NOOPTFILES = ${NOOPTFILES}
317     NOOPTFLAGS = ${NOOPTFLAGS}
318     # Flags and libraries needed for linking
319     LIBS = ${LIBS}
320    
321     EOF
322    
323     cat srclist.inc >> ${mfile}
324     cat f77list.inc >> ${mfile}
325     cat objlist.inc >> ${mfile}
326     rm -f srclist.inc f77list.inc objlist.inc
327    
328     cat >> ${mfile} <<EOF
329    
330     .SUFFIXES:
331 cnh 1.5 .SUFFIXES: .o .f .p .F .c
332 cnh 1.1
333     all: \$(EXECUTABLE)
334     \$(EXECUTABLE): \$(OBJFILES)
335     \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
336     links:
337     @-\$(LN) $SRCSTARS .
338     depend:
339     @make links
340     makedepend -o .f \$(INCLUDES) \$(SRCFILES)
341     clean:
342     -rm -rf *.o *.f *.p ${RMFILES}
343 cnh 1.6 Clean:
344     @make clean
345 adcroft 1.8 -find . -type l -exec rm {} \;
346     -rm Makefile.bak
347 cnh 1.1
348     # The normal chain of rules is ( .F - .f - .o )
349     .F.f:
350 cnh 1.6 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
351 cnh 1.1 .f.o:
352     \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
353    
354     # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain
355     .F.p:
356 cnh 1.6 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
357 cnh 1.1 .p.f:
358     \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
359     EOF
360    
361     # Make list of "exceptions" that need ".p" files
362     foreach sf ($KPPFILES)
363     set fname=( ${sf:t} )
364     echo "${fname:r}.f: ${fname:r}.p" >> ${mfile}
365     end
366     foreach sf ($NOOPTFILES)
367     set fname=( ${sf:t} )
368     echo "${fname:r}.o: ${fname:r}.f" >> ${mfile}
369     echo ' $(FC) $(FFLAGS) $(NOOPTFLAGS) -c $<' >> ${mfile}
370     end
371     echo >> ${mfile}
372     echo "# DO NOT DELETE" >> ${mfile}
373    
374     exit

  ViewVC Help
Powered by ViewVC 1.1.22