1 |
#!/bin/csh -f |
2 |
# |
3 |
# $Header: /u/gcmpack/models/MITgcmUV/tools/genmake.sgi,v 1.3 1998/04/24 19:32:20 adcroft Exp $ |
4 |
# |
5 |
# Makefile generator for MITgcm UV codes |
6 |
# |
7 |
|
8 |
# Generate make files for SGI IRIX system |
9 |
set mfile = ( Makefile.sgi ) |
10 |
set mach = ( 'SGI IRIX/mips4' ) |
11 |
|
12 |
# Directories for source, includes, binaries and executables |
13 |
# Note |
14 |
# o If you prefer/need everything under a single directory |
15 |
# copy everything in ../psupp/src, ../model/src, |
16 |
# ../psupp/inc and ../model/inc into a directory and then |
17 |
# edit the paths below to read |
18 |
# set PSUPP_SDIR = ( ) |
19 |
# set MODEL_SDIR = ( ) |
20 |
# set PSUPP_IDIR = ( ) |
21 |
# set MODEL_IDIR = ( ) |
22 |
# set TDIR = ( ) |
23 |
# set BDIR = ( ) |
24 |
# set EDIR = ( ) |
25 |
set PSUPP_SDIR = ( ../eesupp/src/ ) |
26 |
set MODEL_SDIR = ( ../model/src/ ) |
27 |
set PSUPP_IDIR = ( ../eesupp/inc/ ) |
28 |
set MODEL_IDIR = ( ../model/inc/ ) |
29 |
set TDIR = ( ../tools/ ) |
30 |
set BDIR = ( ../bin/ ) |
31 |
set EDIR = ( ../exe/ ) |
32 |
set EXE = ( MITgcmUV ) |
33 |
|
34 |
set CPP = ( '/lib/cpp -P' ) |
35 |
set FCOMP = ( 'f77' ) |
36 |
set LINK = ( 'f77' ) |
37 |
#set LINK = ( 'mpif77' ) |
38 |
set DEFINES = ( '-DUSE_IRIX' ) |
39 |
set F77FLAGS = ( '-extend_source -mp -mpio -bytereclen -Ofast -r10000' ) |
40 |
set INCLUDES = ( '-I.' ) |
41 |
#set INCLUDES = ( '-I. -I/usr/local/mpi/include' ) |
42 |
set LIBS = ( ' ' ) |
43 |
|
44 |
echo "Creating make file ${mfile} " |
45 |
echo "#" > ${mfile} |
46 |
echo "# Multithreaded + multi-processing makefile for $mach " >> ${mfile} |
47 |
echo "# This make file was generated automatically by the command" >> ${mfile} |
48 |
echo "# " \"${0}\" >> ${mfile} |
49 |
echo "# on `hostname`:`pwd` " >> ${mfile} |
50 |
echo "# " `date` >> ${mfile} |
51 |
echo "# by $user" >> ${mfile} |
52 |
echo "# " >> ${mfile} |
53 |
|
54 |
cat >> ${mfile} <<EOF |
55 |
|
56 |
# PSUPP_SDIR: Directory holding parallel support routines |
57 |
# MODEL_SDIR: Directory model code |
58 |
# PSUPP_IDIR: Directory holding parallel support header files |
59 |
# MODEL_IDIR: Directory model header files |
60 |
# TDIR : Directory where build tools are stored |
61 |
# BDIR : Directory where object files are written |
62 |
# EDIR : Directory where executable that is generated is written |
63 |
# INCLUDES : Directories searched for header files |
64 |
# CPP : C-preprocessor command |
65 |
# FCOMP : Fortran compiler command |
66 |
# LINK : Command for link editor program |
67 |
# Note |
68 |
# ==== |
69 |
# o PSUPP_SDIR ... EDIR can all be set to the current directory if |
70 |
# you want to organise things that way. Alternatively they can be |
71 |
# set to different directories so that code can be kept on a backed |
72 |
# up disk while object files and executables are created on scratch |
73 |
# disks. I prefer this latter setup! |
74 |
# o Under Solaris if the disk on which the compiler is generating |
75 |
# object files and executables is mounted via NFS rather than being |
76 |
# a local SCSI disk compilation times can increase by a factor of |
77 |
# ten! |
78 |
PSUPP_SDIR = ${PSUPP_SDIR} |
79 |
MODEL_SDIR = ${MODEL_SDIR} |
80 |
PSUPP_IDIR = ${PSUPP_IDIR} |
81 |
MODEL_IDIR = ${MODEL_IDIR} |
82 |
TDIR = ${TDIR} |
83 |
BDIR = ${BDIR} |
84 |
EDIR = ${EDIR} |
85 |
EXE = \$(EDIR)${EXE} |
86 |
|
87 |
# C preprocessor |
88 |
CPP = ${CPP} |
89 |
# Fortran compiler |
90 |
FC = ${FCOMP} |
91 |
# Link editor |
92 |
LINK = ${LINK} |
93 |
|
94 |
# Defines for CPP |
95 |
DEFINES = ${DEFINES} |
96 |
# Includes for CPP |
97 |
INCLUDES = ${INCLUDES} -I\$(PSUPP_IDIR) -I\$(MODEL_IDIR) |
98 |
# Optim./debug for FC |
99 |
F77FLAGS = ${F77FLAGS} |
100 |
EOF |
101 |
|
102 |
set psupp_slist = ( ) |
103 |
set psupp_olist = ( ) |
104 |
if ( ${PSUPP_SDIR} != ${MODEL_SDIR} ) then |
105 |
set flist = `ls -1 ${PSUPP_SDIR} | grep '.*\.F'` |
106 |
if ( "${flist}" != "" ) then |
107 |
foreach f ( $flist ) |
108 |
set fname = ( ${f:t} ) |
109 |
set pf = ( ${fname:r}.f ) |
110 |
set of = ( ${fname:r}.o ) |
111 |
set psupp_slist = ( ${psupp_slist} ${f} ) |
112 |
set psupp_olist = ( ${psupp_olist} ${of} ) |
113 |
end |
114 |
endif |
115 |
endif |
116 |
|
117 |
set model_slist = ( ) |
118 |
set model_olist = ( ) |
119 |
set flist = `ls -1 ${MODEL_SDIR} | grep '.*\.F'` |
120 |
if ( "${flist}" != "" ) then |
121 |
foreach f ( ${flist} ) |
122 |
set fname = ( ${f:t} ) |
123 |
set pf = ( ${fname:r}.f ) |
124 |
set of = ( ${fname:r}.o ) |
125 |
set model_slist = ( ${model_slist} ${f} ) |
126 |
set model_olist = ( ${model_olist} ${of} ) |
127 |
end |
128 |
endif |
129 |
|
130 |
echo " " >> ${mfile} |
131 |
echo "# =========== " >> ${mfile} |
132 |
echo "# File lists " >> ${mfile} |
133 |
echo "# =========== " >> ${mfile} |
134 |
if ( $#psupp_olist == 0 ) then |
135 |
echo 'psupp_objs = ' >> ${mfile} |
136 |
else if ( $#psupp_olist == 1 ) then |
137 |
echo 'psupp_objs = '${psupp_olist} >> ${mfile} |
138 |
else |
139 |
echo 'psupp_objs = '$psupp_olist[1] '\' >> ${mfile} |
140 |
set psupp_count = 2 |
141 |
while ( $psupp_count < $#psupp_olist ) |
142 |
echo ' '$psupp_olist[$psupp_count] '\' >> ${mfile} |
143 |
@ psupp_count = $psupp_count + 1 |
144 |
end |
145 |
echo ' '$psupp_olist[$#psupp_olist] >> ${mfile} |
146 |
endif |
147 |
echo " " >> ${mfile} |
148 |
if ( $#psupp_slist == 0 ) then |
149 |
echo 'psupp_srcs = ' >> ${mfile} |
150 |
else if ( $#psupp_slist == 1 ) then |
151 |
echo 'psupp_srcs = $(PSUPP_SDIR)'${psupp_slist} >> ${mfile} |
152 |
else |
153 |
echo 'psupp_srcs = $(PSUPP_SDIR)'$psupp_slist[1] '\' >> ${mfile} |
154 |
set psupp_count = 2 |
155 |
while ( $psupp_count < $#psupp_slist ) |
156 |
echo ' $(PSUPP_SDIR)'$psupp_slist[$psupp_count] '\' >> ${mfile} |
157 |
@ psupp_count = $psupp_count + 1 |
158 |
end |
159 |
echo ' $(PSUPP_SDIR)'$psupp_slist[$#psupp_slist] >> ${mfile} |
160 |
endif |
161 |
echo " " >> ${mfile} |
162 |
if ( $#model_olist == 0 ) then |
163 |
echo 'model_objs = ' >> ${mfile} |
164 |
else if ( $#model_olist == 1 ) then |
165 |
echo 'model_objs = '${model_olist} >> ${mfile} |
166 |
else |
167 |
echo 'model_objs = '$model_olist[1] '\' >> ${mfile} |
168 |
set model_count = 2 |
169 |
while ( $model_count < $#model_olist ) |
170 |
echo ' '$model_olist[$model_count] '\' >> ${mfile} |
171 |
@ model_count = $model_count + 1 |
172 |
end |
173 |
echo ' '$model_olist[$#model_olist] >> ${mfile} |
174 |
endif |
175 |
echo " " >> ${mfile} |
176 |
if ( $#model_slist == 0 ) then |
177 |
echo 'model_srcs = ' >> ${mfile} |
178 |
else if ( $#model_slist == 1 ) then |
179 |
echo 'model_srcs = $(MODEL_SDIR)'${model_slist} >> ${mfile} |
180 |
else |
181 |
echo 'model_srcs = $(MODEL_SDIR)'$model_slist[1] '\' >> ${mfile} |
182 |
set model_count = 2 |
183 |
while ( $model_count < $#model_slist ) |
184 |
echo ' $(MODEL_SDIR)'$model_slist[$model_count] '\' >> ${mfile} |
185 |
@ model_count = $model_count + 1 |
186 |
end |
187 |
echo ' $(MODEL_SDIR)'$model_slist[$#model_slist] >> ${mfile} |
188 |
endif |
189 |
echo " " >> ${mfile} |
190 |
echo 'objs = $(psupp_objs) $(model_objs)' >> ${mfile} |
191 |
echo 'srcs = $(psupp_srcs) $(model_srcs)' >> ${mfile} |
192 |
echo " " >> ${mfile} |
193 |
echo "# =========== " >> ${mfile} |
194 |
echo "# Begin rules " >> ${mfile} |
195 |
echo "# =========== " >> ${mfile} |
196 |
echo " " >> ${mfile} |
197 |
echo ".SUFFIXES: " >> ${mfile} |
198 |
echo ".SUFFIXES: .o .f .F" >> ${mfile} |
199 |
echo " " >> ${mfile} |
200 |
echo '$(EXE): $(objs) ' >> ${mfile} |
201 |
echo ' $(LINK) -o $(EXE) $(F77FLAGS) $(objs)' >> ${mfile} |
202 |
echo " " >> ${mfile} |
203 |
echo '.F.f:' >> ${mfile} |
204 |
echo ' $(CPP) $(INCLUDES) $(DEFINES) $< > $@' >> ${mfile} |
205 |
echo '.f.o:' >> ${mfile} |
206 |
echo ' $(FC) $(F77FLAGS) -c $<' >> ${mfile} |
207 |
echo " " >> ${mfile} |
208 |
echo 'clean: ' >> ${mfile} |
209 |
echo ' -rm -f *.o *.f ' >> ${mfile} |
210 |
echo ' -rm -rf rii_files' >> ${mfile} |
211 |
echo 'Clean: ' >> ${mfile} |
212 |
echo ' @make clean ' >> ${mfile} |
213 |
echo ' -rm -f *.h *.F ' >> ${mfile} |
214 |
echo " " >> ${mfile} |
215 |
echo 'depend: ' >> ${mfile} |
216 |
echo ' ln -sf $(PSUPP_SDIR)/*.F $(MODEL_SDIR)/*.F .' >> ${mfile} |
217 |
echo '# ln -sf $(PSUPP_IDIR)/*.h $(MODEL_IDIR)/*.h .' >> ${mfile} |
218 |
echo ' makedepend $(INCLUDES) -o .f *.F' >> ${mfile} |
219 |
echo " " >> ${mfile} |