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

Contents of /MITgcm/tools/genmake.hp

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


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

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

  ViewVC Help
Powered by ViewVC 1.1.22