/[MITgcm]/MITgcm/tools/genmake.sun
ViewVC logotype

Contents of /MITgcm/tools/genmake.sun

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3.2.1 - (show annotations) (download)
Sat Jun 20 21:15:24 1998 UTC (25 years, 9 months ago) by cnh
Branch: checkpoint7-4degree-ref
Changes since 1.3: +2 -2 lines
Changed executable name to mitgcmuv

1 #!/bin/csh -f
2 #
3 # $Header: /u/gcmpack/models/MITgcmUV/tools/genmake.sun,v 1.3 1998/05/18 15:11:21 cnh Exp $
4 #
5 # Makefile generator for MITgcm UV codes
6 #
7
8 # Generate make files for Sun SOLARIS system
9 set mfile = ( Makefile.sun )
10 set mach = ( 'Sun/SOLARIS' )
11
12 # ***************************************************************************************************
13 # Directories for source, includes, binaries and executables
14 # ***************************************************************************************************
15 # Note
16 # o If you prefer/need everything under a single directory
17 # copy everything in ../eesupp/src, ../model/src,
18 # ../eesupp/inc and ../model/inc into a directory and then
19 # edit the paths below to read
20 # set EESUPP_SDIR = ( )
21 # set MODEL_SDIR = ( )
22 # set EESUPP_IDIR = ( )
23 # set MODEL_IDIR = ( )
24 # set TDIR = ( )
25 # set BDIR = ( )
26 # set EDIR = ( )
27 set EESUPP_SDIR = ( ../eesupp/src/ )
28 set MODEL_SDIR = ( ../model/src/ )
29 set EESUPP_IDIR = ( ../eesupp/inc/ )
30 set MODEL_IDIR = ( ../model/inc/ )
31 set TDIR = ( ../tools/ )
32 set BDIR = ( ../bin/ )
33 set EDIR = ( ../exe/ )
34 set EXE = ( mitgcmuv )
35
36 # ***************************************************************************************************
37 # Pathnames and arguments for the commands used on this platform
38 # ***************************************************************************************************
39 set CPP = ( '/usr/ccs/lib/cpp -P $(INCLUDES) -DTARGET_SUN' )
40 set FCOMP = ( 'f77 -stackvar -O5 -explicitpar -vpara -loopinfo -c -e -u -noautopar' \
41 '$(INCLUDES)' )
42 set FCOMP0 = ( 'f77 -stackvar -g -O0 -c -e -u $(INCLUDES)' )
43 set LINK = ( 'f77 -O5 -explicitpar -vpara -loopinfo -e -u -noautopar' )
44 set LINKOPTS = ('-L/usr/local/mpi/lib/solaris/ch_shmem -lmpi -lthread ' \
45 '-lsocket -lnsl -fast' )
46 set INCLUDES = ( '-I. -I$(EESUPP_IDIR) -I$(MODEL_IDIR) ' \
47 '-I/usr/local/mpi/include' )
48 set MAKEDEPEND = ( /usr/openwin/bin/makedepend )
49
50 # ***************************************************************************************************
51 # Write Makefile.xxx header
52 # ***************************************************************************************************
53 echo "Creating make file ${mfile} "
54 echo "#" > ${mfile}
55 echo "# Multithreaded + multi-processing makefile for $mach " >> ${mfile}
56 echo "# This make file was generated automatically by the command" >> ${mfile}
57 echo "# " \"${0}\" >> ${mfile}
58 echo "# on `hostname`:`pwd` " >> ${mfile}
59 echo "# " `date` >> ${mfile}
60 echo "# by $user" >> ${mfile}
61 echo "# Notes " >> ${mfile}
62 echo "# ===== " >> ${mfile}
63 echo "# o Solaris parallel threads are controlled by" >> ${mfile}
64 echo "# setenv PARALLEL " >> ${mfile}
65 echo "# o The -stackvar option is important for multi-threaded" >> ${mfile}
66 echo "# execution. Without it local variables may be allocated to" >> ${mfile}
67 echo "# global bss storage which means they are not private " >> ${mfile}
68 echo "# per thread. " >> ${mfile}
69 echo "# " >> ${mfile}
70 cat >> ${mfile} <<EOF
71 # EESUPP_SDIR: Directory holding parallel support routines
72 # MODEL_SDIR : Directory model code
73 # EESUPP_IDIR: Directory holding parallel support header files
74 # MODEL_IDIR : Directory model header files
75 # TDIR : Directory where build tools are stored
76 # BDIR : Directory where object files are written
77 # EDIR : Directory where executable that is generated is written
78 # INCLUDES : Directories searched for header files
79 # CPP : C-preprocessor command
80 # FCOMP : Fortran compiler command
81 # LINK : Command for link editor program
82 # Note
83 # ====
84 # o EESUPP_SDIR ... EDIR can all be set to the current directory if
85 # you want to organise things that way. Alternatively they can be
86 # set to different directories so that code can be kept on a backed
87 # up disk while object files and executables are created on scratch
88 # disks. I prefer this latter setup!
89 # o Under Solaris if the disk on which the compiler is generating
90 # object files and executables is mounted via NFS rather than being
91 # a local SCSI disk compilation times can increase by a factor of
92 # ten!
93 EESUPP_SDIR = ${EESUPP_SDIR}
94 MODEL_SDIR = ${MODEL_SDIR}
95 EESUPP_IDIR = ${EESUPP_IDIR}
96 MODEL_IDIR = ${MODEL_IDIR}
97 TDIR = ${TDIR}
98 BDIR = ${BDIR}
99 EDIR = ${EDIR}
100 INCLUDES = ${INCLUDES}
101 EXE = \$(EDIR)${EXE}
102 EOF
103 echo "# C preprocessor " >> ${mfile}
104 echo 'CPP =' ${CPP} >> ${mfile}
105 echo "# Fortran compiler " >> ${mfile}
106 echo 'FCOMP = '${FCOMP} >> ${mfile}
107 echo 'FCOMP0 = '${FCOMP0} >> ${mfile}
108 echo "# Link editor " >> ${mfile}
109 echo 'LINK = '${LINK} >> ${mfile}
110 echo 'LINKOPTS = '${LINKOPTS} >> ${mfile}
111 echo "# Header dependency" >> ${mfile}
112 echo 'MAKEDEPEND = '${MAKEDEPEND} >> ${mfile}
113 echo " " >> ${mfile}
114
115 # ***************************************************************************************************
116 # Generate build commands for individual .F files
117 # ***************************************************************************************************
118 # Execution environment code
119 if ( ${EESUPP_SDIR} != ${MODEL_SDIR} ) then
120 set sdir = ( ${EESUPP_SDIR} )
121 set sdir_pref = ( '$(EESUPP_SDIR)' )
122 set rp = rp1
123 goto make-mf-entries
124 rp1:
125 set eesupp_files = ( $files )
126 set eesupp_slist = ( $slist )
127 set eesupp_olist = ( $olist )
128 endif
129 # "Model" code
130 set sdir = ( ${MODEL_SDIR} )
131 set sdir_pref = ( '$(MODEL_SDIR)' )
132 set rp = rp2
133 goto make-mf-entries
134 rp2:
135 set model_files = ( $files )
136 set model_slist = ( $slist )
137 set model_olist = ( $olist )
138
139 # ***************************************************************************************************
140 # Generate file lists for various mmake utilities
141 # ***************************************************************************************************
142 echo " " >> ${mfile}
143 echo "# =========== " >> ${mfile}
144 echo "# File lists " >> ${mfile}
145 echo "# =========== " >> ${mfile}
146 set flist = ( ${eesupp_olist} ); set fpref = ( );
147 set vnam = ( eesupp_objs )
148 set rp = rp3
149 goto make-mf-list
150 rp3:
151 set flist = ( ${eesupp_slist} ); set fpref = ( '$(EESUPP_SDIR)' );
152 set vnam = ( eesupp_srcs )
153 set rp = rp4
154 goto make-mf-list
155 rp4:
156 set flist = ( ${eesupp_slist} ); set fpref = ( );
157 set vnam = ( eesupp_sfil )
158 set rp = rp5
159 goto make-mf-list
160 rp5:
161 set flist = ( ${model_olist} ); set fpref = ( );
162 set vnam = ( model_objs )
163 set rp = rp6
164 goto make-mf-list
165 rp6:
166 set flist = ( ${model_slist} ); set fpref = ( '$(MODEL_SDIR)' );
167 set vnam = ( model_srcs )
168 set rp = rp7
169 goto make-mf-list
170 rp7:
171 set flist = ( ${model_slist} ); set fpref = ( );
172 set vnam = ( model_sfil )
173 set rp = rp8
174 goto make-mf-list
175 rp8:
176 echo 'objs = $(eesupp_objs) $(model_objs)' >> ${mfile}
177 echo 'srcs = $(eesupp_srcs) $(model_srcs)' >> ${mfile}
178 echo 'sfil = $(eesupp_sfil) $(model_sfil)' >> ${mfile}
179 echo " " >> ${mfile}
180
181 # ***************************************************************************************************
182 # Write top-level rules for building the executable,
183 # generating dependencies etc...
184 # ***************************************************************************************************
185 echo "# =========== " >> ${mfile}
186 echo "# Begin rules " >> ${mfile}
187 echo "# =========== " >> ${mfile}
188 echo " " >> ${mfile}
189 echo '$(EXE): $(objs) ' >> ${mfile}
190 echo ' $(LINK) -o $(EXE) $(objs) $(LINKOPTS)' >> ${mfile}
191 echo " " >> ${mfile}
192 echo 'clean: ' >> ${mfile}
193 echo ' rm *.o *.f *.out *.cmp ' >> ${mfile}
194 echo " " >> ${mfile}
195 echo 'depend: ' >> ${mfile}
196 echo ' @-ln -s $(srcs) . ;$(MAKEDEPEND) -o .f -f $(TDIR)'${mfile}' $(INCLUDES) $(sfil) ' >> ${mfile}
197 echo " " >> ${mfile}
198
199 # ***************************************************************************************************
200 # Add per file dependencies
201 # ***************************************************************************************************
202 cat ${mfile}.$$ >> ${mfile}
203 \rm ${mfile}.$$
204
205 # ***************************************************************************************************
206 # THE END
207 # ***************************************************************************************************
208 exit
209
210 # ***************************************************************************************************
211 # This block generates the commands to turn a .F file into a .o file.
212 # It may need to be customised for different platforms.
213 # ***************************************************************************************************
214 make-mf-entries:
215 set files = ( );
216 set slist = ( );
217 set olist = ( );
218 set flist = `ls -1 ${sdir} | grep '.*\.F'`
219 if ( "${flist}" != "" ) then
220 foreach f ( $flist )
221 set fname = ( ${f:t} )
222 set pf = ( ${fname:r}.f )
223 set of = ( ${fname:r}.o )
224 echo ${pf}: "${sdir_pref}"${fname} >> ${mfile}.$$
225 echo ' @echo Preprocessing '"${sdir_pref}"${fname} >> ${mfile}.$$
226 echo ' @ $(CPP) '"${sdir_pref}"${fname}' > '$pf >> ${mfile}.$$
227 echo ${of}: ${pf} >> ${mfile}.$$
228 echo ' @echo Compiling '${pf} >> ${mfile}.$$
229 # Compile fbar.F without optimisation. This file holds the barrier
230 # routines which rely on shared variables which can be accessed
231 # concurrently. Optimisation knows nothing about parallel access
232 # it assumes sequential semantics and rearranges code on that
233 # basis. This can be harmful here!
234 if ( "${fname}" == "barrier.F" || "${fname}" == "different_multiple.F" ) then
235 echo ' @ $(FCOMP0) '$pf >> ${mfile}.$$
236 else
237 echo ' @ $(FCOMP) '$pf >> ${mfile}.$$
238 endif
239 set files = ( ${files} ${fname} )
240 set slist = ( ${slist} ${f} )
241 set olist = ( ${olist} ${of} )
242 end
243 endif
244 endif
245 goto ${rp}
246
247 make-mf-list:
248 if ( $#flist == 0 ) then
249 echo ${vnam} = >> ${mfile}
250 else if ( $#flist == 1 ) then
251 echo ${vnam} = "${fpref}"${flist} >> ${mfile}
252 else
253 echo ${vnam} = "${fpref}"$flist[1] '\' >> ${mfile}
254 set count = 2
255 while ( $count < $#flist )
256 echo ' '"${fpref}"$flist[$count] '\' >> ${mfile}
257 @ count = $count + 1
258 end
259 echo ' '"${fpref}"$flist[$#flist] >> ${mfile}
260 endif
261 echo " " >> ${mfile}
262 goto $rp
263
264 # $ Id: $

  ViewVC Help
Powered by ViewVC 1.1.22