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

Diff of /MITgcm/tools/genmake2

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

revision 1.11.2.5 by adcroft, Thu Oct 2 14:27:50 2003 UTC revision 1.75 by edhill, Wed Apr 7 20:28:09 2004 UTC
# Line 1  Line 1 
1  #!/bin/bash  #! /usr/bin/env bash
2  #  #
3  # $Header$  # $Header$
4  #  #
# Line 13  Line 13 
13  test_for_package_in_cpp_options() {  test_for_package_in_cpp_options() {
14      cpp_options=$1      cpp_options=$1
15      pkg=$2      pkg=$2
16      grep -i "#define.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg" || exit 99
17      RETVAL=$?      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg" || exit 99
18      if test "x${RETVAL}" = x0 ; then      test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg" || exit 99
19          echo "Error: In $cpp_options there is an illegal line: #define ALLOW_$pkg"      test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg" || exit 99
20          exit 99  }
21      fi  
22      grep -i "#undef.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1  # Search for particular CPP #cmds associated with MPI
23      RETVAL=$?  # usage: test_for_mpi_in_cpp_eeoptions CPP_file
24      if test "x${RETVAL}" = x0 ; then  test_for_mpi_in_cpp_eeoptions() {
25          echo "Error: In $cpp_options there is an illegal line: #undef ALLOW_$pkg"      cpp_options=$1
26          exit 99      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI" || exit 99
27      fi      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI" || exit 99
28      grep -i "#define.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1      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=$?      RETVAL=$?
39      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
40          echo "Error: In $cpp_options there is an illegal line: #define DISABLE_$pkg"          printf "Error: In $file there is an illegal line: "
41          exit 99          grep -i "$strng" $file
42            return 1
43      fi      fi
44      grep -i "#undef.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1      return 0
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         echo "Error: In $cpp_options there is an illegal line: #undef DISABLE_$pkg"  
         exit 99  
    fi  
45  }  }
46    
47  # Read the $ROOTDIR/pkg/pkg_groups file and expand any references to  # Read the $ROOTDIR/pkg/pkg_groups file and expand any references to
# Line 46  expand_pkg_groups() { Line 51  expand_pkg_groups() {
51      PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"      PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"
52      if test -r $PKG_GROUPS ; then      if test -r $PKG_GROUPS ; then
53          cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp          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          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp
55          matched=0          matched=0
56          for i in $PACKAGES ; do          for i in $PACKAGES ; do
57              line=`grep $i ./p2.tmp`              line=`grep "^ *$i" ./p2.tmp`
58              RETVAL=$?              RETVAL=$?
59              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
60                  matched=1                  matched=1
61                  replace=`echo $line | awk '{ $1=""; $2=""; print $0 }'`                  replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
62                  echo "    replacing \"$i\" with: $replace"                  echo "    replacing \"$i\" with: $replace"
63                  new_packages="$new_packages $replace"                  new_packages="$new_packages $replace"
64              else              else
# Line 62  expand_pkg_groups() { Line 67  expand_pkg_groups() {
67          done          done
68          PACKAGES=$new_packages          PACKAGES=$new_packages
69          rm -f ./p[1,2].tmp          rm -f ./p[1,2].tmp
70            return $matched
71      else      else
72          echo "Warning: can't read package groups definition file: $PKG_GROUPS"          echo "Warning: can't read package groups definition file: $PKG_GROUPS"
73      fi      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        #  First check the ability to create a *.F/.f pair.
80        cat <<EOF >> ./hello.F
81          program hello
82          write(*,*) 'hi'
83          stop
84          end
85    EOF
86        cp ./hello.F ./hello.f
87        RETVAL=$?
88        if test "x$RETVAL" != x0 ; then
89            FEXT='fp'
90            F90EXT='fp90'
91            return
92        fi
93        rm -f ./hello.f
94    
95        #  Then check the ability of ${MAKE} to use the two.
96        test -e Makefile  &&  mv -f Makefile Makefile.bak
97        cat <<EOF >> Makefile
98    .SUFFIXES:
99    hello.f: hello.F
100            cp -f hello.F hello.f
101    EOF
102        ( $MAKE hello.f ) > /dev/null 2>&1
103        RETVAL=$?
104        if test "x$RETVAL" != x0 -o ! -f ./hello.f ; then
105            FEXT='fp'
106            F90EXT='fp90'
107            return
108        fi
109        rm -f ./hello.f ./hello.F Makefile
110        test -e Makefile  &&  mv -f Makefile.bak Makefile
111    
112        #  Both tests passed, so use the default.
113        FEXT='F'
114        F90EXT='F90'
115    }
116    
117    
118  # Guess possible config options for this host  # Guess possible config options for this host
119  find_possible_configs()  {  find_possible_configs()  {
120    
121      tmp1=`uname`"_"`uname -m`      tmp1=`uname`"_"`uname -m`
122      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
123      PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/'`      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
124        tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
125        tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
126        tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
127        PLATFORM=$tmp3
128      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
129      echo "  The platform appears to be:  $PLATFORM"      echo "  The platform appears to be:  $PLATFORM"
 #     if test "x$OFLIST" = x ; then  
 #       echo "  No pre-defined options files were found matching this platform"  
 #       echo "  but examples for other platforms can be found in:"  
 #       echo "    $ROOTDIR/tools/build_options"  
 #     else  
 #       echo "  Options files (located in $ROOTDIR/tools/build_options) that"  
 #       echo "  may work with this machine are:"  
 #       for i in $OFLIST ; do  
 #           echo "    $i"  
 #       done  
 #     fi  
130            
131      echo "test" > test      echo "test" > test
132      ln -s ./test link      ln -s ./test link
# Line 103  find_possible_configs()  { Line 144  find_possible_configs()  {
144          CPP="cpp -traditional -P"          CPP="cpp -traditional -P"
145      fi      fi
146    
147        #  The "original" makedepend is part of the Imake system that is
148        #  most often distributed with XFree86 or with an XFree86 source
149        #  package.  As a result, many machines (eg. generic Linux) do not
150        #  have a system-default "makedepend" available.  For those
151        #  systems, we have two fall-back options:
152        #
153        #    1) a makedepend implementation shipped with the cyrus-imapd
154        #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
155        #
156        #    2) a known-buggy xmakedpend shell script
157        #
158        #  So the choices are, in order:
159        #
160        #    1) use the user-specified program
161        #    2) use a system-wide default
162        #    3) locally build and use the cyrus implementation
163        #    4) fall back to the buggy local xmakedpend script
164        #
165        if test "x${MAKEDEPEND}" = x ; then
166          which makedepend > /dev/null 2>&1
167          RETVAL=$?
168          if test ! "x${RETVAL}" = x0 ; then
169             echo "    a system-default makedepend was not found."
170    
171             #  Try to build the cyrus impl
172             rm -f ./genmake_cy_md
173             (
174                 cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
175                     &&  ./configure > /dev/null 2>&1  \
176                     &&  make > /dev/null 2>&1  \
177                     &&  ./makedepend ifparser.c > /dev/null 2>&1  \
178                     &&  echo "true"
179             ) > ./genmake_cy_md
180             grep true ./genmake_cy_md > /dev/null 2>&1
181             RETVAL=$?
182             if test "x$RETVAL" = x0 ; then
183                 MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
184             else
185                 MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
186             fi
187             rm -f ./genmake_cy_md
188          fi
189        fi
190    
191      # look for possible fortran compilers      # look for possible fortran compilers
192      tmp="$MITGCM_FC $FC g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
193      p_FC=      p_FC=
194      for c in $tmp ; do      for c in $tmp ; do
195          rm -f ./hello.f ./hello          rm -f ./hello.f ./hello
# Line 121  EOF Line 206  EOF
206              p_FC="$p_FC $c"              p_FC="$p_FC $c"
207          fi          fi
208      done      done
209        rm -f ./hello.f ./hello
210      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
211          cat 1>&2 <<EOF          cat 1>&2 <<EOF
212    
# Line 136  EOF Line 222  EOF
222          echo "  The possible FORTRAN compilers found in your path are:"          echo "  The possible FORTRAN compilers found in your path are:"
223          echo "   "$p_FC          echo "   "$p_FC
224          if test "x$FC" = x ; then          if test "x$FC" = x ; then
225              FC=`echo $p_FC | awk '{print $1}'`              FC=`echo $p_FC | $AWK '{print $1}'`
226                echo "  Setting FORTRAN compiler to: "$FC
227          fi          fi
228      fi      fi
229    
230      for i in $p_FC ; do      if test "x$OPTFILE" = x ; then
231          p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
232          if test -r $p_OF ; then          if test ! -r $OPTFILE ; then
233              OPTFILE=$p_OF               echo "  I looked for the file "$OPTFILE" but did not find it"
234              echo "  The options file:  $p_OF"          fi
235              echo "    appears to match so we'll use it."      fi
236              break  #    echo "  The options file:  $p_OF"
237          fi  #    echo "    appears to match so we'll use it."
238      done  #   for i in $p_FC ; do
239    #p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
240    #if test -r $p_OF ; then
241    #    OPTFILE=$p_OF
242    #    echo "  The options file:  $p_OF"
243    #    echo "    appears to match so we'll use it."
244    #    break
245    #fi
246    #   done
247      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
248          cat 1>&2 <<EOF          cat 1>&2 <<EOF
249    
# Line 202  get_pdepend_list()  { Line 297  get_pdepend_list()  {
297      #  strip the comments and then convert the dependency file into      #  strip the comments and then convert the dependency file into
298      #  two arrays: PNAME, DNAME      #  two arrays: PNAME, DNAME
299      cat $1 | sed -e 's/#.*$//g' \      cat $1 | sed -e 's/#.*$//g' \
300          | awk 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \          | $AWK 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \
301          > ./.pd_tmp          > ./.pd_tmp
302      source ./.pd_tmp      . ./.pd_tmp
303      rm -f ./.pd_tmp      rm -f ./.pd_tmp
304    
305      echo -n "PNAME = "${}      printf "PNAME = "${}
306  }  }
307    
308    
309  #  Explain usage  #  Explain usage
310  usage()  {  usage()  {
311      echo  cat <<EOF
312      echo "Usage: "$0" [OPTIONS]"  
313      echo "  where [OPTIONS] can be:"  Usage: "$0" [OPTIONS]
314      echo    where [OPTIONS] can be:
315      echo "    -help | --help | -h | --h"  
316      echo "    -nooptfile | --nooptfile"      -help | --help | -h | --h
317      echo "      -optfile NAME | --optfile NAME | -of NAME | --of NAME"            Print this help message and exit.
318      echo "      -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME"  
319      echo "    -pdepend NAME | --pdepend NAME"      -nooptfile | --nooptfile
320      echo "      -pdepend=NAME | --pdepend=NAME"        -optfile NAME | --optfile NAME | -of NAME | --of NAME
321      echo "    -pdefault NAME | --pdefault NAME"        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
322      echo "      -pdefault=NAME | --pdefault=NAME"            Use "NAME" as the optfile.  By default, an attempt will be
323      echo "    -make NAME | -m NAME"            made to find an appropriate "standard" optfile in the
324      echo "      --make=NAME | -m=NAME"            tools/build_options/ directory.
325      echo "    -makefile NAME | -mf NAME"  
326      echo "      --makefile=NAME | -mf=NAME"      -pdepend NAME | --pdepend NAME
327      echo "    -platform NAME | --platform NAME | -pl NAME | --pl NAME"        -pdepend=NAME | --pdepend=NAME
328      echo "      -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME"            Get package dependency information from "NAME".
329      echo "    -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME"  
330      echo "      -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME"      -pdefault NAME | --pdefault NAME
331      echo "    -mods NAME | --mods NAME | -mo NAME | --mo NAME"        -pdefault=NAME | --pdefault=NAME
332      echo "      -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME"            Get the default package list from "NAME".
333      echo "    -disable NAME | --disable NAME"  
334      echo "      -disable=NAME | --disable=NAME"      -make NAME | -m NAME
335      echo "    -enable NAME | --enable NAME"        --make=NAME | -m=NAME
336      echo "      -enable=NAME | --enable=NAME"            Use "NAME" for the MAKE program. The default is "make" but
337      echo "    -noopt NAME | --noopt NAME"            many platforms, "gmake" is the preferred choice.
338      echo "      -noopt=NAME | --noopt=NAME"  
339  #    echo "    -cpp NAME | --cpp NAME"      -makefile NAME | -mf NAME
340  #    echo "      -cpp=NAME | --cpp=NAME"        --makefile=NAME | -mf=NAME
341      echo "    -fortran NAME | --fortran NAME | -fc NAME | --fc NAME"            Call the makefile "NAME".  The default is "Makefile".
342      echo "      -fc=NAME | --fc=NAME"  
343      echo "    -[no]ieee | --[no]ieee"      -makedepend NAME | -md NAME
344      echo "    -[no]mpi | --[no]mpi"        --makedepend=NAME | -md=NAME
345      echo "    -[no]jam | --[no]jam"            Use "NAME" for the MAKEDEPEND program.
346      echo  
347      echo "  and NAME is a string such as:"      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
348      echo        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
349      echo "    --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'"            Specify the location of the MITgcm ROOTDIR as "NAME".
350      echo "    -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'"            By default, genamke will try to find the location by
351      echo "    -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'"            looking in parent directories (up to the 5th parent).
352      echo  
353      echo "  which, depending upon your shell, may need to be single-quoted"      -mods NAME | --mods NAME | -mo NAME | --mo NAME
354      echo "  if it contains spaces, dashes, or other special characters."        -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME
355              Here, "NAME" specifies a list of directories that are
356              used for additional source code.  Files found in the
357              "mods list" are given preference over files of the same
358              name found elsewhere.
359    
360        -disable NAME | --disable NAME
361          -disable=NAME | --disable=NAME
362              Here "NAME" specifies a list of packages that we don't
363              want to use.  If this violates package dependencies,
364              genamke will exit with an error message.
365    
366        -enable NAME | --enable NAME
367          -enable=NAME | --enable=NAME
368              Here "NAME" specifies a list of packages that we wish
369              to specifically enable.  If this violates package
370              dependencies, genamke will exit with an error message.
371    
372        -standarddirs NAME | --standarddirs NAME
373          -standarddirs=NAME | --standarddirs=NAME
374              Here, "NAME" specifies a list of directories to be
375              used as the "standard" code.
376    
377        -fortran NAME | --fortran NAME | -fc NAME | --fc NAME
378          -fc=NAME | --fc=NAME
379              Use "NAME" as the fortran compiler.  By default, genmake
380              will search for a working compiler by trying a list of
381              "usual suspects" such as g77, f77, etc.
382    
383        -[no]ieee | --[no]ieee
384              Do or don't use IEEE numerics.  Note that this option
385              *only* works if it is supported by the OPTFILE that
386              is being used.
387    
388        -mpi | --mpi
389              Include MPI header files and link to MPI libraries
390        -mpi=PATH | --mpi=PATH
391              Include MPI header files and link to MPI libraries using MPI_ROOT
392              set to PATH. i.e. Include files from $PATH/include, link to libraries
393              from $PATH/lib and use binaries from $PATH/bin.
394    
395        -bash NAME
396              Explicitly specify the Bourne or BASH shell to use
397    
398      While it is most often a single word, the "NAME" variables specified
399      above can in many cases be a space-delimited string such as:
400    
401        --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'
402        -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'
403        -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'
404    
405      which, depending upon your shell, may need to be single-quoted.
406    
407      For more detailed genmake documentation, please see:
408    
409        http://mitgcm.org/devel_HOWTO/
410    
411    EOF
412    
413      exit 1      exit 1
414  }  }
415    
416  #eh3 # This is the generic configuration.  #  Build a CPP macro to automate calling C routines from FORTRAN
417  #eh3 set LN         = ( 'ln -s' )  get_fortran_c_namemangling()  {
418  #eh3 set CPP        = ( '/lib/cpp -P' )      default_nm="#define FC_NAMEMANGLE(X) X ## _"
419  #eh3 set S64        = ( '$(TOOLSDIR)/set64bitConst.sh' )      
420  #eh3 set KPP        = (  )      cat > genmake_test.c <<EOF
421  #eh3 set FC         = ( 'f77' )  void tcall( char * string ) { tsub( string ); }
422  #eh3 set LINK       = $FC  EOF
423  #eh3 set MAKEDEPEND = ( 'makedepend' )      $MAKE genmake_test.o >> genmake_warnings 2>&1
424  #eh3 set INCLUDES   = ( -I. )      RETVAL=$?
425  #eh3 set FFLAGS     = (  )      if test "x$RETVAL" != x0 ; then
426  #eh3 set FOPTIM     = (  )          FC_NAMEMANGLE=$default_nm
427  #eh3 set CFLAGS     = (  )          cat <<EOF>> genmake_errors
428  #eh3 set KFLAGS1    = (  )  
429  #eh3 set KFLAGS2    = (  )  WARNING: C test compile fails
430  #eh3 set LIBS       = (  )  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
431  #eh3 set KPPFILES   = (  )  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
432  #eh3 if (! $?NOOPTFILES ) set NOOPTFILES = (  )  EOF
433  #eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = (  )          return 1
434        fi
435        c_tcall=`nm genmake_test.o | grep 'T ' | grep tcall | cut -d ' ' -f 3`
436        RETVAL=$?
437        if test "x$RETVAL" != x0 ; then
438            FC_NAMEMANGLE=$default_nm
439            cat <<EOF>> genmake_warnings
440    
441    WARNING: The "nm" command failed.
442    WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
443    WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
444    EOF
445            return 1
446        fi
447        cat > genmake_tcomp.f <<EOF
448          subroutine tcall( string )
449          character*(*) string
450          call tsub( string )
451          end
452    EOF
453        $FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1
454        RETVAL=$?
455        if test "x$RETVAL" != x0 ; then
456            FC_NAMEMANGLE=$default_nm
457            cat <<EOF>> genmake_warnings
458    
459    WARNING: FORTRAN test compile fails -- please see "genmake_errors"
460    WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
461    WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
462    EOF
463            return 1
464        fi
465        f_tcall=`nm genmake_tcomp.o | grep 'T ' | grep tcall | cut -d ' ' -f 3`
466        RETVAL=$?
467        if test "x$RETVAL" != x0 ; then
468            FC_NAMEMANGLE=$default_nm
469            cat <<EOF>> genmake_warnings
470    
471    WARNING: The "nm" command failed.
472    WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
473    WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
474    EOF
475            return 1
476        fi
477    
478        c_a=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
479        f_a=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
480        c_b=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
481        f_b=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
482    
483        nmangle="X"
484        if test "x$c_a" != "x$f_a" ; then
485            comm="echo x$f_a | sed -e 's|x$c_a||'"
486            a=`eval $comm`
487            nmangle="$a ## $nmangle"
488        fi
489        if test "x$c_b" != "x$f_b" ; then
490            comm="echo x$f_b | sed -e 's|x$c_b||'"
491            b=`eval $comm`
492            nmangle="$nmangle ## $b"
493        fi
494    
495        FC_NAMEMANGLE="#define FC_NAMEMANGLE(X)  $nmangle"
496    
497        #  cleanup the testing files
498        rm -f genmake_tcomp.* genmake_test.*
499    }
500    
501    
502    check_HAVE_CLOC()  {
503        get_fortran_c_namemangling
504        cat <<EOF > genmake_tc_1.c
505    $FC_NAMEMANGLE
506    #include <stdio.h>
507    #include <stdlib.h>
508    #include <unistd.h>
509    #include <assert.h>
510    #include <sys/time.h>
511    void FC_NAMEMANGLE(cloc) ( double *curtim )
512    {
513     struct timeval tv1;
514     gettimeofday(&tv1 , (void *)NULL );
515     *curtim =  (double)((tv1.tv_usec)+(tv1.tv_sec)*1.E6);
516     *curtim = *curtim/1.E6;
517    }
518    EOF
519        make genmake_tc_1.o >> genmake_tc.log 2>&1
520        RET_C=$?
521        cat <<EOF > genmake_tc_2.f
522          program hello
523          Real*8 wtime
524          external cloc
525          call cloc(wtime)
526          print *," HELLO WORLD", wtime
527          end program hello
528    EOF
529        $FC $FFLAGS -o genmake_tc genmake_tc_2.f genmake_tc_1.o >> genmake_tc.log 2>&1
530        RET_F=$?
531        test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1
532        RETVAL=$?
533        if test "x$RETVAL" = x0 ; then
534            HAVE_CLOC=t
535            DEFINES="$DEFINES -DHAVE_CLOC"
536        fi
537        rm -f genmake_tc*
538    }
539    
540    
541    check_netcdf_libs()  {
542        cat <<EOF > genmake_tnc.for
543          program fgennc
544    #include "netcdf.inc"
545          integer iret, ncid, xid
546          iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
547          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
548          iret = nf_def_dim(ncid, 'X', 11, xid)
549          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
550          iret = nf_close(ncid)
551          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
552          end
553    EOF
554        $CPP genmake_tnc.for > genmake_tnc.f  \
555            &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1
556        RET_COMPILE=$?
557        test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
558        RETVAL=$?
559        if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
560            HAVE_NETCDF=t
561        else
562            # try again with "-lnetcdf" added to the libs
563            $CPP genmake_tnc.for > genmake_tnc.f  \
564                &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \
565                $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1
566            RET_COMPILE=$?
567            test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
568            RETVAL=$?
569            if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
570                LIBS="$LIBS -lnetcdf"
571                HAVE_NETCDF=t
572            else
573                cat genmake_tnc.log >> genmake_warnings
574            fi
575        fi
576        rm -f genmake_tnc*
577    }
578    
579    
580    
581    ###############################################################################
582    #   Sequential part of script starts here
583    ###############################################################################
584    
585  #  Set defaults here  #  Set defaults here
586  COMMANDL="$0 $@"  COMMANDL="$0 $@"
# Line 287  LN= Line 590  LN=
590  S64=  S64=
591  KPP=  KPP=
592  FC=  FC=
593    CPP=
594  LINK=  LINK=
595  DEFINES="-DWORDLENGTH=4"  DEFINES=
596  PACKAGES=  PACKAGES=
597  ENABLE=  ENABLE=
598  DISABLE=  DISABLE=
# Line 304  FOPTIM= Line 608  FOPTIM=
608  CFLAGS=  CFLAGS=
609  KFLAGS1=  KFLAGS1=
610  KFLAGS2=  KFLAGS2=
611    #LDADD=
612  LIBS=  LIBS=
613  KPPFILES=  KPPFILES=
614  NOOPTFILES=  NOOPTFILES=
615  NOOPTFLAGS=  NOOPTFLAGS=
616    MPI=
617    MPIPATH=
618    
619    # DEFINES checked by test compilation
620    HAVE_SYSTEM=
621    HAVE_FDATE=
622    FC_NAMEMANGLE=
623    HAVE_CLOC=
624    HAVE_NETCDF=
625    
626  MODS=  MODS=
627  TOOLSDIR=  TOOLSDIR=
628  SOURCEDIRS=  SOURCEDIRS=
629  INCLUDEDIRS=  INCLUDEDIRS=
630    STANDARDDIRS="USE_THE_DEFAULT"
631    
632    G2ARGS=
633    BASH=
634  PWD=`pwd`  PWD=`pwd`
635  MAKE=make  MAKE=make
636    AWK=awk
637  THISHOSTNAME=`hostname`  THISHOSTNAME=`hostname`
638  THISCWD=`pwd`  THISCWD=`pwd`
639  THISDATE=`date`  THISDATE=`date`
# Line 323  MACHINE=`uname -a` Line 641  MACHINE=`uname -a`
641  EXECUTABLE=  EXECUTABLE=
642  EXEHOOK=  EXEHOOK=
643  EXEDIR=  EXEDIR=
644    PACKAGES_CONF=
645    IEEE=
646    if test "x$MITGCM_IEEE" != x ; then
647        IEEE=$MITGCM_IEEE
648    fi
649    FEXT=
650    F90EXT=
651    
652    AUTODIFF_PKG_USED=f
653    AD_OPTFILE=
654    TAF=
655    AD_TAF_FLAGS=
656    FTL_TAF_FLAGS=
657    SVD_TAF_FLAGS=
658    TAF_EXTRA=
659    TAMC=
660    AD_TAMC_FLAGS=
661    FTL_TAF_FLAGS=
662    SVD_TAMC_FLAGS=
663    TAMC_EXTRA=
664    
665    
666  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
667  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
668  gm_s2="FC IEEE MPI JAM DUMPSTATE"  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS"
669    
670  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
671  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "
672  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
673  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"
674  gm_s6="EXECUTABLE EXEHOOK EXEDIR"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
675    gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE"
676    
677  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6"  #  The following are all related to adjoint/tangent-linear stuff
678    gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
679    gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
680    gm_s12="TAF_EXTRA TAMC_EXTRA"
681    
682    gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7"
683    gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
684    
685    cat <<EOF
686    
687    GENMAKE :
688    
689    A program for GENerating MAKEfiles for the MITgcm project.  For a
690    quick list of options, use "genmake -h" or for more detail see:
691    
692      http://mitgcm.org/devel_HOWTO/
693    
694    EOF
695    
 echo  
696  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
697  gm_local="./gm_local"  gm_local="genmake_local"
698  echo -n "  getting local config information:  "  for i in . $MODS ; do
699        if test -r $i/$gm_local ; then
700            . $i/$gm_local
701            break
702        fi
703    done
704    printf "  getting local config information:  "
705  if test -e $gm_local ; then  if test -e $gm_local ; then
706      echo "using $gm_local"      echo "using $gm_local"
707      source $gm_local      . $gm_local
708      # echo "DISABLE=$DISABLE"      # echo "DISABLE=$DISABLE"
709      # echo "ENABLE=$ENABLE"      # echo "ENABLE=$ENABLE"
710  else  else
# Line 361  fi Line 722  fi
722  #   n=$(( $n + 1 ))  #   n=$(( $n + 1 ))
723  #done  #done
724  #parse_options  #parse_options
   
725  ac_prev=  ac_prev=
726  for ac_option ; do  for ac_option ; do
727    
728        G2ARGS="$G2ARGS \"$ac_option\""
729    
730      # If the previous option needs an argument, assign it.      # If the previous option needs an argument, assign it.
731      if test -n "$ac_prev"; then      if test -n "$ac_prev"; then
732          eval "$ac_prev=\$ac_option"          eval "$ac_prev=\$ac_option"
# Line 386  for ac_option ; do Line 748  for ac_option ; do
748          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
749              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
750                    
751            -adoptfile | --adoptfile | -adof | --adof)
752                ac_prev=AD_OPTFILE ;;
753            -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
754                AD_OPTFILE=$ac_optarg ;;
755            
756          -pdepend | --pdepend)          -pdepend | --pdepend)
757              ac_prev=PDEPEND ;;              ac_prev=PDEPEND ;;
758          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
# Line 401  for ac_option ; do Line 768  for ac_option ; do
768          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
769              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
770                    
771            -bash | --bash)
772                ac_prev=BASH ;;
773            -bash=* | --bash=*)
774                BASH=$ac_optarg ;;
775            
776            -makedepend | --makedepend | -md | --md)
777                ac_prev=MAKEDEPEND ;;
778            -makedepend=* | --makedepend=* | -md=* | --md=*)
779                MAKEDEPEND=$ac_optarg ;;
780            
781          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -ma | --ma)
782              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
783          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -ma=* | --ma=*)
784              MAKEFILE=$ac_optarg ;;              MAKEFILE=$ac_optarg ;;
785                    
786          -platform | --platform | -pl | --pl)          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)
787              ac_prev=PLATFORM ;;              echo "ERROR: The platform option has been removed.  Please specify"
788          -platform=* | --platform=* | -pl=* | --pl=*)              echo "  the build options using the \"optfile\" mechanism."
789              PLATFORM=$ac_optarg ;;              echo
790                usage
791                ;;
792                    
793          -rootdir | --rootdir | -rd | --rd)          -rootdir | --rootdir | -rd | --rd)
794              ac_prev=ROOTDIR ;;              ac_prev=ROOTDIR ;;
# Line 431  for ac_option ; do Line 810  for ac_option ; do
810          -enable=* | --enable=*)          -enable=* | --enable=*)
811              ENABLE=$ac_optarg ;;              ENABLE=$ac_optarg ;;
812                    
813          -noopt | --noopt)          -standarddirs | --standarddirs)
814              ac_prev=NOOPT ;;              ac_prev=STANDARDDIRS ;;
815          -noopt=* | --noopt=*)          -standarddirs=* | --standarddirs=*)
816              NOOPT=$ac_optarg ;;              STANDARDDIRS=$ac_optarg ;;
817            
818  #           -cpp | --cpp)  #           -cpp | --cpp)
819  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
820  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
# Line 447  for ac_option ; do Line 826  for ac_option ; do
826              FC=$ac_optarg ;;              FC=$ac_optarg ;;
827                    
828          -ieee | --ieee)          -ieee | --ieee)
829              IEEE=1 ;;              IEEE=true ;;
830          -noieee | --noieee)          -noieee | --noieee)
831              IEEE=0 ;;              IEEE= ;;
832            
833          -mpi | --mpi)          -mpi | --mpi)
834              MPI=1 ;;              MPI=true ;;
835          -nompi | --nompi)          -mpi=* | --mpi=*)
836              MPI=0 ;;              MPIPATH=$ac_optarg
837                        MPI=true ;;
838          -jam | --jam)          
839              JAM=1 ;;  #       -jam | --jam)
840          -nojam | --nojam)  #           JAM=1 ;;
841              JAM=0 ;;  #       -nojam | --nojam)
842    #           JAM=0 ;;
843                    
844          -ds | --ds)          -ds | --ds)
845              DUMPSTATE=t ;;              DUMPSTATE=t ;;
846                    
847            -taf_extra | --taf_extra)
848                ac_prev=TAF_EXTRA ;;
849            -taf_extra=* | --taf_extra=*)
850                TAF_EXTRA=$ac_optarg ;;
851    
852            -tamc_extra | --tamc_extra)
853                ac_prev=TAMC_EXTRA ;;
854            -tamc_extra=* | --tamc_extra=*)
855                TAMC_EXTRA=$ac_optarg ;;
856    
857          -*)          -*)
858              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
859              usage              usage
# Line 478  for ac_option ; do Line 868  for ac_option ; do
868            
869  done  done
870    
871    if test -f ./.genmakerc ; then
872        echo
873        echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
874        echo "  file.  This file format is no longer supported.  Please see:"
875        echo
876        echo "    http://mitgcm.org/devel_HOWTO/"
877        echo
878        echo "  for directions on how to setup and use the new \"genmake2\" input"
879        echo "  files and send an email to MITgcm-support@mitgcm.org if you want help."
880        echo
881    fi
882    
883  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
884      if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
885          ROOTDIR=".."          ROOTDIR=".."
# Line 485  if test "x${ROOTDIR}" = x ; then Line 887  if test "x${ROOTDIR}" = x ; then
887          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
888              if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then              if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
889                  ROOTDIR=$d                  ROOTDIR=$d
890                  echo -n "Warning:  ROOTDIR was not specified but there appears to be"                  printf "Warning:  ROOTDIR was not specified but there appears to be"
891                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
892                  break                  break
893              fi              fi
# Line 516  fi Line 918  fi
918  if test "x$OPTFILE" != xNONE ; then  if test "x$OPTFILE" != xNONE ; then
919      if test -f "$OPTFILE" -a -r "$OPTFILE" ; then      if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
920          echo "    using OPTFILE=\"$OPTFILE\""          echo "    using OPTFILE=\"$OPTFILE\""
921          source "$OPTFILE"          . "$OPTFILE"
922          RETVAL=$?          RETVAL=$?
923          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
924              echo -n "Error: failed to source OPTFILE \"$OPTFILE\""              printf "Error: failed to source OPTFILE \"$OPTFILE\""
925              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
926              exit 1              exit 1
927          fi          fi
928          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" != xf ; then
929              cp -f $OPTFILE "gm_optfile"              cp -f $OPTFILE "genmake_optfile"
930          fi          fi
931      else      else
932          echo "Error: can't read OPTFILE=\"$OPTFILE\""          echo "Error: can't read OPTFILE=\"$OPTFILE\""
# Line 532  if test "x$OPTFILE" != xNONE ; then Line 934  if test "x$OPTFILE" != xNONE ; then
934      fi      fi
935  fi  fi
936    
937  #  Check that FC, LINK, CPP, and S64 are defined.  If not, complain  #  Check for broken systems that cannot correctly distinguish *.F and *.f files
938  #  and abort!  if test "x$FEXT" = x -a "x$F90EXT" = x ; then
939        check_for_broken_Ff
940    fi
941    
942    echo "  getting AD_OPTFILE information:  "
943    if test "x${AD_OPTFILE}" = x ; then
944        if test "x$MITGCM_AD_OF" = x ; then
945            AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
946        else
947            AD_OPTFILE=$MITGCM_AD_OF
948        fi
949    fi
950    if test "x${AD_OPTFILE}" != xNONE ; then
951        if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then
952            echo "    using AD_OPTFILE=\"$AD_OPTFILE\""
953            . "$AD_OPTFILE"
954            RETVAL=$?
955            if test "x$RETVAL" != x0 ; then
956                printf "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
957                echo "--please check that variable syntax is bash-compatible"
958                exit 1
959            fi
960            if test "x$DUMPSTATE" != xf ; then
961                cp -f $AD_OPTFILE "genmake_ad_optfile"
962            fi
963        else
964            echo "Error: can't read AD_OPTFILE=\"$AD_OPTFILE\""
965            exit 1
966        fi
967    fi
968    
969    #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
970    #  either set defaults or complain and abort!
971    if test ! "x$BASH" = x ; then
972        # add a trailing space so that it works within the Makefile syntax (see below)
973        BASH="$BASH "
974    fi
975  if test "x$FC" = x ; then  if test "x$FC" = x ; then
976      cat <<EOF 1>&2      cat <<EOF 1>&2
977    
978  Error: no Fortran compiler: please specify using one of the following:  Error: no Fortran compiler: please specify using one of the following:
979    1) within the options file ("FC=...") as specified by "-of=OPTFILE"    1) within the options file ("FC=...") as specified by "-of=OPTFILE"
980    2) the "-fc=XXX" command-line option    2) the "-fc=XXX" command-line option
981    3) the "./gm_local" file    3) the "./genmake_local" file
982  EOF  EOF
983      exit 1      exit 1
984  fi  fi
985  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
986      LINK=$FC      LINK=$FC
987  fi  fi
988    if test "x$MAKE" = x ; then
989        MAKE="make"
990    fi
991  if test "x$CPP" = x ; then  if test "x$CPP" = x ; then
992      CPP="cpp"      CPP=cpp
993  fi  fi
994  echo "#define A a" | cpp > test_cpp 2>&1  #EH3 === UGLY ===
995    #  The following an ugly little hack to check for $CPP in /lib/ and it
996    #  should eventually be replaced with a more general function that
997    #  searches a combo of the user's path and a list of "usual suspects"
998    #  to find the correct location for binaries such as $CPP.
999    for i in " " "/lib/" ; do
1000        echo "#define A a" | $i$CPP > test_cpp 2>&1 && CPP=$i$CPP
1001    done
1002    #EH3 === UGLY ===
1003    echo "#define A a" | $CPP > test_cpp 2>&1
1004  RETVAL=$?  RETVAL=$?
1005  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
1006      cat <<EOF 1>&2      cat <<EOF 1>&2
# Line 558  if test "x$RETVAL" != x0 ; then Line 1008  if test "x$RETVAL" != x0 ; then
1008  Error: C pre-processor "$CPP" failed the test case: please specify using:  Error: C pre-processor "$CPP" failed the test case: please specify using:
1009    
1010    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
1011    2) the "./gm_local" file    2) the "./genmake_local" file
1012      3) with the CPP environment variable
1013    
1014  EOF  EOF
1015      exit 1      exit 1
# Line 568  fi Line 1019  fi
1019  if test "x$MAKEDEPEND" = x ; then  if test "x$MAKEDEPEND" = x ; then
1020      MAKEDEPEND=makedepend      MAKEDEPEND=makedepend
1021  fi  fi
1022    if test "x$LN" = x ; then
1023        LN="ln -s"
1024    fi
1025    echo "test" > genmake_test_ln
1026    $LN genmake_test_ln genmake_tlink
1027    RETVAL=$?
1028    if test "x$RETVAL" != x0 ; then
1029        cat <<EOF 1>&2
1030    
1031    Error: The command "ln -s" failed -- please specify a working soft-link
1032      command in the optfile.
1033    
1034    EOF
1035        exit 1
1036    fi
1037    rm -f genmake_test_ln genmake_tlink
1038    
1039    if test ! "x$MPI" = x ; then
1040          echo "  Turning on MPI cpp macros"
1041          DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1042    fi
1043    
1044    printf "\n===  Checking system libraries  ===\n"
1045    printf "  Do we have the system() command using $FC...  "
1046    cat > genmake_tcomp.f <<EOF
1047          program hello
1048          call system('echo hi')
1049          end
1050    EOF
1051    $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1
1052    RETVAL=$?
1053    if test "x$RETVAL" = x0 ; then
1054        HAVE_SYSTEM=t
1055        DEFINES="$DEFINES -DHAVE_SYSTEM"
1056        echo "yes"
1057    else
1058        HAVE_SYSTEM=
1059        echo "no"
1060    fi
1061    rm -f genmake_tcomp*
1062    
1063    printf "  Do we have the fdate() command using $FC...  "
1064    cat > genmake_tcomp.f <<EOF
1065          program hello
1066          CHARACTER(128) string
1067          string = ' '
1068          call fdate( string )
1069          print *, string
1070          end
1071    EOF
1072    $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1
1073    RETVAL=$?
1074    if test "x$RETVAL" = x0 ; then
1075        HAVE_FDATE=t
1076        DEFINES="$DEFINES -DHAVE_FDATE"
1077        echo "yes"
1078    else
1079        HAVE_FDATE=
1080        echo "no"
1081    fi
1082    rm -f genmake_tcomp*
1083    
1084    printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1085    check_HAVE_CLOC
1086    if test "x$HAVE_CLOC" != x ; then
1087        echo "yes"
1088    else
1089        echo "no"
1090    fi
1091    rm -f genmake_t*
1092    
1093    printf "  Can we create NetCDF-enabled binaries...  "
1094    check_netcdf_libs
1095    if test "x$HAVE_NETCDF" != x ; then
1096        echo "yes"
1097    else
1098        echo "no"
1099    fi
1100    
1101    
1102  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1103  echo -n "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
1104  for d in $MODS ; do  for d in $MODS ; do
1105      if test ! -d $d ; then      if test ! -d $d ; then
1106          echo          echo
1107          echo "Error: MODS directory \"$d\" not found!"          echo "Error: MODS directory \"$d\" not found!"
1108          exit 1          exit 1
1109      else      else
1110          echo -n " $d"          printf " $d"
1111          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1112          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
1113      fi      fi
# Line 607  if test "x${TOOLSDIR}" = x ; then Line 1137  if test "x${TOOLSDIR}" = x ; then
1137      TOOLSDIR="$ROOTDIR/tools"      TOOLSDIR="$ROOTDIR/tools"
1138  fi  fi
1139  if test ! -d ${TOOLSDIR} ; then  if test ! -d ${TOOLSDIR} ; then
1140      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"
1141      exit 1      exit 1
1142  fi  fi
1143  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1144      S64='$(TOOLSDIR)/set64bitConst.sh'      S64='$(TOOLSDIR)/set64bitConst.sh'
1145  fi  fi
1146    THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1147    
1148  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
1149    
# Line 621  EXECUTABLE=${EXECUTABLE:-mitgcmuv} Line 1152  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
1152  #  they appear as regular source code  #  they appear as regular source code
1153  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
1154      echo "  Making source files in eesupp from templates"      echo "  Making source files in eesupp from templates"
1155      $MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1      ( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1
1156      RETVAL=$?      RETVAL=$?
1157      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
1158          rm -f make_eesupp.errors          rm -f make_eesupp.errors
1159      else      else
1160          echo "Error: problem encountered while building source files in eesupp:"          echo "Error: problem encountered while building source files in eesupp:"
1161          cat make_eesupp.errors          cat make_eesupp.errors 1>&2
1162          exit 1          exit 1
1163      fi      fi
1164  fi  fi
1165    
1166    #same for exch2
1167    if test -r $ROOTDIR"/pkg/exch2/Makefile" ; then
1168        echo "  Making source files in exch2 from  templates"
1169        ( cd $ROOTDIR"/pkg/exch2/" && $MAKE ) > make_exch2.errors 2>&1
1170        RETVAL=$?
1171        if test "x${RETVAL}" = x0 ; then
1172            rm -f make_exch2.errors
1173        else
1174            echo "Error: problem encountered while building source files in exch2:"
1175            cat make_exch2.errors 1>&2
1176            exit 1
1177        fi
1178    fi
1179    
1180  printf "\n===  Determining package settings  ===\n"  printf "\n===  Determining package settings  ===\n"
1181  if  test "x${PDEPEND}" = x ; then  if  test "x${PDEPEND}" = x ; then
1182      tmp=$ROOTDIR"/pkg/pkg_depend"      tmp=$ROOTDIR"/pkg/pkg_depend"
# Line 651  echo "  getting package dependency info Line 1196  echo "  getting package dependency info
1196  #  Strip the comments and then convert the dependency file into  #  Strip the comments and then convert the dependency file into
1197  #  two arrays: PNAME, DNAME  #  two arrays: PNAME, DNAME
1198  cat $PDEPEND | sed -e 's/#.*$//g' \  cat $PDEPEND | sed -e 's/#.*$//g' \
1199      | awk 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \      | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
1200      > ./.pd_tmp      > ./.pd_tmp
1201  RETVAL=$?  RETVAL=$?
1202  if test ! "x${RETVAL}" = x0 ; then  if test ! "x${RETVAL}" = x0 ; then
1203      echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""      echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""
1204      exit 1      exit 1
1205  fi  fi
1206  source ./.pd_tmp  . ./.pd_tmp
1207  rm -f ./.pd_tmp  rm -f ./.pd_tmp
1208    
1209  #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"  #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"
1210  #  file should eventually be added so that, for convenience, one can  #  file should eventually be added so that, for convenience, one can
1211  #  specify groups of packages using names like "ocean" and "atmosphere".  #  specify groups of packages using names like "ocean" and "atmosphere".
1212  echo  -n "  checking default package list:  "  echo "  checking default package list:  "
1213  if test "x${PDEFAULT}" = x ; then  if test "x${PDEFAULT}" = x ; then
1214      for i in "." $MODS ; do      for i in "." $MODS ; do
1215          if test -r $i"/packages.conf" ; then          if test -r $i"/packages.conf" ; then
# Line 677  if test "x${PDEFAULT}" = x ; then Line 1222  if test "x${PDEFAULT}" = x ; then
1222      PDEFAULT="$ROOTDIR/pkg/pkg_default"      PDEFAULT="$ROOTDIR/pkg/pkg_default"
1223  fi  fi
1224  if test "x${PDEFAULT}" = xNONE ; then  if test "x${PDEFAULT}" = xNONE ; then
1225      echo "default packages file disabled"      echo "    default packages file disabled"
1226  else  else
1227      if test ! -r $PDEFAULT ; then      if test ! -r $PDEFAULT ; then
         echo ""  
1228          echo "Warning:  can't read default packages from PDEFAULT=\"$PDEFAULT\""          echo "Warning:  can't read default packages from PDEFAULT=\"$PDEFAULT\""
1229      else      else
1230          echo "  using PDEFAULT=\"$PDEFAULT\""          echo "    using PDEFAULT=\"$PDEFAULT\""
1231          #  Strip the comments and add all the names          #  Strip the comments and add all the names
1232          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | awk '(NF>0){print $0}'`          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
1233          RETVAL=$?          RETVAL=$?
1234          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
1235              echo -n "Error: can't parse default package list "              printf "Error: can't parse default package list "
1236              echo "-- please check PDEFAULT=\"$PDEFAULT\""              echo "-- please check PDEFAULT=\"$PDEFAULT\""
1237              exit 1              exit 1
1238          fi          fi
# Line 696  else Line 1240  else
1240              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
1241          done          done
1242          echo "    before group expansion packages are: $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
1243          expand_pkg_groups          while ! expand_pkg_groups; do echo > /dev/null; done
1244          echo "    after group expansion packages are:  $PACKAGES"          echo "    after group expansion packages are:  $PACKAGES"
1245      fi      fi
1246  fi  fi
1247    
1248  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
1249    for i in $PACKAGES ; do
1250        echo $i >> ./.tmp_pack
1251    done
1252    for i in `grep  "-" ./.tmp_pack` ; do
1253        j=`echo $i | sed 's/[-]//'`
1254        DISABLE="$DISABLE $j"
1255    done
1256  pack=  pack=
1257  for p in $PACKAGES ; do  for p in $PACKAGES ; do
1258      addit="t"      addit="t"
# Line 718  PACKAGES="$pack" Line 1269  PACKAGES="$pack"
1269  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
1270  echo "" > ./.tmp_pack  echo "" > ./.tmp_pack
1271  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
1272    # Test if each explicitly referenced package exists
1273  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1274      if test ! -d "$ROOTDIR/pkg/$i" ; then      j=`echo $i | sed 's/[-+]//'`
1275        if test ! -d "$ROOTDIR/pkg/$j" ; then
1276          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""
1277          exit 1          exit 1
1278      fi      fi
1279      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
1280  done  done
 pack=`cat ./.tmp_pack | sort | uniq`  
 rm -f ./.tmp_pack  
1281  PACKAGES=  PACKAGES=
1282  for i in $pack ; do  for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do
1283      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
1284  done  done
1285    rm -f ./.tmp_pack
1286  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1287    
1288  echo "  applying package dependency rules"  echo "  applying package dependency rules"
# Line 807  for i in $PACKAGES ; do Line 1359  for i in $PACKAGES ; do
1359      if test -d $adr ; then      if test -d $adr ; then
1360          SOURCEDIRS="$SOURCEDIRS $adr"          SOURCEDIRS="$SOURCEDIRS $adr"
1361          INCLUDEDIRS="$INCLUDEDIRS $adr"          INCLUDEDIRS="$INCLUDEDIRS $adr"
1362            if test "x$i" = xautodiff ; then
1363                AUTODIFF_PKG_USED=t
1364            fi
1365      else      else
1366          echo "Error: the directory \"$adr\" for package $i doesn't exist"          echo "Error: the directory \"$adr\" for package $i doesn't exist"
1367          exit 1          exit 1
1368      fi      fi
1369  done  done
1370    
1371  #  This is compatible with the old genmake.  The "DISABLE_*" flags  #  Build MNC templates and check for ability to build and use NetCDF
1372  #  need to be replaced by the "ALLOW_*" flags set below.  echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1373  #  RETVAL=$?
1374  # echo -n "  Setting package-specific CPP flags:  "  if test "x$RETVAL" = x0 ; then
1375  # pkrm=( mom_fluxform mom_vecinv generic_advdiff )      ( cd $ROOTDIR"/pkg/mnc" && $MAKE templates ) > make_mnc.errors 2>&1
1376  # pkrmdef=( -DDISABLE_MOM_FLUXFORM -DDISABLE_MOM_VECINV -DDISABLE_GENERIC_ADVDIFF -DDISABLE_DEBUGMODE )      RETVAL=$?
1377  # echo -n "  "      if test "x${RETVAL}" = x0 ; then
1378  # i=0          rm -f make_mnc.errors
1379  # while test $i -lt "${#pkrm[@]}" ; do      else
1380  #     echo "$PACKAGES" | grep "${pk[$i]}" > /dev/null 2>&1          echo "Error: problem encountered while building source files in pkg/mnc:"
1381  #     RETVAL=$?          cat make_mnc.errors 1>&2
1382  #     if test "x$RETVAL" = x1 ; then          exit 1
1383  #       DEFINES="$DEFINES ${pkdef[$i]}"      fi
1384  #       echo -n " ${pkdef[$i]}"      if test "x$HAVE_NETCDF" != xt ; then
1385  #     fi          cat <<EOF
 #     i=$(( $i + 1 ))  
 # done  
 # echo  
1386    
1387  # Create a list of #define and #undef to enable/disable packages  WARNING: the "mnc" package has been enabled but tests failed to
1388  PACKAGES_DOT_H=PACKAGES.h    compile and/or execute NetCDF applications.  Please check that:
 cat <<EOF >$PACKAGES_DOT_H".tmp"  
 C=== GENMAKE v2 ===  
 C  The following defines have been set by GENMAKE, so please do not  
 C  edit anything below these comments.  In general, you should  
 C  add or remove packages by re-running genmake with different  
 C  "-enable" and/or "-disable" options.  
1389    
1390  C  Packages disabled by genmake:    1) NetCDF is installed for your compiler and
1391      2) the LIBS variable (within the 'optfile") specifies the correct
1392           NetCDF library to link against.
1393      
1394  EOF  EOF
1395        fi
1396    fi
1397    
1398    # Create a list of #define and #undef to enable/disable packages
1399    PACKAGES_DOT_H=PACKAGES_CONFIG.h
1400  #  The following UGLY HACK sets multiple "#undef"s and it needs to go  #  The following UGLY HACK sets multiple "#undef"s and it needs to go
1401  #  away.  On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h  #  away.  On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h
1402  #  file would eventually be split up so that all package-related #define  #  file would eventually be split up so that all package-related #define
1403  #  statements could be separated and handled only by genmake.  #  statements could be separated and handled only by genmake.
1404  names=`ls -1 "$ROOTDIR/pkg"`  names=`ls -1 "$ROOTDIR/pkg"`
1405  all_pack=  all_pack=
1406    DISABLED_PACKAGES=
1407  for n in $names ; do  for n in $names ; do
1408      if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then      if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then
1409          has_pack="f"          has_pack="f"
# Line 859  for n in $names ; do Line 1414  for n in $names ; do
1414              fi              fi
1415          done          done
1416          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1417              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`
1418              echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
 #           DEFINES="$DEFINES -U$undef"  
   
 #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  
             case $n in  
                 mom_fluxform)  
                     DEFINES="$DEFINES -DDISABLE_MOM_FLUXFORM"  
                     ;;  
                 mom_vecinv)  
                     DEFINES="$DEFINES -DDISABLE_MOM_VECINV"  
                     ;;  
                 debug)  
                     DEFINES="$DEFINES -DDISABLE_DEBUGMODE"  
                     ;;  
             esac  
 #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  
   
1419          fi          fi
1420      fi      fi
1421  done  done
1422  cat <<EOF >>$PACKAGES_DOT_H".tmp"  ENABLED_PACKAGES=
   
 C  Packages enabled by genmake:  
 EOF  
1423  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1424      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`
1425      echo "#define $def" >> $PACKAGES_DOT_H".tmp"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1426  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
1427    
1428  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
1429      case $i in      case $i in
1430          aim_v23)          aim_v23)
1431              echo "#define   ALLOW_AIM" >> $PACKAGES_DOT_H".tmp"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
1432              DEFINES="$DEFINES -DALLOW_AIM"              echo "Warning: ALLOW_AIM is set to enable aim_v23."
             echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"  
1433              ;;              ;;
1434      esac      esac
1435  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
1436    
1437  done  done
 if test ! -f $PACKAGES_DOT_H ; then  
     mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H  
 else  
     cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H  
     RETVAL=$?  
     if test "x$RETVAL" = x0 ; then  
         rm -f $PACKAGES_DOT_H".tmp"  
     else  
         mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"  
         mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H  
     fi  
 fi  
1438    
1439  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
1440  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
1441  STANDARDDIRS=${STANDARDDIRS:-"eesupp model"}  if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
1442  for d in $STANDARDDIRS ; do      STANDARDDIRS="eesupp model"
1443      adr="$ROOTDIR/$d/src"  fi
1444      if test ! -d $adr ; then  if test "x$STANDARDDIRS" != x ; then
1445          echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""      for d in $STANDARDDIRS ; do
1446          echo "  is correct and that you correctly specified the STANDARDDIRS option"          adr="$ROOTDIR/$d/src"
1447          exit 1          if test ! -d $adr ; then
1448      else              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1449          SOURCEDIRS="$SOURCEDIRS $adr"              echo "  is correct and that you correctly specified the STANDARDDIRS option"
1450      fi              exit 1
1451      adr="$ROOTDIR/$d/inc"          else
1452      if test ! -d $adr ; then              SOURCEDIRS="$SOURCEDIRS $adr"
1453          echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""          fi
1454          echo "  is correct and that you correctly specified the STANDARDDIRS option"          adr="$ROOTDIR/$d/inc"
1455          exit 1          if test ! -d $adr ; then
1456      else              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1457          INCLUDEDIRS="$INCLUDEDIRS $adr"              echo "  is correct and that you correctly specified the STANDARDDIRS option"
1458      fi              exit 1
1459  done          else
1460                INCLUDEDIRS="$INCLUDEDIRS $adr"
1461            fi
1462        done
1463    fi
1464    
1465  echo " Searching for CPP_OPTIONS.h in order to warn about the presence"  echo "  Searching for *OPTIONS.h files in order to warn about the presence"
1466  echo " of \"#define ALLOW_PKGNAME\"-type statements:"  echo "    of \"#define \"-type statements that are no longer allowed:"
1467  CPP_OPTIONS=  CPP_OPTIONS=
1468    CPP_EEOPTIONS=
1469  spaths=". $INCLUDEDIRS"  spaths=". $INCLUDEDIRS"
1470    names=`ls -1 "$ROOTDIR/pkg"`
1471  for i in $spaths ; do  for i in $spaths ; do
1472      try="$i/CPP_OPTIONS.h"      try="$i/CPP_OPTIONS.h"
1473      #  echo -n "    trying $try : "      if test -f $try -a -r $try -a "x$CPP_OPTIONS" = x ; then
     if test -f $try -a -r $try ; then  
1474          echo "    found CPP_OPTIONS=\"$try\""          echo "    found CPP_OPTIONS=\"$try\""
1475          CPP_OPTIONS="$try"          CPP_OPTIONS="$try"
1476          break          # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
1477            for n in $names ; do
1478                test_for_package_in_cpp_options $CPP_OPTIONS $n
1479            done
1480        fi
1481        try="$i/CPP_EEOPTIONS.h"
1482        if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" = x ; then
1483            echo "    found CPP_EEOPTIONS=\"$try\""
1484            # New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h
1485    #**** not yet enabled ****
1486    #        test_for_mpi_in_cpp_eeoptions $try
1487    #**** not yet enabled ****
1488            CPP_EEOPTIONS="$try"
1489      fi      fi
1490  done  done
1491  if test "x$CPP_OPTIONS" = x ; then  if test "x$CPP_OPTIONS" = x ; then
1492      echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"      echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"
1493      exit 1      exit 1
1494  fi  fi
1495  # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h  
1496  names=`ls -1 "$ROOTDIR/pkg"`  #  Here, we build the list of files to be "run through" the adjoint
1497  for n in $names ; do  #  compiler.
1498      test_for_package_in_cpp_options $CPP_OPTIONS $n  if test -f ./ad_files ; then
1499        rm -f ./ad_files
1500    fi
1501    echo "  Creating the list of files for the adjoint compiler."
1502    for i in $SOURCEDIRS ; do
1503        list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
1504        for j in $list_files ; do
1505            cat $i/$j >> ad_files
1506        done
1507  done  done
1508    
1509    
# Line 975  rm -rf .links.tmp Line 1523  rm -rf .links.tmp
1523  mkdir .links.tmp  mkdir .links.tmp
1524  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
1525  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
1526  echo -n 'SRCFILES = '    > srclist.inc  printf 'SRCFILES = '    > srclist.inc
1527  echo -n 'CSRCFILES = '   > csrclist.inc  printf 'CSRCFILES = '   > csrclist.inc
1528  echo -n 'F90SRCFILES = ' > f90srclist.inc  printf 'F90SRCFILES = ' > f90srclist.inc
1529  echo -n 'HEADERFILES = ' > hlist.inc  printf 'HEADERFILES = ' > hlist.inc
1530    printf 'AD_FLOW_FILES = ' > ad_flow_files.inc
1531  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
1532  for d in $alldirs ; do  for d in $alldirs ; do
1533      deplist=      deplist=
1534      sfiles=`( cd $d; echo *.[h,c,F] )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
1535      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
1536      for sf in $sfiles ; do      for sf in $sfiles ; do
1537          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
1538              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
1539                  extn=`echo $sf | awk -F '.' '{print $NF}'`                  case $d/$sf in
1540                  touch .links.tmp/$sf                    ./$PACKAGES_DOT_H)
1541                  deplist="$deplist $sf"                          ;;
1542                      ./AD_CONFIG.h)
1543                            ;;
1544                      ./FC_NAMEMANGLE.h)
1545                            ;;
1546                      *)
1547                            touch .links.tmp/$sf
1548                            deplist="$deplist $sf"
1549                            ;;
1550                    esac
1551                    extn=`echo $sf | $AWK -F '.' '{print $NF}'`
1552                  case $extn in                  case $extn in
1553                      F)                      F)
1554                          echo    " \\"  >> srclist.inc                          echo    " \\"  >> srclist.inc
1555                          echo -n " $sf" >> srclist.inc                          printf " $sf" >> srclist.inc
1556                          ;;                          ;;
1557                      F90)                      F90)
1558                          echo    " \\"  >> f90srclist.inc                          echo    " \\"  >> f90srclist.inc
1559                          echo -n " $sf" >> f90srclist.inc                          printf " $sf" >> f90srclist.inc
1560                          ;;                          ;;
1561                      c)                      c)
1562                          echo    " \\"  >> csrclist.inc                          echo    " \\"  >> csrclist.inc
1563                          echo -n " $sf" >> csrclist.inc                          printf " $sf" >> csrclist.inc
1564                          ;;                          ;;
1565                      h)                      h)
1566                          echo    " \\"  >> hlist.inc                          echo    " \\"  >> hlist.inc
1567                          echo -n " $sf" >> hlist.inc                          printf " $sf" >> hlist.inc
1568                            ;;
1569                        flow)
1570                            echo    " \\"  >> ad_flow_files.inc
1571                            printf " $sf" >> ad_flow_files.inc
1572                          ;;                          ;;
1573                  esac                  esac
1574              fi              fi
# Line 1023  echo "" >> srclist.inc Line 1586  echo "" >> srclist.inc
1586  echo "" >> csrclist.inc  echo "" >> csrclist.inc
1587  echo "" >> f90srclist.inc  echo "" >> f90srclist.inc
1588  echo "" >> hlist.inc  echo "" >> hlist.inc
1589    echo "" >> ad_flow_files.inc
1590    
1591  if test -e $MAKEFILE ; then  if test -e $MAKEFILE ; then
1592      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
# Line 1033  echo "#    $MACHINE" >> $MAKEFILE Line 1597  echo "#    $MACHINE" >> $MAKEFILE
1597  echo "# This makefile was generated automatically on" >> $MAKEFILE  echo "# This makefile was generated automatically on" >> $MAKEFILE
1598  echo "#    $THISDATE" >> $MAKEFILE  echo "#    $THISDATE" >> $MAKEFILE
1599  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
1600  echo "#    $0 $@" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
1601  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
1602  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE
1603    
1604    EXE_AD=$EXECUTABLE"_ad"
1605    EXE_FTL=$EXECUTABLE"_ftl"
1606    EXE_SVD=$EXECUTABLE"_svd"
1607    
1608  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1609    #
1610    # OPTFILE="$OPTFILE"
1611  #  #
1612  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
1613  # SOURCEDIRS   : Directories containing the source (.F) files  # SOURCEDIRS   : Directories containing the source (.F) files
# Line 1064  EXEDIR      = ${EXEDIR} Line 1635  EXEDIR      = ${EXEDIR}
1635  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
1636  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIR}
1637    
1638    #eh3  new defines for the adjoint work
1639    AUTODIFF    = ${ROOTDIR}/pkg/autodiff
1640    EXE_AD      = ${EXE_AD}
1641    EXE_FTL     = ${EXE_FTL}
1642    EXE_SVD     = ${EXE_SVD}
1643    
1644    ENABLED_PACKAGES = ${ENABLED_PACKAGES}
1645    DISABLED_PACKAGES = ${DISABLED_PACKAGES}
1646    
1647    # These files are created by Makefile
1648    SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h
1649    
1650  EOF  EOF
1651    
1652  #  Note: figure out some way to add Hyades JAM libraries here  #  Note: figure out some way to add Hyades JAM libraries here
# Line 1082  FC = ${FC} Line 1665  FC = ${FC}
1665  # Fortran compiler  # Fortran compiler
1666  F90C = ${F90C}  F90C = ${F90C}
1667  # Link editor  # Link editor
1668  LINK = ${LINK}  LINK = ${LINK} ${LDADD}
1669    
1670  # Defines for CPP  # Defines for CPP
1671  DEFINES = ${DEFINES}  DEFINES = ${DEFINES}
# Line 1109  MAKEFILE=${MAKEFILE} Line 1692  MAKEFILE=${MAKEFILE}
1692    
1693  EOF  EOF
1694    
1695  cat srclist.inc    >> $MAKEFILE  cat srclist.inc       >> $MAKEFILE
1696  cat csrclist.inc   >> $MAKEFILE  cat csrclist.inc      >> $MAKEFILE
1697  cat f90srclist.inc >> $MAKEFILE  cat f90srclist.inc    >> $MAKEFILE
1698  cat hlist.inc      >> $MAKEFILE  cat hlist.inc         >> $MAKEFILE
1699  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE  cat ad_flow_files.inc >> $MAKEFILE
1700  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE  echo >> $MAKEFILE
1701  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.'$FEXT'=.f)'        >> $MAKEFILE
1702    echo 'F90FILES =  $(F90SRCFILES:.'$F90EXT'=.f90)' >> $MAKEFILE
1703    echo 'OBJFILES =  $(SRCFILES:.'$FEXT'=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.'$F90EXT'=.o)' >> $MAKEFILE
1704    echo >> $MAKEFILE
1705    echo '.SUFFIXES:' >> $MAKEFILE
1706    echo '.SUFFIXES: .o .f .p .'$FEXT' .c .'$F90EXT' .f90' >> $MAKEFILE
1707    
1708  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc
1709    rm -f ad_flow_files.inc
1710    
1711  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1712    
 .SUFFIXES:  
 .SUFFIXES: .o .f .p .F .c .F90 .f90  
   
1713  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
1714  \$(EXECUTABLE): \$(OBJFILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)
1715            @echo Creating \$@ ...
1716          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
1717  depend:  depend:
1718          @make links          @make links
1719          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
1720          ${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
1721            -rm -f makedepend.out
1722    
1723  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
1724    
1725  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77FILES) \$(F90FILES)
1726    
# Line 1141  output.txt: \$(EXECUTABLE) Line 1729  output.txt: \$(EXECUTABLE)
1729          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
1730    
1731  clean:  clean:
1732          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl}          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} *.template
1733  Clean:  Clean:
1734          @make clean          @make clean
1735          @make cleanlinks          @make cleanlinks
1736          -rm -f Makefile.bak gm_state gm_optfile make.log          -rm -f \$(SPECIAL_FILES)
1737            -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak
1738  CLEAN:  CLEAN:
1739          @make Clean          @make Clean
1740          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
# Line 1153  CLEAN: Line 1742  CLEAN:
1742          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1743          -rm -f \$(EXECUTABLE) output.txt          -rm -f \$(EXECUTABLE) output.txt
1744    
1745    #eh3 Makefile: makefile
1746  makefile:  makefile:
1747          ${0} $@          $THIS_SCRIPT $G2ARGS
1748  cleanlinks:  cleanlinks:
1749          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
1750    
1751  # The normal chain of rules is (  .F - .f - .o  )  # Special targets ($SPECIAL_FILES) which are create by make
1752  .F.f:  ${PACKAGES_DOT_H}:
1753            @echo Creating \$@ ...
1754            @$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) > \$@
1755    AD_CONFIG.h:
1756            @echo Creating \$@ ...
1757            @$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 > \$@
1758    FC_NAMEMANGLE.h:
1759            @echo Creating \$@ ...
1760            echo "$FC_NAMEMANGLE" > \$@
1761    
1762    # The normal chain of rules is (  .$FEXT - .f - .o  )
1763    .$FEXT.f:
1764          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1765  .f.o:  .f.o:
1766          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
1767  .F90.f90:  .$F90EXT.f90:
1768          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1769  .f90.o:  .f90.o:
1770          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
1771  .c.o:  .c.o:
1772          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) -c \$<
1773    
1774  # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain  # Special exceptions that use the ( .$FEXT - .p - .f - .o ) rule-chain
1775  .F.p:  .$FEXT.p:
1776          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1777  .p.f:  .p.f:
1778          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
1779    
1780    #=========================================
1781    #===  Automatic Differentiation Rules  ===
1782    
1783    TAMC           = ${TAMC}
1784    TAF            = ${TAF}
1785    
1786    TAF_EXTRA      = ${TAF_EXTRA}
1787    TAMC_EXTRA     = ${TAMC_EXTRA}
1788    
1789    EOF
1790    
1791    ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS"
1792    ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF_FLAGS"
1793    ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
1794    for i in $ad_vars ; do
1795        name=$i
1796        t1="t2=\$"`echo $i`
1797        eval $t1
1798        printf "%-20s = " $name >> $MAKEFILE
1799        echo $t2 >> $MAKEFILE
1800    done
1801    
1802    echo "  Add the source list for AD code generation"
1803    echo >> $MAKEFILE
1804    printf "AD_FILES = " >> $MAKEFILE
1805    AD_FILES=`cat ad_files`
1806    for i in $AD_FILES ; do
1807        echo    " \\" >> $MAKEFILE
1808        printf " $i" >> $MAKEFILE
1809    done
1810    echo >> $MAKEFILE
1811    rm -f ad_files
1812    
1813    cat >>$MAKEFILE <<EOF
1814    
1815    # ... AD ...
1816    adall: ad_taf
1817    adtaf: ad_taf_output.f
1818    adtamc: ad_tamc_output.f
1819    
1820    ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1821            @$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
1822            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
1823            -rm -f ad_config.template
1824            @make \$(F77FILES)
1825            @make \$(AD_FLOW_FILES)
1826            cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f
1827    
1828    ad_taf_output.f: ad_input_code.f
1829            \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f
1830            cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f
1831    
1832    adtafonly:
1833            \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f
1834            cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f
1835    
1836    ad_taf: ad_taf_output.o \$(OBJFILES)
1837            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
1838    
1839    ad_tamc_output.f: ad_input_code.f
1840            \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f
1841            cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.f
1842    
1843    ad_tamc: ad_tamc_output.o \$(OBJFILES)
1844            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
1845    
1846    
1847    # ... FTL ...
1848    ftlall: ftl_taf
1849    ftltaf: ftl_taf_output.f
1850    ftltamc: ftl_tamc_output.f
1851    
1852    ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1853            @$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
1854            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
1855            -rm -f ftl_config.template
1856            @make \$(F77FILES)
1857            @make \$(AD_FLOW_FILES)
1858            cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f
1859    
1860    ftl_taf_output.f: ftl_input_code.f
1861            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f
1862            cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f
1863    
1864    ftltafonly:
1865            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f
1866            cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f
1867    
1868    ftl_taf: ftl_taf_output.o \$(OBJFILES)
1869            \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
1870    
1871    ftl_tamc_output.f: ftl_input_code.f
1872            \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f
1873            cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.f
1874    
1875    ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
1876            \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
1877    
1878    
1879    # ... SVD ...
1880    svdtaf: ad_taf_output.f ftl_taf_output.f
1881    svdall: svd_taf
1882    
1883    svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES)
1884            \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS)
1885    
1886    
1887    #=========================================
1888    
1889  EOF  EOF
1890    
1891  if test "x$EXEHOOK" != x ; then  if test "x$EXEHOOK" != x ; then
# Line 1212  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 1922  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
1922    
1923  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
1924    
1925    # Create special header files
1926    $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"
1927    if test ! -f $PACKAGES_DOT_H ; then
1928        mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1929    else
1930        cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H > /dev/null 2>&1
1931        RETVAL=$?
1932        if test "x$RETVAL" = x0 ; then
1933            rm -f $PACKAGES_DOT_H".tmp"
1934        else
1935            mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"
1936            mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1937        fi
1938    fi
1939    if test ! -f AD_CONFIG.h ; then
1940        $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
1941    fi
1942    
1943    
1944  #  Write the "state" for future records  #  Write the "state" for future records
1945  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" != xf ; then
1946      echo -n "" > gm_state      printf "" > genmake_state
1947      for i in $gm_state ; do      for i in $gm_state ; do
1948          t1="t2=\$$i"          t1="t2=\$$i"
1949          eval $t1          eval $t1
1950          echo "$i='$t2'" >> gm_state          echo "$i='$t2'" >> genmake_state
1951      done      done
1952  fi  fi

Legend:
Removed from v.1.11.2.5  
changed lines
  Added in v.1.75

  ViewVC Help
Powered by ViewVC 1.1.22