/[MITgcm]/MITgcm/tools/genmake2
ViewVC logotype

Contents of /MITgcm/tools/genmake2

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


Revision 1.238 - (show annotations) (download)
Tue Aug 28 21:11:22 2012 UTC (7 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint63s
Changes since 1.237: +53 -61 lines
- define variable MAKE within Makefile and use it in place of 'make';
- update AD_CONFIG.h (if needed) before building any of the executable
  (forward, adjoint or tangent-lin); this involves a 2nd invocation of make;
  and add the usual #ifndef/#define AD_CONFIG_H in AD_CONFIG.h;

1 #! /usr/bin/env bash
2 #
3 # $Header: /u/gcmpack/MITgcm/tools/genmake2,v 1.237 2012/08/24 23:41:17 jmc Exp $
4 # $Name: $
5 #
6 # Makefile generator for MITgcm UV codes
7 # created by cnh 03/98
8 # adapted by aja 06/98
9 # modified by aja 01/00
10 # rewritten in bash by eh3 08/03
11
12 # Explain usage
13 usage() {
14 cat <<EOF
15
16 Usage: "$0" [OPTIONS]
17 where [OPTIONS] can be:
18
19 -help | --help | -h | --h
20 Print this help message and exit.
21
22 -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
23 -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
24 Use "NAME" as the adoptfile. By default, the file at
25 "tools/adjoint_options/adjoint_default" will be used.
26
27 -nooptfile | --nooptfile
28 -optfile NAME | --optfile NAME | -of NAME | --of NAME
29 -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
30 Use "NAME" as the optfile. By default, an attempt will be
31 made to find an appropriate "standard" optfile in the
32 tools/build_options/ directory.
33
34 -pdepend NAME | --pdepend NAME
35 -pdepend=NAME | --pdepend=NAME
36 Get package dependency information from "NAME".
37
38 -pgroups NAME | --pgroups NAME
39 -pgroups=NAME | --pgroups=NAME
40 Get the package groups information from "NAME".
41
42 -bash NAME
43 Explicitly specify the Bourne or BASH shell to use
44
45 -make NAME | -m NAME
46 --make=NAME | -m=NAME
47 Use "NAME" for the MAKE program. The default is "make" but
48 many platforms, "gmake" is the preferred choice.
49
50 -makefile NAME | -mf NAME
51 --makefile=NAME | -mf=NAME
52 Call the makefile "NAME". The default is "Makefile".
53
54 -makedepend NAME | -md NAME
55 --makedepend=NAME | -md=NAME
56 Use "NAME" for the MAKEDEPEND program.
57
58 -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
59 -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
60 Specify the location of the MITgcm ROOTDIR as "NAME".
61 By default, genamke will try to find the location by
62 looking in parent directories (up to the 5th parent).
63
64 -mods NAME | --mods NAME | -mo NAME | --mo NAME
65 -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME
66 Here, "NAME" specifies a list of directories that are
67 used for additional source code. Files found in the
68 "mods list" are given preference over files of the same
69 name found elsewhere.
70
71 -disable NAME | --disable NAME
72 -disable=NAME | --disable=NAME
73 Here "NAME" specifies a list of packages that we don't
74 want to use. If this violates package dependencies,
75 genamke will exit with an error message.
76
77 -enable NAME | --enable NAME
78 -enable=NAME | --enable=NAME
79 Here "NAME" specifies a list of packages that we wish
80 to specifically enable. If this violates package
81 dependencies, genamke will exit with an error message.
82
83 -standarddirs NAME | --standarddirs NAME
84 -standarddirs=NAME | --standarddirs=NAME
85 Here, "NAME" specifies a list of directories to be
86 used as the "standard" code.
87
88 -fortran NAME | --fortran NAME | -fc NAME | --fc NAME
89 -fc=NAME | --fc=NAME
90 Use "NAME" as the fortran compiler. By default, genmake
91 will search for a working compiler by trying a list of
92 "usual suspects" such as g77, f77, etc.
93
94 -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
95 Use "NAME" as the C compiler. By default, genmake
96 will search for a working compiler by trying a list of
97 "usual suspects" such as gcc, c89, cc, etc.
98
99 -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4
100 Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW)
101 *only* works if CPP_EEOPTIONS.h allows this.
102
103 -ignoretime | -ignore_time | --ignoretime | --ignore_time
104 Ignore all the "wall clock" routines entirely. This will
105 not in any way hurt the model results -- it simply means
106 that the code that checks how long the model spends in
107 various routines will give junk values.
108
109 -ts | --ts
110 Produce timing information per timestep
111 -papis | --papis
112 Produce summary MFlop/s (and IPC) with PAPI per timestep
113 -pcls | --pcls
114 Produce summary MFlop/s etc. with PCL per timestep
115 -foolad | --foolad
116 Fool the AD code generator
117 -papi | --papi
118 Performance analysis with PAPI
119 -pcl | --pcl
120 Performance analysis with PCL
121 -hpmt | --hpmt
122 Performance analysis with the HPM Toolkit
123
124 -ieee | --ieee
125 use IEEE numerics. Note that this option *only* works
126 if it is supported by the OPTFILE that is being used.
127 -devel | --devel
128 Add additional warning and debugging flags for development
129 (if supported by the OPTFILE); also switch to IEEE numerics.
130 -gsl | --gsl
131 Use GSL to control floating point rounding and precision
132
133 -mpi | --mpi
134 Include MPI header files and link to MPI libraries
135 -mpi=PATH | --mpi=PATH
136 Include MPI header files and link to MPI libraries using MPI_ROOT
137 set to PATH. i.e. Include files from \$PATH/include, link to libraries
138 from \$PATH/lib and use binaries from \$PATH/bin.
139
140 -omp | --omp
141 Activate OpenMP code + use Compiler option OMPFLAG
142 -omp=OMPFLAG | --omp=OMPFLAG
143 Activate OpenMP code + use Compiler option OMPFLAG
144
145 -es | --es | -embed-source | --embed-source
146 Embed a tarball containing the full source code
147 (including the Makefile, etc.) used to build the
148 executable [off by default]
149
150 -ds | --ds
151 Report genmake internal variables status (DUMPSTATE)
152 to file "genmake_state" (for debug purpose)
153
154 While it is most often a single word, the "NAME" variables specified
155 above can in many cases be a space-delimited string such as:
156
157 --enable pkg1 --enable 'pkg1 pkg2' --enable 'pkg1 pkg2 pkg3'
158 -mods=dir1 -mods='dir1' -mods='dir1 dir2 dir3'
159 -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'
160
161 which, depending upon your shell, may need to be single-quoted.
162
163 For more detailed genmake documentation, please see:
164
165 http://mitgcm.org/public/devel_HOWTO/
166
167 EOF
168
169 exit 1
170 }
171
172 # Search for particular CPP #cmds associated with packages
173 # usage: test_for_package_in_cpp_options CPP_file package_name
174 test_for_package_in_cpp_options() {
175 cpp_options=$1
176 pkg=$2
177 test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg[ ]"
178 test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg[ ]"
179 test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg[ ]"
180 test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg[ ]"
181 test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg$"
182 test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg$"
183 test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg$"
184 test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg$"
185 }
186
187 # Search for particular CPP #cmds associated with MPI
188 # usage: test_for_mpi_in_cpp_eeoptions CPP_file
189 test_for_mpi_in_cpp_eeoptions() {
190 cpp_options=$1
191 test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI[ ]"
192 test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI[ ]"
193 test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI[ ]"
194 test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI[ ]"
195 test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI$"
196 test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI$"
197 test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI$"
198 test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI$"
199 }
200
201 # Search for particular string in a file. Return 1 if detected, 0 if not
202 # usage: test_for_string_in_file file string
203 test_for_string_in_file() {
204 file=$1
205 strng=$2
206 grep -i "$strng" $file > /dev/null 2>&1
207 RETVAL=$?
208 if test "x${RETVAL}" = x0 ; then
209 printf "Error: In $file there is an illegal line: "
210 grep -i "$strng" $file
211 exit 99
212 fi
213 return 0
214 }
215
216 # Read the $ROOTDIR/pkg/pkg_groups file and expand any references to
217 # the package list.
218 expand_pkg_groups() {
219 new_packages=
220 if test -r $PKG_GROUPS ; then
221 cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp
222 cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp
223 matched=0
224 for i in $PACKAGES ; do
225 line=`grep "^ *$i" ./p2.tmp`
226 RETVAL=$?
227 if test "x$RETVAL" = x0 ; then
228 matched=1
229 replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
230 echo " replacing \"$i\" with:$replace"
231 new_packages="$new_packages $replace"
232 else
233 new_packages="$new_packages $i"
234 fi
235 done
236 PACKAGES=$new_packages
237 rm -f ./p[1,2].tmp
238 return $matched
239 else
240 echo "Warning: can't read package groups definition file: $PKG_GROUPS"
241 fi
242 }
243
244 # Check for broken environments (eg. cygwin, MacOSX w/HFS+) that
245 # cannot distinguish [*.F/*.F90] from [*.f/*.f90] files.
246 check_for_broken_Ff() {
247 # Do we have defaults for $FS and/or $FS90 ?
248 tfs=f
249 tfs9=f90
250 if test "x$FS" != x ; then
251 tfs="$FS"
252 fi
253 if test "x$FS90" != x ; then
254 tfs9="$FS90"
255 fi
256
257 # First check the ability to create a *.F/.f pair.
258 cat <<EOF >> genmake_hello.F
259 program hello
260 write(*,*) 'hi'
261 stop
262 end
263 EOF
264 cp genmake_hello.F "genmake_hello."$tfs > /dev/null 2>&1
265 RETVAL=$?
266 if test "x$RETVAL" != x0 ; then
267 if test "x$FS" = x ; then
268 FS='for'
269 FS90='fr9'
270 check_for_broken_Ff
271 else
272 cat <<EOF 2>&1
273 ERROR: Your file system cannot distinguish between *.F and *.f files
274 (fails the "cp" test) and this program cannot find a suitable
275 replacement extension. Please try a different build environment or
276 contact the <MITgcm-support@mitgcm.org> list for help.
277
278 EOF
279 exit -1
280 fi
281 return
282 fi
283 rm -f genmake_hello.*
284
285 # Check the ability of ${MAKE} and ${LN} to use the current set
286 # of extensions.
287 cat <<EOF >> genmake_hello.F
288 program hello
289 write(*,*) 'hi'
290 stop
291 end
292 EOF
293 test -f $MAKEFILE && mv -f $MAKEFILE $MAKEFILE".tst"
294 cat <<EOF >> $MAKEFILE
295 .SUFFIXES:
296 .SUFFIXES: .$tfs .F
297 .F.$tfs:
298 $LN \$< \$@
299 EOF
300 $MAKE -f $MAKEFILE "genmake_hello."$tfs > /dev/null 2>&1
301 RETVAL=$?
302 if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then
303 if test "x$FS" = x ; then
304 FS='for'
305 FS90='fr9'
306 check_for_broken_Ff
307 else
308 echo "ERROR: test: '$MAKE -f $MAKEFILE genmake_hello.$tfs' Failed"
309 echo " see simple makefile: '$MAKEFILE' (left here)"
310 echo " Please check (1) your '$MAKE' command, (2) your '$LN' command"
311 echo " and (3) the allowed sufix '.F' and '.$tfs' in makefile"
312 echo " or contact the <MITgcm-support@mitgcm.org> list for help."
313 echo ""
314 exit -1
315 return
316 fi
317 fi
318 rm -f genmake_hello.* $MAKEFILE
319 test -f $MAKEFILE".tst" && mv -f $MAKEFILE".tst" $MAKEFILE
320
321 # If we make it here, use the extensions
322 FS=$tfs
323 FS90=$tfs9
324 return
325 }
326
327 look_for_makedepend() {
328
329 # The "original" makedepend is part of the Imake system that is
330 # most often distributed with XFree86 or with an XFree86 source
331 # package. As a result, many machines (eg. generic Linux) do not
332 # have a system-default "makedepend" available. For those
333 # systems, we have two fall-back options:
334 #
335 # 1) a makedepend implementation shipped with the cyrus-imapd
336 # package: ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
337 #
338 # 2) a known-buggy xmakedpend shell script
339 #
340 # So the choices are, in order:
341 #
342 # 1) use the user-specified program
343 # 2) use a system-wide default
344 # 3) locally build and use the cyrus implementation
345 # 4) fall back to the buggy local xmakedpend script
346 #
347 echo >> $LOGFILE
348 echo "running: look_for_makedepend()" >> $LOGFILE
349 if test "x${MAKEDEPEND}" != x ; then
350 echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
351 RETVAL=$?
352 if test x"$RETVAL" = x0 ; then
353 build_cyrus_makedepend
354 RETVAL=$?
355 if test "x$RETVAL" != x0 ; then
356 echo "WARNING: unable to build cyrus-makedepend. Try 'makedepend'"
357 MAKEDEPEND=
358 fi
359 else
360 echo "${MAKEDEPEND}" | grep 'tools.xmakedepend' > /dev/null 2>&1
361 RETVAL=$?
362 if test "x$RETVAL" = x0 ; then
363 MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
364 fi
365 echo " --> MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
366 fi
367 fi
368 if test "x${MAKEDEPEND}" = x ; then
369 which makedepend > /dev/null 2>&1
370 RV0=$?
371 test -f $MAKEFILE && mv -f $MAKEFILE $MAKEFILE".tst"
372 # echo 'MAKEFILE="'$MAKEFILE'"'
373 cat <<EOF >> $MAKEFILE
374 # THIS IS A TEST MAKEFILE GENERATED BY "genmake2"
375 #
376 # Some "makedepend" implementations will die if they cannot
377 # find a Makefile -- so this file is here to gives them an
378 # empty one to find and parse.
379 EOF
380 cat <<EOF >> genmake_tc.f
381 program test
382 write(*,*) 'test'
383 stop
384 end
385 EOF
386 makedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1
387 RV1=$?
388 test -f $MAKEFILE && rm -f $MAKEFILE
389 test -f $MAKEFILE".tst" && mv -f $MAKEFILE".tst" $MAKEFILE
390 if test "x${RV0}${RV1}" = x00 ; then
391 MAKEDEPEND=makedepend
392 echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
393 else
394 echo " system-default makedepend not found. Try to build cyrus-makedepend"
395 # Try to build the cyrus implementation
396 build_cyrus_makedepend
397 RETVAL=$?
398 if test "x$RETVAL" != x0 ; then
399 echo "WARNING: unable to build cyrus-makedepend. Use local xmakedepend"
400 MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
401 echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
402 fi
403 fi
404 fi
405 }
406
407 build_cyrus_makedepend() {
408 echo >> $LOGFILE
409 echo "running: build_cyrus_makedepend()" >> $LOGFILE
410 rm -f ./genmake_cy_md
411 (
412 cd $ROOTDIR/tools/cyrus-imapd-makedepend \
413 && ./configure > /dev/null 2>&1 \
414 && $MAKE > /dev/null 2>&1
415 if test -x ./makedepend.exe ; then
416 $LN ./makedepend.exe ./makedepend
417 fi
418 ./makedepend ifparser.c > /dev/null 2>&1 \
419 && echo "true"
420 ) > ./genmake_cy_md
421 grep true ./genmake_cy_md > /dev/null 2>&1
422 RETVAL=$?
423 rm -f ./genmake_cy_md
424 if test "x$RETVAL" = x0 ; then
425 MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
426 echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
427 return 0
428 else
429 echo "WARNING: fail to build cyrus-imapd-makedepend" >> $LOGFILE
430 return 1
431 fi
432 }
433
434 build_embed_encode()
435 {
436 printf " building the embed-encode utility... "
437 if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then
438 if test ! -d "$ROOTDIR/tools/embed_encode" ; then
439 echo
440 echo " Error: can't locate \"$ROOTDIR/tools/embed_encode\""
441 echo
442 EMBED_SRC=f
443 return 1
444 fi
445 clist="cc gcc c89 $CC"
446 for ic in $clist ; do
447 comm="$ic -o encode_files encode_files.c"
448 ( cd $ROOTDIR/tools/embed_encode && $comm ) > /dev/null 2>&1
449 RETVAL=$?
450 if test "x$RETVAL" = x0 ; then
451 echo "OK"
452 return 0
453 fi
454 done
455 echo
456 echo " Error: unable to build $ROOTDIR/embed_encode/encode_files"
457 echo " so it has been disabled"
458 echo
459 EMBED_SRC=f
460 return 1
461 fi
462 echo "OK"
463 }
464
465 # look for possible C compilers
466 look_for_C_compilers() {
467 echo >> $LOGFILE
468 echo "running: look_for_C_compilers()" >> $LOGFILE
469 rm -f ./genmake_hello.c ./genmake_hello
470 cat >> genmake_hello.c << EOF
471 #include <stdio.h>
472 int main(int argc, char **argv) {
473 printf("Hello!\n");
474 return 0;
475 }
476 EOF
477 tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc icc"
478 p_CC=
479 for c in $tmp ; do
480 COMM="$c $CFLAGS -o genmake_hello genmake_hello.c"
481 echo $COMM >> $LOGFILE
482 $COMM >> $LOGFILE 2>&1
483 RETVAL=$?
484 if test "x${RETVAL}" = x0 ; then
485 echo " $c test successful" >> $LOGFILE
486 p_CC="$p_CC $c"
487 fi
488 done
489 rm -f ./genmake_hello.c ./genmake_hello
490 if test "x${p_CC}" = x ; then
491 cat 1>&2 <<EOF
492
493 Error: No C compilers were found in your path. Please specify one using:
494
495 1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
496 2) the CC or MITGCM_CC environment variables.
497
498 EOF
499 exit 1
500 else
501 echo " The possible C compilers found in your path are: $p_CC" | tee -a $LOGFILE
502 if test "x$CC" = x ; then
503 CC=`echo $p_CC | $AWK '{print $1}'`
504 echo " Setting C compiler to: "$CC
505 fi
506 fi
507 echo " --> set CC='$CC'" >> $LOGFILE
508 }
509
510 # Guess possible config options for this host
511 find_possible_optfile() {
512
513 echo >> $LOGFILE
514 echo "running: find_possible_optfile()" >> $LOGFILE
515 tmp1=`uname`"_"`uname -m`
516 tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
517 tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
518 tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
519 tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
520 tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
521 PLATFORM=$tmp3
522 echo $PLATFORM | grep cygwin > /dev/null 2>&1 && PLATFORM=cygwin_ia32
523 OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
524 echo " The platform appears to be: $PLATFORM" | tee -a $LOGFILE
525
526 #================================================================
527 # look for possible FORTRAN compilers
528 echo " look for possible FORTRAN compilers" >> $LOGFILE
529 tmp="$MITGCM_FC $FC efc gfortran g77 f77 pgf77 pgf95 ifc ifort f90 f95 mpif77 mpf77 mpxlf95 g95"
530 p_FC=
531 rm -f ./genmake_hello.f
532 cat >> genmake_hello.f <<EOF
533 program hello
534 do i=1,3
535 print *, 'hello world : ', i
536 enddo
537 end
538 EOF
539 for f in $tmp ; do
540 COMM="$f -o genmake_hello genmake_hello.f"
541 echo $COMM >> $LOGFILE
542 $COMM >> $LOGFILE 2>&1
543 RETVAL=$?
544 if test "x${RETVAL}" = x0 ; then
545 echo " $f test successful" >> $LOGFILE
546 p_FC="$p_FC $f"
547 fi
548 done
549 rm -f ./genmake_hello.f ./genmake_hello
550 if test "x${p_FC}" = x ; then
551 cat 1>&2 <<EOF
552
553 Error: No Fortran compilers were found in your path. Please specify one using:
554
555 1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
556 2) a command-line option (eg. "-fc NAME"), or
557 3) the FC or MITGCM_FC environment variables.
558
559 EOF
560 exit 1
561 else
562 echo " The possible FORTRAN compilers found in your path are: $p_FC" | tee -a $LOGFILE
563 fi
564
565 # Use the first of the compilers found in the current PATH
566 # that has a correctly-named optfile
567 if test "x$OPTFILE" = x -a "x$FC" = x ; then
568 for i in $p_FC ; do
569 OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
570 if test -r $OPTFILE ; then
571 echo " Setting OPTFILE to: "$OPTFILE | tee -a $LOGFILE
572 break
573 fi
574 done
575 fi
576
577 if test "x$OPTFILE" = x ; then
578 OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
579 if test ! -r $OPTFILE ; then
580 echo " I looked for the file "$OPTFILE" but did not find it"
581 fi
582 fi
583
584 if test "x$OPTFILE" = x ; then
585 cat 1>&2 <<EOF
586
587 Error: No options file was found in: $ROOTDIR/tools/build_options/
588 that matches this platform ("$PLATFORM") and the compilers found in
589 your path. Please specify an "optfile" using:
590
591 1) the command line (eg. "-optfile=path/to/OPTFILE"), or
592 2) the MITGCM_OF environment variable.
593
594 If you need help, please contact the developers at <MITgcm-support@mitgcm.org>.
595
596 EOF
597 exit 1
598 fi
599 }
600
601 # Parse the package dependency information
602 get_pdepend_list() {
603
604 # strip the comments and then convert the dependency file into
605 # two arrays: PNAME, DNAME
606 cat $1 | sed -e 's/#.*$//g' \
607 | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
608 > ./.pd_tmp
609 RETVAL=$?
610 if test ! "x${RETVAL}" = x0 ; then
611 echo "Error: unable to parse package dependencies -- please check PKG_DEPEND=\"$1\""
612 exit 1
613 fi
614 . ./.pd_tmp
615 rm -f ./.pd_tmp
616 }
617
618 # Build a CPP macro to automate calling C routines from FORTRAN
619 get_fortran_c_namemangling() {
620
621 #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
622 if test ! "x$FC_NAMEMANGLE" = x ; then
623 return 0
624 fi
625 echo " running: get_fortran_c_namemangling()" >> $LOGFILE
626
627 default_nm="#define FC_NAMEMANGLE(X) X ## _"
628
629 cat > genmake_test.c <<EOF
630 void tcall( char * string ) { tsub( string ); }
631 EOF
632 COMM="$CC $CFLAGS -c genmake_test.c"
633 echo ' '$COMM >> $LOGFILE
634 $COMM >> $LOGFILE 2>&1
635 RETVAL=$?
636 if test "x$RETVAL" != x0 ; then
637 FC_NAMEMANGLE=$default_nm
638 cat <<EOF>> $LOGFILE
639
640 WARNING: C test compile fails
641 WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
642 WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
643 EOF
644 return 1
645 fi
646 c_tcall=`nm genmake_test.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
647 RETVAL=$?
648 if test "x$RETVAL" != x0 ; then
649 FC_NAMEMANGLE=$default_nm
650 cat <<EOF>> $LOGFILE
651
652 WARNING: The "nm" command failed.
653 WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
654 WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
655 EOF
656 return 1
657 fi
658 cat > genmake_tcomp.$FS <<EOF
659 subroutine tcall( string )
660 character*(*) string
661 call tsub( string )
662 end
663 EOF
664 COMM="$FC $FFLAGS -c genmake_tcomp.$FS"
665 echo ' '$COMM >> $LOGFILE
666 $COMM >> $LOGFILE 2>&1
667 RETVAL=$?
668 if test "x$RETVAL" != x0 ; then
669 FC_NAMEMANGLE=$default_nm
670 cat <<EOF>> $LOGFILE
671
672 WARNING: FORTRAN test compile fails -- please see '$LOGFILE'
673 WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
674 WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
675 EOF
676 return 1
677 fi
678 f_tcall=`nm genmake_tcomp.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
679 RETVAL=$?
680 if test "x$RETVAL" != x0 ; then
681 FC_NAMEMANGLE=$default_nm
682 cat <<EOF>> $LOGFILE
683
684 WARNING: The "nm" command failed.
685 WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
686 WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
687 EOF
688 return 1
689 fi
690
691 c_a=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
692 f_a=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
693 c_b=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
694 f_b=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
695
696 nmangle="X"
697 if test "x$c_a" != "x$f_a" ; then
698 comm="echo x$f_a | sed -e 's|x$c_a||'"
699 a=`eval $comm`
700 nmangle="$a ## $nmangle"
701 fi
702 if test "x$c_b" != "x$f_b" ; then
703 comm="echo x$f_b | sed -e 's|x$c_b||'"
704 b=`eval $comm`
705 nmangle="$nmangle ## $b"
706 fi
707
708 FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) $nmangle"
709
710 # cleanup the testing files
711 rm -f genmake_tcomp.* genmake_test.*
712
713 echo " --> set FC_NAMEMANGLE='$FC_NAMEMANGLE'" >> $LOGFILE
714 }
715
716 check_HAVE_CLOC() {
717 echo >> $LOGFILE
718 echo "running: check_HAVE_CLOC()" >> $LOGFILE
719 get_fortran_c_namemangling
720 cat <<EOF > genmake_tc_1.c
721 $FC_NAMEMANGLE
722 #include <stdio.h>
723 #include <stdlib.h>
724 #include <unistd.h>
725 #include <assert.h>
726 #include <sys/time.h>
727 void FC_NAMEMANGLE(cloc) ( double *curtim )
728 {
729 struct timeval tv1;
730 gettimeofday(&tv1 , (void *)NULL );
731 *curtim = (double)((tv1.tv_usec)+(tv1.tv_sec)*1.E6);
732 *curtim = *curtim/1.E6;
733 }
734 EOF
735 COMM="$CC $CFLAGS -c genmake_tc_1.c"
736 echo $COMM >> $LOGFILE
737 $COMM >> $LOGFILE 2>&1
738 RET_C=$?
739 cat <<EOF > genmake_tc_2.$FS
740 program hello
741 REAL*8 wtime
742 external cloc
743 call cloc(wtime)
744 print *," HELLO WORLD", wtime
745 end
746 EOF
747 COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
748 echo $COMM >> $LOGFILE
749 $COMM >> $LOGFILE 2>&1
750 RET_F=$?
751 test -x ./genmake_tc && ./genmake_tc >> $LOGFILE 2>&1
752 RETVAL=$?
753 if test "x$RETVAL" = x0 ; then
754 HAVE_CLOC=t
755 fi
756 rm -f genmake_tc*
757 echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE
758 }
759
760 check_HAVE_SIGREG() {
761 if test ! "x$HAVE_SIGREG" = x ; then
762 return
763 fi
764 echo >> $LOGFILE
765 echo "running: check_HAVE_SIGREG()" >> $LOGFILE
766 get_fortran_c_namemangling
767 cat <<EOF > genmake_tc_1.c
768 $FC_NAMEMANGLE
769 #include <stdlib.h>
770 #include <stdio.h>
771 #include <signal.h>
772 #include <errno.h>
773 #include <ucontext.h>
774
775 int * ip;
776
777 static void killhandler(
778 unsigned int sn, siginfo_t si, struct ucontext *sc )
779 {
780 *ip = *ip + 1;
781 return;
782 }
783
784 void FC_NAMEMANGLE(sigreg) (int * aip)
785 {
786 struct sigaction s;
787 ip = aip;
788 s.sa_flags = SA_SIGINFO;
789 s.sa_sigaction = (void *)killhandler;
790 if(sigaction (SIGTERM,&s,(struct sigaction *)NULL)) {
791 printf("Sigaction returned error = %d\n", errno);
792 exit(0);
793 }
794 return;
795 }
796 EOF
797 COMM="$CC $CFLAGS -c genmake_tc_1.c"
798 echo $COMM >> $LOGFILE
799 $COMM >> $LOGFILE 2>&1
800 RET_C=$?
801 cat <<EOF > genmake_tc_2.$FS
802 program hello
803 integer anint
804 common /iv/ anint
805 external sigreg
806 call sigreg(anint)
807 end
808 EOF
809 cat genmake_tc_2.$FS >> $LOGFILE
810 COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
811 echo $COMM >> $LOGFILE
812 $COMM >> $LOGFILE 2>&1
813 RETVAL=$?
814 if test "x$RETVAL" = x0 ; then
815 HAVE_SIGREG=t
816 fi
817 rm -f genmake_tc*
818 echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE
819 }
820
821 check_HAVE_SETRLSTK() {
822 if test ! "x$HAVE_SETRLSTK" = x ; then
823 return
824 fi
825 echo >> $LOGFILE
826 echo "running: check_HAVE_SETRLSTK()" >> $LOGFILE
827 get_fortran_c_namemangling
828 cat <<EOF > genmake_tc_1.c
829 $FC_NAMEMANGLE
830 #include <sys/time.h>
831 #include <sys/resource.h>
832 #include <unistd.h>
833 void FC_NAMEMANGLE(setrlstk) ()
834 {
835 struct rlimit rls;
836 rls.rlim_cur = RLIM_INFINITY;
837 rls.rlim_max = RLIM_INFINITY;
838 setrlimit(RLIMIT_STACK, &rls);
839 return;
840 }
841 EOF
842 COMM="$CC $CFLAGS -c genmake_tc_1.c"
843 echo $COMM >> $LOGFILE
844 $COMM >> $LOGFILE 2>&1
845 RET_C=$?
846 cat <<EOF > genmake_tc_2.$FS
847 program hello
848 external setrlstk
849 call setrlstk()
850 end
851 EOF
852 cat genmake_tc_2.$FS >> $LOGFILE
853 COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
854 echo $COMM >> $LOGFILE
855 $COMM >> $LOGFILE 2>&1
856 RETVAL=$?
857 if test "x$RETVAL" = x0 ; then
858 HAVE_SETRLSTK=t
859 fi
860 rm -f genmake_tc*
861 echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE
862 }
863
864 check_HAVE_STAT() {
865 echo >> $LOGFILE
866 echo "running: check_HAVE_STAT()" >> $LOGFILE
867 get_fortran_c_namemangling
868 cat <<EOF > genmake_tc_1.c
869 $FC_NAMEMANGLE
870 #include <stdio.h>
871 #include <stdlib.h>
872 #include <unistd.h>
873 #include <sys/stat.h>
874 #include <sys/types.h>
875 void FC_NAMEMANGLE(tfsize) ( int *nbyte )
876 {
877 char name[512];
878 struct stat astat;
879
880 name[0] = 'a'; name[1] = '\0';
881 if (! stat(name, &astat))
882 *nbyte = (int)(astat.st_size);
883 else
884 *nbyte = -1;
885 }
886 EOF
887 COMM="$CC $CFLAGS -c genmake_tc_1.c"
888 echo $COMM >> $LOGFILE
889 $COMM >> genmake_tc.log 2>&1
890 RET_C=$?
891 cat <<EOF > genmake_tc_2.$FS
892 program hello
893 integer nbyte
894 call tfsize(nbyte)
895 print *," HELLO WORLD", nbyte
896 end
897 EOF
898 cat genmake_tc_2.$FS >> $LOGFILE
899 COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
900 echo $COMM >> $LOGFILE
901 $COMM >> genmake_tc.log 2>&1
902 RETVAL=$?
903 if test "x$RETVAL" = x0 ; then
904 HAVE_STAT=t
905 fi
906 rm -f genmake_tc*
907 echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE
908 }
909
910 check_netcdf_libs() {
911 if test ! "x$SKIP_NETCDF_CHECK" = x ; then
912 return
913 fi
914 echo >> $LOGFILE
915 echo "running: check_netcdf_libs()" >> $LOGFILE
916 cat <<EOF > genmake_tnc.F
917 program fgennc
918 #include "netcdf.inc"
919 EOF
920 if test ! "x$MPI" = x ; then
921 echo '#include "mpif.h"' >> genmake_tnc.F
922 fi
923 cat <<EOF >> genmake_tnc.F
924 integer iret, ncid, xid
925 iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
926 IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
927 iret = nf_def_dim(ncid, 'X', 11, xid)
928 IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
929 iret = nf_close(ncid)
930 IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
931 end
932 EOF
933 echo "=== genmake_tnc.F >>>" > genmake_tnc.log
934 cat genmake_tnc.F >> genmake_tnc.log
935 echo "<<< genmake_tnc.F ===" >> genmake_tnc.log
936 RET_CPP=f
937 COMM="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES"
938 echo "$COMM" >> genmake_tnc.log
939 eval $COMM > genmake_tnc.$FS 2>/dev/null && RET_CPP=t
940 if test "x$RET_CPP" = xf ; then
941 echo " WARNING: CPP failed to pre-process the netcdf test." \
942 >> genmake_tnc.log
943 echo " Please check that \$INCLUDES is properly set." \
944 >> genmake_tnc.log
945 fi
946 echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
947 echo " && $LINK $FFLAGS $FOPTIM -o genmake_tnc.o $LIBS" >> genmake_tnc.log
948 $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \
949 && $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
950 RET_COMPILE=$?
951 cat genmake_tnc.log >> $LOGFILE
952
953 #EH3 Remove test program execution for machines that either disallow
954 #EH3 execution or cannot support it (eg. cross-compilers)
955 #EH3
956 #EH3 test -x ./genmake_tnc && ./genmake_tnc >> genmake_tnc.log 2>&1
957 #EH3 RETVAL=$?
958 #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
959
960 if test "x$RET_COMPILE" = x0 ; then
961 HAVE_NETCDF=t
962 echo "check_netcdf: successful" >> $LOGFILE
963 else
964 # try again with "-lnetcdf" added to the libs
965 echo "==> try again with added '-lnetcdf'" > genmake_tnc.log
966 echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
967 echo " && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
968 echo " && $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
969 cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null \
970 && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \
971 && $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
972 RET_COMPILE=$?
973 echo >> $LOGFILE
974 cat genmake_tnc.log >> $LOGFILE
975 if test "x$RET_COMPILE" = x0 ; then
976 LIBS="$LIBS -lnetcdf"
977 HAVE_NETCDF=t
978 echo "check_netcdf: successful" >> $LOGFILE
979 else
980 # try again with "-lnetcdff" added to the libs
981 echo "==> try again with added '-lnetcdff -lnetcdf'" > genmake_tnc.log
982 echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
983 echo " && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
984 echo " && $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
985 cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null \
986 && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \
987 && $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdff -lnetcdf >> genmake_tnc.log 2>&1
988 RET_COMPILE=$?
989 echo >> $LOGFILE
990 cat genmake_tnc.log >> $LOGFILE
991 if test "x$RET_COMPILE" = x0 ; then
992 LIBS="$LIBS -lnetcdff -lnetcdf"
993 HAVE_NETCDF=t
994 echo "check_netcdf: successful" >> $LOGFILE
995 fi
996 fi
997 fi
998 rm -f genmake_tnc*
999 echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE
1000 }
1001
1002 check_lapack_libs() {
1003 if test ! "x$SKIP_LAPACK_CHECK" = x ; then
1004 return
1005 fi
1006 echo >> $LOGFILE
1007 echo "running: check_lapack_libs()" >> $LOGFILE
1008 cat <<EOF > genmake_tla.F
1009 program fgenla
1010 integer info
1011 integer ipiv( 2 )
1012 double precision ab( 4, 2 ), b( 2 )
1013 data ab / 0., 0., 1., 2., 0., 2., 1., 0. /
1014 data b / 1., 1. /
1015 call dgbsv( 2, 1, 1, 1, ab, 4, ipiv, b, 2, info )
1016 IF (info .NE. 0) write(*,*) 'Error:', info
1017 write(*,*) b
1018 end
1019 EOF
1020 echo "=== genmake_tla.F >>>" > genmake_tla.log
1021 cat genmake_tla.F >> genmake_tla.log
1022 echo "<<< genmake_tla.F ===" >> genmake_tla.log
1023 RET_CPP=f
1024 COMM="cat genmake_tla.F | $CPP $DEFINES $INCLUDES"
1025 echo "$COMM" >> genmake_tla.log
1026 eval $COMM > genmake_tla.$FS 2>/dev/null && RET_CPP=t
1027 if test "x$RET_CPP" = xf ; then
1028 echo " WARNING: CPP failed to pre-process the lapack test." \
1029 >> genmake_tla.log
1030 echo " Please check that \$INCLUDES is properly set." \
1031 >> genmake_tla.log
1032 fi
1033 echo "$FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1034 echo " && $LINK $FFLAGS $FOPTIM -o genmake_tla.o $LIBS" >> genmake_tla.log
1035 $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1 \
1036 && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS >> genmake_tla.log 2>&1
1037 RET_COMPILE=$?
1038 cat genmake_tla.log >> $LOGFILE
1039
1040 # test program execution not always possible (see check_netcdf_libs)
1041 #
1042 #test -x ./genmake_tla && ./genmake_tla >> genmake_tla.log 2>&1
1043 #RETVAL=$?
1044 #if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
1045
1046 if test "x$RET_COMPILE" = x0 ; then
1047 HAVE_LAPACK=t
1048 echo "check_lapack: successful" >> $LOGFILE
1049 else
1050 # try again with "-llapack" added to the libs
1051 echo "==> try again with added '-llapack'" > genmake_tla.log
1052 echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1053 echo " && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1054 echo " && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack" >> genmake_tla.log
1055 cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null \
1056 && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1 \
1057 && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack >> genmake_tla.log 2>&1
1058 RET_COMPILE=$?
1059 echo >> $LOGFILE
1060 cat genmake_tla.log >> $LOGFILE
1061 if test "x$RET_COMPILE" = x0 ; then
1062 LIBS="$LIBS -llapack"
1063 HAVE_LAPACK=t
1064 echo "check_lapack: successful" >> $LOGFILE
1065 else
1066 # try again with "-lf77blas -lcblas" added to the libs
1067 echo "==> try again with added '-llapack -lf77blas -lcblas'" > genmake_tla.log
1068 echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1069 echo " && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1070 echo " && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas" >> genmake_tla.log
1071 cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null \
1072 && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1 \
1073 && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas >> genmake_tla.log 2>&1
1074 RET_COMPILE=$?
1075 echo >> $LOGFILE
1076 cat genmake_tla.log >> $LOGFILE
1077 if test "x$RET_COMPILE" = x0 ; then
1078 LIBS="$LIBS -llapack -lf77blas -lcblas"
1079 HAVE_LAPACK=t
1080 echo "check_lapack: successful" >> $LOGFILE
1081 else
1082 # try again with "-latlas" added to the libs
1083 echo "==> try again with added '-llapack -lf77blas -lcblas -latlas'" > genmake_tla.log
1084 echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1085 echo " && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1086 echo " && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas" >> genmake_tla.log
1087 cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null \
1088 && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1 \
1089 && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas >> genmake_tla.log 2>&1
1090 RET_COMPILE=$?
1091 echo >> $LOGFILE
1092 cat genmake_tla.log >> $LOGFILE
1093 if test "x$RET_COMPILE" = x0 ; then
1094 LIBS="$LIBS -llapack -lf77blas -lcblas -latlas"
1095 HAVE_LAPACK=t
1096 echo "check_lapack: successful" >> $LOGFILE
1097 fi
1098 fi
1099 fi
1100 fi
1101 rm -f genmake_tla*
1102 echo " --> set HAVE_LAPACK='$HAVE_LAPACK'" >> $LOGFILE
1103 }
1104
1105
1106 ###############################################################################
1107 # Sequential part of script starts here
1108 ###############################################################################
1109
1110 # Set defaults here
1111 COMMANDL="$0 $@"
1112
1113 PLATFORM=
1114 LN=
1115 S64=
1116 KPP=
1117 #FC=
1118 #CC=gcc
1119 #CPP=
1120 LINK=
1121 DEFINES=
1122 PACKAGES=
1123 ENABLE=
1124 DISABLE=
1125 # MAKEFILE=
1126 # MAKEDEPEND=
1127 PKG_DEPEND=
1128 PKG_GROUPS=
1129 DUMPSTATE=f
1130 OPTFILE=
1131 INCLUDES="-I. $INCLUDES"
1132 FFLAGS=
1133 FOPTIM=
1134 FEXTRAFLAGS=
1135 USE_EXTENDED_SRC=
1136 EXTENDED_SRC_FLAG=
1137 GET_FC_VERSION=
1138 CFLAGS=
1139 KFLAGS1=
1140 KFLAGS2=
1141 #LDADD=
1142 LIBS=
1143 KPPFILES=
1144 NOOPTFILES=
1145 NOOPTFLAGS=
1146 MPI=
1147 MPIPATH=
1148 OMP=
1149 OMPFLAG=
1150 USE_R4=
1151 TS=
1152 PAPIS=
1153 PCLS=
1154 FOOLAD=
1155 PAPI=
1156 PCL=
1157 HPMT=
1158 GSL=
1159 DEVEL=
1160 HAVE_TEST_L=
1161
1162 # DEFINES checked by test compilation or command-line
1163 HAVE_SYSTEM=
1164 HAVE_FDATE=
1165 FC_NAMEMANGLE=
1166 HAVE_CLOC=
1167 # HAVE_SETRLSTK=
1168 HAVE_STAT=
1169 HAVE_NETCDF=
1170 HAVE_ETIME=
1171 IGNORE_TIME=
1172 HAVE_LAPACK=
1173
1174 MODS=
1175 TOOLSDIR=
1176 SOURCEDIRS=
1177 INCLUDEDIRS=
1178 STANDARDDIRS="USE_THE_DEFAULT"
1179
1180 #- local config file
1181 gm_local="genmake_local"
1182
1183 G2ARGS=
1184 BASH=
1185 PWD=`pwd`
1186 test "x$MAKE" = x && MAKE=make
1187 test "x$AWK" = x && AWK=awk
1188 EMBED_SRC=
1189 THISHOST=`hostname`
1190 THISCWD=`pwd`
1191 THISDATE=`date`
1192 THISUSER=`echo $USER`
1193 THISVER=
1194 MACHINE=`uname -a`
1195 EXECUTABLE=
1196 EXEHOOK=
1197 EXEDIR=
1198 IEEE=
1199 if test "x$MITGCM_IEEE" != x ; then
1200 IEEE=$MITGCM_IEEE
1201 fi
1202 FS=
1203 FS90=
1204
1205 AUTODIFF_PKG_USED=f
1206 AD_OPTFILE=
1207 TAF=
1208 AD_TAF_FLAGS=
1209 FTL_TAF_FLAGS=
1210 SVD_TAF_FLAGS=
1211 TAF_EXTRA=
1212 TAMC=
1213 AD_TAMC_FLAGS=
1214 FTL_TAF_FLAGS=
1215 SVD_TAMC_FLAGS=
1216 TAMC_EXTRA=
1217
1218 # The following state can be set directly by command-line switches
1219 gm_s1="ROOTDIR STANDARDDIRS MODS PKG_DEPEND PKG_GROUPS DISABLE ENABLE"
1220 gm_s2="PLATFORM OPTFILE MAKE MAKEFILE MAKEDEPEND FC CC MPI OMP USE_R4"
1221 gm_s3="FEXTRAFLAGS IEEE DEVEL GSL TS PAPIS PCLS PAPI PCL HPMT DUMPSTATE"
1222
1223 # The following state is not directly set by command-line switches
1224 gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM"
1225 gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
1226 gm_s6="TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"
1227 gm_s7="PWD THISHOST THISUSER THISDATE THISVER MACHINE"
1228 gm_s8="FC_NAMEMANGLE HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME HAVE_LAPACK"
1229
1230 # The following are all related to adjoint/tangent-linear stuff
1231 gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
1232 gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
1233 gm_s12="TAF_EXTRA TAMC_EXTRA"
1234
1235 gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8"
1236 gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
1237
1238 cat <<EOF
1239
1240 GENMAKE :
1241
1242 A program for GENerating MAKEfiles for the MITgcm project.
1243 For a quick list of options, use "genmake2 -h"
1244 or for more detail see the Developer's HOWTO manual at:
1245 http://mitgcm.org/public/docs.html
1246
1247 EOF
1248
1249 LOGFILE="genmake.log"
1250 #- clean-up previous genmake logfiles:
1251 rm -f genmake_state genmake_*optfile $LOGFILE
1252
1253 echo "=== Processing options files and arguments ==="
1254
1255 #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
1256 #parse_options
1257 ac_prev=
1258 for ac_option in "$@" ; do
1259
1260 G2ARGS="$G2ARGS \"$ac_option\""
1261
1262 # If the previous option needs an argument, assign it.
1263 if test -n "$ac_prev"; then
1264 eval "$ac_prev=\$ac_option"
1265 ac_prev=
1266 continue
1267 fi
1268
1269 ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
1270
1271 case $ac_option in
1272
1273 -help | --help | -h | --h)
1274 usage ;;
1275
1276 -nooptfile | --nooptfile)
1277 OPTFILE="NONE" ;;
1278 -optfile | --optfile | -of | --of)
1279 ac_prev=OPTFILE ;;
1280 -optfile=* | --optfile=* | -of=* | --of=*)
1281 OPTFILE=$ac_optarg ;;
1282
1283 -adoptfile | --adoptfile | -adof | --adof)
1284 ac_prev=AD_OPTFILE ;;
1285 -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
1286 AD_OPTFILE=$ac_optarg ;;
1287
1288 -pdepend | --pdepend)
1289 ac_prev=PKG_DEPEND ;;
1290 -pdepend=* | --pdepend=*)
1291 PKG_DEPEND=$ac_optarg ;;
1292
1293 -pgroups | --pgroups)
1294 ac_prev=PKG_GROUPS ;;
1295 -pgroups=* | --pgroups=*)
1296 PKG_GROUPS=$ac_optarg ;;
1297
1298 -make | --make | -m | --m)
1299 ac_prev=MAKE ;;
1300 -make=* | --make=* | -m=* | --m=*)
1301 MAKE=$ac_optarg ;;
1302
1303 -bash | --bash)
1304 ac_prev=BASH ;;
1305 -bash=* | --bash=*)
1306 BASH=$ac_optarg ;;
1307
1308 -makedepend | --makedepend | -md | --md)
1309 ac_prev=MAKEDEPEND ;;
1310 -makedepend=* | --makedepend=* | -md=* | --md=*)
1311 MAKEDEPEND=$ac_optarg ;;
1312
1313 -makefile | --makefile | -mf | --mf)
1314 ac_prev=MAKEFILE ;;
1315 -makefile=* | --makefile=* | -mf=* | --mf=*)
1316 MAKEFILE=$ac_optarg ;;
1317
1318 -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)
1319 echo "ERROR: The platform option has been removed. Please specify"
1320 echo " the build options using the \"optfile\" mechanism."
1321 echo
1322 usage
1323 ;;
1324
1325 -rootdir | --rootdir | -rd | --rd)
1326 ac_prev=ROOTDIR ;;
1327 -rootdir=* | --rootdir=* | -rd=* | --rd=*)
1328 ROOTDIR=$ac_optarg ;;
1329
1330 -mods | --mods | -mo | --mo)
1331 ac_prev=MODS ;;
1332 -mods=* | --mods=* | -mo=* | --mo=*)
1333 MODS=$ac_optarg ;;
1334
1335 -disable | --disable)
1336 ac_prev=DISABLE ;;
1337 -disable=* | --disable=*)
1338 DISABLE=$ac_optarg ;;
1339
1340 -enable | --enable)
1341 ac_prev=ENABLE ;;
1342 -enable=* | --enable=*)
1343 ENABLE=$ac_optarg ;;
1344
1345 -standarddirs | --standarddirs)
1346 ac_prev=STANDARDDIRS ;;
1347 -standarddirs=* | --standarddirs=*)
1348 STANDARDDIRS=$ac_optarg ;;
1349
1350 # -cpp | --cpp)
1351 # ac_prev=cpp ;;
1352 # -cpp=* | --cpp=*)
1353 # CPP=$ac_optarg ;;
1354
1355 -cc | --cc)
1356 ac_prev=CC ;;
1357 -cc=* | --cc=*)
1358 CC=$ac_optarg ;;
1359
1360 -fortran | --fortran | -fc | --fc)
1361 ac_prev=FC ;;
1362 -fc=* | --fc=*)
1363 FC=$ac_optarg ;;
1364
1365 -fs | --fs)
1366 ac_prev=FS ;;
1367 -fs=* | --fs=*)
1368 FS=$ac_optarg ;;
1369
1370 -fs90 | --fs90)
1371 ac_prev=FS90 ;;
1372 -fs90=* | --fs90=*)
1373 FS90=$ac_optarg ;;
1374
1375 -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )
1376 USE_R4=true ;;
1377
1378 -ieee | --ieee)
1379 IEEE=true ;;
1380 -noieee | --noieee)
1381 echo "Warning: ignore option '$ac_option' (default is already without '-ieee')" ;;
1382 -devel | --devel)
1383 IEEE=true ; DEVEL=true ;;
1384 -gsl | --gsl)
1385 GSL=true ;;
1386
1387 -ts | --ts)
1388 TS=true ;;
1389 -papis | --papis)
1390 PAPIS=true ;;
1391 -pcls | --pcls)
1392 PCLS=true ;;
1393 -foolad | --foolad)
1394 FOOLAD=true ;;
1395 -papi | --papi)
1396 PAPI=true ;;
1397 -pcl | --pcl)
1398 PCL=true ;;
1399 -hpmt | --hpmt)
1400 HPMT=true ;;
1401
1402 -mpi | --mpi)
1403 MPI=true ;;
1404 -mpi=* | --mpi=*)
1405 MPIPATH=$ac_optarg
1406 MPI=true ;;
1407
1408 -omp | --omp)
1409 OMP=true ;;
1410 -omp=* | --omp=*)
1411 OMPFLAG=$ac_optarg
1412 OMP=true ;;
1413
1414 -ds | --ds)
1415 DUMPSTATE=t ;;
1416
1417 -extra_flag | --extra_flag)
1418 ac_prev=FEXTRAFLAGS ;;
1419 -extra_flag=* | --extra_flag=*)
1420 FEXTRAFLAGS=$ac_optarg ;;
1421
1422 -taf_extra | --taf_extra)
1423 ac_prev=TAF_EXTRA ;;
1424 -taf_extra=* | --taf_extra=*)
1425 TAF_EXTRA=$ac_optarg ;;
1426
1427 -tamc_extra | --tamc_extra)
1428 ac_prev=TAMC_EXTRA ;;
1429 -tamc_extra=* | --tamc_extra=*)
1430 TAMC_EXTRA=$ac_optarg ;;
1431
1432 -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1433 IGNORE_TIME="-DIGNORE_TIME" ;;
1434
1435 -es | --es | -embed-source | --embed-source)
1436 EMBED_SRC=t ;;
1437
1438 -*)
1439 echo "Error: unrecognized option: "$ac_option
1440 usage
1441 ;;
1442
1443 *)
1444 echo "Error: unrecognized argument: "$ac_option
1445 usage
1446 ;;
1447
1448 esac
1449
1450 done
1451
1452 printf " getting local config information: "
1453 if test -f $gm_local ; then
1454 echo "using $gm_local"
1455 . $gm_local
1456 else
1457 echo "none found"
1458 fi
1459
1460 if test -f ./.genmakerc ; then
1461 echo
1462 echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
1463 echo " file. This file format is no longer supported. For directions on"
1464 echo " how to setup and use the new \"genmake2\" script, please see:"
1465 echo " http://mitgcm.org/public/devel_HOWTO/"
1466 echo " and send an email to MITgcm-support@mitgcm.org if you need help."
1467 echo "WARNING: ignore \"./.genmakerc\" and continue."
1468 echo
1469 fi
1470
1471 # Find the MITgcm ${ROOTDIR}
1472 if test "x${ROOTDIR}" = x ; then
1473 tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1474 if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesupp -a -d ../pkg ; then
1475 ROOTDIR=".."
1476 else
1477 for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
1478 if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
1479 ROOTDIR=$d
1480 printf "Warning: ROOTDIR was not specified ;"
1481 echo " try using a local copy of MITgcm found at \"$ROOTDIR\""
1482 break
1483 fi
1484 done
1485 fi
1486 fi
1487 if test "x${ROOTDIR}" = x ; then
1488 echo "Error: Cannot determine ROOTDIR for MITgcm code."
1489 echo " Please specify a ROOTDIR using either an options "
1490 echo " file or a command-line option."
1491 exit 1
1492 fi
1493 if test ! -d ${ROOTDIR} ; then
1494 echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!"
1495 exit 1
1496 fi
1497
1498 # Find the MITgcm ${THISVER}
1499 version_file="${ROOTDIR}/doc/tag-index"
1500 if test -f $version_file ; then
1501 THISVER=`$AWK '/^checkpoint/{print $1; exit}' $version_file`
1502 #- remove ./BUILD_INFO.h file if older than version_file
1503 if test -f ./BUILD_INFO.h -a ./BUILD_INFO.h -ot $version_file ; then
1504 echo " remove ./BUILD_INFO.h (older than ${version_file})"
1505 rm -f ./BUILD_INFO.h
1506 fi
1507 fi
1508
1509 if test "x$MAKEFILE" = x ; then
1510 MAKEFILE="Makefile"
1511 fi
1512
1513 echo " getting OPTFILE information:"
1514 if test "x${OPTFILE}" = x ; then
1515 if test "x$MITGCM_OF" = x ; then
1516 echo "Warning: no OPTFILE specified so we'll look for possible settings"
1517 printf "\n=== Searching for possible settings for OPTFILE ===\n"
1518 find_possible_optfile
1519 else
1520 OPTFILE=$MITGCM_OF
1521 fi
1522 fi
1523 if test "x$OPTFILE" != xNONE ; then
1524 if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
1525 echo " using OPTFILE=\"$OPTFILE\""
1526 . "$OPTFILE"
1527 RETVAL=$?
1528 if test "x$RETVAL" != x0 ; then
1529 printf "Error: failed to source OPTFILE \"$OPTFILE\""
1530 echo "--please check that variable syntax is bash-compatible"
1531 exit 1
1532 fi
1533 if test "x$DUMPSTATE" = xt ; then
1534 cp -f $OPTFILE "genmake_optfile"
1535 fi
1536 else
1537 echo "Error: can't read OPTFILE=\"$OPTFILE\""
1538 exit 1
1539 fi
1540 fi
1541
1542 echo " getting AD_OPTFILE information:"
1543 if test "x${AD_OPTFILE}" = x ; then
1544 if test "x$MITGCM_AD_OF" = x ; then
1545 AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
1546 else
1547 AD_OPTFILE=$MITGCM_AD_OF
1548 fi
1549 fi
1550 if test "x${AD_OPTFILE}" != xNONE ; then
1551 if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then
1552 echo " using AD_OPTFILE=\"$AD_OPTFILE\""
1553 . "$AD_OPTFILE"
1554 RETVAL=$?
1555 if test "x$RETVAL" != x0 ; then
1556 printf "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
1557 echo "--please check that variable syntax is bash-compatible"
1558 exit 1
1559 fi
1560 if test "x$DUMPSTATE" = xt ; then
1561 cp -f $AD_OPTFILE "genmake_ad_optfile"
1562 fi
1563 else
1564 echo "Error: can't read AD_OPTFILE=\"$AD_OPTFILE\""
1565 exit 1
1566 fi
1567 fi
1568
1569 #====================================================================
1570 # Set default values if not set by the optfile
1571 #
1572 # Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined. If not,
1573 # either set defaults or complain and abort!
1574 if test ! "x$BASH" = x ; then
1575 # add a trailing space so that it works within the Makefile syntax (see below)
1576 BASH="$BASH "
1577 fi
1578 if test "x$FC" = x ; then
1579 cat <<EOF 1>&2
1580
1581 Error: no Fortran compiler: please specify using one of the following:
1582 1) within the options file ("FC=...") as specified by "-of=OPTFILE"
1583 2) the "-fc=XXX" command-line option
1584 3) the "./genmake_local" file
1585 EOF
1586 exit 1
1587 fi
1588 if test "x$GET_FC_VERSION" != x ; then
1589 echo "Get compiler version using: $FC $GET_FC_VERSION" >> $LOGFILE
1590 ff=`echo $FC | sed 's/ .*//'` ; xx=`echo $ff | sed 's/^./& /' | sed 's/ .*//'`
1591 if test $xx != '/' ; then which $ff >> $LOGFILE ; fi
1592 $FC $GET_FC_VERSION > genmake_fc_vers1 2> genmake_fc_vers2
1593 if test -s genmake_fc_vers1 ; then
1594 cat genmake_fc_vers1 >> $LOGFILE
1595 else
1596 cat genmake_fc_vers2 >> $LOGFILE
1597 fi
1598 echo "<-- compiler version ----" >> $LOGFILE
1599 rm -f genmake_fc_vers1 genmake_fc_vers2
1600 fi
1601
1602 if test "x$CC" = x ; then
1603 look_for_C_compilers
1604 fi
1605
1606 if test "x$LINK" = x ; then
1607 LINK=$FC
1608 fi
1609 if test "x$MAKE" = x ; then
1610 MAKE="make"
1611 fi
1612 if test "x$CPP" = x ; then
1613 CPP="cpp -traditional -P"
1614 fi
1615 #EH3 === UGLY ===
1616 # The following is an ugly little hack to check for $CPP in /lib/ and
1617 # it should eventually be replaced with a more general function that
1618 # searches a combo of the user's path and a list of "usual suspects"
1619 # to find the correct location for binaries such as $CPP.
1620 for i in " " "/lib/" ; do
1621 echo "#define A a" | $i$CPP > test_cpp 2>&1 && CPP=$i$CPP
1622 done
1623 #EH3 === UGLY ===
1624 echo "#define A a" | $CPP > test_cpp 2>&1
1625 RETVAL=$?
1626 if test "x$RETVAL" != x0 ; then
1627 cat <<EOF 1>&2
1628
1629 Error: C pre-processor "$CPP" failed the test case: please specify using:
1630
1631 1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
1632 2) the "./genmake_local" file
1633 3) with the CPP environment variable
1634
1635 EOF
1636 exit 1
1637 else
1638 rm -f test_cpp
1639 fi
1640
1641 look_for_makedepend
1642
1643 # Check that soft-link command is set and usable
1644 if test "x$LN" = x ; then
1645 LN="ln -s"
1646 fi
1647 echo "test" > genmake_test_ln
1648 $LN genmake_test_ln genmake_tlink
1649 RETVAL=$?
1650 if test "x$RETVAL" != x0 ; then
1651 cat <<EOF 1>&2
1652
1653 Error: The command "$LN" failed -- please specify a working soft-link
1654 command in the optfile.
1655
1656 EOF
1657 exit 1
1658 fi
1659 test -L genmake_tlink > /dev/null 2>&1
1660 RETVAL=$?
1661 if test "x$RETVAL" = x0 ; then
1662 HAVE_TEST_L=t
1663 fi
1664 rm -f genmake_test_ln genmake_tlink
1665
1666 # Check for broken *.F/*.f handling and fix if possible
1667 check_for_broken_Ff
1668
1669 if test ! "x$MPI" = x ; then
1670 echo " Turning on MPI cpp macros"
1671 DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1672 fi
1673 if test ! "x$OMP" = x ; then
1674 echo " Add OMPFLAG and turn on OpenMP cpp macros"
1675 FFLAGS="$FFLAGS $OMPFLAG"
1676 F90FLAGS="$F90FLAGS $OMPFLAG"
1677 DEFINES="$DEFINES -DUSE_OMP_THREADING"
1678 fi
1679
1680 if test ! "x$USE_R4" = x ; then
1681 echo " Turning on LET_RS_BE_REAL4 cpp flag"
1682 DEFINES="$DEFINES -DLET_RS_BE_REAL4"
1683 fi
1684
1685 if test ! "x$TS" = x ; then
1686 echo " Turning on timing per timestep"
1687 if test ! "x$FOOLAD" = x ; then
1688 DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"
1689 else
1690 DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1691 fi
1692 PACKAGES="$PACKAGES showflops"
1693 fi
1694 if test ! "x$PAPIS" = x ; then
1695 echo " Turning on PAPI flop summary per timestep"
1696 echo " Please make sure PAPIINC, PAPILIB are defined"
1697 if test ! "x$FOOLAD" = x ; then
1698 DEFINES="$DEFINES -DUSE_PAPI_FLOPS_SFP"
1699 else
1700 DEFINES="$DEFINES -DUSE_PAPI_FLOPS"
1701 fi
1702 INCLUDES="$INCLUDES $PAPIINC"
1703 LIBS="$LIBS $PAPILIB"
1704 PACKAGES="$PACKAGES showflops"
1705 fi
1706 if test ! "x$PCLS" = x ; then
1707 echo " Turning on PCL counter summary per timestep"
1708 echo " Please make sure PCLINC, PCLLIB are defined"
1709 if test ! "x$FOOLAD" = x ; then
1710 DEFINES="$DEFINES -DUSE_PCL_FLOPS_SFP"
1711 else
1712 DEFINES="$DEFINES -DUSE_PCL_FLOPS"
1713 fi
1714 INCLUDES="$INCLUDES $PCLINC"
1715 LIBS="$LIBS $PCLLIB"
1716 PACKAGES="$PACKAGES showflops"
1717 fi
1718 if test ! "x$PAPI" = x ; then
1719 if test ! "x$PAPIS" = x ; then
1720 echo " PAPI performance analysis and flop summary per timestep cannot co-exist!"
1721 echo " Sticking with PAPI flop summary per timestep!"
1722 else
1723 echo " Turning on performance analysis with PAPI"
1724 echo " Please make sure PAPIINC, PAPILIB are defined"
1725 DEFINES="$DEFINES -DUSE_PAPI"
1726 INCLUDES="$INCLUDES $PAPIINC"
1727 LIBS="$LIBS $PAPILIB"
1728 fi
1729 fi
1730 if test ! "x$PCL" = x ; then
1731 if test ! "x$PCLS" = x ; then
1732 echo " PCL performance analysis and flop summary per timestep cannot co-exist!"
1733 echo " Sticking with PCL flop summary per timestep!"
1734 else
1735 echo " Turning on performance analysis with PCL"
1736 echo " Please make sure PCLINC, PCLLIB are defined"
1737 DEFINES="$DEFINES -DUSE_PCL"
1738 INCLUDES="$INCLUDES $PCLINC"
1739 LIBS="$LIBS $PCLLIB"
1740 fi
1741 fi
1742 if test ! "x$HPMT" = x ; then
1743 if test ! "x$PAPI" = x ; then
1744 echo " PAPI and the HPM Toolkit cannot co-exist!"
1745 echo " Sticking with PAPI!"
1746 else
1747 if test ! "x$PCL" = x ; then
1748 echo " PCL and the HPM Toolkit cannot co-exist!"
1749 echo " Sticking with PCL!"
1750 else
1751 echo " Turning on performance analysis with the HPM Toolkit"
1752 echo " Please make sure HPMTINC, HPMTLIB are defined"
1753 DEFINES="$DEFINES -DUSE_LIBHPM"
1754 INCLUDES="$INCLUDES $HPMTINC"
1755 LIBS="$LIBS $HPMTLIB"
1756 fi
1757 fi
1758 fi
1759 if test ! "x$GSL" = x ; then
1760 echo " Turning on use of GSL to control floating point calculations"
1761 echo " Please make sure GSLINC, GSLLIB are defined"
1762 DEFINES="$DEFINES -DUSE_GSL_IEEE"
1763 INCLUDES="$INCLUDES $GSLINC"
1764 LIBS="$LIBS $GSLLIB"
1765 fi
1766 #- if USE_EXTENDED_SRC is set, add EXTENDED_SRC_FLAG to FFLAGS :
1767 if test ! "x$USE_EXTENDED_SRC" = x ; then
1768 FFLAGS="$FFLAGS $EXTENDED_SRC_FLAG"
1769 F90FIXEDFORMAT="$F90FIXEDFORMAT $EXTENDED_SRC_FLAG"
1770 fi
1771
1772 printf "\n=== Checking system libraries ===\n"
1773 printf " Do we have the system() command using $FC... "
1774 cat > genmake_tcomp.$FS <<EOF
1775 program hello
1776 call system('echo hi')
1777 end
1778 EOF
1779 $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1780 RETVAL=$?
1781 if test "x$RETVAL" = x0 ; then
1782 HAVE_SYSTEM=t
1783 DEFINES="$DEFINES -DHAVE_SYSTEM"
1784 echo "yes"
1785 else
1786 HAVE_SYSTEM=
1787 echo "no"
1788 fi
1789 rm -f genmake_tcomp*
1790
1791 printf " Do we have the fdate() command using $FC... "
1792 cat > genmake_tcomp.$FS <<EOF
1793 program hello
1794 CHARACTER*(128) string
1795 string = ' '
1796 call fdate( string )
1797 print *, string
1798 end
1799 EOF
1800 $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1801 RETVAL=$?
1802 if test "x$RETVAL" = x0 ; then
1803 HAVE_FDATE=t
1804 DEFINES="$DEFINES -DHAVE_FDATE"
1805 echo "yes"
1806 else
1807 HAVE_FDATE=
1808 echo "no"
1809 fi
1810 rm -f genmake_tcomp*
1811
1812 printf " Do we have the etime() command using $FC... "
1813 cat > genmake_tcomp.$FS <<EOF
1814 program hello
1815 REAL*4 ACTUAL, TARRAY(2)
1816 EXTERNAL ETIME
1817 REAL*4 ETIME
1818 actual = etime( tarray )
1819 print *, tarray
1820 end
1821 EOF
1822 $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1823 RETVAL=$?
1824 if test "x$RETVAL" = x0 ; then
1825 HAVE_ETIME=t
1826 DEFINES="$DEFINES -DHAVE_ETIME"
1827 echo "yes"
1828 else
1829 HAVE_ETIME=
1830 echo "no"
1831 fi
1832 rm -f genmake_tcomp*
1833
1834 printf " Can we call simple C routines (here, \"cloc()\") using $FC... "
1835 check_HAVE_CLOC
1836 if test "x$HAVE_CLOC" != x ; then
1837 DEFINES="$DEFINES -DHAVE_CLOC"
1838 echo "yes"
1839 else
1840 echo "no"
1841 if test "x$EMBED_SRC" = xt ; then
1842 echo " WARNING: you requested file embedding but it has"
1843 echo " been disabled since C code cannot be called"
1844 EMBED_SRC=
1845 fi
1846 fi
1847 rm -f genmake_t*
1848
1849 printf " Can we unlimit the stack size using $FC... "
1850 check_HAVE_SETRLSTK
1851 if test "x$HAVE_SETRLSTK" = xt ; then
1852 DEFINES="$DEFINES -DHAVE_SETRLSTK"
1853 echo "yes"
1854 else
1855 echo "no"
1856 fi
1857 rm -f genmake_t*
1858
1859 printf " Can we register a signal handler using $FC... "
1860 check_HAVE_SIGREG
1861 if test "x$HAVE_SIGREG" = xt ; then
1862 DEFINES="$DEFINES -DHAVE_SIGREG"
1863 echo "yes"
1864 else
1865 echo "no"
1866 fi
1867 rm -f genmake_t*
1868
1869 printf " Can we use stat() through C calls... "
1870 check_HAVE_STAT
1871 if test "x$HAVE_STAT" != x ; then
1872 DEFINES="$DEFINES -DHAVE_STAT"
1873 echo "yes"
1874 else
1875 echo "no"
1876 fi
1877 rm -f genmake_t*
1878
1879 printf " Can we create NetCDF-enabled binaries... "
1880 check_netcdf_libs
1881 if test "x$HAVE_NETCDF" != x ; then
1882 DEFINES="$DEFINES -DHAVE_NETCDF"
1883 echo "yes"
1884 else
1885 echo "no"
1886 fi
1887
1888 printf " Can we create LAPACK-enabled binaries... "
1889 check_lapack_libs
1890 if test "x$HAVE_LAPACK" != x ; then
1891 DEFINES="$DEFINES -DHAVE_LAPACK"
1892 echo "yes"
1893 else
1894 echo "no"
1895 fi
1896 DEFINES="$DEFINES $IGNORE_TIME"
1897
1898 if test "x$EMBED_SRC" = xt ; then
1899 build_embed_encode
1900 fi
1901 if test "x$EMBED_SRC" = xt ; then
1902 ENABLE="$ENABLE embed_files"
1903 # DEFINES="$DEFINES -DHAVE_EMBED_SRC"
1904 fi
1905
1906 printf "\n=== Setting defaults ===\n"
1907 printf " Adding MODS directories: "
1908 for d in $MODS ; do
1909 if test ! -d $d ; then
1910 echo
1911 echo "Error: MODS directory \"$d\" not found!"
1912 exit 1
1913 else
1914 printf "$d "
1915 SOURCEDIRS="$SOURCEDIRS $d"
1916 INCLUDEDIRS="$INCLUDEDIRS $d"
1917 fi
1918 done
1919 echo
1920
1921 #if test "x${PLATFORM}" = x ; then
1922 # PLATFORM=$p_PLATFORM
1923 #fi
1924
1925 if test "x${EXEDIR}" = x ; then
1926 tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1927 if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1928 EXEDIR=../exe
1929 else
1930 EXEDIR=.
1931 fi
1932 fi
1933 if test ! -d ${EXEDIR} ; then
1934 echo "Error: the specified EXEDIR (\"$EXEDIR\") does not exist!"
1935 exit 1
1936 fi
1937
1938 if test "x${TOOLSDIR}" = x ; then
1939 TOOLSDIR="$ROOTDIR/tools"
1940 fi
1941 if test ! -d ${TOOLSDIR} ; then
1942 echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"
1943 exit 1
1944 fi
1945 if test "x$S64" = x ; then
1946 echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1947 RETVAL=$?
1948 if test "x${RETVAL}" = x0 ; then
1949 S64='$(TOOLSDIR)/set64bitConst.sh'
1950 else
1951 echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1952 RETVAL=$?
1953 if test "x${RETVAL}" = x0 ; then
1954 S64='$(TOOLSDIR)/set64bitConst.csh'
1955 else
1956 cat <<EOF
1957
1958 ERROR: neither of the two default scripts:
1959
1960 ${TOOLSDIR}/set64bitConst.sh
1961 ${TOOLSDIR}/set64bitConst.csh
1962
1963 are working so please check paths or specify (with \$S64) a
1964 working version of this script.
1965
1966 EOF
1967 exit 1
1968 fi
1969 fi
1970 fi
1971 THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1972
1973 EXECUTABLE=${EXECUTABLE:-mitgcmuv}
1974
1975 # Set Standard Code Directories:
1976 if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
1977 STANDARDDIRS="eesupp model"
1978 fi
1979 # if model in Standard-Code-Dir, add eesupp (needed to compile model)
1980 echo " $STANDARDDIRS " | grep ' model ' > /dev/null 2>&1
1981 ckM=$?
1982 echo " $STANDARDDIRS " | grep ' eesupp ' > /dev/null 2>&1
1983 ckE=$?
1984 if test $ckM = 0 -a $ckE = 1 ; then
1985 STANDARDDIRS="$STANDARDDIRS eesupp"
1986 fi
1987
1988 # We have a special set of source files in eesupp/src which are
1989 # generated from some template source files. We'll make them first so
1990 # they appear as regular source code
1991 if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
1992 echo " Making source files in eesupp from templates"
1993 ( cd $ROOTDIR"/eesupp/src/" && $MAKE clean_old && $MAKE \
1994 ) > make_eesupp.errors 2>&1
1995 RETVAL=$?
1996 if test "x${RETVAL}" = x0 ; then
1997 rm -f make_eesupp.errors
1998 else
1999 echo "Error: problem encountered while building source files in eesupp:"
2000 cat make_eesupp.errors 1>&2
2001 exit 1
2002 fi
2003 fi
2004
2005 #same for pkg/exch2 and pkg/regrid
2006 for pdir in exch2 regrid ; do
2007 if test -r $ROOTDIR"/pkg/${pdir}/Makefile" ; then
2008 echo " Making source files in pkg/${pdir} from templates"
2009 ( cd $ROOTDIR"/pkg/"${pdir} && $MAKE clean_old && $MAKE \
2010 ) > make_${pdir}.errors 2>&1
2011 RETVAL=$?
2012 if test "x${RETVAL}" = x0 ; then
2013 rm -f make_${pdir}.errors
2014 else
2015 echo "Error: problem encountered while building source files in pkg/${pdir}:"
2016 cat make_${pdir}.errors 1>&2
2017 exit 1
2018 fi
2019 fi
2020 done
2021
2022 printf "\n=== Determining package settings ===\n"
2023 if test "x${PKG_DEPEND}" = x ; then
2024 tmp=$ROOTDIR"/pkg/pkg_depend"
2025 if test -r $tmp ; then PKG_DEPEND=$tmp ; fi
2026 fi
2027 if test "x${PKG_DEPEND}" = x ; then
2028 echo "Warning: No package dependency information was specified."
2029 echo " Please check that ROOTDIR/pkg/pkg_depend exists."
2030 else
2031 if test ! -r ${PKG_DEPEND} ; then
2032 echo "Error: can't read package dependency info from PKG_DEPEND=\"$PKG_DEPEND\""
2033 exit 1
2034 fi
2035 echo " getting package dependency info from $PKG_DEPEND"
2036 # Strip the comments and then convert the dependency file into arrays: PNAME, DNAME
2037 get_pdepend_list $PKG_DEPEND
2038 fi
2039
2040 # A default package groups file "$ROOTDIR/pkg/pkg_groups" is provided
2041 # to define the "default_pkg_list" and package groups (for convenience, one
2042 # can specify a group of packages using names like "ocean" and "atmosphere").
2043 if test "x${PKG_GROUPS}" = x ; then
2044 tmp=$ROOTDIR"/pkg/pkg_groups"
2045 if test -r $tmp ; then PKG_GROUPS=$tmp ; fi
2046 fi
2047 if test "x${PKG_GROUPS}" = x ; then
2048 echo "Warning: No package groups information was specified."
2049 echo " Please check that ROOTDIR/pkg/pkg_groups exists."
2050 else
2051 if test ! -r ${PKG_GROUPS} ; then
2052 echo "Error: can't read package groups info from PKG_GROUPS=\"$PKG_GROUPS\""
2053 exit 1
2054 fi
2055 echo " getting package groups info from $PKG_GROUPS"
2056 fi
2057
2058 # Search for packages to compile.
2059 echo " checking list of packages to compile:"
2060 PKG_LIST=
2061 if test "x${PKG_LIST}" = x ; then
2062 for i in "." $MODS ; do
2063 if test -r $i"/packages.conf" ; then
2064 PKG_LIST=$i"/packages.conf"
2065 break
2066 fi
2067 done
2068 fi
2069 if test "x${PKG_LIST}" = x ; then
2070 pkg_list='default_pkg_list'
2071 if test "x${PKG_GROUPS}" = x ; then
2072 echo "Error: need package groups info to expand pkg_list=\"$pkg_list\""
2073 exit 1
2074 fi
2075 else
2076 if test ! -r $PKG_LIST ; then
2077 echo "Error: can't read package list from PKG_LIST=\"$PKG_LIST\""
2078 exit 1
2079 else
2080 echo " using PKG_LIST=\"$PKG_LIST\""
2081 # Strip the comments and add all the names
2082 pkg_list=`cat $PKG_LIST | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
2083 RETVAL=$?
2084 if test "x${RETVAL}" != x0 ; then
2085 printf "Error: can't parse package list "
2086 echo "-- please check PKG_LIST=\"$PKG_LIST\""
2087 exit 1
2088 fi
2089 fi
2090 fi
2091 for i in $pkg_list ; do
2092 PACKAGES="$PACKAGES $i"
2093 done
2094 echo " before group expansion packages are:$PACKAGES"
2095 if test "x${PKG_GROUPS}" != x ; then
2096 RET=1
2097 while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
2098 echo " after group expansion packages are: $PACKAGES"
2099 fi
2100
2101 echo " applying DISABLE settings"
2102 echo "" > ./.tmp_pack
2103 for i in $PACKAGES ; do
2104 echo $i >> ./.tmp_pack
2105 done
2106 for i in `grep "-" ./.tmp_pack` ; do
2107 j=`echo $i | sed 's/[-]//'`
2108 DISABLE="$DISABLE $j"
2109 done
2110 pack=
2111 for p in $PACKAGES ; do
2112 addit="t"
2113 for d in $DISABLE ; do
2114 if test "x$p" = "x$d" ; then
2115 addit="f"
2116 fi
2117 done
2118 if test "x$addit" = xt ; then
2119 pack="$pack $p"
2120 fi
2121 done
2122 PACKAGES="$pack"
2123 echo " applying ENABLE settings"
2124 echo "" > ./.tmp_pack
2125 PACKAGES="$PACKAGES $ENABLE"
2126 # Test if each explicitly referenced package exists
2127 for i in $PACKAGES ; do
2128 j=`echo $i | sed 's/[-+]//'`
2129 if test ! -d "$ROOTDIR/pkg/$j" ; then
2130 echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
2131 exit 1
2132 fi
2133 echo $i >> ./.tmp_pack
2134 done
2135 PACKAGES=
2136 for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do
2137 PACKAGES="$PACKAGES $i"
2138 done
2139 rm -f ./.tmp_pack
2140 echo " packages are: $PACKAGES"
2141
2142 # Check for package MNC: if NetCDF is available, then build the MNC
2143 # template files ; otherwise, delete mnc from the list of packages.
2144 echo " $PACKAGES " | grep ' mnc ' > /dev/null 2>&1
2145 mnc_in=$?
2146 if test "x$HAVE_NETCDF" != xt ; then
2147 if test "x$mnc_in" = x0 ; then
2148 cat <<EOF
2149 *********************************************************************
2150 WARNING: the "mnc" package was enabled but tests failed to compile
2151 NetCDF applications. Please check that:
2152
2153 1) NetCDF is correctly installed for this compiler and
2154 2) the LIBS variable (within the "optfile") specifies the correct
2155 NetCDF library to link against.
2156
2157 Due to this failure, the "mnc" package is now DISABLED.
2158 *********************************************************************
2159 EOF
2160 PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
2161 DISABLE="$DISABLE mnc"
2162 else
2163 # this prevent to add mnc (due to pdepend rules) if not available
2164 DISABLE="$DISABLE mnc"
2165 fi
2166 else
2167 # we have NetCDF, we try to build MNC template files
2168 ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
2169 RETVAL=$?
2170 if test "x${RETVAL}" = x0 ; then
2171 rm -f make_mnc.errors
2172 else
2173 echo "Error: problem encountered while building source files in pkg/mnc:"
2174 cat make_mnc.errors 1>&2
2175 if test "x$mnc_in" = x0 ; then
2176 exit 1
2177 else
2178 DISABLE="$DISABLE mnc"
2179 fi
2180 fi
2181 fi
2182
2183 # Check for package PROFILES: if NetCDF is not available,
2184 # then delete profiles from the list of available packages.
2185 if test "x$HAVE_NETCDF" != xt ; then
2186 echo " $PACKAGES " | grep ' profiles ' > /dev/null 2>&1
2187 RETVAL=$?
2188 if test "x$RETVAL" = x0 ; then
2189 cat <<EOF
2190 *********************************************************************
2191 WARNING: the "profiles" package was enabled but tests failed to
2192 compile NetCDF applications. Please check that:
2193
2194 1) NetCDF is correctly installed for this compiler and
2195 2) the LIBS variable (within the "optfile") specifies the correct
2196 NetCDF library to link against.
2197
2198 Due to this failure, the "profiles" package is now DISABLED.
2199 *********************************************************************
2200 EOF
2201 PACKAGES=`echo $PACKAGES | sed -e 's/profiles//g'`
2202 DISABLE="$DISABLE profiles"
2203 else
2204 # this prevent to add profiles (due to pdepend rules) if not available
2205 DISABLE="$DISABLE profiles"
2206 fi
2207 fi
2208
2209 # Check for package RADTRANS: if LAPACK is not available,
2210 # then issue a warning that the direct radtrans solver is not available.
2211 if test "x$HAVE_LAPACK" != xt ; then
2212 echo " $PACKAGES " | grep ' radtrans ' > /dev/null 2>&1
2213 RETVAL=$?
2214 if test "x$RETVAL" = x0 ; then
2215 cat <<EOF
2216 *********************************************************************
2217 WARNING: the "radtrans" package was enabled but tests failed to
2218 compile LAPACK applications. This means that the direct radtrans
2219 solver is not available and compilation will fail if it is enabled.
2220 If you want to use the direct solver, please check that:
2221
2222 1) LAPACK is correctly installed for this compiler and
2223 2) the LIBS variable (within the "optfile") specifies the correct
2224 LAPACK library to link against.
2225 *********************************************************************
2226 EOF
2227 fi
2228 fi
2229
2230 if test "x${PKG_DEPEND}" != x ; then
2231 echo " applying package dependency rules"
2232 ck=
2233 while test "x$ck" != xtt ; do
2234 i=0
2235 # rtot=${#PNAME[@]}
2236 rtot=$nname
2237 while test $i -le $rtot ; do
2238
2239 # Is $pname in the current $PACKAGES list?
2240 # pname=${PNAME[$i]}
2241 tmp="pname=\"\$PNAME_$i\""
2242 eval $tmp
2243 pin="f"
2244 for p in $PACKAGES ; do
2245 if test "x$p" = "x$pname" ; then
2246 pin="t"
2247 fi
2248 done
2249 # or in the current $STANDARDDIRS list?
2250 for p in $STANDARDDIRS ; do
2251 if test "x$p" = "x$pname" ; then pin="t" ; fi
2252 done
2253
2254 # Is the DNAME entry a (+) or (-) rule ?
2255 tmp="dname=\"\$DNAME_$i\""
2256 eval $tmp
2257 plus="-"
2258 echo $dname | grep '^+' > /dev/null 2>&1
2259 RETVAL=$?
2260 if test "x$RETVAL" = x0 ; then
2261 plus="+"
2262 fi
2263
2264 # Is $dname in the current $PACKAGES list?
2265 dname=`echo $dname | sed -e 's/^[+-]//'`
2266 din="f"
2267 for p in $PACKAGES ; do
2268 if test "x$p" = "x$dname" ; then
2269 din="t"
2270 fi
2271 done
2272
2273 # Do we need to add $dname according to the dependency rules?
2274 if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then
2275 #echo " " $pname ": need to add :" $dname
2276 in_dis="f"
2277 for dis in $DISABLE ; do
2278 if test "x$dis" = "x$dname" ; then
2279 in_dis="t"
2280 fi
2281 done
2282 if test "x$in_dis" = xt ; then
2283 echo "Error: can't satisfy package dependencies:"
2284 echo " \"$dname\" is required by the dependency rules"
2285 echo " but is disallowed by the DISABLE settings"
2286 exit 1
2287 else
2288 PACKAGES="$PACKAGES $dname"
2289 ck=
2290 fi
2291 fi
2292
2293 # Do we need to get rid of $dname according to the dependency rules?
2294 if test "x$pin" = xt -a "x$plus" = "x-" -a "x$din" = xt; then
2295 echo "Error: can't satisfy package dependencies:"
2296 echo " \"$pname\" was requested but is disallowed by"
2297 echo " the dependency rules for \"$dname\""
2298 exit 1
2299 fi
2300 i=`echo "$i + 1" | bc -l`
2301 #i=$(( $i + 1 ))
2302 done
2303 ck=$ck"t"
2304 done
2305 echo " packages are: $PACKAGES"
2306 fi
2307 for i in $PACKAGES ; do
2308 adr="$ROOTDIR/pkg/$i"
2309 if test -d $adr ; then
2310 SOURCEDIRS="$SOURCEDIRS $adr"
2311 INCLUDEDIRS="$INCLUDEDIRS $adr"
2312 if test "x$i" = xautodiff ; then
2313 AUTODIFF_PKG_USED=t
2314 fi
2315 else
2316 echo "Error: the directory \"$adr\" for package $i doesn't exist"
2317 exit 1
2318 fi
2319 done
2320
2321 # Create a list of #define and #undef to enable/disable packages
2322 PACKAGES_DOT_H=PACKAGES_CONFIG.h
2323 # The following UGLY HACK sets multiple "#undef"s and it needs to go
2324 # away. On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h
2325 # file would eventually be split up so that all package-related #define
2326 # statements could be separated and handled only by genmake.
2327 names=`ls -1 "$ROOTDIR/pkg"`
2328 all_pack=
2329 DISABLED_PACKAGES=
2330 for n in $names ; do
2331 if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then
2332 has_pack="f"
2333 for pack in $PACKAGES ; do
2334 if test "x$pack" = "x$n" ; then
2335 has_pack="t"
2336 break
2337 fi
2338 done
2339 if test "x$has_pack" = xf ; then
2340 undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
2341 DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
2342 fi
2343 fi
2344 done
2345 ENABLED_PACKAGES=
2346 for i in $PACKAGES ; do
2347 def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
2348 ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
2349 #eh3 DEFINES="$DEFINES -D$def"
2350
2351 #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
2352 case $i in
2353 aim_v23)
2354 ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
2355 echo "Warning: ALLOW_AIM is set to enable aim_v23."
2356 ;;
2357 esac
2358 #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
2359
2360 done
2361
2362 echo " Adding STANDARDDIRS='$STANDARDDIRS'"
2363 BUILDDIR=${BUILDDIR:-.}
2364 if test "x$STANDARDDIRS" != x ; then
2365 for d in $STANDARDDIRS ; do
2366 adr="$ROOTDIR/$d/src"
2367 if test ! -d $adr ; then
2368 echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
2369 echo " is correct and that you correctly specified the STANDARDDIRS option"
2370 exit 1
2371 else
2372 SOURCEDIRS="$SOURCEDIRS $adr"
2373 fi
2374 adr="$ROOTDIR/$d/inc"
2375 if test ! -d $adr ; then
2376 echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
2377 echo " is correct and that you correctly specified the STANDARDDIRS option"
2378 exit 1
2379 else
2380 INCLUDEDIRS="$INCLUDEDIRS $adr"
2381 fi
2382 done
2383 fi
2384
2385 echo " Searching for *OPTIONS.h files in order to warn about the presence"
2386 echo " of \"#define \"-type statements that are no longer allowed:"
2387 CPP_OPTIONS=
2388 CPP_EEOPTIONS=
2389 spaths=". $INCLUDEDIRS"
2390 names=`ls -1 "$ROOTDIR/pkg"`
2391 for i in $spaths ; do
2392 try="$i/CPP_OPTIONS.h"
2393 if test -f $try -a -r $try -a "x$CPP_OPTIONS" = x ; then
2394 echo " found CPP_OPTIONS=\"$try\""
2395 CPP_OPTIONS="$try"
2396 # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
2397 for n in $names ; do
2398 test_for_package_in_cpp_options $CPP_OPTIONS $n
2399 done
2400 fi
2401 try="$i/CPP_EEOPTIONS.h"
2402 if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" = x ; then
2403 echo " found CPP_EEOPTIONS=\"$try\""
2404 # New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h
2405 #**** not yet enabled ****
2406 # test_for_mpi_in_cpp_eeoptions $try
2407 #**** not yet enabled ****
2408 CPP_EEOPTIONS="$try"
2409 fi
2410 done
2411 if test "x$CPP_OPTIONS" = x ; then
2412 echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"
2413 exit 1
2414 fi
2415
2416 # Here, we build the list of files to be "run through" the adjoint
2417 # compiler.
2418 if test -f ./adSrcFiles.tmp ; then
2419 rm -f ./adSrcFiles.tmp
2420 fi
2421 echo " Creating the list of files for the adjoint compiler."
2422 touch adSrcFiles.tmp
2423 for i in $SOURCEDIRS ; do
2424 list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2425 for j in $list_files ; do
2426 cat $i/$j >> adSrcFiles.tmp
2427 done
2428 done
2429 if test ! "x"$FS = "x.f" ; then
2430 cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f
2431 mv -f adSrcFiles.tmp_f adSrcFiles.tmp
2432 fi
2433
2434 echo
2435 echo "=== Creating the Makefile ==="
2436 echo " setting INCLUDES"
2437 for i in $INCLUDEDIRS ; do
2438 if test ! -d $i ; then
2439 echo "Warning: can't find INCLUDEDIRS=\"$i\""
2440 fi
2441 done
2442
2443 if test ! "x$DIVA" = x ; then
2444 echo " Creating the pseudo-MPI include directory"
2445 INCLUDES="-I./mpi_headers $INCLUDES"
2446 rm -rf ./mpi_headers
2447 mkdir -p ./mpi_headers
2448
2449 if test "x$MPIINCLUDEDIR" = x ; then
2450 if test "x$MPIHOME" = x ; then
2451 MPIHOME='/usr'
2452 fi
2453 MPIINCLUDEDIR='$MPIHOME/include'
2454 fi
2455
2456 if test -r $MPIINCLUDEDIR/mpif.h ; then
2457 for i in $MPI_HEADER_FILES; do
2458 cp -p $MPIINCLUDEDIR/$i ./mpi_headers
2459 done
2460
2461 perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h
2462 else
2463 echo " We cannot create a copy of mpif.h!"
2464 # exit -1
2465 fi
2466 fi
2467
2468 echo " Determining the list of source and include files"
2469 rm -rf .links.tmp
2470 mkdir .links.tmp
2471 touch .links.tmp/foo
2472 if test ! -r ".links.tmp/foo" ; then
2473 echo
2474 echo "ERROR : something is wrong with your directory permissions or"
2475 echo " your user file-creation mask (\"umask\") since creating a"
2476 echo " sub-dir, touch-ing a file within it, and then reading it is"
2477 echo " not working. Please try setting your umask to something"
2478 echo " sane such as:"
2479 echo
2480 echo " umask 0002"
2481 echo
2482 echo " and please verify that you have the proper permissions for"
2483 echo " creating sub-directories and then reading files created"
2484 echo " within them."
2485 echo
2486 exit 1
2487 fi
2488 rm -f .links.tmp/foo
2489
2490 if test "x$OPENAD" != x ; then
2491 OAD_DONT_COMPILE="/dev/null"
2492 OAD_DONT_TRANSFORM="/dev/null"
2493 OAD_KEEP_ORIGINAL="/dev/null"
2494 OAD_CB2M_FILES="/dev/null"
2495 echo " looking for dontCompile file: "
2496 for i in "." $MODS ; do
2497 if test -r $i"/dontCompile" ; then
2498 OAD_DONT_COMPILE=$i"/dontCompile"
2499 echo " found $OAD_DONT_COMPILE"
2500 break
2501 fi
2502 done
2503 echo " looking for dontTransform file: "
2504 for i in "." $MODS ; do
2505 if test -r $i"/dontTransform" ; then
2506 OAD_DONT_TRANSFORM=$i"/dontTransform"
2507 echo " found $OAD_DONT_TRANSFORM"
2508 break
2509 fi
2510 done
2511 echo " looking for keepOriginal file: "
2512 for i in "." $MODS ; do
2513 if test -r $i"/keepOriginal" ; then
2514 OAD_KEEP_ORIGINAL=$i"/keepOriginal"
2515 echo " found $OAD_KEEP_ORIGINAL"
2516 break
2517 fi
2518 done
2519 echo " looking for cb2mFiles: "
2520 for i in "." $MODS ; do
2521 if test -r $i"/cb2mFiles" ; then
2522 OAD_CB2M_FILES=$i"/cb2mFiles"
2523 echo " found $OAD_CB2M_FILES"
2524 break
2525 fi
2526 done
2527 echo " OpenAD exceptions: "
2528 fi
2529
2530 echo "# This section creates symbolic links" > srclinks.tmp
2531 echo "" >> srclinks.tmp
2532 printf 'F77_SRC_FILES = ' > F77srclist.tmp
2533 printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp
2534 printf 'C_SRC_FILES = ' > csrclist.tmp
2535 printf 'F90_SRC_FILES = ' > F90srclist.tmp
2536 printf 'H_SRC_FILES = ' > hsrclist.tmp
2537 printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp
2538 alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2539 for d in $alldirs ; do
2540 deplist=
2541 sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
2542 sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
2543 if test "x$OPENAD" != x ; then
2544 sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2545 fi
2546 for sf in $sfiles ; do
2547 if test ! -r ".links.tmp/$sf" ; then
2548 if test -f "$d/$sf" ; then
2549 ignore_f=f
2550 case $d/$sf in
2551 ./$PACKAGES_DOT_H)
2552 ignore_f=t
2553 ;;
2554 ./AD_CONFIG.h)
2555 ignore_f=t
2556 ;;
2557 ./FC_NAMEMANGLE.h)
2558 ignore_f=t
2559 ;;
2560 ./BUILD_INFO.h)
2561 ignore_f=t
2562 ;;
2563 ./EMBEDDED_FILES.h)
2564 ignore_f=t
2565 ;;
2566 *)
2567 # For the local directory *ONLY*,
2568 # ignore all soft-links
2569 if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
2570 ignore_f=t
2571 else
2572 touch .links.tmp/$sf
2573 deplist="$deplist $sf"
2574 fi
2575 ;;
2576 esac
2577 if test "x$ignore_f" = xf ; then
2578 extn=`echo $sf | $AWK -F. '{print $NF}'`
2579 case $extn in
2580 F)
2581 echo " \\" >> F77srclist.tmp
2582 printf " $sf" >> F77srclist.tmp
2583 if test "x$OPENAD" != x ; then
2584 basename=${sf%%.F}
2585 isAD=`egrep ^$basename.f'[ ]*' adSrcFiles.tmp`
2586 if test -z "$isAD" ; then
2587 toBeIgnored=`egrep ^$basename'[ ]*' ${OAD_DONT_COMPILE}`
2588 if test -z "$toBeIgnored" ; then
2589 echo " \\" >> nonADF77srclist.tmp
2590 printf " $sf" >> nonADF77srclist.tmp
2591 else
2592 echo " not to be compiled : $sf"
2593 fi
2594 else # file is initially listed as an AD file we want to exclude it
2595 # or we want to retain the untransformed version
2596 notToBeTransformed=`egrep ^$basename'[ ]*' ${OAD_DONT_TRANSFORM}`
2597 untransformedVersionToBeKept=`egrep ^$basename'[ ]*' ${OAD_KEEP_ORIGINAL}`
2598 if test -n "$notToBeTransformed"; then
2599 echo " not to be transformed: $sf"
2600 fi
2601 if test -n "$untransformedVersionToBeKept" ; then
2602 echo " original to be kept : $sf"
2603 fi
2604 if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2605 echo " \\" >> nonADF77srclist.tmp
2606 printf " $sf" >> nonADF77srclist.tmp
2607 fi
2608 fi
2609 fi
2610 ;;
2611 F90)
2612 echo " \\" >> F90srclist.tmp
2613 printf " $sf" >> F90srclist.tmp
2614 ;;
2615 c)
2616 echo " \\" >> csrclist.tmp
2617 printf " $sf" >> csrclist.tmp
2618 ;;
2619 h)
2620 echo " \\" >> hsrclist.tmp
2621 printf " $sf" >> hsrclist.tmp
2622 ;;
2623 flow)
2624 echo " \\" >> ad_flow_files.tmp
2625 printf " $sf" >> ad_flow_files.tmp
2626 ;;
2627 esac
2628 fi
2629 fi
2630 fi
2631 done
2632 if test "x$deplist" != x ; then
2633 if test "$d" != "." ; then
2634 echo "" >> srclinks.tmp
2635 echo "# These files are linked from $d" >> srclinks.tmp
2636 echo "$deplist :" >> srclinks.tmp
2637 # We need to make sure that the link isn't already there.
2638 # This may happen when make thinks that a header file has to be "remade"
2639 # because a module it depends on has changed. In this case we do nothing.
2640 printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp
2641 fi
2642 fi
2643 done
2644 rm -rf .links.tmp
2645 echo "" >> F77srclist.tmp
2646 echo "" >> nonADF77srclist.tmp
2647 echo "" >> csrclist.tmp
2648 echo "" >> F90srclist.tmp
2649 echo "" >> hsrclist.tmp
2650 echo "" >> ad_flow_files.tmp
2651
2652 CMDLINE=$0
2653 for xx in "$@" ; do nw=`echo $xx | wc -w`
2654 if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
2655 else CMDLINE="$CMDLINE '$xx'" ; fi
2656 done
2657
2658 if test -f $MAKEFILE ; then
2659 mv -f $MAKEFILE "$MAKEFILE.old"
2660 fi
2661 echo " Writing makefile: $MAKEFILE"
2662 echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE
2663 echo "# $MACHINE" >> $MAKEFILE
2664 echo "# This makefile was generated automatically on" >> $MAKEFILE
2665 echo "# $THISDATE" >> $MAKEFILE
2666 echo "# by the command:" >> $MAKEFILE
2667 echo "# $CMDLINE" >> $MAKEFILE
2668 echo "# executed by:" >> $MAKEFILE
2669 echo "# ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2670
2671 EXE_AD=$EXECUTABLE"_ad"
2672 EXE_FTL=$EXECUTABLE"_ftl"
2673 EXE_SVD=$EXECUTABLE"_svd"
2674
2675 cat >>$MAKEFILE <<EOF
2676 #
2677 # OPTFILE="$OPTFILE"
2678 #
2679 # BUILDDIR : Directory where object files are written
2680 # SOURCEDIRS : Directories containing the source (.F) files
2681 # INCLUDEDIRS : Directories containing the header-source (.h) files
2682 # EXEDIR : Directory where executable that is generated is written
2683 # EXECUTABLE : Full path of executable binary
2684 #
2685 # CPP : C-preprocessor command
2686 # INCLUDES : Directories searched for header files
2687 # DEFINES : Macro definitions for CPP
2688 # MAKEDEPEND : Dependency generator
2689 # FC : Fortran compiler command
2690 # FFLAGS : Configuration/debugging options for FC
2691 # FOPTIM : Optimization options for FC
2692 # LINK : Command for link editor program
2693 # LIBS : Library flags /or/ additional optimization/debugging flags
2694
2695 ROOTDIR = ${ROOTDIR}
2696 BUILDDIR = ${BUILDDIR}
2697 SOURCEDIRS = ${SOURCEDIRS}
2698 INCLUDEDIRS = ${INCLUDEDIRS}
2699 EXEDIR = ${EXEDIR}
2700 EXECUTABLE = \$(EXEDIR)/${EXECUTABLE}
2701 TOOLSDIR = ${TOOLSDIR}
2702
2703 #eh3 new defines for the adjoint work
2704 AUTODIFF = ${ROOTDIR}/pkg/autodiff
2705 EXE_AD = ${EXE_AD}
2706 EXE_FTL = ${EXE_FTL}
2707 EXE_SVD = ${EXE_SVD}
2708
2709 ENABLED_PACKAGES = ${ENABLED_PACKAGES}
2710 DISABLED_PACKAGES = ${DISABLED_PACKAGES}
2711
2712 # These files are created by Makefile
2713 SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h
2714 EOF
2715
2716 if test "x$EMBED_SRC" = xt ; then
2717 echo "EMBEDDED_FILES = EMBEDDED_FILES.h" >>$MAKEFILE
2718 else
2719 echo "EMBEDDED_FILES = " >>$MAKEFILE
2720 fi
2721
2722 cat >>$MAKEFILE <<EOF
2723 # Unix ln (link)
2724 LN = ${LN}
2725 # C preprocessor
2726 CPP = cat \$< | ${S64} | ${CPP}
2727 # Dependency generator
2728 MAKEDEPEND = ${MAKEDEPEND}
2729 # Special preprocessor (KAP on DECs, FPP on Crays)
2730 KPP = ${KPP}
2731 # Fortran compiler
2732 FC = ${FC}
2733 # Fortran compiler
2734 F90C = ${F90C}
2735 # C compiler
2736 CC = ${CC}
2737 # Link editor
2738 LINK = ${LINK} ${LDADD}
2739
2740 # Defines for CPP
2741 DEFINES = ${DEFINES}
2742 # Includes for CPP
2743 INCLUDES = ${INCLUDES}
2744 # Flags for KPP
2745 KFLAGS1 = ${KFLAGS1}
2746 KFLAGS2 = ${KFLAGS2}
2747 # Optim./debug for FC
2748 FFLAGS = ${FFLAGS} ${FEXTRAFLAGS}
2749 FOPTIM = ${FOPTIM}
2750 # Optim./debug for FC
2751 F90FLAGS = ${F90FLAGS}
2752 F90OPTIM = ${F90OPTIM}
2753 F90FIXEDFORMAT = ${F90FIXEDFORMAT}
2754 # Flags for CC
2755 CFLAGS = ${CFLAGS}
2756 # Files that should not be optimized
2757 NOOPTFILES = ${NOOPTFILES}
2758 NOOPTFLAGS = ${NOOPTFLAGS}
2759 # Flags and libraries needed for linking
2760 LIBS = ${LIBS}
2761 # Name of the makefile
2762 MAKEFILE = ${MAKEFILE}
2763 # Name of the make program
2764 MAKE = ${MAKE}
2765
2766 EOF
2767
2768 cat F77srclist.tmp >> $MAKEFILE
2769 cat nonADF77srclist.tmp >> $MAKEFILE
2770 cat csrclist.tmp >> $MAKEFILE
2771 cat F90srclist.tmp >> $MAKEFILE
2772 cat hsrclist.tmp >> $MAKEFILE
2773 cat ad_flow_files.tmp >> $MAKEFILE
2774
2775 rm -f F77srclist.tmp nonADF77srclist.tmp csrclist.tmp F90srclist.tmp hsrclist.tmp ad_flow_files.tmp
2776
2777 echo >> $MAKEFILE
2778
2779 # add definitions for preprocessed sources
2780 # and note that not all systems allow case sensitive extensions
2781 # hence the $FS and $FS90 here.
2782 # for fixed format f90 files we use ff90 or FF90 resp
2783 # but these are not expected to be the original source files
2784
2785 echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')' >> $MAKEFILE
2786 echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE
2787 echo 'OBJFILES= $(F77_SRC_FILES:.F=.o) $(C_SRC_FILES:.c=.o) $(F90_SRC_FILES:.F90=.o)' >> $MAKEFILE
2788 echo 'FLOWFILES = $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE
2789 echo >> $MAKEFILE
2790 echo '.SUFFIXES:' >> $MAKEFILE
2791 echo '.SUFFIXES: .o .'$FS' .p .F .c .f'$FS90' .'$FS90' .FF90 .F90 .flowdir .flow' >> $MAKEFILE
2792
2793 cat >>$MAKEFILE <<EOF
2794
2795 all: fwd_exe_target
2796 fwd_exe_target:
2797 @echo Update AD_CONFIG.h and make \$(EXECUTABLE)
2798 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Forward version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
2799 @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2800 @-rm -f ad_config.template
2801 \$(MAKE) -f \$(MAKEFILE) \$(EXECUTABLE)
2802
2803 \$(EXECUTABLE): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(EMBEDDED_FILES)
2804 @echo Creating \$@ ...
2805 \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2806
2807 depend:
2808 @\$(MAKE) -f \$(MAKEFILE) links
2809 \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
2810 \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2811 -rm -f makedepend.out
2812
2813 lib: libmitgcmuv.a
2814
2815 libmitgcmuv.a: \$(OBJFILES)
2816 ar rcv libmitgcmuv.a \$(OBJFILES)
2817 ar d libmitgcmuv.a main.o
2818
2819 obj: \$(OBJFILES)
2820
2821 links: \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(SPECIAL_FILES)
2822
2823 small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
2824
2825 output.txt: \$(EXECUTABLE)
2826 @printf 'running ... '
2827 @\$(EXECUTABLE) > \$@
2828
2829 # remove most of the files that "make" generates
2830 clean:
2831 -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2832 -rm -rf *.o
2833 -rm -rf *.$FS *.flowdir
2834 -rm -rf *.f$FS90 \$(AD_CLEAN) ad_input*
2835
2836 # remove most of the files that "make" and "make depend" generate
2837 Clean:
2838 @\$(MAKE) -f \$(MAKEFILE) clean
2839 @\$(MAKE) -f \$(MAKEFILE) cleanlinks
2840 -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old
2841 -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log taf_ftl.log
2842 -rm -f genmake_warnings genmake_errors make.log
2843
2844 # remove also the executable, files that "genmake2" generates (except Makefile)
2845 # and output from a run (plus log files from testreport)
2846 CLEAN:
2847 @\$(MAKE) -f \$(MAKEFILE) Clean
2848 -rm -f \$(EXECUTABLE) \$(EXE_AD) \$(EXE_FTL) *.bak
2849 -rm -f $LOGFILE genmake_state genmake_*optfile
2850 -rm -f SIZE.h.mpi genmake.tr_log make.tr_log
2851 -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2852 -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2853 -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2854 -rm -f *.txt STD* *diagnostics.log datetime
2855 -rm -f *_MIT_CE_000.opt0000 costfunction*0000
2856 -rm -rf mnc_test_*
2857
2858 makefile:
2859 $THIS_SCRIPT $G2ARGS
2860 cleanlinks:
2861 -find . -type l -exec rm {} \;
2862
2863 # Special targets (SPECIAL_FILES) which are created by make
2864 ${PACKAGES_DOT_H}:
2865 @echo Creating \$@ ...
2866 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@
2867 AD_CONFIG.h:
2868 @echo Creating \$@ ...
2869 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Default version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > \$@
2870 FC_NAMEMANGLE.h:
2871 @echo Creating \$@ ...
2872 echo "$FC_NAMEMANGLE" > \$@
2873
2874 BUILD_INFO.h:
2875 @echo Creating \$@ ...
2876 EOF
2877
2878 test ! "x$THISVER" = x && echo " -echo \"#define THISVER '$THISVER'\" > \$@" >> $MAKEFILE
2879 test ! "x$THISUSER" = x && echo " -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2880 test ! "x$THISDATE" = x && echo " -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2881 test ! "x$THISHOST" = x && echo " -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2882
2883 if test "x$EMBED_SRC" = xt ; then
2884 cat >>$MAKEFILE <<EOF
2885
2886 decode_files.o : EMBEDDED_FILES.h
2887
2888 ## \$(F77_PP_SRC_FILES)
2889 all_fF.tar.gz : \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2890 @echo Creating \$@ ...
2891 -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2892 -rm -f all_fF.tar.gz
2893 -gzip all_fF.tar
2894
2895 EMBEDDED_FILES.h : all_fF.tar.gz
2896 @echo Creating \$@ ...
2897 -\${ROOTDIR}/tools/embed_encode/encode_files EMBEDDED_FILES.h all_fF.tar.gz
2898
2899 EOF
2900 fi
2901
2902 cat >>$MAKEFILE <<EOF
2903
2904 # The normal chain of rules is ( .F - .$FS - .o )
2905
2906 ## This nullifies any default implicit rules concerning these two file types:
2907 ## %.o : %.F
2908
2909 .F.$FS:
2910 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2911 .$FS.o:
2912 \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2913 .F.o:
2914 \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2915 .F90.$FS90:
2916 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2917 .FF90.f$FS90:
2918 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2919 .$FS90.o:
2920 \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2921 .f$FS90.o:
2922 cp \$< \$(basename \$<).f90
2923 \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$(F90FIXEDFORMAT) \$(basename \$<).f90
2924 .c.o:
2925 \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
2926 .flow.flowdir:
2927 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2928
2929 # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2930 .F.p:
2931 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2932 .p.$FS:
2933 \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
2934
2935 EOF
2936
2937 #=========================================
2938 #=== Automatic Differentiation Rules ===
2939 #=== for TAMC/TAF ======================
2940
2941 if test "x$OPENAD" = x ; then
2942
2943 cat >>$MAKEFILE <<EOF
2944
2945 TAMC = ${TAMC}
2946 TAF = ${TAF}
2947
2948 TAF_EXTRA = ${TAF_EXTRA}
2949 TAMC_EXTRA = ${TAMC_EXTRA}
2950
2951 EOF
2952
2953 ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS"
2954 ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF_FLAGS"
2955 ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
2956 for i in $ad_vars ; do
2957 name=$i
2958 t1="t2=\$"`echo "$i"`
2959 eval $t1
2960 printf "%-20s = " $name >> $MAKEFILE
2961 echo "$t2" | sed -e 's| \+| |g' >> $MAKEFILE
2962 done
2963
2964 echo " Add the source list for AD code generation"
2965 echo >> $MAKEFILE
2966 printf "AD_FILES = " >> $MAKEFILE
2967 AD_FILES=`cat adSrcFiles.tmp`
2968 for i in $AD_FILES ; do
2969 echo " \\" >> $MAKEFILE
2970 printf " $i" >> $MAKEFILE
2971 done
2972 echo >> $MAKEFILE
2973 rm -f adSrcFiles.tmp
2974
2975 cat >>$MAKEFILE <<EOF
2976
2977 # ... AD ...
2978 adall: ad_exe_target
2979 adtaf: ad_taf_output.$FS
2980 adtamc: ad_tamc_output.$FS
2981
2982 ad_exe_target:
2983 @echo Update AD_CONFIG.h and make \$(EXE_AD)
2984 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
2985 @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2986 @-rm -f ad_config.template
2987 \$(MAKE) -f \$(MAKEFILE) \$(EXE_AD)
2988
2989 ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES)
2990 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
2991 cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2992 @-rm -f ad_config.template
2993 @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
2994 @\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)
2995 cat \$(FLOWFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS
2996
2997 ad_taf_output.$FS: ad_input_code.$FS
2998 \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2999 ls -l ad_input_code_ad.$FS
3000 cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
3001
3002 adtafonly:
3003 \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3004 ls -l ad_input_code_ad.$FS
3005 cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
3006
3007 \${EXE_AD}: ad_taf_output.o \$(OBJFILES)
3008 \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
3009
3010 ad_tamc_output.$FS: ad_input_code.$FS
3011 \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
3012 cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
3013
3014 ad_tamc: ad_tamc_output.o \$(OBJFILES)
3015 \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
3016
3017 adonlyfwd:
3018 patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
3019
3020 adtrick:
3021 patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
3022
3023 adobj: ad_taf_output.o \$(OBJFILES)
3024
3025 # ... FTL ...
3026 ftlall: ftl_exe_target
3027 ftltaf: ftl_taf_output.$FS
3028 ftltamc: ftl_tamc_output.$FS
3029
3030 ftl_exe_target:
3031 @echo Update AD_CONFIG.h and make \$(EXE_FTL)
3032 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3033 @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3034 @-rm -f ad_config.template
3035 \$(MAKE) -f \$(MAKEFILE) \$(EXE_FTL)
3036
3037 ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)
3038 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3039 cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3040 @-rm -f ad_config.template
3041 @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3042 @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3043 cat \$(AD_FLOW_FILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ftl_input_code.$FS
3044
3045 ftl_taf_output.$FS: ftl_input_code.$FS
3046 \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3047 ls -l ftl_input_code_ftl.$FS
3048 cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
3049
3050 ftltafonly:
3051 \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3052 ls -l ftl_input_code_ftl.$FS
3053 cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
3054
3055 \${EXE_FTL}: ftl_taf_output.o \$(OBJFILES)
3056 \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
3057
3058 ftl_tamc_output.$FS: ftl_input_code.$FS
3059 \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
3060 cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS
3061
3062 ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
3063 \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
3064
3065 # ... SVD ...
3066 svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
3067 @echo "--->>> Only ran TAF to generate SVD code! <<<---"
3068 @echo "--->>> Do make svdall afterwards to compile. <<<---"
3069 svdall: svd_touch svd_taf
3070
3071 svd_taf: \$(OBJFILES)
3072 \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS)
3073
3074 @echo "--->>> Only COMPILE svd code! <<<---"
3075 @echo "--->>> Assumes you previously <<<---"
3076 @echo "--->>> did make svdtaf <<<---"
3077
3078 svd_touch:
3079 @echo "--->>> Only COMPILE svd code! <<<---"
3080 @echo "--->>> Assumes you previously <<<---"
3081 @echo "--->>> did make svdtaf <<<---"
3082 touch ad_taf_output.$FS ftl_taf_output.$FS
3083 \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
3084 \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
3085 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "SVD version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3086 cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3087 @-rm -f ad_config.template
3088
3089 EOF
3090
3091 fi
3092
3093 #=== for OpenAD ========================
3094
3095 if test "x$OPENAD" != x ; then
3096
3097 # ============ begin OpenAD specific section ==============
3098
3099 cat >>$MAKEFILE <<EOF
3100
3101 # all the source files linked from the various locations:
3102 ALL_LINKED_FILES= \
3103 \$(F77_SRC_FILES) \
3104 \$(C_SRC_FILES) \
3105 \$(H_SRC_FILES) \
3106 \$(F90_SRC_FILES) \
3107 \$(SPECIAL_FILES)
3108
3109 ifndef OPENADROOT
3110 \$(error "Error: environment variable OPENADROOT not defined!")
3111 endif
3112
3113 ifndef XAIFSCHEMAROOT
3114 \$(error "Error: environment variable XAIFSCHEMAROOT not defined!")
3115 endif
3116
3117 ifndef XAIFBOOSTERROOT
3118 \$(error "Error: environment variable XAIFBOOSTERROOT not defined!")
3119 endif
3120
3121 EOF
3122
3123 echo " Add the source list for common block to module conversion "
3124 echo >> $MAKEFILE
3125 printf "CB2M_F90_SRC_NAMES = " >> $MAKEFILE
3126 for i in `cat ${OAD_CB2M_FILES}` ; do
3127 echo " \\" >> $MAKEFILE
3128 printf " $i" >> $MAKEFILE
3129 done
3130 echo >> $MAKEFILE
3131
3132 echo " Add the source list for AD code generation"
3133 echo >> $MAKEFILE
3134 printf "AD_FILES = " >> $MAKEFILE
3135 for i in `cat ${OAD_CB2M_FILES}` ; do
3136 echo " \\" >> $MAKEFILE
3137 printf " ${i}_mod.f$FS90" >> $MAKEFILE
3138 done
3139 AD_FILES=`cat adSrcFiles.tmp`
3140 for i in $AD_FILES ; do
3141 basename=${i%%.f}
3142 toBeIgnored=`egrep ^$basename'[ ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`
3143 if test -z "$toBeIgnored" ; then
3144 echo " \\" >> $MAKEFILE
3145 printf " $i" >> $MAKEFILE
3146 fi
3147 done
3148 echo >> $MAKEFILE
3149 rm -f adSrcFiles.tmp
3150
3151 cat >>$MAKEFILE <<EOF
3152
3153 adAll: \$(EXE_AD)
3154 .PHONY: adAll
3155
3156 CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))
3157
3158 .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90)
3159
3160 .PHONY: adDepend
3161 adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90)
3162 \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
3163 \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
3164 -rm -f makedepend.out
3165
3166 OPENAD_SUPPORT_F90_SRC_FILES = \
3167 w2f__types.F90 \
3168 OAD_active.F90 \
3169 OAD_cp.F90 \
3170 OAD_rev.F90 \
3171 OAD_tape.F90
3172
3173 OPENAD_SUPPORT_C_SRC_FILES = \
3174 iaddr.c \
3175 timeRatio.c
3176
3177 f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)
3178 cat \$^ > \$@
3179
3180 f95_test.f90: all_mods.xb.x2w.w2f.pp.f$FS90 \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
3181 cat \$^ > \$@
3182
3183 f95_test.out: f95_test_mods.f90 f95_test.f90
3184 f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1
3185 f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1
3186
3187 CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)
3188
3189 AD_OBJ_FILES_S1=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) OAD_intrinsics_oad.o \$(CB2M_AD_FILES:.f$FS90=_oad.o)
3190
3191 AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o)
3192
3193 \$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.tag \$(AD_OBJ_FILES_S2)
3194 \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)
3195
3196 # create sources files modules from header files containing common blocks
3197 %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk
3198 ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk
3199
3200 # create new header files with USE statements for the new modules made above
3201 %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk
3202 ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
3203
3204 # change the include directives of everybody to refer to the new header files with the USE statements
3205 %_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash
3206 ../OAD_support/cb2mUseModules.bash $< ${MPI}
3207
3208 # makefile debug rule
3209 small_f: \$(CB2M_F90_PP_SRC_FILES)
3210 .PHONY: small_f
3211
3212 ad_output.txt: \$(EXE_AD)
3213 @printf 'linking data files ... '
3214 \$(LN) -f ../input_ad/data* ../input_ad/eedata .
3215 \$(LN) -f ../../global_ocean.90x40x15/input/*.bin .
3216 @printf 'running ... '
3217 @./\$(EXE_AD) > \$@
3218
3219 ad_input_code.f$FS90: \$(CB2M_AD_FILES)
3220 cat \$^ > \$@
3221
3222 # canonicalizer
3223 ad_input_code_sf.pre.f90 : \$(CB2M_AD_FILES)
3224 \${OPENADFORTTK_BASE}/tools/SourceProcessing/preProcess.py --timing --r8 -H -S -o \$@ \$^
3225
3226 # replace stop statements (to avoid the implied unstructured control flow) with print statements
3227 ad_input_code_sf.pre.s2p.f90 : ad_input_code_sf.pre.f90
3228 cat \$< | sed -f ../OAD_support/stop2print.sed > ad_input_code_sf.pre.s2p.f90
3229
3230 # F -> WHIRL
3231 ad_input_code_sf.pre.s2p.B: ad_input_code_sf.pre.s2p.f90
3232 \${OPEN64ROOT}/crayf90/sgi/mfef90 -r8 -z -F ad_input_code_sf.pre.s2p.f90
3233
3234 # WHIRL -> XAIF
3235 ad_input_code_sf.pre.s2p.xaif : ad_input_code_sf.pre.s2p.B
3236 \${OPENADFORTTK}/bin/whirl2xaif -s -n --debug 1 -o \$@ \$<
3237
3238 # XAIF -> XAIF'
3239 ad_input_code_sf.pre.s2p.xb.xaif : ad_input_code_sf.pre.s2p.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd
3240 \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r
3241
3242 # XAIF' -> WHIRL'
3243 ad_input_code_sf.pre.s2p.xb.x2w.B : ad_input_code_sf.pre.s2p.xb.xaif
3244 \${OPENADFORTTK}/bin/xaif2whirl --debug 1 ad_input_code_sf.pre.s2p.B \$<
3245
3246 # WHIRL' -> F'
3247 ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.B
3248 \${OPEN64ROOT}/whirl2f/whirl2f -FLIST:ftn_file=\$@ -openad \$<
3249
3250 # insert template directives
3251 ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 ../OAD_support/insertTemplateDir.bash
3252 ../OAD_support/insertTemplateDir.bash \$< \$@
3253
3254 PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F
3255 # postprocess F'
3256 postProcess.tag: ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90 \$(PPEXTRAS:.F=.f) | w2f__types.f90
3257 \${OPENADFORTTK_BASE}/tools/SourceProcessing/postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed --separateOutput --pathSuffix "" --filenameSuffix "_oad" -m r -i ../OAD_support/ad_inline.f \$<
3258 # the target is a placeholder to trigger a single execution of the rule
3259 touch \$@
3260 # put this so make knows about the postprocessing output
3261 OAD_intrinsics_oad.f \$(CB2M_AD_FILES:.f$FS90=_oad.f): postProcess.tag
3262
3263 # link the XAIF schema files
3264 %.xsd:
3265 \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3266
3267 # link the support files:
3268 \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):
3269 \$(LN) ../OAD_support/\$@ .
3270
3271 AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag \$(PPEXTRAS:.F=.f)
3272
3273 # ============ end OpenAD specific section ==============
3274
3275 EOF
3276
3277 fi
3278
3279 #=========================================
3280
3281 if test "x$EXEHOOK" != x ; then
3282 printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
3283 fi
3284
3285 echo " Making list of \"exceptions\" that need \".p\" files"
3286 for i in $KPPFILES ; do
3287 base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
3288 RETVAL=$?
3289 if test "x$RETVAL" != x0 ; then
3290 echo "Error: unable to add file \"$i\" to the exceptions list"
3291 fi
3292 echo "$base.$FS: $base.p" >> $MAKEFILE
3293 done
3294
3295 echo " Making list of NOOPTFILES"
3296 for i in $NOOPTFILES ; do
3297 base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
3298 RETVAL=$?
3299 if test "x$RETVAL" != x0 ; then
3300 echo "Error: unable to add file \"$i\" to the exceptions list"
3301 fi
3302 echo "$base.o: $base.$FS" >> $MAKEFILE
3303 printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
3304 done
3305
3306 echo " Add rules for links"
3307 cat srclinks.tmp >> $MAKEFILE
3308 rm -f srclinks.tmp
3309
3310 echo " Adding makedepend marker"
3311 printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE
3312
3313 printf "\n=== Done ===\n"
3314
3315 # Create special header files
3316 $BASH $TOOLSDIR/convert_cpp_cmd2defines -bPACKAGES_CONFIG_H "Disabled packages:" $DISABLED_PACKAGES " " "Enabled packages:" $ENABLED_PACKAGES > $PACKAGES_DOT_H".tmp"
3317 if test ! -f $PACKAGES_DOT_H ; then
3318 mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
3319 else
3320 cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H > /dev/null 2>&1
3321 RETVAL=$?
3322 if test "x$RETVAL" = x0 ; then
3323 rm -f $PACKAGES_DOT_H".tmp"
3324 else
3325 mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"
3326 mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
3327 fi
3328 fi
3329 if test ! -f AD_CONFIG.h ; then
3330 $BASH $TOOLSDIR/convert_cpp_cmd2defines "Default version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > AD_CONFIG.h
3331 fi
3332
3333 # Write the "state" for future records
3334 if test "x$DUMPSTATE" = xt ; then
3335 printf "" > genmake_state
3336 for i in $gm_state ; do
3337 t1="t2=\$$i"
3338 eval $t1
3339 echo "$i='$t2'" | sed -e 's/ */ /g' >> genmake_state
3340 done
3341 fi

  ViewVC Help
Powered by ViewVC 1.1.22