/[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.130 - (show annotations) (download)
Sun Sep 11 18:52:26 2005 UTC (13 years, 10 months ago) by edhill
Branch: MAIN
Changes since 1.129: +47 -1 lines
 o add HAVE_SETRLSTK define and useSETRLSTK flag (eedata) which calls
   a C routine to unlimit the stack size
   - very helpful on clusters of workstations since the ulimit/limit
     behavior can (otherwise) only be inherited from parent processes
     which is difficult with some MPI-over-ssh/rsh implementations

1 #! /usr/bin/env bash
2 #
3 # $Header: /u/gcmpack/MITgcm/tools/genmake2,v 1.129 2005/09/05 14:56:47 edhill Exp $
4 #
5 # Makefile generator for MITgcm UV codes
6 # created by cnh 03/98
7 # adapted by aja 06/98
8 # modified by aja 01/00
9 # rewritten in bash by eh3 08/03
10
11 # Search for particular CPP #cmds associated with packages
12 # usage: test_for_package_in_cpp_options CPP_file package_name
13 test_for_package_in_cpp_options() {
14 cpp_options=$1
15 pkg=$2
16 test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg" || exit 99
17 test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg" || exit 99
18 test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg" || exit 99
19 test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg" || exit 99
20 }
21
22 # Search for particular CPP #cmds associated with MPI
23 # usage: test_for_mpi_in_cpp_eeoptions CPP_file
24 test_for_mpi_in_cpp_eeoptions() {
25 cpp_options=$1
26 test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI" || exit 99
27 test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI" || exit 99
28 test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI" || exit 99
29 test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI" || exit 99
30 }
31
32 # Search for particular string in a file. Return 1 if detected, 0 if not
33 # usage: test_for_string_in_file file string
34 test_for_string_in_file() {
35 file=$1
36 strng=$2
37 grep -i "$strng" $file > /dev/null 2>&1
38 RETVAL=$?
39 if test "x${RETVAL}" = x0 ; then
40 printf "Error: In $file there is an illegal line: "
41 grep -i "$strng" $file
42 return 1
43 fi
44 return 0
45 }
46
47 # Read the $ROOTDIR/pkg/pkg_groups file and expand any references to
48 # the package list.
49 expand_pkg_groups() {
50 new_packages=
51 PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"
52 if test -r $PKG_GROUPS ; then
53 cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp
54 cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp
55 matched=0
56 for i in $PACKAGES ; do
57 line=`grep "^ *$i" ./p2.tmp`
58 RETVAL=$?
59 if test "x$RETVAL" = x0 ; then
60 matched=1
61 replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
62 echo " replacing \"$i\" with: $replace"
63 new_packages="$new_packages $replace"
64 else
65 new_packages="$new_packages $i"
66 fi
67 done
68 PACKAGES=$new_packages
69 rm -f ./p[1,2].tmp
70 return $matched
71 else
72 echo "Warning: can't read package groups definition file: $PKG_GROUPS"
73 fi
74 }
75
76 # Check for broken environments (eg. cygwin, MacOSX w/HFS+) that
77 # cannot distinguish [*.F/*.F90] from [*.f/*.f90] files.
78 check_for_broken_Ff() {
79 # Do we have defaults for $FS and/or $FS90 ?
80 tfs=f
81 tfs9=f90
82 if test "x$FS" != x ; then
83 tfs="$FS"
84 fi
85 if test "x$FS90" != x ; then
86 tfs9="$FS90"
87 fi
88
89 # First check the ability to create a *.F/.f pair.
90 cat <<EOF >> genmake_hello.F
91 program hello
92 write(*,*) 'hi'
93 stop
94 end
95 EOF
96 cp genmake_hello.F "genmake_hello."$tfs > /dev/null 2>&1
97 RETVAL=$?
98 if test "x$RETVAL" != x0 ; then
99 if test "x$FS" = x ; then
100 FS='for'
101 FS90='fr9'
102 check_for_broken_Ff
103 else
104 cat <<EOF 2>&1
105 ERROR: Your file system cannot distinguish between *.F and *.f files
106 (fails the "cp" test) and this program cannot find a suitable
107 replacement extension. Please try a different build environment or
108 contact the <MITgcm-support@mitgcm.org> list for help.
109
110 EOF
111 exit -1
112 fi
113 return
114 fi
115 rm -f genmake_hello.*
116
117 # Check the ability of ${MAKE} and ${LN} to use the current set
118 # of extensions.
119 cat <<EOF >> genmake_hello.F
120 program hello
121 write(*,*) 'hi'
122 stop
123 end
124 EOF
125 test -f $MAKEFILE && mv -f $MAKEFILE $MAKEFILE".tst"
126 cat <<EOF >> $MAKEFILE
127 .SUFFIXES:
128 .SUFFIXES: .$tfs .F
129 .F.$tfs:
130 $LN \$< \$@
131 EOF
132 $MAKE "genmake_hello."$tfs > /dev/null 2>&1
133 RETVAL=$?
134 if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then
135 if test "x$FS" = x ; then
136 FS='for'
137 FS90='fr9'
138 check_for_broken_Ff
139 else
140 cat <<EOF 2>&1
141 ERROR: Your file system cannot distinguish between *.F and *.f files
142 (fails the "make/ln" test) and this program cannot find a suitable
143 replacement extension. Please try a different build environment or
144 contact the <MITgcm-support@mitgcm.org> list for help.
145
146 EOF
147 exit -1
148 return
149 fi
150 fi
151 rm -f genmake_hello.* $MAKEFILE
152 test -f $MAKEFILE".tst" && mv -f $MAKEFILE".tst" $MAKEFILE
153
154 # If we make it here, use the extensions
155 FS=$tfs
156 FS90=$tfs9
157 return
158 }
159
160
161 look_for_makedepend() {
162
163 # The "original" makedepend is part of the Imake system that is
164 # most often distributed with XFree86 or with an XFree86 source
165 # package. As a result, many machines (eg. generic Linux) do not
166 # have a system-default "makedepend" available. For those
167 # systems, we have two fall-back options:
168 #
169 # 1) a makedepend implementation shipped with the cyrus-imapd
170 # package: ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
171 #
172 # 2) a known-buggy xmakedpend shell script
173 #
174 # So the choices are, in order:
175 #
176 # 1) use the user-specified program
177 # 2) use a system-wide default
178 # 3) locally build and use the cyrus implementation
179 # 4) fall back to the buggy local xmakedpend script
180 #
181 if test "x${MAKEDEPEND}" = x ; then
182 which makedepend > /dev/null 2>&1
183 RV0=$?
184 test -f $MAKEFILE && mv -f $MAKEFILE $MAKEFILE".tst"
185 # echo 'MAKEFILE="'$MAKEFILE'"'
186 cat <<EOF >> $MAKEFILE
187 # THIS IS A TEST MAKEFILE GENERATED BY "genmake2"
188 #
189 # Some "makedepend" implementations will die if they cannot
190 # find a Makefile -- so this file is here to gives them an
191 # empty one to find and parse.
192 EOF
193 cat <<EOF >> genmake_tc.f
194 program test
195 write(*,*) 'test'
196 stop
197 end
198 EOF
199 makedepend genmake_tc.f > /dev/null 2>&1
200 RV1=$?
201 test -f $MAKEFILE && rm -f $MAKEFILE
202 test -f $MAKEFILE".tst" && mv -f $MAKEFILE".tst" $MAKEFILE
203 if test "x${RV0}${RV1}" = x00 ; then
204 MAKEDEPEND=makedepend
205 else
206 echo " a system-default makedepend was not found."
207
208 # Try to build the cyrus implementation
209 build_cyrus_makedepend
210 RETVAL=$?
211 if test "x$RETVAL" != x0 ; then
212 MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
213 fi
214 rm -f ./genmake_cy_md
215 fi
216 else
217 # echo "MAKEDEPEND=${MAKEDEPEND}"
218 echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
219 RETVAL=$?
220 if test x"$RETVAL" = x0 ; then
221 build_cyrus_makedepend
222 fi
223 fi
224 }
225
226
227 build_cyrus_makedepend() {
228 rm -f ./genmake_cy_md
229 (
230 cd $ROOTDIR/tools/cyrus-imapd-makedepend \
231 && ./configure > /dev/null 2>&1 \
232 && make > /dev/null 2>&1
233 if test -x ./makedepend.exe ; then
234 $LN ./makedepend.exe ./makedepend
235 fi
236 ./makedepend ifparser.c > /dev/null 2>&1 \
237 && echo "true"
238 ) > ./genmake_cy_md
239 grep true ./genmake_cy_md > /dev/null 2>&1
240 RETVAL=$?
241 rm -f ./genmake_cy_md
242 if test "x$RETVAL" = x0 ; then
243 MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
244 return 0
245 else
246 echo "WARNING: unable to build cyrus-imapd-makedepend"
247 return 1
248 fi
249 }
250
251 # Guess possible config options for this host
252 find_possible_configs() {
253
254 tmp1=`uname`"_"`uname -m`
255 tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
256 tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
257 tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
258 tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
259 tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
260 PLATFORM=$tmp3
261 echo $PLATFORM | grep cygwin > /dev/null 2>&1 && PLATFORM=cygwin_ia32
262 OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
263 echo " The platform appears to be: $PLATFORM"
264
265 echo "test" > test
266 ln -s ./test link
267 RETVAL=$?
268 if test "x${RETVAL}" = x0 ; then
269 LN="ln -s"
270 else
271 echo "Error: \"ln -s\" does not appear to work on this system!"
272 echo " For help, please contact <MITgcm-support@mitgcm.org>."
273 exit 1
274 fi
275 rm -f test link
276
277 if test "x$CPP" = x ; then
278 CPP="cpp -traditional -P"
279 fi
280
281 look_for_makedepend
282
283 #================================================================
284 # look for possible C compilers
285 tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc"
286 p_CC=
287 for c in $tmp ; do
288 rm -f ./genmake_hello.c ./genmake_hello
289 cat >> genmake_hello.c << EOF
290 #include <stdio.h>
291 int main(int argc, char **argv) {
292 printf("Hello!\n");
293 return 0;
294 }
295 EOF
296 $c -o genmake_hello genmake_hello.c > /dev/null 2>&1
297 RETVAL=$?
298 if test "x${RETVAL}" = x0 ; then
299 p_CC="$p_CC $c"
300 fi
301 done
302 rm -f ./genmake_hello.c ./genmake_hello
303 if test "x${p_CC}" = x ; then
304 cat 1>&2 <<EOF
305
306 Error: No C compilers were found in your path. Please specify one using:
307
308 1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
309 2) the CC or MITGCM_CC environment variables.
310
311 EOF
312 exit 1
313 else
314 echo " The possible C compilers found in your path are:"
315 echo " "$p_CC
316 if test "x$CC" = x ; then
317 CC=`echo $p_CC | $AWK '{print $1}'`
318 echo " Setting C compiler to: "$CC
319 fi
320 fi
321
322 #================================================================
323 # look for possible FORTRAN compilers
324 tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 gfortran"
325 p_FC=
326 for c in $tmp ; do
327 rm -f ./hello.f ./hello
328 cat >> hello.f <<EOF
329 program hello
330 do i=1,3
331 print *, 'hello world : ', i
332 enddo
333 end
334 EOF
335 $c -o hello hello.f > /dev/null 2>&1
336 RETVAL=$?
337 if test "x${RETVAL}" = x0 ; then
338 p_FC="$p_FC $c"
339 fi
340 done
341 rm -f ./hello.f ./hello
342 if test "x${p_FC}" = x ; then
343 cat 1>&2 <<EOF
344
345 Error: No Fortran compilers were found in your path. Please specify one using:
346
347 1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
348 2) a command-line option (eg. "-fc NAME"), or
349 3) the FC or MITGCM_FC environment variables.
350
351 EOF
352 exit 1
353 else
354 echo " The possible FORTRAN compilers found in your path are:"
355 echo " "$p_FC
356 if test "x$FC" = x ; then
357 FC=`echo $p_FC | $AWK '{print $1}'`
358 echo " Setting FORTRAN compiler to: "$FC
359 fi
360 fi
361
362 if test "x$OPTFILE" = x ; then
363 OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
364 if test ! -r $OPTFILE ; then
365 echo " I looked for the file "$OPTFILE" but did not find it"
366 fi
367 fi
368 # echo " The options file: $p_OF"
369 # echo " appears to match so we'll use it."
370 # for i in $p_FC ; do
371 #p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
372 #if test -r $p_OF ; then
373 # OPTFILE=$p_OF
374 # echo " The options file: $p_OF"
375 # echo " appears to match so we'll use it."
376 # break
377 #fi
378 # done
379 if test "x$OPTFILE" = x ; then
380 cat 1>&2 <<EOF
381
382 Error: No options file was found in: $ROOTDIR/tools/build_options/
383 that matches this platform ("$PLATFORM") and the compilers found in
384 your path. Please specify an "optfile" using:
385
386 1) the command line (eg. "-optfile=path/to/OPTFILE"), or
387 2) the MITGCM_OF environment variable.
388
389 If you need help, please contact the developers at <MITgcm-support@mitgcm.org>.
390
391 EOF
392 exit 1
393 fi
394
395 # # look for possible MPI libraries
396 # mpi_libs=
397 # mpi_fort=`which mpif77 2>/dev/null`
398 # RETVAL=$?
399 # if test "x${RETVAL}" = x0 ; then
400 # cat >>test.f <<EOF
401 # PROGRAM HELLO
402 # DO 10, I=1,10
403 # PRINT *,'Hello World'
404 # 10 CONTINUE
405 # STOP
406 # END
407 # EOF
408 # eval "$mpi_fort -showme test.f > out"
409 # RETVAL=$?
410 # if test "x${RETVAL}" = x0 ; then
411 # a=`cat out`
412 # for i in $a ; do
413 # case $i in
414 # -*)
415 # mpi_libs="$mpi_libs $i" ;;
416 # esac
417 # done
418 # echo "The MPI libs appear to be:"
419 # echo " "$mpi_libs
420 # fi
421 # rm -f test.f out
422 # fi
423
424 }
425
426 # Parse the package dependency information
427 get_pdepend_list() {
428
429 # strip the comments and then convert the dependency file into
430 # two arrays: PNAME, DNAME
431 cat $1 | sed -e 's/#.*$//g' \
432 | $AWK 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \
433 > ./.pd_tmp
434 . ./.pd_tmp
435 rm -f ./.pd_tmp
436
437 printf "PNAME = "${}
438 }
439
440
441 # Explain usage
442 usage() {
443 cat <<EOF
444
445 Usage: "$0" [OPTIONS]
446 where [OPTIONS] can be:
447
448 -help | --help | -h | --h
449 Print this help message and exit.
450
451 -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
452 -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
453 Use "NAME" as the adoptfile. By default, the file at
454 "tools/adjoint_options/adjoint_default" will be used.
455
456 -nooptfile | --nooptfile
457 -optfile NAME | --optfile NAME | -of NAME | --of NAME
458 -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
459 Use "NAME" as the optfile. By default, an attempt will be
460 made to find an appropriate "standard" optfile in the
461 tools/build_options/ directory.
462
463 -pdepend NAME | --pdepend NAME
464 -pdepend=NAME | --pdepend=NAME
465 Get package dependency information from "NAME".
466
467 -pdefault NAME | --pdefault NAME
468 -pdefault=NAME | --pdefault=NAME
469 Get the default package list from "NAME".
470
471 -make NAME | -m NAME
472 --make=NAME | -m=NAME
473 Use "NAME" for the MAKE program. The default is "make" but
474 many platforms, "gmake" is the preferred choice.
475
476 -makefile NAME | -mf NAME
477 --makefile=NAME | -mf=NAME
478 Call the makefile "NAME". The default is "Makefile".
479
480 -makedepend NAME | -md NAME
481 --makedepend=NAME | -md=NAME
482 Use "NAME" for the MAKEDEPEND program.
483
484 -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
485 -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
486 Specify the location of the MITgcm ROOTDIR as "NAME".
487 By default, genamke will try to find the location by
488 looking in parent directories (up to the 5th parent).
489
490 -mods NAME | --mods NAME | -mo NAME | --mo NAME
491 -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME
492 Here, "NAME" specifies a list of directories that are
493 used for additional source code. Files found in the
494 "mods list" are given preference over files of the same
495 name found elsewhere.
496
497 -disable NAME | --disable NAME
498 -disable=NAME | --disable=NAME
499 Here "NAME" specifies a list of packages that we don't
500 want to use. If this violates package dependencies,
501 genamke will exit with an error message.
502
503 -enable NAME | --enable NAME
504 -enable=NAME | --enable=NAME
505 Here "NAME" specifies a list of packages that we wish
506 to specifically enable. If this violates package
507 dependencies, genamke will exit with an error message.
508
509 -standarddirs NAME | --standarddirs NAME
510 -standarddirs=NAME | --standarddirs=NAME
511 Here, "NAME" specifies a list of directories to be
512 used as the "standard" code.
513
514 -fortran NAME | --fortran NAME | -fc NAME | --fc NAME
515 -fc=NAME | --fc=NAME
516 Use "NAME" as the fortran compiler. By default, genmake
517 will search for a working compiler by trying a list of
518 "usual suspects" such as g77, f77, etc.
519
520 -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
521 Use "NAME" as the C compiler. By default, genmake
522 will search for a working compiler by trying a list of
523 "usual suspects" such as gcc, c89, cc, etc.
524
525 -[no]ieee | --[no]ieee
526 Do or don't use IEEE numerics. Note that this option
527 *only* works if it is supported by the OPTFILE that
528 is being used.
529
530 -ts | --ts
531 Produce timing information per timestep
532
533 -mpi | --mpi
534 Include MPI header files and link to MPI libraries
535 -mpi=PATH | --mpi=PATH
536 Include MPI header files and link to MPI libraries using MPI_ROOT
537 set to PATH. i.e. Include files from \$PATH/include, link to libraries
538 from \$PATH/lib and use binaries from \$PATH/bin.
539
540 -bash NAME
541 Explicitly specify the Bourne or BASH shell to use
542
543 While it is most often a single word, the "NAME" variables specified
544 above can in many cases be a space-delimited string such as:
545
546 --enable pkg1 --enable 'pkg1 pkg2' --enable 'pkg1 pkg2 pkg3'
547 -mods=dir1 -mods='dir1' -mods='dir1 dir2 dir3'
548 -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'
549
550 which, depending upon your shell, may need to be single-quoted.
551
552 For more detailed genmake documentation, please see:
553
554 http://mitgcm.org/devel_HOWTO/
555
556 EOF
557
558 exit 1
559 }
560
561 # Build a CPP macro to automate calling C routines from FORTRAN
562 get_fortran_c_namemangling() {
563
564 #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
565 if test ! "x$FC_NAMEMANGLE" = x ; then
566 return 0
567 fi
568
569 default_nm="#define FC_NAMEMANGLE(X) X ## _"
570
571 cat > genmake_test.c <<EOF
572 void tcall( char * string ) { tsub( string ); }
573 EOF
574 $MAKE genmake_test.o >> genmake_warnings 2>&1
575 RETVAL=$?
576 if test "x$RETVAL" != x0 ; then
577 FC_NAMEMANGLE=$default_nm
578 cat <<EOF>> genmake_errors
579
580 WARNING: C test compile fails
581 WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
582 WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
583 EOF
584 return 1
585 fi
586 c_tcall=`nm genmake_test.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
587 RETVAL=$?
588 if test "x$RETVAL" != x0 ; then
589 FC_NAMEMANGLE=$default_nm
590 cat <<EOF>> genmake_warnings
591
592 WARNING: The "nm" command failed.
593 WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
594 WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
595 EOF
596 return 1
597 fi
598 cat > genmake_tcomp.$FS <<EOF
599 subroutine tcall( string )
600 character*(*) string
601 call tsub( string )
602 end
603 EOF
604 $FC $FFLAGS $DEFINES -c genmake_tcomp.$FS >> genmake_warnings 2>&1
605 RETVAL=$?
606 if test "x$RETVAL" != x0 ; then
607 FC_NAMEMANGLE=$default_nm
608 cat <<EOF>> genmake_warnings
609
610 WARNING: FORTRAN test compile fails -- please see "genmake_errors"
611 WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
612 WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
613 EOF
614 return 1
615 fi
616 f_tcall=`nm genmake_tcomp.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
617 RETVAL=$?
618 if test "x$RETVAL" != x0 ; then
619 FC_NAMEMANGLE=$default_nm
620 cat <<EOF>> genmake_warnings
621
622 WARNING: The "nm" command failed.
623 WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
624 WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
625 EOF
626 return 1
627 fi
628
629 c_a=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
630 f_a=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
631 c_b=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
632 f_b=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
633
634 nmangle="X"
635 if test "x$c_a" != "x$f_a" ; then
636 comm="echo x$f_a | sed -e 's|x$c_a||'"
637 a=`eval $comm`
638 nmangle="$a ## $nmangle"
639 fi
640 if test "x$c_b" != "x$f_b" ; then
641 comm="echo x$f_b | sed -e 's|x$c_b||'"
642 b=`eval $comm`
643 nmangle="$nmangle ## $b"
644 fi
645
646 FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) $nmangle"
647
648 # cleanup the testing files
649 rm -f genmake_tcomp.* genmake_test.*
650 }
651
652
653 check_HAVE_CLOC() {
654 get_fortran_c_namemangling
655 cat <<EOF > genmake_tc_1.c
656 $FC_NAMEMANGLE
657 #include <stdio.h>
658 #include <stdlib.h>
659 #include <unistd.h>
660 #include <assert.h>
661 #include <sys/time.h>
662 void FC_NAMEMANGLE(cloc) ( double *curtim )
663 {
664 struct timeval tv1;
665 gettimeofday(&tv1 , (void *)NULL );
666 *curtim = (double)((tv1.tv_usec)+(tv1.tv_sec)*1.E6);
667 *curtim = *curtim/1.E6;
668 }
669 EOF
670 make genmake_tc_1.o >> genmake_warnings 2>&1
671 RET_C=$?
672 cat <<EOF > genmake_tc_2.$FS
673 program hello
674 REAL*8 wtime
675 external cloc
676 call cloc(wtime)
677 print *," HELLO WORLD", wtime
678 end
679 EOF
680 $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1
681 RET_F=$?
682 test -x ./genmake_tc && ./genmake_tc >> genmake_warnings 2>&1
683 RETVAL=$?
684 if test "x$RETVAL" = x0 ; then
685 HAVE_CLOC=t
686 DEFINES="$DEFINES -DHAVE_CLOC"
687 fi
688 rm -f genmake_tc*
689 }
690
691
692 check_HAVE_SETRLSTK() {
693 get_fortran_c_namemangling
694 cat <<EOF > genmake_tc_1.c
695 $FC_NAMEMANGLE
696 #include <sys/time.h>
697 #include <sys/resource.h>
698 #include <unistd.h>
699 void FC_NAMEMANGLE(setrlstk) ()
700 {
701 struct rlimit rls;
702 rls.rlim_cur = RLIM_INFINITY;
703 rls.rlim_max = RLIM_INFINITY;
704 setrlimit(RLIMIT_STACK, &rls);
705 return;
706 }
707 EOF
708 make genmake_tc_1.o >> genmake_warnings 2>&1
709 RET_C=$?
710 cat <<EOF > genmake_tc_2.$FS
711 program hello
712 external setrlstk
713 call setrlstk()
714 end
715 EOF
716 $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1
717 RET_F=$?
718 test -x ./genmake_tc && ./genmake_tc >> genmake_warnings 2>&1
719 RETVAL=$?
720 if test "x$RETVAL" = x0 ; then
721 HAVE_SETRLSTK=t
722 DEFINES="$DEFINES -DHAVE_SETRLSTK"
723 fi
724 rm -f genmake_tc*
725 }
726
727
728 check_HAVE_STAT() {
729 get_fortran_c_namemangling
730 cat <<EOF > genmake_tc_1.c
731 $FC_NAMEMANGLE
732 #include <stdio.h>
733 #include <stdlib.h>
734 #include <unistd.h>
735 #include <sys/stat.h>
736 #include <sys/types.h>
737 void FC_NAMEMANGLE(tfsize) ( int *nbyte )
738 {
739 char name[512];
740 struct stat astat;
741
742 name[0] = 'a'; name[1] = '\0';
743 if (! stat(name, &astat))
744 *nbyte = (int)(astat.st_size);
745 else
746 *nbyte = -1;
747 }
748 EOF
749 make genmake_tc_1.o >> genmake_tc.log 2>&1
750 RET_C=$?
751 cat <<EOF > genmake_tc_2.$FS
752 program hello
753 integer nbyte
754 call tfsize(nbyte)
755 print *," HELLO WORLD", nbyte
756 end
757 EOF
758 $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_tc.log 2>&1
759 RET_F=$?
760 test -x ./genmake_tc && ./genmake_tc >> genmake_tc.log 2>&1
761 RETVAL=$?
762 if test "x$RETVAL" = x0 ; then
763 HAVE_STAT=t
764 DEFINES="$DEFINES -DHAVE_STAT"
765 fi
766 rm -f genmake_tc*
767 }
768
769
770 check_netcdf_libs() {
771 if test ! "x$SKIP_NETCDF_CHECK" = x ; then
772 return
773 fi
774 echo "" > genmake_tnc.log
775 cat <<EOF > genmake_tnc.F
776 program fgennc
777 #include "netcdf.inc"
778 EOF
779 if test ! "x$MPI" = x ; then
780 echo '#include "mpif.h"' >> genmake_tnc.F
781 fi
782 cat <<EOF >> genmake_tnc.F
783 integer iret, ncid, xid
784 iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
785 IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
786 iret = nf_def_dim(ncid, 'X', 11, xid)
787 IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
788 iret = nf_close(ncid)
789 IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
790 end
791 EOF
792 echo "Executing:" > genmake_tnc.log
793 echo " $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS" \
794 > genmake_tnc.log
795 RET_CPP=f
796 $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null \
797 && RET_CPP=t
798 if test "x$RET_CPP" = xf ; then
799 echo " WARNING: CPP failed to pre-process the netcdf test." \
800 > genmake_tnc.log
801 echo " Please check that \$INCLUDES is properly set." \
802 > genmake_tnc.log
803 fi
804 echo "Executing:" > genmake_tnc.log
805 echo " $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS" > genmake_tnc.log
806 echo " $LINK -o genmake_tnc.o $LIBS" > genmake_tnc.log
807 $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \
808 && $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
809 RET_COMPILE=$?
810
811 #EH3 Remove test program execution for machines that either disallow
812 #EH3 execution or cannot support it (eg. cross-compilers)
813 #EH3
814 #EH3 test -x ./genmake_tnc && ./genmake_tnc >> genmake_tnc.log 2>&1
815 #EH3 RETVAL=$?
816 #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
817
818 if test "x$RET_COMPILE" = x0 ; then
819 HAVE_NETCDF=t
820 else
821 # try again with "-lnetcdf" added to the libs
822 $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null \
823 && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \
824 && $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
825 RET_COMPILE=$?
826 if test "x$RET_COMPILE" = x0 ; then
827 LIBS="$LIBS -lnetcdf"
828 HAVE_NETCDF=t
829 else
830 cat genmake_tnc.log >> genmake_warnings
831 fi
832 fi
833 rm -f genmake_tnc*
834 }
835
836
837
838 ###############################################################################
839 # Sequential part of script starts here
840 ###############################################################################
841
842 # Set defaults here
843 COMMANDL="$0 $@"
844
845 PLATFORM=
846 LN=
847 S64=
848 KPP=
849 #FC=
850 #CC=gcc
851 #CPP=
852 LINK=
853 DEFINES=
854 PACKAGES=
855 ENABLE=
856 DISABLE=
857 # MAKEFILE=
858 # MAKEDEPEND=
859 PDEPEND=
860 DUMPSTATE=t
861 PDEFAULT=
862 OPTFILE=
863 INCLUDES="-I. $INCLUDES"
864 FFLAGS=
865 FOPTIM=
866 CFLAGS=
867 KFLAGS1=
868 KFLAGS2=
869 #LDADD=
870 LIBS=
871 KPPFILES=
872 NOOPTFILES=
873 NOOPTFLAGS=
874 MPI=
875 MPIPATH=
876 TS=
877
878 # DEFINES checked by test compilation or command-line
879 HAVE_SYSTEM=
880 HAVE_FDATE=
881 FC_NAMEMANGLE=
882 HAVE_CLOC=
883 HAVE_SETRLSTK=
884 HAVE_STAT=
885 HAVE_NETCDF=
886 HAVE_ETIME=
887 IGNORE_TIME=
888
889 MODS=
890 TOOLSDIR=
891 SOURCEDIRS=
892 INCLUDEDIRS=
893 STANDARDDIRS="USE_THE_DEFAULT"
894
895 G2ARGS=
896 BASH=
897 PWD=`pwd`
898 test "x$MAKE" = x && MAKE=make
899 test "x$AWK" = x && AWK=awk
900 THISHOST=`hostname`
901 THISCWD=`pwd`
902 THISDATE=`date`
903 THISUSER=`echo $USER`
904 THISVER=
905 MACHINE=`uname -a`
906 EXECUTABLE=
907 EXEHOOK=
908 EXEDIR=
909 PACKAGES_CONF=
910 IEEE=
911 if test "x$MITGCM_IEEE" != x ; then
912 IEEE=$MITGCM_IEEE
913 fi
914 FS=
915 FS90=
916
917 AUTODIFF_PKG_USED=f
918 AD_OPTFILE=
919 TAF=
920 AD_TAF_FLAGS=
921 FTL_TAF_FLAGS=
922 SVD_TAF_FLAGS=
923 TAF_EXTRA=
924 TAMC=
925 AD_TAMC_FLAGS=
926 FTL_TAF_FLAGS=
927 SVD_TAMC_FLAGS=
928 TAMC_EXTRA=
929
930
931 # The following state can be set directly by command-line switches
932 gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
933 gm_s2="FC CPP IEEE TS MPI JAM DUMPSTATE STANDARDDIRS"
934
935 # The following state is not directly set by command-line switches
936 gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "
937 gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
938 gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
939 gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
940 gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
941
942 # The following are all related to adjoint/tangent-linear stuff
943 gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
944 gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
945 gm_s12="TAF_EXTRA TAMC_EXTRA"
946
947 gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7"
948 gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
949
950 cat <<EOF
951
952 GENMAKE :
953
954 A program for GENerating MAKEfiles for the MITgcm project. For a
955 quick list of options, use "genmake -h" or for more detail see:
956
957 http://mitgcm.org/devel_HOWTO/
958
959 EOF
960
961 echo "=== Processing options files and arguments ==="
962 gm_local="genmake_local"
963 for i in . $MODS ; do
964 if test -r $i/$gm_local ; then
965 . $i/$gm_local
966 break
967 fi
968 done
969 printf " getting local config information: "
970 if test -f $gm_local ; then
971 echo "using $gm_local"
972 . $gm_local
973 # echo "DISABLE=$DISABLE"
974 # echo "ENABLE=$ENABLE"
975 else
976 echo "none found"
977 fi
978
979 #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
980 #OPTIONS=
981 #n=0
982 #for i ; do
983 # echo "$i $n"
984 # setvar="OPTIONS[$n]='$i'"
985 # # echo " $setvar"
986 # eval "$setvar"
987 # n=$(( $n + 1 ))
988 #done
989 #parse_options
990 ac_prev=
991 for ac_option in "$@" ; do
992
993 G2ARGS="$G2ARGS \"$ac_option\""
994
995 # If the previous option needs an argument, assign it.
996 if test -n "$ac_prev"; then
997 eval "$ac_prev=\$ac_option"
998 ac_prev=
999 continue
1000 fi
1001
1002 ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
1003
1004 case $ac_option in
1005
1006 -help | --help | -h | --h)
1007 usage ;;
1008
1009 -nooptfile | --nooptfile)
1010 OPTFILE="NONE" ;;
1011 -optfile | --optfile | -of | --of)
1012 ac_prev=OPTFILE ;;
1013 -optfile=* | --optfile=* | -of=* | --of=*)
1014 OPTFILE=$ac_optarg ;;
1015
1016 -adoptfile | --adoptfile | -adof | --adof)
1017 ac_prev=AD_OPTFILE ;;
1018 -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
1019 AD_OPTFILE=$ac_optarg ;;
1020
1021 -pdepend | --pdepend)
1022 ac_prev=PDEPEND ;;
1023 -pdepend=* | --pdepend=*)
1024 PDEPEND=$ac_optarg ;;
1025
1026 -pdefault | --pdefault)
1027 ac_prev=PDEFAULT ;;
1028 -pdefault=* | --pdefault=*)
1029 PDEFAULT=$ac_optarg ;;
1030
1031 -make | --make | -m | --m)
1032 ac_prev=MAKE ;;
1033 -make=* | --make=* | -m=* | --m=*)
1034 MAKE=$ac_optarg ;;
1035
1036 -bash | --bash)
1037 ac_prev=BASH ;;
1038 -bash=* | --bash=*)
1039 BASH=$ac_optarg ;;
1040
1041 -makedepend | --makedepend | -md | --md)
1042 ac_prev=MAKEDEPEND ;;
1043 -makedepend=* | --makedepend=* | -md=* | --md=*)
1044 MAKEDEPEND=$ac_optarg ;;
1045
1046 -makefile | --makefile | -ma | --ma)
1047 ac_prev=MAKEFILE ;;
1048 -makefile=* | --makefile=* | -ma=* | --ma=*)
1049 MAKEFILE=$ac_optarg ;;
1050
1051 -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)
1052 echo "ERROR: The platform option has been removed. Please specify"
1053 echo " the build options using the \"optfile\" mechanism."
1054 echo
1055 usage
1056 ;;
1057
1058 -rootdir | --rootdir | -rd | --rd)
1059 ac_prev=ROOTDIR ;;
1060 -rootdir=* | --rootdir=* | -rd=* | --rd=*)
1061 ROOTDIR=$ac_optarg ;;
1062
1063 -mods | --mods | -mo | --mo)
1064 ac_prev=MODS ;;
1065 -mods=* | --mods=* | -mo=* | --mo=*)
1066 MODS=$ac_optarg ;;
1067
1068 -disable | --disable)
1069 ac_prev=DISABLE ;;
1070 -disable=* | --disable=*)
1071 DISABLE=$ac_optarg ;;
1072
1073 -enable | --enable)
1074 ac_prev=ENABLE ;;
1075 -enable=* | --enable=*)
1076 ENABLE=$ac_optarg ;;
1077
1078 -standarddirs | --standarddirs)
1079 ac_prev=STANDARDDIRS ;;
1080 -standarddirs=* | --standarddirs=*)
1081 STANDARDDIRS=$ac_optarg ;;
1082
1083 # -cpp | --cpp)
1084 # ac_prev=cpp ;;
1085 # -cpp=* | --cpp=*)
1086 # CPP=$ac_optarg ;;
1087
1088 -cc | --cc)
1089 ac_prev=CC ;;
1090 -cc=* | --cc=*)
1091 CC=$ac_optarg ;;
1092
1093 -fortran | --fortran | -fc | --fc)
1094 ac_prev=FC ;;
1095 -fc=* | --fc=*)
1096 FC=$ac_optarg ;;
1097
1098 -fs | --fs)
1099 ac_prev=FS ;;
1100 -fs=* | --fs=*)
1101 FS=$ac_optarg ;;
1102
1103 -fs90 | --fs90)
1104 ac_prev=FS90 ;;
1105 -fs90=* | --fs90=*)
1106 FS90=$ac_optarg ;;
1107
1108 -ieee | --ieee)
1109 IEEE=true ;;
1110 -noieee | --noieee)
1111 IEEE= ;;
1112
1113 -ts | --ts)
1114 TS=true ;;
1115
1116 -mpi | --mpi)
1117 MPI=true ;;
1118 -mpi=* | --mpi=*)
1119 MPIPATH=$ac_optarg
1120 MPI=true ;;
1121
1122 # -jam | --jam)
1123 # JAM=1 ;;
1124 # -nojam | --nojam)
1125 # JAM=0 ;;
1126
1127 -ds | --ds)
1128 DUMPSTATE=t ;;
1129
1130 -taf_extra | --taf_extra)
1131 ac_prev=TAF_EXTRA ;;
1132 -taf_extra=* | --taf_extra=*)
1133 TAF_EXTRA=$ac_optarg ;;
1134
1135 -tamc_extra | --tamc_extra)
1136 ac_prev=TAMC_EXTRA ;;
1137 -tamc_extra=* | --tamc_extra=*)
1138 TAMC_EXTRA=$ac_optarg ;;
1139
1140 -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1141 IGNORE_TIME="-DIGNORE_TIME" ;;
1142
1143 -*)
1144 echo "Error: unrecognized option: "$ac_option
1145 usage
1146 ;;
1147
1148 *)
1149 echo "Error: unrecognized argument: "$ac_option
1150 usage
1151 ;;
1152
1153 esac
1154
1155 done
1156
1157
1158 if test -f ./.genmakerc ; then
1159 echo
1160 echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
1161 echo " file. This file format is no longer supported. Please see:"
1162 echo
1163 echo " http://mitgcm.org/devel_HOWTO/"
1164 echo
1165 echo " for directions on how to setup and use the new \"genmake2\" input"
1166 echo " files and send an email to MITgcm-support@mitgcm.org if you want help."
1167 echo
1168 fi
1169
1170 # Find the MITgcm ${ROOTDIR}
1171 if test "x${ROOTDIR}" = x ; then
1172 tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1173 if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
1174 ROOTDIR=".."
1175 else
1176 for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
1177 if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
1178 ROOTDIR=$d
1179 printf "Warning: ROOTDIR was not specified but there appears to be"
1180 echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
1181 break
1182 fi
1183 done
1184 fi
1185 fi
1186 if test "x${ROOTDIR}" = x ; then
1187 echo "Error: Cannot determine ROOTDIR for MITgcm code."
1188 echo " Please specify a ROOTDIR using either an options "
1189 echo " file or a command-line option."
1190 exit 1
1191 fi
1192 if test ! -d ${ROOTDIR} ; then
1193 echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!"
1194 exit 1
1195 fi
1196
1197 # Find the MITgcm ${THISVER}
1198 if test -f "${ROOTDIR}/doc/tag-index" ; then
1199 THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`
1200 fi
1201
1202 if test "x$MAKEFILE" = x ; then
1203 MAKEFILE="Makefile"
1204 fi
1205
1206 echo " getting OPTFILE information: "
1207 if test "x${OPTFILE}" = x ; then
1208 if test "x$MITGCM_OF" = x ; then
1209 echo "Warning: no OPTFILE specified so we'll look for possible settings"
1210 printf "\n=== Searching for possible settings for OPTFILE ===\n"
1211 find_possible_configs
1212 else
1213 OPTFILE=$MITGCM_OF
1214 fi
1215 fi
1216 if test "x$OPTFILE" != xNONE ; then
1217 if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
1218 echo " using OPTFILE=\"$OPTFILE\""
1219 . "$OPTFILE"
1220 RETVAL=$?
1221 if test "x$RETVAL" != x0 ; then
1222 printf "Error: failed to source OPTFILE \"$OPTFILE\""
1223 echo "--please check that variable syntax is bash-compatible"
1224 exit 1
1225 fi
1226 if test "x$DUMPSTATE" != xf ; then
1227 cp -f $OPTFILE "genmake_optfile"
1228 fi
1229 else
1230 echo "Error: can't read OPTFILE=\"$OPTFILE\""
1231 exit 1
1232 fi
1233 fi
1234
1235 echo " getting AD_OPTFILE information: "
1236 if test "x${AD_OPTFILE}" = x ; then
1237 if test "x$MITGCM_AD_OF" = x ; then
1238 AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
1239 else
1240 AD_OPTFILE=$MITGCM_AD_OF
1241 fi
1242 fi
1243 if test "x${AD_OPTFILE}" != xNONE ; then
1244 if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then
1245 echo " using AD_OPTFILE=\"$AD_OPTFILE\""
1246 . "$AD_OPTFILE"
1247 RETVAL=$?
1248 if test "x$RETVAL" != x0 ; then
1249 printf "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
1250 echo "--please check that variable syntax is bash-compatible"
1251 exit 1
1252 fi
1253 if test "x$DUMPSTATE" != xf ; then
1254 cp -f $AD_OPTFILE "genmake_ad_optfile"
1255 fi
1256 else
1257 echo "Error: can't read AD_OPTFILE=\"$AD_OPTFILE\""
1258 exit 1
1259 fi
1260 fi
1261
1262 #====================================================================
1263 # Set default values if not set by the optfile
1264 #
1265 # Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined. If not,
1266 # either set defaults or complain and abort!
1267 if test ! "x$BASH" = x ; then
1268 # add a trailing space so that it works within the Makefile syntax (see below)
1269 BASH="$BASH "
1270 fi
1271 if test "x$FC" = x ; then
1272 cat <<EOF 1>&2
1273
1274 Error: no Fortran compiler: please specify using one of the following:
1275 1) within the options file ("FC=...") as specified by "-of=OPTFILE"
1276 2) the "-fc=XXX" command-line option
1277 3) the "./genmake_local" file
1278 EOF
1279 exit 1
1280 fi
1281 if test "x$CC" = x ; then
1282 CC=cc
1283 # cat <<EOF 1>&2
1284 # Error: no C compiler: please specify using one of the following:
1285 # 1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1286 # 2) the "-cc=XXX" command-line option
1287 # 3) the "./genmake_local" file
1288 # EOF
1289 # exit 1
1290 fi
1291 if test "x$LINK" = x ; then
1292 LINK=$FC
1293 fi
1294 if test "x$MAKE" = x ; then
1295 MAKE="make"
1296 fi
1297 if test "x$CPP" = x ; then
1298 CPP=cpp
1299 fi
1300 #EH3 === UGLY ===
1301 # The following is an ugly little hack to check for $CPP in /lib/ and
1302 # it should eventually be replaced with a more general function that
1303 # searches a combo of the user's path and a list of "usual suspects"
1304 # to find the correct location for binaries such as $CPP.
1305 for i in " " "/lib/" ; do
1306 echo "#define A a" | $i$CPP > test_cpp 2>&1 && CPP=$i$CPP
1307 done
1308 #EH3 === UGLY ===
1309 echo "#define A a" | $CPP > test_cpp 2>&1
1310 RETVAL=$?
1311 if test "x$RETVAL" != x0 ; then
1312 cat <<EOF 1>&2
1313
1314 Error: C pre-processor "$CPP" failed the test case: please specify using:
1315
1316 1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
1317 2) the "./genmake_local" file
1318 3) with the CPP environment variable
1319
1320 EOF
1321 exit 1
1322 else
1323 rm -f test_cpp
1324 fi
1325 look_for_makedepend
1326 if test "x$LN" = x ; then
1327 LN="ln -s"
1328 fi
1329 echo "test" > genmake_test_ln
1330 $LN genmake_test_ln genmake_tlink
1331 RETVAL=$?
1332 if test "x$RETVAL" != x0 ; then
1333 cat <<EOF 1>&2
1334
1335 Error: The command "ln -s" failed -- please specify a working soft-link
1336 command in the optfile.
1337
1338 EOF
1339 exit 1
1340 fi
1341 rm -f genmake_test_ln genmake_tlink
1342
1343 # Check for broken *.F/*.f handling and fix if possible
1344 check_for_broken_Ff
1345
1346 if test ! "x$MPI" = x ; then
1347 echo " Turning on MPI cpp macros"
1348 DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1349 fi
1350
1351 if test ! "x$TS" = x ; then
1352 echo " Turning on timing per timestep"
1353 DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1354 fi
1355
1356 printf "\n=== Checking system libraries ===\n"
1357 printf " Do we have the system() command using $FC... "
1358 cat > genmake_tcomp.$FS <<EOF
1359 program hello
1360 call system('echo hi')
1361 end
1362 EOF
1363 $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1364 RETVAL=$?
1365 if test "x$RETVAL" = x0 ; then
1366 HAVE_SYSTEM=t
1367 DEFINES="$DEFINES -DHAVE_SYSTEM"
1368 echo "yes"
1369 else
1370 HAVE_SYSTEM=
1371 echo "no"
1372 fi
1373 rm -f genmake_tcomp*
1374
1375 printf " Do we have the fdate() command using $FC... "
1376 cat > genmake_tcomp.$FS <<EOF
1377 program hello
1378 CHARACTER*(128) string
1379 string = ' '
1380 call fdate( string )
1381 print *, string
1382 end
1383 EOF
1384 $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1385 RETVAL=$?
1386 if test "x$RETVAL" = x0 ; then
1387 HAVE_FDATE=t
1388 DEFINES="$DEFINES -DHAVE_FDATE"
1389 echo "yes"
1390 else
1391 HAVE_FDATE=
1392 echo "no"
1393 fi
1394 rm -f genmake_tcomp*
1395
1396 printf " Do we have the etime() command using $FC... "
1397 cat > genmake_tcomp.$FS <<EOF
1398 program hello
1399 REAL*4 ACTUAL, TARRAY(2)
1400 EXTERNAL ETIME
1401 REAL*4 ETIME
1402 actual = etime( tarray )
1403 print *, tarray
1404 end
1405 EOF
1406 $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1407 RETVAL=$?
1408 if test "x$RETVAL" = x0 ; then
1409 HAVE_ETIME=t
1410 DEFINES="$DEFINES -DHAVE_ETIME"
1411 echo "yes"
1412 else
1413 HAVE_ETIME=
1414 echo "no"
1415 fi
1416 rm -f genmake_tcomp*
1417
1418 printf " Can we call simple C routines (here, \"cloc()\") using $FC... "
1419 check_HAVE_CLOC
1420 if test "x$HAVE_CLOC" != x ; then
1421 echo "yes"
1422 else
1423 echo "no"
1424 fi
1425 rm -f genmake_t*
1426
1427 printf " Can we unlimit the stack size using $FC... "
1428 check_HAVE_SETRLSTK
1429 if test "x$HAVE_SETRLSTK" != x ; then
1430 echo "yes"
1431 else
1432 echo "no"
1433 fi
1434 rm -f genmake_t*
1435
1436 printf " Can we use stat() through C calls... "
1437 check_HAVE_STAT
1438 if test "x$HAVE_STAT" != x ; then
1439 echo "yes"
1440 else
1441 echo "no"
1442 fi
1443 rm -f genmake_t*
1444
1445 printf " Can we create NetCDF-enabled binaries... "
1446 check_netcdf_libs
1447 if test "x$HAVE_NETCDF" != x ; then
1448 echo "yes"
1449 else
1450 echo "no"
1451 fi
1452 DEFINES="$DEFINES $IGNORE_TIME"
1453
1454 printf "\n=== Setting defaults ===\n"
1455 printf " Adding MODS directories: "
1456 for d in $MODS ; do
1457 if test ! -d $d ; then
1458 echo
1459 echo "Error: MODS directory \"$d\" not found!"
1460 exit 1
1461 else
1462 printf " $d"
1463 SOURCEDIRS="$SOURCEDIRS $d"
1464 INCLUDEDIRS="$INCLUDEDIRS $d"
1465 fi
1466 done
1467 echo
1468
1469 if test "x${PLATFORM}" = x ; then
1470 PLATFORM=$p_PLATFORM
1471 fi
1472
1473 if test "x${EXEDIR}" = x ; then
1474 tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1475 if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1476 EXEDIR=../exe
1477 else
1478 EXEDIR=.
1479 fi
1480 fi
1481 if test ! -d ${EXEDIR} ; then
1482 echo "Error: the specified EXEDIR (\"$EXEDIR\") does not exist!"
1483 exit 1
1484 fi
1485
1486 if test "x${TOOLSDIR}" = x ; then
1487 TOOLSDIR="$ROOTDIR/tools"
1488 fi
1489 if test ! -d ${TOOLSDIR} ; then
1490 echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"
1491 exit 1
1492 fi
1493 if test "x$S64" = x ; then
1494 echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1495 RETVAL=$?
1496 if test "x${RETVAL}" = x0 ; then
1497 S64='$(TOOLSDIR)/set64bitConst.sh'
1498 else
1499 echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1500 RETVAL=$?
1501 if test "x${RETVAL}" = x0 ; then
1502 S64='$(TOOLSDIR)/set64bitConst.csh'
1503 else
1504 cat <<EOF
1505
1506 ERROR: neither of the two default scripts:
1507
1508 ${TOOLSDIR}/set64bitConst.sh
1509 ${TOOLSDIR}/set64bitConst.csh
1510
1511 are working so please check paths or specify (with \$S64) a
1512 working version of this script.
1513
1514 EOF
1515 exit 1
1516 fi
1517 fi
1518 fi
1519 THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1520
1521 EXECUTABLE=${EXECUTABLE:-mitgcmuv}
1522
1523 # We have a special set of source files in eesupp/src which are
1524 # generated from some template source files. We'll make them first so
1525 # they appear as regular source code
1526 if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
1527 echo " Making source files in eesupp from templates"
1528 ( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1
1529 RETVAL=$?
1530 if test "x${RETVAL}" = x0 ; then
1531 rm -f make_eesupp.errors
1532 else
1533 echo "Error: problem encountered while building source files in eesupp:"
1534 cat make_eesupp.errors 1>&2
1535 exit 1
1536 fi
1537 fi
1538
1539 #same for exch2
1540 if test -r $ROOTDIR"/pkg/exch2/Makefile" ; then
1541 echo " Making source files in exch2 from templates"
1542 ( cd $ROOTDIR"/pkg/exch2/" && $MAKE ) > make_exch2.errors 2>&1
1543 RETVAL=$?
1544 if test "x${RETVAL}" = x0 ; then
1545 rm -f make_exch2.errors
1546 else
1547 echo "Error: problem encountered while building source files in exch2:"
1548 cat make_exch2.errors 1>&2
1549 exit 1
1550 fi
1551 fi
1552
1553 printf "\n=== Determining package settings ===\n"
1554 if test "x${PDEPEND}" = x ; then
1555 tmp=$ROOTDIR"/pkg/pkg_depend"
1556 if test -r $tmp ; then
1557 PDEPEND=$tmp
1558 else
1559 echo "Warning: No package dependency information was specified."
1560 echo " Please check that ROOTDIR/pkg/pkg_depend exists."
1561 fi
1562 else
1563 if test ! -r ${PDEPEND} ; then
1564 echo "Error: can't read package dependency info from PDEPEND=\"$PDEPEND\""
1565 exit 1
1566 fi
1567 fi
1568 echo " getting package dependency info from $PDEPEND"
1569 # Strip the comments and then convert the dependency file into
1570 # two arrays: PNAME, DNAME
1571 cat $PDEPEND | sed -e 's/#.*$//g' \
1572 | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
1573 > ./.pd_tmp
1574 RETVAL=$?
1575 if test ! "x${RETVAL}" = x0 ; then
1576 echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""
1577 exit 1
1578 fi
1579 . ./.pd_tmp
1580 rm -f ./.pd_tmp
1581
1582 # Search for default packages. Note that a "$ROOTDIR/pkg/pkg_groups"
1583 # file should eventually be added so that, for convenience, one can
1584 # specify groups of packages using names like "ocean" and "atmosphere".
1585 echo " checking default package list: "
1586 if test "x${PDEFAULT}" = x ; then
1587 for i in "." $MODS ; do
1588 if test -r $i"/packages.conf" ; then
1589 PDEFAULT=$i"/packages.conf"
1590 break
1591 fi
1592 done
1593 fi
1594 if test "x${PDEFAULT}" = x ; then
1595 PDEFAULT="$ROOTDIR/pkg/pkg_default"
1596 fi
1597 if test "x${PDEFAULT}" = xNONE ; then
1598 echo " default packages file disabled"
1599 else
1600 if test ! -r $PDEFAULT ; then
1601 echo "Warning: can't read default packages from PDEFAULT=\"$PDEFAULT\""
1602 else
1603 echo " using PDEFAULT=\"$PDEFAULT\""
1604 # Strip the comments and add all the names
1605 def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
1606 RETVAL=$?
1607 if test "x${RETVAL}" != x0 ; then
1608 printf "Error: can't parse default package list "
1609 echo "-- please check PDEFAULT=\"$PDEFAULT\""
1610 exit 1
1611 fi
1612 for i in $def ; do
1613 PACKAGES="$PACKAGES $i"
1614 done
1615 echo " before group expansion packages are: $PACKAGES"
1616 RET=1
1617 while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
1618 echo " after group expansion packages are: $PACKAGES"
1619 fi
1620 fi
1621
1622 echo " applying DISABLE settings"
1623 for i in $PACKAGES ; do
1624 echo $i >> ./.tmp_pack
1625 done
1626 for i in `grep "-" ./.tmp_pack` ; do
1627 j=`echo $i | sed 's/[-]//'`
1628 DISABLE="$DISABLE $j"
1629 done
1630 pack=
1631 for p in $PACKAGES ; do
1632 addit="t"
1633 for d in $DISABLE ; do
1634 if test "x$p" = "x$d" ; then
1635 addit="f"
1636 fi
1637 done
1638 if test "x$addit" = xt ; then
1639 pack="$pack $p"
1640 fi
1641 done
1642 PACKAGES="$pack"
1643 echo " applying ENABLE settings"
1644 echo "" > ./.tmp_pack
1645 PACKAGES="$PACKAGES $ENABLE"
1646 # Test if each explicitly referenced package exists
1647 for i in $PACKAGES ; do
1648 j=`echo $i | sed 's/[-+]//'`
1649 if test ! -d "$ROOTDIR/pkg/$j" ; then
1650 echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""
1651 exit 1
1652 fi
1653 echo $i >> ./.tmp_pack
1654 done
1655 PACKAGES=
1656 for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do
1657 PACKAGES="$PACKAGES $i"
1658 done
1659 rm -f ./.tmp_pack
1660 echo " packages are: $PACKAGES"
1661
1662 # Check availability of NetCDF and then either build the MNC template
1663 # files or delete mnc from the list of available packages.
1664 echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1665 RETVAL=$?
1666 if test "x$RETVAL" = x0 ; then
1667 if test "x$HAVE_NETCDF" != xt ; then
1668 cat <<EOF
1669
1670 *********************************************************************
1671 WARNING: the "mnc" package was enabled but tests failed to compile
1672 NetCDF applications. Please check that:
1673
1674 1) NetCDF is correctly installed for this compiler and
1675 2) the LIBS variable (within the "optfile") specifies the correct
1676 NetCDF library to link against.
1677
1678 Due to this failure, the "mnc" package is now DISABLED.
1679 *********************************************************************
1680
1681 EOF
1682 PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
1683 DISABLE="$DISABLE mnc"
1684 else
1685 ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
1686 RETVAL=$?
1687 if test "x${RETVAL}" = x0 ; then
1688 rm -f make_mnc.errors
1689 else
1690 echo "Error: problem encountered while building source files in pkg/mnc:"
1691 cat make_mnc.errors 1>&2
1692 exit 1
1693 fi
1694 fi
1695 fi
1696
1697 echo " applying package dependency rules"
1698 ck=
1699 while test "x$ck" != xtt ; do
1700 i=0
1701 # rtot=${#PNAME[@]}
1702 rtot=$nname
1703 while test $i -lt $rtot ; do
1704
1705 # Is $pname in the current $PACKAGES list?
1706 # pname=${PNAME[$i]}
1707 tmp="pname=\"\$PNAME_$i\""
1708 eval $tmp
1709 pin="f"
1710 for p in $PACKAGES ; do
1711 if test "x$p" = "x$pname" ; then
1712 pin="t"
1713 fi
1714 done
1715
1716 # Is the DNAME entry a (+) or (-) rule ?
1717 tmp="dname=\"\$DNAME_$i\""
1718 eval $tmp
1719 plus="-"
1720 echo $dname | grep '^+' > /dev/null 2>&1
1721 RETVAL=$?
1722 if test "x$RETVAL" = x0 ; then
1723 plus="+"
1724 fi
1725
1726 # Is $dname in the current $PACKAGES list?
1727 dname=`echo $dname | sed -e 's/^[+-]//'`
1728 din="f"
1729 for p in $PACKAGES ; do
1730 if test "x$p" = "x$dname" ; then
1731 din="t"
1732 fi
1733 done
1734
1735 # Do we need to add $dname according to the dependency rules?
1736 if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then
1737 in_dis="f"
1738 for dis in $DISABLE ; do
1739 if test "x$dis" = "x$dname" ; then
1740 in_dis="t"
1741 fi
1742 done
1743 if test "x$in_dis" = xt ; then
1744 echo "Error: can't satisfy package dependencies:"
1745 echo " \"$dname\" is required by the dependency rules"
1746 echo " but is disallowed by the DISABLE settings"
1747 exit 1
1748 else
1749 PACKAGES="$PACKAGES $dname"
1750 ck=
1751 fi
1752 fi
1753
1754 # Do we need to get rid of $dname according to the dependency rules?
1755 if test "x$pin" = xt -a "x$plus" = "x-" -a "x$din" = xt; then
1756 echo "Error: can't satisfy package dependencies:"
1757 echo " \"$pname\" was requested but is disallowed by"
1758 echo " the dependency rules for \"$dname\""
1759 exit 1
1760 fi
1761 i=`echo "$i + 1" | bc -l`
1762 #i=$(( $i + 1 ))
1763 done
1764 ck=$ck"t"
1765 done
1766 echo " packages are: $PACKAGES"
1767 for i in $PACKAGES ; do
1768 adr="$ROOTDIR/pkg/$i"
1769 if test -d $adr ; then
1770 SOURCEDIRS="$SOURCEDIRS $adr"
1771 INCLUDEDIRS="$INCLUDEDIRS $adr"
1772 if test "x$i" = xautodiff ; then
1773 AUTODIFF_PKG_USED=t
1774 fi
1775 else
1776 echo "Error: the directory \"$adr\" for package $i doesn't exist"
1777 exit 1
1778 fi
1779 done
1780
1781 # Create a list of #define and #undef to enable/disable packages
1782 PACKAGES_DOT_H=PACKAGES_CONFIG.h
1783 # The following UGLY HACK sets multiple "#undef"s and it needs to go
1784 # away. On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h
1785 # file would eventually be split up so that all package-related #define
1786 # statements could be separated and handled only by genmake.
1787 names=`ls -1 "$ROOTDIR/pkg"`
1788 all_pack=
1789 DISABLED_PACKAGES=
1790 for n in $names ; do
1791 if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then
1792 has_pack="f"
1793 for pack in $PACKAGES ; do
1794 if test "x$pack" = "x$n" ; then
1795 has_pack="t"
1796 break
1797 fi
1798 done
1799 if test "x$has_pack" = xf ; then
1800 undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1801 DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
1802 fi
1803 fi
1804 done
1805 ENABLED_PACKAGES=
1806 for i in $PACKAGES ; do
1807 def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1808 ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1809 #eh3 DEFINES="$DEFINES -D$def"
1810
1811 #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
1812 case $i in
1813 aim_v23)
1814 ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
1815 echo "Warning: ALLOW_AIM is set to enable aim_v23."
1816 ;;
1817 esac
1818 #EH3 WARNING : This is an UGLY HACK that needs to be removed!!!
1819
1820 done
1821
1822 echo " Adding STANDARDDIRS"
1823 BUILDDIR=${BUILDDIR:-.}
1824 if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
1825 STANDARDDIRS="eesupp model"
1826 fi
1827 if test "x$STANDARDDIRS" != x ; then
1828 for d in $STANDARDDIRS ; do
1829 adr="$ROOTDIR/$d/src"
1830 if test ! -d $adr ; then
1831 echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1832 echo " is correct and that you correctly specified the STANDARDDIRS option"
1833 exit 1
1834 else
1835 SOURCEDIRS="$SOURCEDIRS $adr"
1836 fi
1837 adr="$ROOTDIR/$d/inc"
1838 if test ! -d $adr ; then
1839 echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1840 echo " is correct and that you correctly specified the STANDARDDIRS option"
1841 exit 1
1842 else
1843 INCLUDEDIRS="$INCLUDEDIRS $adr"
1844 fi
1845 done
1846 fi
1847
1848 echo " Searching for *OPTIONS.h files in order to warn about the presence"
1849 echo " of \"#define \"-type statements that are no longer allowed:"
1850 CPP_OPTIONS=
1851 CPP_EEOPTIONS=
1852 spaths=". $INCLUDEDIRS"
1853 names=`ls -1 "$ROOTDIR/pkg"`
1854 for i in $spaths ; do
1855 try="$i/CPP_OPTIONS.h"
1856 if test -f $try -a -r $try -a "x$CPP_OPTIONS" = x ; then
1857 echo " found CPP_OPTIONS=\"$try\""
1858 CPP_OPTIONS="$try"
1859 # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
1860 for n in $names ; do
1861 test_for_package_in_cpp_options $CPP_OPTIONS $n
1862 done
1863 fi
1864 try="$i/CPP_EEOPTIONS.h"
1865 if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" = x ; then
1866 echo " found CPP_EEOPTIONS=\"$try\""
1867 # New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h
1868 #**** not yet enabled ****
1869 # test_for_mpi_in_cpp_eeoptions $try
1870 #**** not yet enabled ****
1871 CPP_EEOPTIONS="$try"
1872 fi
1873 done
1874 if test "x$CPP_OPTIONS" = x ; then
1875 echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"
1876 exit 1
1877 fi
1878
1879 # Here, we build the list of files to be "run through" the adjoint
1880 # compiler.
1881 if test -f ./ad_files ; then
1882 rm -f ./ad_files
1883 fi
1884 echo " Creating the list of files for the adjoint compiler."
1885 for i in $SOURCEDIRS ; do
1886 list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
1887 for j in $list_files ; do
1888 cat $i/$j >> ad_files
1889 done
1890 done
1891 if test ! "x"$FS = "x.f" ; then
1892 cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f
1893 mv -f ad_files_f ad_files
1894 fi
1895
1896 echo
1897 echo "=== Creating the Makefile ==="
1898 echo " setting INCLUDES"
1899 for i in $INCLUDEDIRS ; do
1900 if test ! -d $i ; then
1901 echo "Warning: can't find INCLUDEDIRS=\"$i\""
1902 fi
1903 done
1904
1905 echo " Determining the list of source and include files"
1906 rm -rf .links.tmp
1907 mkdir .links.tmp
1908 echo "# This section creates symbolic links" > srclinks.tmp
1909 echo "" >> srclinks.tmp
1910 printf 'SRCFILES = ' > srclist.inc
1911 printf 'CSRCFILES = ' > csrclist.inc
1912 printf 'F90SRCFILES = ' > f90srclist.inc
1913 printf 'HEADERFILES = ' > hlist.inc
1914 printf 'AD_FLOW_FILES = ' > ad_flow_files.inc
1915 alldirs="$SOURCEDIRS $INCLUDEDIRS ."
1916 for d in $alldirs ; do
1917 deplist=
1918 sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
1919 sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
1920 for sf in $sfiles ; do
1921 if test ! -r ".links.tmp/$sf" ; then
1922 if test -f "$d/$sf" ; then
1923 case $d/$sf in
1924 ./$PACKAGES_DOT_H)
1925 ;;
1926 ./AD_CONFIG.h)
1927 ;;
1928 ./FC_NAMEMANGLE.h)
1929 ;;
1930 ./BUILD_INFO.h)
1931 ;;
1932 *)
1933 touch .links.tmp/$sf
1934 deplist="$deplist $sf"
1935 ;;
1936 esac
1937 extn=`echo $sf | $AWK -F. '{print $NF}'`
1938 case $extn in
1939 F)
1940 echo " \\" >> srclist.inc
1941 printf " $sf" >> srclist.inc
1942 ;;
1943 F90)
1944 echo " \\" >> f90srclist.inc
1945 printf " $sf" >> f90srclist.inc
1946 ;;
1947 c)
1948 echo " \\" >> csrclist.inc
1949 printf " $sf" >> csrclist.inc
1950 ;;
1951 h)
1952 echo " \\" >> hlist.inc
1953 printf " $sf" >> hlist.inc
1954 ;;
1955 flow)
1956 echo " \\" >> ad_flow_files.inc
1957 printf " $sf" >> ad_flow_files.inc
1958 ;;
1959 esac
1960 fi
1961 fi
1962 done
1963 if test "x$deplist" != x ; then
1964 echo "" >> srclinks.tmp
1965 echo "# These files are linked from $d" >> srclinks.tmp
1966 echo "$deplist :" >> srclinks.tmp
1967 printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp
1968 fi
1969 done
1970 rm -rf .links.tmp
1971 echo "" >> srclist.inc
1972 echo "" >> csrclist.inc
1973 echo "" >> f90srclist.inc
1974 echo "" >> hlist.inc
1975 echo "" >> ad_flow_files.inc
1976
1977 if test -f $MAKEFILE ; then
1978 mv -f $MAKEFILE "$MAKEFILE.bak"
1979 fi
1980 echo " Writing makefile: $MAKEFILE"
1981 echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE
1982 echo "# $MACHINE" >> $MAKEFILE
1983 echo "# This makefile was generated automatically on" >> $MAKEFILE
1984 echo "# $THISDATE" >> $MAKEFILE
1985 echo "# by the command:" >> $MAKEFILE
1986 echo "# $0 $G2ARGS" >> $MAKEFILE
1987 echo "# executed by:" >> $MAKEFILE
1988 echo "# ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
1989
1990 EXE_AD=$EXECUTABLE"_ad"
1991 EXE_FTL=$EXECUTABLE"_ftl"
1992 EXE_SVD=$EXECUTABLE"_svd"
1993
1994 cat >>$MAKEFILE <<EOF
1995 #
1996 # OPTFILE="$OPTFILE"
1997 #
1998 # BUILDDIR : Directory where object files are written
1999 # SOURCEDIRS : Directories containing the source (.F) files
2000 # INCLUDEDIRS : Directories containing the header-source (.h) files
2001 # EXEDIR : Directory where executable that is generated is written
2002 # EXECUTABLE : Full path of executable binary
2003 #
2004 # CPP : C-preprocessor command
2005 # INCLUDES : Directories searched for header files
2006 # DEFINES : Macro definitions for CPP
2007 # MAKEDEPEND : Dependency generator
2008 # KPP : Special preprocessor command (specific to platform)
2009 # KFLAGS : Flags for KPP
2010 # FC : Fortran compiler command
2011 # FFLAGS : Configuration/debugging options for FC
2012 # FOPTIM : Optimization options for FC
2013 # LINK : Command for link editor program
2014 # LIBS : Library flags /or/ additional optimization/debugging flags
2015
2016 ROOTDIR = ${ROOTDIR}
2017 BUILDDIR = ${BUILDDIR}
2018 SOURCEDIRS = ${SOURCEDIRS}
2019 INCLUDEDIRS = ${INCLUDEDIRS}
2020 EXEDIR = ${EXEDIR}
2021 EXECUTABLE = \$(EXEDIR)/${EXECUTABLE}
2022 TOOLSDIR = ${TOOLSDIR}
2023
2024 #eh3 new defines for the adjoint work
2025 AUTODIFF = ${ROOTDIR}/pkg/autodiff
2026 EXE_AD = ${EXE_AD}
2027 EXE_FTL = ${EXE_FTL}
2028 EXE_SVD = ${EXE_SVD}
2029
2030 ENABLED_PACKAGES = ${ENABLED_PACKAGES}
2031 DISABLED_PACKAGES = ${DISABLED_PACKAGES}
2032
2033 # These files are created by Makefile
2034 SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h
2035
2036 EOF
2037
2038 # Note: figure out some way to add Hyades JAM libraries here
2039
2040 cat >>$MAKEFILE <<EOF
2041 # Unix ln (link)
2042 LN = ${LN}
2043 # C preprocessor
2044 CPP = cat \$< | ${S64} | ${CPP}
2045 # Dependency generator
2046 MAKEDEPEND = ${MAKEDEPEND}
2047 # Special preprocessor (KAP on DECs, FPP on Crays)
2048 KPP = ${KPP}
2049 # Fortran compiler
2050 FC = ${FC}
2051 # Fortran compiler
2052 F90C = ${F90C}
2053 # C compiler
2054 CC = ${CC}
2055 # Link editor
2056 LINK = ${LINK} ${LDADD}
2057
2058 # Defines for CPP
2059 DEFINES = ${DEFINES}
2060 # Includes for CPP
2061 INCLUDES = ${INCLUDES}
2062 # Flags for KPP
2063 KFLAGS1 = ${KFLAGS1}
2064 KFLAGS2 = ${KFLAGS2}
2065 # Optim./debug for FC
2066 FFLAGS = ${FFLAGS}
2067 FOPTIM = ${FOPTIM}
2068 # Optim./debug for FC
2069 F90FLAGS = ${F90FLAGS}
2070 F90OPTIM = ${F90OPTIM}
2071 # Flags for CC
2072 CFLAGS = ${CFLAGS}
2073 # Files that should not be optimized
2074 NOOPTFILES = ${NOOPTFILES}
2075 NOOPTFLAGS = ${NOOPTFLAGS}
2076 # Flags and libraries needed for linking
2077 LIBS = ${LIBS}
2078 # Name of the Mekfile
2079 MAKEFILE=${MAKEFILE}
2080
2081 EOF
2082
2083 cat srclist.inc >> $MAKEFILE
2084 cat csrclist.inc >> $MAKEFILE
2085 cat f90srclist.inc >> $MAKEFILE
2086 cat hlist.inc >> $MAKEFILE
2087 cat ad_flow_files.inc >> $MAKEFILE
2088 echo >> $MAKEFILE
2089 echo 'F77FILES = $(SRCFILES:.F=.'$FS')' >> $MAKEFILE
2090 echo 'F90FILES = $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE
2091 echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
2092 echo >> $MAKEFILE
2093 echo '.SUFFIXES:' >> $MAKEFILE
2094 echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE
2095 rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc
2096 rm -f ad_flow_files.inc
2097
2098 cat >>$MAKEFILE <<EOF
2099
2100 all: \$(EXECUTABLE)
2101 \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)
2102 @echo Creating \$@ ...
2103 \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2104 depend:
2105 @make links
2106 \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
2107 \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2108 -rm -f makedepend.out
2109
2110 links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
2111
2112 small_f: \$(F77FILES) \$(F90FILES)
2113
2114 output.txt: \$(EXECUTABLE)
2115 @printf 'running ... '
2116 @\$(EXECUTABLE) > \$@
2117
2118 clean:
2119 -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2120 Clean:
2121 @make clean
2122 @make cleanlinks
2123 -rm -f \$(SPECIAL_FILES)
2124 -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak
2125 CLEAN:
2126 @make Clean
2127 -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2128 -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2129 -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2130 -rm -f \$(EXECUTABLE) output.txt STD*
2131
2132 #eh3 Makefile: makefile
2133 makefile:
2134 $THIS_SCRIPT $G2ARGS
2135 cleanlinks:
2136 -find . -type l -exec rm {} \;
2137
2138 # Special targets (SPECIAL_FILES) which are create by make
2139 ${PACKAGES_DOT_H}:
2140 @echo Creating \$@ ...
2141 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@
2142 AD_CONFIG.h:
2143 @echo Creating \$@ ...
2144 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > \$@
2145 FC_NAMEMANGLE.h:
2146 @echo Creating \$@ ...
2147 echo "$FC_NAMEMANGLE" > \$@
2148
2149 BUILD_INFO.h:
2150 @echo Creating \$@ ...
2151 EOF
2152
2153 test ! "x$THISVER" = x && echo " -echo \"#define THISVER '$THISVER'\" > \$@" >> $MAKEFILE
2154 test ! "x$THISUSER" = x && echo " -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2155 test ! "x$THISDATE" = x && echo " -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2156 test ! "x$THISHOST" = x && echo " -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2157
2158 cat >>$MAKEFILE <<EOF
2159
2160 # The normal chain of rules is ( .F - .$FS - .o )
2161
2162 ## This nullifies any default implicit rules concerning these two file types:
2163 ## %.o : %.F
2164
2165 .F.$FS:
2166 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2167 .$FS.o:
2168 \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2169 .F90.$FS90:
2170 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2171 .$FS90.o:
2172 \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2173 .c.o:
2174 \$(CC) \$(CFLAGS) -c \$<
2175
2176 # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2177 .F.p:
2178 \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2179 .p.$FS:
2180 \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
2181
2182 #=========================================
2183 #=== Automatic Differentiation Rules ===
2184
2185 TAMC = ${TAMC}
2186 TAF = ${TAF}
2187
2188 TAF_EXTRA = ${TAF_EXTRA}
2189 TAMC_EXTRA = ${TAMC_EXTRA}
2190
2191 EOF
2192
2193 ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS"
2194 ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF_FLAGS"
2195 ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
2196 for i in $ad_vars ; do
2197 name=$i
2198 t1="t2=\$"`echo $i`
2199 eval $t1
2200 printf "%-20s = " $name >> $MAKEFILE
2201 echo $t2 >> $MAKEFILE
2202 done
2203
2204 echo " Add the source list for AD code generation"
2205 echo >> $MAKEFILE
2206 printf "AD_FILES = " >> $MAKEFILE
2207 AD_FILES=`cat ad_files`
2208 for i in $AD_FILES ; do
2209 echo " \\" >> $MAKEFILE
2210 printf " $i" >> $MAKEFILE
2211 done
2212 echo >> $MAKEFILE
2213 rm -f ad_files
2214
2215 cat >>$MAKEFILE <<EOF
2216
2217 # ... AD ...
2218 adall: ad_taf
2219 adtaf: ad_taf_output.$FS
2220 adtamc: ad_tamc_output.$FS
2221
2222 ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2223 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template
2224 cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2225 -rm -f ad_config.template
2226 @make \$(F77FILES)
2227 @make \$(AD_FLOW_FILES)
2228 cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS
2229
2230 ad_taf_output.$FS: ad_input_code.$FS
2231 \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2232 cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2233
2234 adtafonly:
2235 \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2236 cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2237
2238 ad_taf: ad_taf_output.o \$(OBJFILES)
2239 \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2240
2241 ad_tamc_output.$FS: ad_input_code.$FS
2242 \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2243 cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
2244
2245 ad_tamc: ad_tamc_output.o \$(OBJFILES)
2246 \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2247
2248 adonlyfwd:
2249 patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2250
2251 adtrick:
2252 patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2253
2254 # ... FTL ...
2255 ftlall: ftl_taf
2256 ftltaf: ftl_taf_output.$FS
2257 ftltamc: ftl_tamc_output.$FS
2258
2259 ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2260 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template
2261 cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2262 -rm -f ftl_config.template
2263 @make \$(F77FILES)
2264 @make \$(AD_FLOW_FILES)
2265 cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2266
2267 ftl_taf_output.$FS: ftl_input_code.$FS
2268 \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2269 cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2270
2271 ftltafonly:
2272 \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2273 cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2274
2275 ftl_taf: ftl_taf_output.o \$(OBJFILES)
2276 \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2277
2278 ftl_tamc_output.$FS: ftl_input_code.$FS
2279 \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2280 cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS
2281
2282 ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2283 \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2284
2285
2286 # ... SVD ...
2287 svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
2288 @echo "--->>> Only ran TAF to generate SVD code! <<<---"
2289 @echo "--->>> Do make svdall afterwards to compile. <<<---"
2290 svdall: svd_touch svd_taf
2291
2292 svd_taf: \$(OBJFILES)
2293 \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS)
2294
2295 @echo "--->>> Only COMPILE svd code! <<<---"
2296 @echo "--->>> Assumes you previously <<<---"
2297 @echo "--->>> did make svdtaf <<<---"
2298
2299 svd_touch:
2300 @echo "--->>> Only COMPILE svd code! <<<---"
2301 @echo "--->>> Assumes you previously <<<---"
2302 @echo "--->>> did make svdtaf <<<---"
2303 touch ad_taf_output.$FS ftl_taf_output.$FS
2304 \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
2305 \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
2306 @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template
2307 cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2308 -rm -f ftl_config.template
2309
2310 #=========================================
2311
2312 EOF
2313
2314 if test "x$EXEHOOK" != x ; then
2315 printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
2316 fi
2317
2318 echo " Making list of \"exceptions\" that need \".p\" files"
2319 for i in $KPPFILES ; do
2320 base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
2321 RETVAL=$?
2322 if test "x$RETVAL" != x0 ; then
2323 echo "Error: unable to add file \"$i\" to the exceptions list"
2324 fi
2325 echo "$base.$FS: $base.p" >> $MAKEFILE
2326 done
2327
2328 echo " Making list of NOOPTFILES"
2329 for i in $NOOPTFILES ; do
2330 base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
2331 RETVAL=$?
2332 if test "x$RETVAL" != x0 ; then
2333 echo "Error: unable to add file \"$i\" to the exceptions list"
2334 fi
2335 echo "$base.o: $base.$FS" >> $MAKEFILE
2336 printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
2337 done
2338
2339 echo " Add rules for links"
2340 cat srclinks.tmp >> $MAKEFILE
2341 rm -f srclinks.tmp
2342
2343 echo " Adding makedepend marker"
2344 printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE
2345
2346 printf "\n=== Done ===\n"
2347
2348 # Create special header files
2349 $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" $DISABLED_PACKAGES " " "Enabled packages:" $ENABLED_PACKAGES > $PACKAGES_DOT_H".tmp"
2350 if test ! -f $PACKAGES_DOT_H ; then
2351 mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
2352 else
2353 cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H > /dev/null 2>&1
2354 RETVAL=$?
2355 if test "x$RETVAL" = x0 ; then
2356 rm -f $PACKAGES_DOT_H".tmp"
2357 else
2358 mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"
2359 mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
2360 fi
2361 fi
2362 if test ! -f AD_CONFIG.h ; then
2363 $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > AD_CONFIG.h
2364 fi
2365
2366
2367 # Write the "state" for future records
2368 if test "x$DUMPSTATE" != xf ; then
2369 printf "" > genmake_state
2370 for i in $gm_state ; do
2371 t1="t2=\$$i"
2372 eval $t1
2373 echo "$i='$t2'" >> genmake_state
2374 done
2375 fi

  ViewVC Help
Powered by ViewVC 1.1.22