1 |
#!/bin/csh -f |
2 |
# |
3 |
# $Header: /u/gcmpack/models/MITgcmUV/tools/configure,v 1.6 1998/07/03 20:47:04 adcroft Exp $ |
4 |
# |
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 |
set FFLAGS = ( '-convert big_endian -r8 -extend_source -u -automatic -call_shared -notransform_loops -align dcommons -p1' ) |
103 |
set FOPTIM = ( '-O5 -fast -tune host -inline all' ) |
104 |
set NOOPTFLAGS = ( '-O0' ) |
105 |
set LIBS = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' ) |
106 |
set KPPFILES = ( 'main.F' ) |
107 |
set NOOPTFILES = ( 'barrier.F different_multiple.F load_external_fields.F') |
108 |
set RMFILES = ( '*.p.out' ) |
109 |
breaksw |
110 |
case mips+mpi: |
111 |
echo "Configuring for SGI Mips with MPI" |
112 |
set DEFINES = ( ${DEFINES} '-DTARGET_SGI' ) |
113 |
set INCLUDES = ( '-I/usr/local/mpi/include' ) |
114 |
set FC = ( 'mpif77' ) |
115 |
set LINK = ( 'mpif77' ) |
116 |
set FFLAGS = ( '-extend_source -bytereclen -r10000' ) |
117 |
set FOPTIM = ( '-O3' ) |
118 |
set RMFILES = ( 'rii_files' ) |
119 |
breaksw |
120 |
case mips: |
121 |
echo "Configuring for SGI Mips" |
122 |
set DEFINES = ( ${DEFINES} '-DTARGET_SGI' ) |
123 |
set INCLUDES = ( '-I/usr/local/mpi/include' ) |
124 |
set FFLAGS = ( '-extend_source -mp -mpio -bytereclen -r10000 -mips4' ) |
125 |
set FOPTIM = ( '-O2' ) |
126 |
set NOOPTFLAGS = ( '-O0' ) |
127 |
set NOOPTFILES = ( 'barrier.F different_multiple.F ' \ |
128 |
'load_external_fields.F' ) |
129 |
set RMFILES = ( 'rii_files' ) |
130 |
breaksw |
131 |
case sparc: |
132 |
set LN = ( '/usr/bin/ln -fs' ) |
133 |
set CPP = ( '/usr/ccs/lib/cpp -P' ) |
134 |
set DEFINES = ( ${DEFINES} '-DTARGET_SUN' ) |
135 |
set INCLUDES = ( '-I/usr/local/mpi/include' ) |
136 |
set FFLAGS = ( '-stackvar -explicitpar -vpara -e -u -noautopar') |
137 |
set FOPTIM = ( '-O5' ) |
138 |
set NOOPTFLAGS = ( '-O0' ) |
139 |
set LIBS = ( '-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread' \ |
140 |
'-lsocket -lnsl -fast' ) |
141 |
set NOOPTFILES = ( 'barrier.F different_multiple.F load_external_fields.F') |
142 |
breaksw |
143 |
default: |
144 |
echo "Error: platform not recognized: uname -p = " $platform$USEMPI |
145 |
exit |
146 |
breaksw |
147 |
endsw |
148 |
|
149 |
############################################################################### |
150 |
## ## |
151 |
## Everything below here should not need to be changed. Platform specific ## |
152 |
## changes and code specific changes should be configured above this line. ## |
153 |
## ## |
154 |
############################################################################### |
155 |
|
156 |
# Create list of files |
157 |
set flist = `ls -1 ${SOURCEDIRS} | grep '.*\.F'` |
158 |
if ( $#flist ) then |
159 |
echo -n "SRCFILES = " > srclist.inc |
160 |
echo -n "F77FILES = " > f77list.inc |
161 |
echo -n "OBJFILES = " > objlist.inc |
162 |
foreach ff ( ${flist} ) |
163 |
set fname = ( ${ff:t} ) |
164 |
echo ' \' >> srclist.inc |
165 |
echo -n " " ${fname:r}.F >> srclist.inc |
166 |
echo ' \' >> f77list.inc |
167 |
echo -n " " ${fname:r}.f >> f77list.inc |
168 |
echo ' \' >> objlist.inc |
169 |
echo -n " " ${fname:r}.o >> objlist.inc |
170 |
end |
171 |
echo " " >> srclist.inc |
172 |
echo " " >> f77list.inc |
173 |
echo " " >> objlist.inc |
174 |
else |
175 |
echo No source files found...\! |
176 |
exit |
177 |
endif |
178 |
|
179 |
# Convert lists of directories into command-line options |
180 |
foreach inc ($INCLUDEDIRS) |
181 |
set INCLUDES = ($INCLUDES -I$inc) |
182 |
end |
183 |
set SRCSTARS = ( ) |
184 |
foreach dr ($SOURCEDIRS) |
185 |
set SRCSTARS = ("${SRCSTARS}" $dr/\*.F) |
186 |
end |
187 |
|
188 |
set THISHOSTNAME = ( `hostname` ) |
189 |
set THISCWD = ( `pwd` ) |
190 |
set THISDATE = ( `date` ) |
191 |
|
192 |
########################################### |
193 |
## This is the template for the makefile ## |
194 |
########################################### |
195 |
echo Creating makefile: $mfile |
196 |
echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile} |
197 |
echo "# This makefile was generated automatically pn" >> ${mfile} |
198 |
echo "# $THISDATE" >> ${mfile} |
199 |
echo "# by the command:" >> ${mfile} |
200 |
echo "# ${0} $argv" >> ${mfile} |
201 |
echo "# executed by:" >> ${mfile} |
202 |
echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> ${mfile} |
203 |
cat >> ${mfile} <<EOF |
204 |
# |
205 |
# BUILDDIR : Directory where object files are written |
206 |
# SOURCEDIRS : Directories containing the source (.F) files |
207 |
# INCLUDEDIRS : Directories containing the header-source (.h) files |
208 |
# EXEDIR : Directory where executable that is generated is written |
209 |
# EXECUTABLE : Full path of executable binary |
210 |
# |
211 |
# CPP : C-preprocessor command |
212 |
# INCLUDES : Directories searched for header files |
213 |
# DEFINES : Macro definitions for CPP |
214 |
# KPP : Special preprocessor command (specific to platform) |
215 |
# KFLAGS : Flags for KPP |
216 |
# FC : Fortran compiler command |
217 |
# FFLAGS : Configuration/debugging options for FC |
218 |
# FOPTIM : Optimization options for FC |
219 |
# LINK : Command for link editor program |
220 |
# LIBS : Library flags /or/ additional optimization/debugging flags |
221 |
|
222 |
BUILDDIR = ${BUILDDIR} |
223 |
SOURCEDIRS = ${SOURCEDIRS} |
224 |
INCLUDEDIRS = ${INCLUDEDIRS} |
225 |
EXEDIR = ${EXEDIR} |
226 |
EXECUTABLE = \$(EXEDIR)${EXECUTABLE} |
227 |
|
228 |
# Unix ln (link) |
229 |
LN = ${LN} |
230 |
# C preprocessor |
231 |
CPP = ${CPP} |
232 |
# Special preprocessor (KAP on DECs, FPP on Crays) |
233 |
KPP = ${KPP} |
234 |
# Fortran compiler |
235 |
FC = ${FC} |
236 |
# Link editor |
237 |
LINK = ${LINK} |
238 |
|
239 |
# Defines for CPP |
240 |
DEFINES = ${DEFINES} |
241 |
# Includes for CPP |
242 |
INCLUDES = ${INCLUDES} |
243 |
# Flags for KPP |
244 |
KFLAGS1 = ${KFLAGS1} |
245 |
KFLAGS2 = ${KFLAGS2} |
246 |
# Optim./debug for FC |
247 |
FFLAGS = ${FFLAGS} |
248 |
FOPTIM = ${FOPTIM} |
249 |
# Files that should not be optimized |
250 |
NOOPTFILES = ${NOOPTFILES} |
251 |
NOOPTFLAGS = ${NOOPTFLAGS} |
252 |
# Flags and libraries needed for linking |
253 |
LIBS = ${LIBS} |
254 |
|
255 |
EOF |
256 |
|
257 |
cat srclist.inc >> ${mfile} |
258 |
cat f77list.inc >> ${mfile} |
259 |
cat objlist.inc >> ${mfile} |
260 |
rm -f srclist.inc f77list.inc objlist.inc |
261 |
|
262 |
cat >> ${mfile} <<EOF |
263 |
|
264 |
.SUFFIXES: |
265 |
.SUFFIXES: .o .f .p .F |
266 |
|
267 |
all: \$(EXECUTABLE) |
268 |
\$(EXECUTABLE): \$(OBJFILES) |
269 |
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) |
270 |
links: |
271 |
@-\$(LN) $SRCSTARS . |
272 |
depend: |
273 |
@make links |
274 |
makedepend -o .f \$(INCLUDES) \$(SRCFILES) |
275 |
clean: |
276 |
-rm -rf *.o *.f *.p ${RMFILES} |
277 |
|
278 |
# The normal chain of rules is ( .F - .f - .o ) |
279 |
.F.f: |
280 |
\$(CPP) \$(DEFINES) \$(INCLUDES) \$< > \$@ |
281 |
.f.o: |
282 |
\$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< |
283 |
|
284 |
# Special exceptions that use the ( .F - .p - .f - .o ) rule-chain |
285 |
.F.p: |
286 |
\$(CPP) \$(DEFINES) \$(INCLUDES) \$< > \$@ |
287 |
.p.f: |
288 |
\$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< |
289 |
EOF |
290 |
|
291 |
# Make list of "exceptions" that need ".p" files |
292 |
foreach sf ($KPPFILES) |
293 |
set fname=( ${sf:t} ) |
294 |
echo "${fname:r}.f: ${fname:r}.p" >> ${mfile} |
295 |
end |
296 |
foreach sf ($NOOPTFILES) |
297 |
set fname=( ${sf:t} ) |
298 |
echo "${fname:r}.o: ${fname:r}.f" >> ${mfile} |
299 |
echo ' $(FC) $(FFLAGS) $(NOOPTFLAGS) -c $<' >> ${mfile} |
300 |
end |
301 |
echo >> ${mfile} |
302 |
echo "# DO NOT DELETE" >> ${mfile} |
303 |
|
304 |
exit |