/[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.2 - (hide annotations) (download)
Wed Jul 15 22:05:44 1998 UTC (25 years, 9 months ago) by adcroft
Branch: MAIN
CVS Tags: branch-point-rdot
Branch point for: branch-rdot
Changes since 1.1: +2 -3 lines
We decided to skip the KAP preprocessor stage on the DEC Alpha's
by default. (KAP isn't always available, even on our own well
maintained platforms...)

1 cnh 1.1 #!/bin/csh -f
2     #
3 adcroft 1.2 # $Header: /u/gcmpack/models/MITgcmUV/tools/genmake,v 1.1 1998/07/08 15:24:05 cnh 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     case -makefile*:
15     if ($arg == "-makefile") then
16     set mfile = ( Makefile )
17     else
18     set mfile = ( `echo $arg | sed 's/-makefile=//' `)
19     endif
20     breaksw
21     case -platform:
22     case -platform=:
23     echo "To change platform you must specify one with -platform="
24     echo "eg. -platform=sparc or -platform=mips"
25     exit
26     breaksw
27     case -platform*:
28     set platform = ( `echo $arg | sed 's/-platform=//' `)
29     breaksw
30     case -mpi:
31     echo "Enabling MPI options"
32     set USEMPI
33     breaksw
34     case -help:
35     echo "usage: $0 [-help] [-makefile[=...]] [-platform=...] [-mpi]"
36     exit
37     breaksw
38     default:
39     echo "Unknown command-line option: " $arg
40     echo $0 "-help to show usage"
41     exit
42     breaksw
43     endsw
44     shift allargs
45     end
46    
47     if ($?platform == 0) set platform = (`uname -p`)
48     if ($?mfile == 0) set mfile = ( Makefile.$platform )
49     set mach = ( `uname -a` )
50     echo Operating system: $mach
51    
52     # Directories for source, includes, binaries and executables
53     # Note
54     # o If you prefer/need everything under a single directory
55     # copy everything in ../eesupp/src, ../model/src,
56     # ../eesupp/inc and ../model/inc into a directory and then
57     # edit the paths below to ./
58     set SOURCEDIRS = ( ../eesupp/src/ ../model/src/ ../diags/src/)
59     set INCLUDEDIRS = ( ../eesupp/inc/ ../model/inc/ ../diags/inc/)
60     set BUILDDIR = ( ../bin/ )
61     set EXEDIR = ( ../exe/ )
62     set EXECUTABLE = ( mitgcmuv )
63    
64     # This is the generic configuration.
65     # Platform specific options are chosen below
66     set LN = ( 'ln -sf' )
67     set CPP = ( '/lib/cpp -P' )
68     set KPP = ( )
69     set FC = ( 'f77' )
70     set LINK = ( 'f77' )
71     set DEFINES = ( )
72     set INCLUDES = ( )
73     set FFLAGS = ( )
74     set FOPTIM = ( )
75     set KFLAGS1 = ( )
76     set KFLAGS2 = ( )
77     set LIBS = ( )
78     set KPPFILES = ( )
79     set NOOPTFILES = ( )
80     set NOOPTFLAGS = ( )
81     set RMFILES = ( )
82    
83     # We often want to use different compile/link options is using MPI
84     if ($?USEMPI) then
85     set USEMPI = ( '+mpi' )
86     set DEFINES = ( ${DEFINES} '-DALLOW_USE_MPI -DALWAYS_USE_MPI' )
87     else
88     set USEMPI
89     # set DEFINES = ( ${DEFINES} '-UALLOW_USE_MPI -UALWAYS_USE_MPI' )
90     endif
91    
92     # Platform specific options
93     switch ($platform$USEMPI)
94     case alpha:
95     case alpha+mpi:
96     echo "Configuring for DEC Alpha"
97     set CPP = ( '/usr/bin/cpp -P' )
98     set DEFINES = ( ${DEFINES} '-DTARGET_DEC' )
99     set KPP = ( 'kapf' )
100     set KFLAGS1 = ( '-scan=132 -noconc -cmp=' )
101     set FC = ( 'f77' )
102 adcroft 1.2 set FFLAGS = ( '-convert big_endian -r8 -extend_source -u -automatic -call_shared -notransform_loops -align dcommons' )
103 cnh 1.1 set FOPTIM = ( '-O5 -fast -tune host -inline all' )
104     set NOOPTFLAGS = ( '-O0' )
105     set LIBS = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' )
106     set NOOPTFILES = ( 'barrier.F different_multiple.F load_external_fields.F')
107     set RMFILES = ( '*.p.out' )
108     breaksw
109     case mips+mpi:
110     echo "Configuring for SGI Mips with MPI"
111     set DEFINES = ( ${DEFINES} '-DTARGET_SGI' )
112     set INCLUDES = ( '-I/usr/local/mpi/include' )
113     set FC = ( 'mpif77' )
114     set LINK = ( 'mpif77' )
115     set FFLAGS = ( '-extend_source -bytereclen -r10000' )
116     set FOPTIM = ( '-O3' )
117     set RMFILES = ( 'rii_files' )
118     breaksw
119     case mips:
120     echo "Configuring for SGI Mips"
121     set DEFINES = ( ${DEFINES} '-DTARGET_SGI' )
122     set INCLUDES = ( '-I/usr/local/mpi/include' )
123     set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4' )
124     set FOPTIM = ( '-O2' )
125     set NOOPTFLAGS = ( '-O0' )
126     set NOOPTFILES = ( 'barrier.F different_multiple.F ' \
127     'load_external_fields.F' )
128     set RMFILES = ( 'rii_files' )
129     breaksw
130     case sparc:
131     set LN = ( '/usr/bin/ln -fs' )
132     set CPP = ( '/usr/ccs/lib/cpp -P' )
133     set DEFINES = ( ${DEFINES} '-DTARGET_SUN' )
134     set INCLUDES = ( '-I/usr/local/mpi/include' )
135     set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar')
136     set FOPTIM = ( '-O5' )
137     set NOOPTFLAGS = ( '-O0' )
138     set LIBS = ( '-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread' \
139     '-lsocket -lnsl -fast' )
140     set NOOPTFILES = ( 'barrier.F different_multiple.F load_external_fields.F')
141     breaksw
142     default:
143     echo "Error: platform not recognized: uname -p = " $platform$USEMPI
144     exit
145     breaksw
146     endsw
147    
148     ###############################################################################
149     ## ##
150     ## Everything below here should not need to be changed. Platform specific ##
151     ## changes and code specific changes should be configured above this line. ##
152     ## ##
153     ###############################################################################
154    
155     # Create list of files
156     set flist = `ls -1 ${SOURCEDIRS} | grep '.*\.F'`
157     if ( $#flist ) then
158     echo -n "SRCFILES = " > srclist.inc
159     echo -n "F77FILES = " > f77list.inc
160     echo -n "OBJFILES = " > objlist.inc
161     foreach ff ( ${flist} )
162     set fname = ( ${ff:t} )
163     echo ' \' >> srclist.inc
164     echo -n " " ${fname:r}.F >> srclist.inc
165     echo ' \' >> f77list.inc
166     echo -n " " ${fname:r}.f >> f77list.inc
167     echo ' \' >> objlist.inc
168     echo -n " " ${fname:r}.o >> objlist.inc
169     end
170     echo " " >> srclist.inc
171     echo " " >> f77list.inc
172     echo " " >> objlist.inc
173     else
174     echo No source files found...\!
175     exit
176     endif
177    
178     # Convert lists of directories into command-line options
179     foreach inc ($INCLUDEDIRS)
180     set INCLUDES = ($INCLUDES -I$inc)
181     end
182     set SRCSTARS = ( )
183     foreach dr ($SOURCEDIRS)
184     set SRCSTARS = ("${SRCSTARS}" $dr/\*.F)
185     end
186    
187     set THISHOSTNAME = ( `hostname` )
188     set THISCWD = ( `pwd` )
189     set THISDATE = ( `date` )
190    
191     ###########################################
192     ## This is the template for the makefile ##
193     ###########################################
194     echo Creating makefile: $mfile
195     echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile}
196     echo "# This makefile was generated automatically pn" >> ${mfile}
197     echo "# $THISDATE" >> ${mfile}
198     echo "# by the command:" >> ${mfile}
199     echo "# ${0} $argv" >> ${mfile}
200     echo "# executed by:" >> ${mfile}
201     echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> ${mfile}
202     cat >> ${mfile} <<EOF
203     #
204     # BUILDDIR : Directory where object files are written
205     # SOURCEDIRS : Directories containing the source (.F) files
206     # INCLUDEDIRS : Directories containing the header-source (.h) files
207     # EXEDIR : Directory where executable that is generated is written
208     # EXECUTABLE : Full path of executable binary
209     #
210     # CPP : C-preprocessor command
211     # INCLUDES : Directories searched for header files
212     # DEFINES : Macro definitions for CPP
213     # KPP : Special preprocessor command (specific to platform)
214     # KFLAGS : Flags for KPP
215     # FC : Fortran compiler command
216     # FFLAGS : Configuration/debugging options for FC
217     # FOPTIM : Optimization options for FC
218     # LINK : Command for link editor program
219     # LIBS : Library flags /or/ additional optimization/debugging flags
220    
221     BUILDDIR = ${BUILDDIR}
222     SOURCEDIRS = ${SOURCEDIRS}
223     INCLUDEDIRS = ${INCLUDEDIRS}
224     EXEDIR = ${EXEDIR}
225     EXECUTABLE = \$(EXEDIR)${EXECUTABLE}
226    
227     # Unix ln (link)
228     LN = ${LN}
229     # C preprocessor
230     CPP = ${CPP}
231     # Special preprocessor (KAP on DECs, FPP on Crays)
232     KPP = ${KPP}
233     # Fortran compiler
234     FC = ${FC}
235     # Link editor
236     LINK = ${LINK}
237    
238     # Defines for CPP
239     DEFINES = ${DEFINES}
240     # Includes for CPP
241     INCLUDES = ${INCLUDES}
242     # Flags for KPP
243     KFLAGS1 = ${KFLAGS1}
244     KFLAGS2 = ${KFLAGS2}
245     # Optim./debug for FC
246     FFLAGS = ${FFLAGS}
247     FOPTIM = ${FOPTIM}
248     # Files that should not be optimized
249     NOOPTFILES = ${NOOPTFILES}
250     NOOPTFLAGS = ${NOOPTFLAGS}
251     # Flags and libraries needed for linking
252     LIBS = ${LIBS}
253    
254     EOF
255    
256     cat srclist.inc >> ${mfile}
257     cat f77list.inc >> ${mfile}
258     cat objlist.inc >> ${mfile}
259     rm -f srclist.inc f77list.inc objlist.inc
260    
261     cat >> ${mfile} <<EOF
262    
263     .SUFFIXES:
264     .SUFFIXES: .o .f .p .F
265    
266     all: \$(EXECUTABLE)
267     \$(EXECUTABLE): \$(OBJFILES)
268     \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
269     links:
270     @-\$(LN) $SRCSTARS .
271     depend:
272     @make links
273     makedepend -o .f \$(INCLUDES) \$(SRCFILES)
274     clean:
275     -rm -rf *.o *.f *.p ${RMFILES}
276    
277     # The normal chain of rules is ( .F - .f - .o )
278     .F.f:
279     \$(CPP) \$(DEFINES) \$(INCLUDES) \$< > \$@
280     .f.o:
281     \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
282    
283     # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain
284     .F.p:
285     \$(CPP) \$(DEFINES) \$(INCLUDES) \$< > \$@
286     .p.f:
287     \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
288     EOF
289    
290     # Make list of "exceptions" that need ".p" files
291     foreach sf ($KPPFILES)
292     set fname=( ${sf:t} )
293     echo "${fname:r}.f: ${fname:r}.p" >> ${mfile}
294     end
295     foreach sf ($NOOPTFILES)
296     set fname=( ${sf:t} )
297     echo "${fname:r}.o: ${fname:r}.f" >> ${mfile}
298     echo ' $(FC) $(FFLAGS) $(NOOPTFLAGS) -c $<' >> ${mfile}
299     end
300     echo >> ${mfile}
301     echo "# DO NOT DELETE" >> ${mfile}
302    
303     exit

  ViewVC Help
Powered by ViewVC 1.1.22