/[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.20 by heimbach, Wed Oct 22 15:27:07 2003 UTC revision 1.136 by edhill, Thu Nov 24 17:52:15 2005 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 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        #  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  # Guess possible config options for this host
252  find_possible_configs()  {  find_possible_configs()  {
253    
254      tmp1=`uname`"_"`uname -m`      tmp1=`uname`"_"`uname -m`
255      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
256      PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`      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")`      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
263      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  
264            
265      echo "test" > test      echo "test" > test
266      ln -s ./test link      ln -s ./test link
# Line 103  find_possible_configs()  { Line 278  find_possible_configs()  {
278          CPP="cpp -traditional -P"          CPP="cpp -traditional -P"
279      fi      fi
280    
281      # look for possible fortran compilers      look_for_makedepend
282      tmp="$MITGCM_FC $FC g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"  
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=      p_FC=
326      for c in $tmp ; do      for c in $tmp ; do
327          rm -f ./hello.f ./hello          rm -f ./hello.f ./hello
# Line 121  EOF Line 338  EOF
338              p_FC="$p_FC $c"              p_FC="$p_FC $c"
339          fi          fi
340      done      done
341        rm -f ./hello.f ./hello
342      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
343          cat 1>&2 <<EOF          cat 1>&2 <<EOF
344    
# Line 128  Error: No Fortran compilers were found i Line 346  Error: No Fortran compilers were found i
346    
347      1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),      1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
348      2) a command-line option (eg. "-fc NAME"), or      2) a command-line option (eg. "-fc NAME"), or
349      3) the MITGCM_FC environment variable.      3) the FC or MITGCM_FC environment variables.
350    
351  EOF  EOF
352          exit 1          exit 1
353      else      else
354          echo "  The possible FORTRAN compilers found in your path are:"          echo "  The possible FORTRAN compilers found in your path are:"
355          echo "   "$p_FC          echo "   "$p_FC
         if test "x$FC" = x ; then  
             FC=`echo $p_FC | $AWK '{print $1}'`  
         fi  
356      fi      fi
357    
358      for i in $p_FC ; do      #  Use the first of the compilers found in the current PATH
359          p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i      #  that has a correctly-named optfile
360          if test -r $p_OF ; then      if test "x$OPTFILE" = x  -a  "x$FC" = x ; then
361              OPTFILE=$p_OF          for i in $p_FC ; do
362              echo "  The options file:  $p_OF"              OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
363              echo "    appears to match so we'll use it."              if test -r $OPTFILE ; then
364              break                  echo "  Setting OPTFILE to: "$OPTFILE
365          fi                  break
366      done              fi
367            done
368        fi
369    
370        if test "x$OPTFILE" = x ; then
371            OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
372            if test ! -r $OPTFILE ; then
373                 echo "  I looked for the file "$OPTFILE" but did not find it"
374            fi
375        fi
376    #    echo "  The options file:  $p_OF"
377    #    echo "    appears to match so we'll use it."
378    #   for i in $p_FC ; do
379    #p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
380    #if test -r $p_OF ; then
381    #    OPTFILE=$p_OF
382    #    echo "  The options file:  $p_OF"
383    #    echo "    appears to match so we'll use it."
384    #    break
385    #fi
386    #   done
387      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
388          cat 1>&2 <<EOF          cat 1>&2 <<EOF
389    
# Line 204  get_pdepend_list()  { Line 439  get_pdepend_list()  {
439      cat $1 | sed -e 's/#.*$//g' \      cat $1 | sed -e 's/#.*$//g' \
440          | $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} }' \
441          > ./.pd_tmp          > ./.pd_tmp
442      source ./.pd_tmp      . ./.pd_tmp
443      rm -f ./.pd_tmp      rm -f ./.pd_tmp
444    
445      echo -n "PNAME = "${}      printf "PNAME = "${}
446  }  }
447    
448    
449  #  Explain usage  #  Explain usage
450  usage()  {  usage()  {
451      echo  cat <<EOF
452      echo "Usage: "$0" [OPTIONS]"  
453      echo "  where [OPTIONS] can be:"  Usage: "$0" [OPTIONS]
454      echo    where [OPTIONS] can be:
455      echo "    -help | --help | -h | --h"  
456      echo "    -nooptfile | --nooptfile"      -help | --help | -h | --h
457      echo "      -optfile NAME | --optfile NAME | -of NAME | --of NAME"            Print this help message and exit.
458      echo "      -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME"  
459      echo "    -pdepend NAME | --pdepend NAME"      -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
460      echo "      -pdepend=NAME | --pdepend=NAME"        -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
461      echo "    -pdefault NAME | --pdefault NAME"            Use "NAME" as the adoptfile.  By default, the file at
462      echo "      -pdefault=NAME | --pdefault=NAME"            "tools/adjoint_options/adjoint_default" will be used.
463      echo "    -make NAME | -m NAME"  
464      echo "      --make=NAME | -m=NAME"      -nooptfile | --nooptfile
465      echo "    -makefile NAME | -mf NAME"        -optfile NAME | --optfile NAME | -of NAME | --of NAME
466      echo "      --makefile=NAME | -mf=NAME"        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
467      echo "    -platform NAME | --platform NAME | -pl NAME | --pl NAME"            Use "NAME" as the optfile.  By default, an attempt will be
468      echo "      -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME"            made to find an appropriate "standard" optfile in the
469      echo "    -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME"            tools/build_options/ directory.
470      echo "      -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME"  
471      echo "    -mods NAME | --mods NAME | -mo NAME | --mo NAME"      -pdepend NAME | --pdepend NAME
472      echo "      -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME"        -pdepend=NAME | --pdepend=NAME
473      echo "    -disable NAME | --disable NAME"            Get package dependency information from "NAME".
474      echo "      -disable=NAME | --disable=NAME"  
475      echo "    -enable NAME | --enable NAME"      -pdefault NAME | --pdefault NAME
476      echo "      -enable=NAME | --enable=NAME"        -pdefault=NAME | --pdefault=NAME
477      echo "    -standarddirs NAME | --standarddirs NAME"            Get the default package list from "NAME".
478      echo "      -standarddirs=NAME | --standarddirs=NAME"  
479      echo "    -noopt NAME | --noopt NAME"      -make NAME | -m NAME
480      echo "      -noopt=NAME | --noopt=NAME"        --make=NAME | -m=NAME
481  #    echo "    -cpp NAME | --cpp NAME"            Use "NAME" for the MAKE program. The default is "make" but
482  #    echo "      -cpp=NAME | --cpp=NAME"            many platforms, "gmake" is the preferred choice.
483      echo "    -fortran NAME | --fortran NAME | -fc NAME | --fc NAME"  
484      echo "      -fc=NAME | --fc=NAME"      -makefile NAME | -mf NAME
485      echo "    -[no]ieee | --[no]ieee"        --makefile=NAME | -mf=NAME
486      echo "    -[no]mpi | --[no]mpi"            Call the makefile "NAME".  The default is "Makefile".
487      echo "    -[no]jam | --[no]jam"  
488      echo      -makedepend NAME | -md NAME
489      echo "  and NAME is a string such as:"        --makedepend=NAME | -md=NAME
490      echo            Use "NAME" for the MAKEDEPEND program.
491      echo "    --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'"  
492      echo "    -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'"      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
493      echo "    -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'"        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
494      echo            Specify the location of the MITgcm ROOTDIR as "NAME".
495      echo "  which, depending upon your shell, may need to be single-quoted"            By default, genamke will try to find the location by
496      echo "  if it contains spaces, dashes, or other special characters."            looking in parent directories (up to the 5th parent).
497    
498        -mods NAME | --mods NAME | -mo NAME | --mo NAME
499          -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME
500              Here, "NAME" specifies a list of directories that are
501              used for additional source code.  Files found in the
502              "mods list" are given preference over files of the same
503              name found elsewhere.
504    
505        -disable NAME | --disable NAME
506          -disable=NAME | --disable=NAME
507              Here "NAME" specifies a list of packages that we don't
508              want to use.  If this violates package dependencies,
509              genamke will exit with an error message.
510    
511        -enable NAME | --enable NAME
512          -enable=NAME | --enable=NAME
513              Here "NAME" specifies a list of packages that we wish
514              to specifically enable.  If this violates package
515              dependencies, genamke will exit with an error message.
516    
517        -standarddirs NAME | --standarddirs NAME
518          -standarddirs=NAME | --standarddirs=NAME
519              Here, "NAME" specifies a list of directories to be
520              used as the "standard" code.
521    
522        -fortran NAME | --fortran NAME | -fc NAME | --fc NAME
523          -fc=NAME | --fc=NAME
524              Use "NAME" as the fortran compiler.  By default, genmake
525              will search for a working compiler by trying a list of
526              "usual suspects" such as g77, f77, etc.
527    
528        -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
529              Use "NAME" as the C compiler.  By default, genmake
530              will search for a working compiler by trying a list of
531              "usual suspects" such as gcc, c89, cc, etc.
532    
533        -[no]ieee | --[no]ieee
534              Do or don't use IEEE numerics.  Note that this option
535              *only* works if it is supported by the OPTFILE that
536              is being used.
537    
538        -ts | --ts
539              Produce timing information per timestep
540    
541        -mpi | --mpi
542              Include MPI header files and link to MPI libraries
543        -mpi=PATH | --mpi=PATH
544              Include MPI header files and link to MPI libraries using MPI_ROOT
545              set to PATH. i.e. Include files from \$PATH/include, link to libraries
546              from \$PATH/lib and use binaries from \$PATH/bin.
547    
548        -bash NAME
549              Explicitly specify the Bourne or BASH shell to use
550    
551      While it is most often a single word, the "NAME" variables specified
552      above can in many cases be a space-delimited string such as:
553    
554        --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'
555        -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'
556        -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'
557    
558      which, depending upon your shell, may need to be single-quoted.
559    
560      For more detailed genmake documentation, please see:
561    
562        http://mitgcm.org/devel_HOWTO/
563    
564    EOF
565    
566      exit 1      exit 1
567  }  }
568    
569  #eh3 # This is the generic configuration.  #  Build a CPP macro to automate calling C routines from FORTRAN
570  #eh3 set LN         = ( 'ln -s' )  get_fortran_c_namemangling()  {
571  #eh3 set CPP        = ( '/lib/cpp -P' )  
572  #eh3 set S64        = ( '$(TOOLSDIR)/set64bitConst.sh' )      #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
573  #eh3 set KPP        = (  )      if test ! "x$FC_NAMEMANGLE" = x ; then
574  #eh3 set FC         = ( 'f77' )          return 0
575  #eh3 set LINK       = $FC      fi
576  #eh3 set MAKEDEPEND = ( 'makedepend' )  
577  #eh3 set INCLUDES   = ( -I. )      default_nm="#define FC_NAMEMANGLE(X) X ## _"
578  #eh3 set FFLAGS     = (  )      
579  #eh3 set FOPTIM     = (  )      cat > genmake_test.c <<EOF
580  #eh3 set CFLAGS     = (  )  void tcall( char * string ) { tsub( string ); }
581  #eh3 set KFLAGS1    = (  )  EOF
582  #eh3 set KFLAGS2    = (  )      $MAKE genmake_test.o >> genmake_warnings 2>&1
583  #eh3 set LIBS       = (  )      RETVAL=$?
584  #eh3 set KPPFILES   = (  )      if test "x$RETVAL" != x0 ; then
585  #eh3 if (! $?NOOPTFILES ) set NOOPTFILES = (  )          FC_NAMEMANGLE=$default_nm
586  #eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = (  )          cat <<EOF>> genmake_errors
587    
588    WARNING: C test compile fails
589    WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
590    WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
591    EOF
592            return 1
593        fi
594        c_tcall=`nm genmake_test.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
595        RETVAL=$?
596        if test "x$RETVAL" != x0 ; then
597            FC_NAMEMANGLE=$default_nm
598            cat <<EOF>> genmake_warnings
599    
600    WARNING: The "nm" command failed.
601    WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
602    WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
603    EOF
604            return 1
605        fi
606        cat > genmake_tcomp.$FS <<EOF
607          subroutine tcall( string )
608          character*(*) string
609          call tsub( string )
610          end
611    EOF
612        $FC $FFLAGS -c genmake_tcomp.$FS >> genmake_warnings 2>&1
613        RETVAL=$?
614        if test "x$RETVAL" != x0 ; then
615            FC_NAMEMANGLE=$default_nm
616            cat <<EOF>> genmake_warnings
617    
618    WARNING: FORTRAN test compile fails -- please see "genmake_errors"
619    WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
620    WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
621    EOF
622            return 1
623        fi
624        f_tcall=`nm genmake_tcomp.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
625        RETVAL=$?
626        if test "x$RETVAL" != x0 ; then
627            FC_NAMEMANGLE=$default_nm
628            cat <<EOF>> genmake_warnings
629    
630    WARNING: The "nm" command failed.
631    WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
632    WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
633    EOF
634            return 1
635        fi
636    
637        c_a=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
638        f_a=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
639        c_b=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
640        f_b=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
641    
642        nmangle="X"
643        if test "x$c_a" != "x$f_a" ; then
644            comm="echo x$f_a | sed -e 's|x$c_a||'"
645            a=`eval $comm`
646            nmangle="$a ## $nmangle"
647        fi
648        if test "x$c_b" != "x$f_b" ; then
649            comm="echo x$f_b | sed -e 's|x$c_b||'"
650            b=`eval $comm`
651            nmangle="$nmangle ## $b"
652        fi
653    
654        FC_NAMEMANGLE="#define FC_NAMEMANGLE(X)  $nmangle"
655    
656        #  cleanup the testing files
657        rm -f genmake_tcomp.* genmake_test.*
658    }
659    
660    
661    check_HAVE_CLOC()  {
662        get_fortran_c_namemangling
663        cat <<EOF > genmake_tc_1.c
664    $FC_NAMEMANGLE
665    #include <stdio.h>
666    #include <stdlib.h>
667    #include <unistd.h>
668    #include <assert.h>
669    #include <sys/time.h>
670    void FC_NAMEMANGLE(cloc) ( double *curtim )
671    {
672     struct timeval tv1;
673     gettimeofday(&tv1 , (void *)NULL );
674     *curtim =  (double)((tv1.tv_usec)+(tv1.tv_sec)*1.E6);
675     *curtim = *curtim/1.E6;
676    }
677    EOF
678        make genmake_tc_1.o >> genmake_warnings 2>&1
679        RET_C=$?
680        cat <<EOF > genmake_tc_2.$FS
681          program hello
682          REAL*8 wtime
683          external cloc
684          call cloc(wtime)
685          print *," HELLO WORLD", wtime
686          end
687    EOF
688        $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1
689        RET_F=$?
690        test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1
691        RETVAL=$?
692        if test "x$RETVAL" = x0 ; then
693            HAVE_CLOC=t
694            DEFINES="$DEFINES -DHAVE_CLOC"
695        fi
696        rm -f genmake_tc*
697    }
698    
699    
700    check_HAVE_SETRLSTK()  {
701        get_fortran_c_namemangling
702        cat <<EOF > genmake_tc_1.c
703    $FC_NAMEMANGLE
704    #include <sys/time.h>
705    #include <sys/resource.h>
706    #include <unistd.h>
707    void FC_NAMEMANGLE(setrlstk) ()
708    {
709        struct rlimit rls;
710        rls.rlim_cur = RLIM_INFINITY;
711        rls.rlim_max = RLIM_INFINITY;
712        setrlimit(RLIMIT_STACK, &rls);
713        return;
714    }
715    EOF
716        make genmake_tc_1.o >> genmake_warnings 2>&1
717        RET_C=$?
718        cat <<EOF > genmake_tc_2.$FS
719          program hello
720          external setrlstk
721          call setrlstk()
722          end
723    EOF
724        echo >> genmake_warnings
725        echo "running: check_HAVE_SETRLSTK()" >> genmake_warnings
726        cat genmake_tc_2.$FS >> genmake_warnings
727        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
728        echo $COMM >> genmake_warnings
729        $COMM >> genmake_warnings 2>&1
730        RETVAL=$?
731        if test "x$RETVAL" = x0 ; then
732            HAVE_SETRLSTK=t
733            DEFINES="$DEFINES -DHAVE_SETRLSTK"
734        fi
735        rm -f genmake_tc*
736    }
737    
738    
739    check_HAVE_STAT()  {
740        get_fortran_c_namemangling
741        cat <<EOF > genmake_tc_1.c
742    $FC_NAMEMANGLE
743    #include <stdio.h>
744    #include <stdlib.h>
745    #include <unistd.h>
746    #include <sys/stat.h>
747    #include <sys/types.h>
748    void FC_NAMEMANGLE(tfsize) ( int *nbyte )
749    {
750        char name[512];
751        struct stat astat;
752    
753        name[0] = 'a'; name[1] = '\0';
754        if (! stat(name, &astat))
755            *nbyte = (int)(astat.st_size);
756        else
757            *nbyte = -1;
758    }
759    EOF
760        make genmake_tc_1.o >> genmake_tc.log 2>&1
761        RET_C=$?
762        cat <<EOF > genmake_tc_2.$FS
763          program hello
764          integer nbyte
765          call tfsize(nbyte)
766          print *," HELLO WORLD", nbyte
767          end
768    EOF
769        echo >> genmake_warnings
770        echo "running: check_HAVE_STAT()" >> genmake_warnings
771        cat genmake_tc_2.$FS >> genmake_warnings
772        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
773        echo $COMM >> genmake_warnings
774        $COMM >> genmake_tc.log 2>&1
775        RETVAL=$?
776        if test "x$RETVAL" = x0 ; then
777            HAVE_STAT=t
778            DEFINES="$DEFINES -DHAVE_STAT"
779        fi
780        rm -f genmake_tc*
781    }
782    
783    
784    check_netcdf_libs()  {
785        if test ! "x$SKIP_NETCDF_CHECK" = x ; then
786            return
787        fi
788        echo >> genmake_warnings
789        echo "running: check_netcdf_libs()" >> genmake_warnings
790        cat <<EOF > genmake_tnc.F
791          program fgennc
792    #include "netcdf.inc"
793    EOF
794        if test ! "x$MPI" = x ; then
795            echo '#include "mpif.h"' >> genmake_tnc.F
796        fi
797        cat <<EOF >> genmake_tnc.F
798          integer iret, ncid, xid
799          iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
800          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
801          iret = nf_def_dim(ncid, 'X', 11, xid)
802          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
803          iret = nf_close(ncid)
804          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
805          end
806    EOF
807        echo "===  genmake_tnc.F  ===" > genmake_tnc.log
808        cat genmake_tnc.F >> genmake_tnc.log
809        echo "===  genmake_tnc.F  ===" >> genmake_tnc.log
810        RET_CPP=f
811        COMM="$CPP $DEFINES $INCLUDES genmake_tnc.F"
812        echo "$COMM" >> genmake_tnc.log
813        $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t
814        if test "x$RET_CPP" = xf ; then
815            echo "  WARNING: CPP failed to pre-process the netcdf test." \
816                >> genmake_tnc.log
817            echo "    Please check that \$INCLUDES is properly set." \
818                >> genmake_tnc.log
819        fi
820        echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log
821        echo "  &&  $LINK -o genmake_tnc.o $LIBS" >> genmake_tnc.log
822        $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
823            &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
824        RET_COMPILE=$?
825        cat genmake_tnc.log >> genmake_warnings
826    
827        #EH3  Remove test program execution for machines that either disallow
828        #EH3  execution or cannot support it (eg. cross-compilers)
829        #EH3
830        #EH3 test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
831        #EH3 RETVAL=$?
832        #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
833    
834        if test "x$RET_COMPILE" = x0 ; then
835            HAVE_NETCDF=t
836        else
837            # try again with "-lnetcdf" added to the libs
838            echo "try again with added '-lnetcdf'" > genmake_tnc.log
839            echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log
840            echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
841            echo " &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
842            $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
843                &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
844                &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
845            RET_COMPILE=$?
846            cat genmake_tnc.log >> genmake_warnings
847            if test "x$RET_COMPILE" = x0 ; then
848                LIBS="$LIBS -lnetcdf"
849                HAVE_NETCDF=t
850            fi
851        fi
852        rm -f genmake_tnc*
853    }
854    
855    
856    
857    ###############################################################################
858    #   Sequential part of script starts here
859    ###############################################################################
860    
861  #  Set defaults here  #  Set defaults here
862  COMMANDL="$0 $@"  COMMANDL="$0 $@"
# Line 288  PLATFORM= Line 865  PLATFORM=
865  LN=  LN=
866  S64=  S64=
867  KPP=  KPP=
868  FC=  #FC=
869    #CC=gcc
870    #CPP=
871  LINK=  LINK=
872  DEFINES="-DWORDLENGTH=4"  DEFINES=
873  PACKAGES=  PACKAGES=
874  ENABLE=  ENABLE=
875  DISABLE=  DISABLE=
876  MAKEFILE=  # MAKEFILE=
877  MAKEDEPEND=  # MAKEDEPEND=
878  PDEPEND=  PDEPEND=
879  DUMPSTATE=t  DUMPSTATE=t
880  PDEFAULT=  PDEFAULT=
881  OPTFILE=  OPTFILE=
882  INCLUDES="-I."  INCLUDES="-I. $INCLUDES"
883  FFLAGS=  FFLAGS=
884  FOPTIM=  FOPTIM=
885  CFLAGS=  CFLAGS=
886  KFLAGS1=  KFLAGS1=
887  KFLAGS2=  KFLAGS2=
888    #LDADD=
889  LIBS=  LIBS=
890  KPPFILES=  KPPFILES=
891  NOOPTFILES=  NOOPTFILES=
892  NOOPTFLAGS=  NOOPTFLAGS=
893    MPI=
894    MPIPATH=
895    TS=
896    HAVE_TEST_L=
897    
898    # DEFINES checked by test compilation or command-line
899    HAVE_SYSTEM=
900    HAVE_FDATE=
901    FC_NAMEMANGLE=
902    HAVE_CLOC=
903    HAVE_SETRLSTK=
904    HAVE_STAT=
905    HAVE_NETCDF=
906    HAVE_ETIME=
907    IGNORE_TIME=
908    
909  MODS=  MODS=
910  TOOLSDIR=  TOOLSDIR=
911  SOURCEDIRS=  SOURCEDIRS=
912  INCLUDEDIRS=  INCLUDEDIRS=
913  STANDARDDIRS=  STANDARDDIRS="USE_THE_DEFAULT"
914    
915    G2ARGS=
916    BASH=
917  PWD=`pwd`  PWD=`pwd`
918  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
919  AWK=awk  test "x$AWK" = x   &&  AWK=awk
920  THISHOSTNAME=`hostname`  THISHOST=`hostname`
921  THISCWD=`pwd`  THISCWD=`pwd`
922  THISDATE=`date`  THISDATE=`date`
923    THISUSER=`echo $USER`
924    THISVER=
925  MACHINE=`uname -a`  MACHINE=`uname -a`
926  EXECUTABLE=  EXECUTABLE=
927  EXEHOOK=  EXEHOOK=
# Line 332  IEEE= Line 931  IEEE=
931  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
932      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
933  fi  fi
934    FS=
935    FS90=
936    
937  AUTODIFF_PKG_USED=f  AUTODIFF_PKG_USED=f
938  AD_OPTFILE=  AD_OPTFILE=
# Line 348  TAMC_EXTRA= Line 949  TAMC_EXTRA=
949    
950    
951  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
952  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
953  gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE TS MPI JAM DUMPSTATE STANDARDDIRS"
954    
955  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
956  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 "
957  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
958  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
959  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
960    gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
961    
962  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
963  gm_s7="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
964  gm_s8="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"  gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
965  gm_s9="TAF_EXTRA TAMC_EXTRA"  gm_s12="TAF_EXTRA TAMC_EXTRA"
966    
967  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8 $gm_s9"  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7"
968    gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
969    
970    cat <<EOF
971    
972    GENMAKE :
973    
974    A program for GENerating MAKEfiles for the MITgcm project.  For a
975    quick list of options, use "genmake -h" or for more detail see:
976    
977      http://mitgcm.org/devel_HOWTO/
978    
979    EOF
980    
 echo  
981  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
982  gm_local="genmake_local"  gm_local="genmake_local"
983  for i in . $MODS ; do  for i in . $MODS ; do
984      if test -r $i/$gm_local ; then      if test -r $i/$gm_local ; then
985          source $i/$gm_local          . $i/$gm_local
986          break          break
987      fi      fi
988  done  done
989  echo -n "  getting local config information:  "  printf "  getting local config information:  "
990  if test -e $gm_local ; then  if test -f $gm_local ; then
991      echo "using $gm_local"      echo "using $gm_local"
992      source $gm_local      . $gm_local
993      # echo "DISABLE=$DISABLE"      # echo "DISABLE=$DISABLE"
994      # echo "ENABLE=$ENABLE"      # echo "ENABLE=$ENABLE"
995  else  else
996      echo "none found"      echo "none found"
997  fi  fi
998    
999  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
1000  #OPTIONS=  #OPTIONS=
1001  #n=0  #n=0
1002  #for i ; do  #for i ; do
# Line 396  fi Line 1008  fi
1008  #done  #done
1009  #parse_options  #parse_options
1010  ac_prev=  ac_prev=
1011  for ac_option ; do  for ac_option in "$@" ; do
1012    
1013        G2ARGS="$G2ARGS \"$ac_option\""
1014    
1015      # If the previous option needs an argument, assign it.      # If the previous option needs an argument, assign it.
1016      if test -n "$ac_prev"; then      if test -n "$ac_prev"; then
# Line 419  for ac_option ; do Line 1033  for ac_option ; do
1033          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
1034              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
1035                    
1036          -adoptfile | --adoptfile | -ad | --ad)          -adoptfile | --adoptfile | -adof | --adof)
1037              ac_prev=AD_OPTFILE ;;              ac_prev=AD_OPTFILE ;;
1038          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
1039              AD_OPTFILE=$ac_optarg ;;              AD_OPTFILE=$ac_optarg ;;
# Line 439  for ac_option ; do Line 1053  for ac_option ; do
1053          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
1054              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
1055                    
1056            -bash | --bash)
1057                ac_prev=BASH ;;
1058            -bash=* | --bash=*)
1059                BASH=$ac_optarg ;;
1060            
1061            -makedepend | --makedepend | -md | --md)
1062                ac_prev=MAKEDEPEND ;;
1063            -makedepend=* | --makedepend=* | -md=* | --md=*)
1064                MAKEDEPEND=$ac_optarg ;;
1065            
1066          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -ma | --ma)
1067              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
1068          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -ma=* | --ma=*)
1069              MAKEFILE=$ac_optarg ;;              MAKEFILE=$ac_optarg ;;
1070                    
1071          -platform | --platform | -pl | --pl)          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)
1072              ac_prev=PLATFORM ;;              echo "ERROR: The platform option has been removed.  Please specify"
1073          -platform=* | --platform=* | -pl=* | --pl=*)              echo "  the build options using the \"optfile\" mechanism."
1074              PLATFORM=$ac_optarg ;;              echo
1075                usage
1076                ;;
1077                    
1078          -rootdir | --rootdir | -rd | --rd)          -rootdir | --rootdir | -rd | --rd)
1079              ac_prev=ROOTDIR ;;              ac_prev=ROOTDIR ;;
# Line 474  for ac_option ; do Line 1100  for ac_option ; do
1100          -standarddirs=* | --standarddirs=*)          -standarddirs=* | --standarddirs=*)
1101              STANDARDDIRS=$ac_optarg ;;              STANDARDDIRS=$ac_optarg ;;
1102    
         -noopt | --noopt)  
             ac_prev=NOOPT ;;  
         -noopt=* | --noopt=*)  
             NOOPT=$ac_optarg ;;  
           
1103  #           -cpp | --cpp)  #           -cpp | --cpp)
1104  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1105  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1106  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1107                        
1108            -cc | --cc)
1109                ac_prev=CC ;;
1110            -cc=* | --cc=*)
1111                CC=$ac_optarg ;;
1112            
1113          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1114              ac_prev=FC ;;              ac_prev=FC ;;
1115          -fc=* | --fc=*)          -fc=* | --fc=*)
1116              FC=$ac_optarg ;;              FC=$ac_optarg ;;
1117                    
1118            -fs | --fs)
1119                ac_prev=FS ;;
1120            -fs=* | --fs=*)
1121                FS=$ac_optarg ;;
1122            
1123            -fs90 | --fs90)
1124                ac_prev=FS90 ;;
1125            -fs90=* | --fs90=*)
1126                FS90=$ac_optarg ;;
1127            
1128          -ieee | --ieee)          -ieee | --ieee)
1129              IEEE=true ;;              IEEE=true ;;
1130          -noieee | --noieee)          -noieee | --noieee)
1131              IEEE= ;;              IEEE= ;;
1132            
1133            -ts | --ts)
1134                TS=true ;;
1135    
1136          -mpi | --mpi)          -mpi | --mpi)
1137              MPI=true ;;              MPI=true ;;
1138          -nompi | --nompi)          -mpi=* | --mpi=*)
1139              MPI= ;;              MPIPATH=$ac_optarg
1140                MPI=true ;;
1141                    
1142          -jam | --jam)  #       -jam | --jam)
1143              JAM=1 ;;  #           JAM=1 ;;
1144          -nojam | --nojam)  #       -nojam | --nojam)
1145              JAM=0 ;;  #           JAM=0 ;;
1146                    
1147          -ds | --ds)          -ds | --ds)
1148              DUMPSTATE=t ;;              DUMPSTATE=t ;;
# Line 516  for ac_option ; do Line 1156  for ac_option ; do
1156              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1157          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1158              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1159            
1160            -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1161                IGNORE_TIME="-DIGNORE_TIME" ;;
1162    
1163          -*)          -*)
1164              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
# Line 531  for ac_option ; do Line 1174  for ac_option ; do
1174            
1175  done  done
1176    
1177    
1178  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1179      echo      echo
1180      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
# Line 543  if test -f ./.genmakerc ; then Line 1187  if test -f ./.genmakerc ; then
1187      echo      echo
1188  fi  fi
1189    
1190    #  Find the MITgcm ${ROOTDIR}
1191  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1192      if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1193        if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
1194          ROOTDIR=".."          ROOTDIR=".."
1195      else      else
1196          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
1197              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
1198                  ROOTDIR=$d                  ROOTDIR=$d
1199                  echo -n "Warning:  ROOTDIR was not specified but there appears to be"                  printf "Warning:  ROOTDIR was not specified but there appears to be"
1200                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
1201                  break                  break
1202              fi              fi
# Line 568  if test ! -d ${ROOTDIR} ; then Line 1214  if test ! -d ${ROOTDIR} ; then
1214      exit 1      exit 1
1215  fi  fi
1216    
1217    #  Find the MITgcm ${THISVER}
1218    if test -f "${ROOTDIR}/doc/tag-index" ; then
1219        THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`
1220    fi
1221    
1222    if test "x$MAKEFILE" = x ; then
1223        MAKEFILE="Makefile"
1224    fi
1225    
1226  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
1227  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1228      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
# Line 581  fi Line 1236  fi
1236  if test "x$OPTFILE" != xNONE ; then  if test "x$OPTFILE" != xNONE ; then
1237      if test -f "$OPTFILE" -a -r "$OPTFILE" ; then      if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
1238          echo "    using OPTFILE=\"$OPTFILE\""          echo "    using OPTFILE=\"$OPTFILE\""
1239          source "$OPTFILE"          . "$OPTFILE"
1240          RETVAL=$?          RETVAL=$?
1241          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
1242              echo -n "Error: failed to source OPTFILE \"$OPTFILE\""              printf "Error: failed to source OPTFILE \"$OPTFILE\""
1243              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1244              exit 1              exit 1
1245          fi          fi
# Line 608  fi Line 1263  fi
1263  if test "x${AD_OPTFILE}" != xNONE ; then  if test "x${AD_OPTFILE}" != xNONE ; then
1264      if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then      if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then
1265          echo "    using AD_OPTFILE=\"$AD_OPTFILE\""          echo "    using AD_OPTFILE=\"$AD_OPTFILE\""
1266          source "$AD_OPTFILE"          . "$AD_OPTFILE"
1267          RETVAL=$?          RETVAL=$?
1268          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
1269              echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""              printf "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
1270              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1271              exit 1              exit 1
1272          fi          fi
# Line 624  if test "x${AD_OPTFILE}" != xNONE ; then Line 1279  if test "x${AD_OPTFILE}" != xNONE ; then
1279      fi      fi
1280  fi  fi
1281    
1282  #  Check that FC, LINK, CPP, and S64 are defined.  If not, complain  #====================================================================
1283  #  and abort!  #  Set default values if not set by the optfile
1284    #
1285    #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1286    #  either set defaults or complain and abort!
1287    if test ! "x$BASH" = x ; then
1288        # add a trailing space so that it works within the Makefile syntax (see below)
1289        BASH="$BASH "
1290    fi
1291  if test "x$FC" = x ; then  if test "x$FC" = x ; then
1292      cat <<EOF 1>&2      cat <<EOF 1>&2
1293    
# Line 636  Error: no Fortran compiler: please speci Line 1298  Error: no Fortran compiler: please speci
1298  EOF  EOF
1299      exit 1      exit 1
1300  fi  fi
1301    if test "x$CC" = x ; then
1302        CC=cc
1303    #     cat <<EOF 1>&2
1304    # Error: no C compiler: please specify using one of the following:
1305    #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1306    #   2) the "-cc=XXX" command-line option
1307    #   3) the "./genmake_local" file
1308    # EOF
1309    #     exit 1
1310    fi
1311  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1312      LINK=$FC      LINK=$FC
1313  fi  fi
1314    if test "x$MAKE" = x ; then
1315        MAKE="make"
1316    fi
1317  if test "x$CPP" = x ; then  if test "x$CPP" = x ; then
1318      CPP="cpp"      CPP=cpp
1319  fi  fi
1320    #EH3 === UGLY ===
1321    #  The following is an ugly little hack to check for $CPP in /lib/ and
1322    #  it should eventually be replaced with a more general function that
1323    #  searches a combo of the user's path and a list of "usual suspects"
1324    #  to find the correct location for binaries such as $CPP.
1325    for i in " " "/lib/" ; do
1326        echo "#define A a" | $i$CPP > test_cpp 2>&1 && CPP=$i$CPP
1327    done
1328    #EH3 === UGLY ===
1329  echo "#define A a" | $CPP > test_cpp 2>&1  echo "#define A a" | $CPP > test_cpp 2>&1
1330  RETVAL=$?  RETVAL=$?
1331  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
# Line 651  Error: C pre-processor "$CPP" failed the Line 1335  Error: C pre-processor "$CPP" failed the
1335    
1336    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
1337    2) the "./genmake_local" file    2) the "./genmake_local" file
1338      3) with the CPP environment variable
1339    
1340  EOF  EOF
1341      exit 1      exit 1
1342  else  else
1343      rm -f test_cpp      rm -f test_cpp
1344  fi  fi
1345  if test "x$MAKEDEPEND" = x ; then  look_for_makedepend
1346      MAKEDEPEND=makedepend  if test "x$LN" = x ; then
1347        LN="ln -s"
1348  fi  fi
1349    echo "test" > genmake_test_ln
1350    $LN genmake_test_ln genmake_tlink
1351    RETVAL=$?
1352    if test "x$RETVAL" != x0 ; then
1353        cat <<EOF 1>&2
1354    
1355    Error: The command "ln -s" failed -- please specify a working soft-link
1356      command in the optfile.
1357    
1358    EOF
1359        exit 1
1360    fi
1361    test -L genmake_tlink > /dev/null 2>&1
1362    RETVAL=$?
1363    if test "x$RETVAL" = x0 ; then
1364        HAVE_TEST_L=t
1365    fi
1366    rm -f genmake_test_ln genmake_tlink
1367    
1368    #  Check for broken *.F/*.f handling and fix if possible
1369    check_for_broken_Ff
1370    
1371    if test ! "x$MPI" = x ; then
1372          echo "  Turning on MPI cpp macros"
1373          DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1374    fi
1375    
1376    if test ! "x$TS" = x ; then
1377          echo "  Turning on timing per timestep"
1378          DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1379    fi
1380    
1381    printf "\n===  Checking system libraries  ===\n"
1382    printf "  Do we have the system() command using $FC...  "
1383    cat > genmake_tcomp.$FS <<EOF
1384          program hello
1385          call system('echo hi')
1386          end
1387    EOF
1388    $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1389    RETVAL=$?
1390    if test "x$RETVAL" = x0 ; then
1391        HAVE_SYSTEM=t
1392        DEFINES="$DEFINES -DHAVE_SYSTEM"
1393        echo "yes"
1394    else
1395        HAVE_SYSTEM=
1396        echo "no"
1397    fi
1398    rm -f genmake_tcomp*
1399    
1400    printf "  Do we have the fdate() command using $FC...  "
1401    cat > genmake_tcomp.$FS <<EOF
1402          program hello
1403          CHARACTER*(128) string
1404          string = ' '
1405          call fdate( string )
1406          print *, string
1407          end
1408    EOF
1409    $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1410    RETVAL=$?
1411    if test "x$RETVAL" = x0 ; then
1412        HAVE_FDATE=t
1413        DEFINES="$DEFINES -DHAVE_FDATE"
1414        echo "yes"
1415    else
1416        HAVE_FDATE=
1417        echo "no"
1418    fi
1419    rm -f genmake_tcomp*
1420    
1421    printf "  Do we have the etime() command using $FC...  "
1422    cat > genmake_tcomp.$FS <<EOF
1423          program hello
1424          REAL*4 ACTUAL, TARRAY(2)
1425          EXTERNAL ETIME
1426          REAL*4 ETIME
1427          actual = etime( tarray )
1428          print *, tarray
1429          end
1430    EOF
1431    $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1432    RETVAL=$?
1433    if test "x$RETVAL" = x0 ; then
1434        HAVE_ETIME=t
1435        DEFINES="$DEFINES -DHAVE_ETIME"
1436        echo "yes"
1437    else
1438        HAVE_ETIME=
1439        echo "no"
1440    fi
1441    rm -f genmake_tcomp*
1442    
1443    printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1444    check_HAVE_CLOC
1445    if test "x$HAVE_CLOC" != x ; then
1446        echo "yes"
1447    else
1448        echo "no"
1449    fi
1450    rm -f genmake_t*
1451    
1452    printf "  Can we unlimit the stack size using $FC...  "
1453    check_HAVE_SETRLSTK
1454    if test "x$HAVE_SETRLSTK" != x ; then
1455        echo "yes"
1456    else
1457        echo "no"
1458    fi
1459    rm -f genmake_t*
1460    
1461    printf "  Can we use stat() through C calls...  "
1462    check_HAVE_STAT
1463    if test "x$HAVE_STAT" != x ; then
1464        echo "yes"
1465    else
1466        echo "no"
1467    fi
1468    rm -f genmake_t*
1469    
1470    printf "  Can we create NetCDF-enabled binaries...  "
1471    check_netcdf_libs
1472    if test "x$HAVE_NETCDF" != x ; then
1473        echo "yes"
1474    else
1475        echo "no"
1476    fi
1477    DEFINES="$DEFINES $IGNORE_TIME"
1478    
1479  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1480  echo -n "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
1481  for d in $MODS ; do  for d in $MODS ; do
1482      if test ! -d $d ; then      if test ! -d $d ; then
1483          echo          echo
1484          echo "Error: MODS directory \"$d\" not found!"          echo "Error: MODS directory \"$d\" not found!"
1485          exit 1          exit 1
1486      else      else
1487          echo -n " $d"          printf " $d"
1488          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1489          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
1490      fi      fi
1491  done  done
1492  echo  echo
1493    
 if test "x$MAKEFILE" = x ; then  
     MAKEFILE="Makefile"  
 fi  
1494  if test "x${PLATFORM}" = x ; then  if test "x${PLATFORM}" = x ; then
1495      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
1496  fi  fi
1497    
1498  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1499      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1500        if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1501          EXEDIR=../exe          EXEDIR=../exe
1502      else      else
1503          EXEDIR=.          EXEDIR=.
# Line 699  if test "x${TOOLSDIR}" = x ; then Line 1512  if test "x${TOOLSDIR}" = x ; then
1512      TOOLSDIR="$ROOTDIR/tools"      TOOLSDIR="$ROOTDIR/tools"
1513  fi  fi
1514  if test ! -d ${TOOLSDIR} ; then  if test ! -d ${TOOLSDIR} ; then
1515      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"
1516      exit 1      exit 1
1517  fi  fi
1518  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1519      S64='$(TOOLSDIR)/set64bitConst.sh'      echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1520        RETVAL=$?
1521        if test "x${RETVAL}" = x0 ; then
1522            S64='$(TOOLSDIR)/set64bitConst.sh'
1523        else
1524            echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1525            RETVAL=$?
1526            if test "x${RETVAL}" = x0 ; then
1527                S64='$(TOOLSDIR)/set64bitConst.csh'
1528            else
1529                cat <<EOF
1530    
1531    ERROR: neither of the two default scripts:
1532    
1533        ${TOOLSDIR}/set64bitConst.sh
1534        ${TOOLSDIR}/set64bitConst.csh
1535    
1536      are working so please check paths or specify (with \$S64) a
1537      working version of this script.
1538    
1539    EOF
1540                exit 1
1541            fi
1542        fi
1543  fi  fi
1544    THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1545    
1546  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
1547    
# Line 713  EXECUTABLE=${EXECUTABLE:-mitgcmuv} Line 1550  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
1550  #  they appear as regular source code  #  they appear as regular source code
1551  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
1552      echo "  Making source files in eesupp from templates"      echo "  Making source files in eesupp from templates"
1553      $MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1      ( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1
1554      RETVAL=$?      RETVAL=$?
1555      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
1556          rm -f make_eesupp.errors          rm -f make_eesupp.errors
1557      else      else
1558          echo "Error: problem encountered while building source files in eesupp:"          echo "Error: problem encountered while building source files in eesupp:"
1559          cat make_eesupp.errors          cat make_eesupp.errors 1>&2
1560          exit 1          exit 1
1561      fi      fi
1562  fi  fi
1563    
1564    #same for exch2
1565    if test -r $ROOTDIR"/pkg/exch2/Makefile" ; then
1566        echo "  Making source files in exch2 from  templates"
1567        ( cd $ROOTDIR"/pkg/exch2/" && $MAKE ) > make_exch2.errors 2>&1
1568        RETVAL=$?
1569        if test "x${RETVAL}" = x0 ; then
1570            rm -f make_exch2.errors
1571        else
1572            echo "Error: problem encountered while building source files in exch2:"
1573            cat make_exch2.errors 1>&2
1574            exit 1
1575        fi
1576    fi
1577    
1578  printf "\n===  Determining package settings  ===\n"  printf "\n===  Determining package settings  ===\n"
1579  if  test "x${PDEPEND}" = x ; then  if  test "x${PDEPEND}" = x ; then
1580      tmp=$ROOTDIR"/pkg/pkg_depend"      tmp=$ROOTDIR"/pkg/pkg_depend"
# Line 750  if test ! "x${RETVAL}" = x0 ; then Line 1601  if test ! "x${RETVAL}" = x0 ; then
1601      echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""      echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""
1602      exit 1      exit 1
1603  fi  fi
1604  source ./.pd_tmp  . ./.pd_tmp
1605  rm -f ./.pd_tmp  rm -f ./.pd_tmp
1606    
1607  #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"  #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"
1608  #  file should eventually be added so that, for convenience, one can  #  file should eventually be added so that, for convenience, one can
1609  #  specify groups of packages using names like "ocean" and "atmosphere".  #  specify groups of packages using names like "ocean" and "atmosphere".
1610  echo  -n "  checking default package list:  "  echo "  checking default package list:  "
1611  if test "x${PDEFAULT}" = x ; then  if test "x${PDEFAULT}" = x ; then
1612      for i in "." $MODS ; do      for i in "." $MODS ; do
1613          if test -r $i"/packages.conf" ; then          if test -r $i"/packages.conf" ; then
# Line 769  if test "x${PDEFAULT}" = x ; then Line 1620  if test "x${PDEFAULT}" = x ; then
1620      PDEFAULT="$ROOTDIR/pkg/pkg_default"      PDEFAULT="$ROOTDIR/pkg/pkg_default"
1621  fi  fi
1622  if test "x${PDEFAULT}" = xNONE ; then  if test "x${PDEFAULT}" = xNONE ; then
1623      echo "default packages file disabled"      echo "    default packages file disabled"
1624  else  else
1625      if test ! -r $PDEFAULT ; then      if test ! -r $PDEFAULT ; then
         echo ""  
1626          echo "Warning:  can't read default packages from PDEFAULT=\"$PDEFAULT\""          echo "Warning:  can't read default packages from PDEFAULT=\"$PDEFAULT\""
1627      else      else
1628          echo "  using PDEFAULT=\"$PDEFAULT\""          echo "    using PDEFAULT=\"$PDEFAULT\""
1629          #  Strip the comments and add all the names          #  Strip the comments and add all the names
1630          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
1631          RETVAL=$?          RETVAL=$?
1632          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
1633              echo -n "Error: can't parse default package list "              printf "Error: can't parse default package list "
1634              echo "-- please check PDEFAULT=\"$PDEFAULT\""              echo "-- please check PDEFAULT=\"$PDEFAULT\""
1635              exit 1              exit 1
1636          fi          fi
# Line 788  else Line 1638  else
1638              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
1639          done          done
1640          echo "    before group expansion packages are: $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
1641          expand_pkg_groups          RET=1
1642            while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
1643          echo "    after group expansion packages are:  $PACKAGES"          echo "    after group expansion packages are:  $PACKAGES"
1644      fi      fi
1645  fi  fi
1646    
1647  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
1648    for i in $PACKAGES ; do
1649        echo $i >> ./.tmp_pack
1650    done
1651    for i in `grep  "-" ./.tmp_pack` ; do
1652        j=`echo $i | sed 's/[-]//'`
1653        DISABLE="$DISABLE $j"
1654    done
1655  pack=  pack=
1656  for p in $PACKAGES ; do  for p in $PACKAGES ; do
1657      addit="t"      addit="t"
# Line 810  PACKAGES="$pack" Line 1668  PACKAGES="$pack"
1668  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
1669  echo "" > ./.tmp_pack  echo "" > ./.tmp_pack
1670  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
1671    # Test if each explicitly referenced package exists
1672  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1673      if test ! -d "$ROOTDIR/pkg/$i" ; then      j=`echo $i | sed 's/[-+]//'`
1674        if test ! -d "$ROOTDIR/pkg/$j" ; then
1675          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""
1676          exit 1          exit 1
1677      fi      fi
1678      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
1679  done  done
 pack=`cat ./.tmp_pack | sort | uniq`  
 rm -f ./.tmp_pack  
1680  PACKAGES=  PACKAGES=
1681  for i in $pack ; do  for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do
1682      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
1683  done  done
1684    rm -f ./.tmp_pack
1685  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1686    
1687    #  Check availability of NetCDF and then either build the MNC template
1688    #  files or delete mnc from the list of available packages.
1689    echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1690    RETVAL=$?
1691    if test "x$RETVAL" = x0 ; then
1692        if test "x$HAVE_NETCDF" != xt ; then
1693            cat <<EOF
1694    
1695    *********************************************************************
1696    WARNING: the "mnc" package was enabled but tests failed to compile
1697      NetCDF applications.  Please check that:
1698    
1699      1) NetCDF is correctly installed for this compiler and
1700      2) the LIBS variable (within the "optfile") specifies the correct
1701           NetCDF library to link against.
1702    
1703      Due to this failure, the "mnc" package is now DISABLED.
1704    *********************************************************************
1705    
1706    EOF
1707            PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
1708            DISABLE="$DISABLE mnc"
1709        else
1710            ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
1711            RETVAL=$?
1712            if test "x${RETVAL}" = x0 ; then
1713                rm -f make_mnc.errors
1714            else
1715                echo "Error: problem encountered while building source files in pkg/mnc:"
1716                cat make_mnc.errors 1>&2
1717                exit 1
1718            fi
1719        fi
1720    fi
1721    
1722  echo "  applying package dependency rules"  echo "  applying package dependency rules"
1723  ck=  ck=
1724  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
# Line 889  while test "x$ck" != xtt ; do Line 1783  while test "x$ck" != xtt ; do
1783              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
1784              exit 1              exit 1
1785          fi          fi
1786          i=$(( $i + 1 ))          i=`echo "$i + 1" | bc -l`
1787            #i=$(( $i + 1 ))
1788      done      done
1789      ck=$ck"t"      ck=$ck"t"
1790  done  done
# Line 908  for i in $PACKAGES ; do Line 1803  for i in $PACKAGES ; do
1803      fi      fi
1804  done  done
1805    
 #  This is compatible with the old genmake.  The "DISABLE_*" flags  
 #  need to be replaced by the "ALLOW_*" flags set below.  
 #  
 # echo -n "  Setting package-specific CPP flags:  "  
 # pkrm=( mom_fluxform mom_vecinv generic_advdiff )  
 # pkrmdef=( -DDISABLE_MOM_FLUXFORM -DDISABLE_MOM_VECINV -DDISABLE_GENERIC_ADVDIFF -DDISABLE_DEBUGMODE )  
 # echo -n "  "  
 # i=0  
 # while test $i -lt "${#pkrm[@]}" ; do  
 #     echo "$PACKAGES" | grep "${pk[$i]}" > /dev/null 2>&1  
 #     RETVAL=$?  
 #     if test "x$RETVAL" = x1 ; then  
 #       DEFINES="$DEFINES ${pkdef[$i]}"  
 #       echo -n " ${pkdef[$i]}"  
 #     fi  
 #     i=$(( $i + 1 ))  
 # done  
 # echo  
   
1806  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
1807  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
 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.  
   
 #ifndef PACKAGES_H  
 #define PACKAGES_H  
   
 C  Packages disabled by genmake:  
 EOF  
1808  #  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
1809  #  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
1810  #  file would eventually be split up so that all package-related #define  #  file would eventually be split up so that all package-related #define
1811  #  statements could be separated and handled only by genmake.  #  statements could be separated and handled only by genmake.
1812  names=`ls -1 "$ROOTDIR/pkg"`  names=`ls -1 "$ROOTDIR/pkg"`
1813  all_pack=  all_pack=
1814    DISABLED_PACKAGES=
1815  for n in $names ; do  for n in $names ; do
1816      if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then      if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then
1817          has_pack="f"          has_pack="f"
# Line 957  for n in $names ; do Line 1822  for n in $names ; do
1822              fi              fi
1823          done          done
1824          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1825              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1826              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!!!  
   
1827          fi          fi
1828      fi      fi
1829  done  done
1830  cat <<EOF >>$PACKAGES_DOT_H".tmp"  ENABLED_PACKAGES=
   
 C  Packages enabled by genmake:  
 EOF  
1831  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1832      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`      def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1833      echo "#define $def" >> $PACKAGES_DOT_H".tmp"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1834  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
1835    
1836  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
1837      case $i in      case $i in
1838          aim_v23)          aim_v23)
1839              echo "#define   ALLOW_AIM" >> $PACKAGES_DOT_H".tmp"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
1840              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 :-)"  
1841              ;;              ;;
1842      esac      esac
1843  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
1844    
1845  done  done
 cat <<EOF >>$PACKAGES_DOT_H".tmp"  
   
 #endif /* PACKAGES_H */  
 EOF  
   
 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  
1846    
1847  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
1848  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
1849  if test "x$STANDARDDIRS" = x ; then  if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
1850      STANDARDDIRS="eesupp model"      STANDARDDIRS="eesupp model"
1851  fi  fi
1852  for d in $STANDARDDIRS ; do  if test "x$STANDARDDIRS" != x ; then
1853      adr="$ROOTDIR/$d/src"      for d in $STANDARDDIRS ; do
1854      if test ! -d $adr ; then          adr="$ROOTDIR/$d/src"
1855          echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""          if test ! -d $adr ; then
1856          echo "  is correct and that you correctly specified the STANDARDDIRS option"              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1857          exit 1              echo "  is correct and that you correctly specified the STANDARDDIRS option"
1858      else              exit 1
1859          SOURCEDIRS="$SOURCEDIRS $adr"          else
1860      fi              SOURCEDIRS="$SOURCEDIRS $adr"
1861      adr="$ROOTDIR/$d/inc"          fi
1862      if test ! -d $adr ; then          adr="$ROOTDIR/$d/inc"
1863          echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""          if test ! -d $adr ; then
1864          echo "  is correct and that you correctly specified the STANDARDDIRS option"              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1865          exit 1              echo "  is correct and that you correctly specified the STANDARDDIRS option"
1866      else              exit 1
1867          INCLUDEDIRS="$INCLUDEDIRS $adr"          else
1868      fi              INCLUDEDIRS="$INCLUDEDIRS $adr"
1869  done          fi
1870        done
1871    fi
1872    
1873  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"
1874  echo " of \"#define ALLOW_PKGNAME\"-type statements:"  echo "    of \"#define \"-type statements that are no longer allowed:"
1875  CPP_OPTIONS=  CPP_OPTIONS=
1876    CPP_EEOPTIONS=
1877  spaths=". $INCLUDEDIRS"  spaths=". $INCLUDEDIRS"
1878    names=`ls -1 "$ROOTDIR/pkg"`
1879  for i in $spaths ; do  for i in $spaths ; do
1880      try="$i/CPP_OPTIONS.h"      try="$i/CPP_OPTIONS.h"
1881      #  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  
1882          echo "    found CPP_OPTIONS=\"$try\""          echo "    found CPP_OPTIONS=\"$try\""
1883          CPP_OPTIONS="$try"          CPP_OPTIONS="$try"
1884          break          # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
1885            for n in $names ; do
1886                test_for_package_in_cpp_options $CPP_OPTIONS $n
1887            done
1888        fi
1889        try="$i/CPP_EEOPTIONS.h"
1890        if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" = x ; then
1891            echo "    found CPP_EEOPTIONS=\"$try\""
1892            # New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h
1893    #**** not yet enabled ****
1894    #        test_for_mpi_in_cpp_eeoptions $try
1895    #**** not yet enabled ****
1896            CPP_EEOPTIONS="$try"
1897      fi      fi
1898  done  done
1899  if test "x$CPP_OPTIONS" = x ; then  if test "x$CPP_OPTIONS" = x ; then
1900      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"
1901      exit 1      exit 1
1902  fi  fi
 # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h  
 names=`ls -1 "$ROOTDIR/pkg"`  
 for n in $names ; do  
     test_for_package_in_cpp_options $CPP_OPTIONS $n  
 done  
   
1903    
1904  #  Here, we build the list of files to be "run through" the adjoint  #  Here, we build the list of files to be "run through" the adjoint
1905  #  compiler.  #  compiler.
# Line 1076  for i in $SOURCEDIRS ; do Line 1913  for i in $SOURCEDIRS ; do
1913          cat $i/$j >> ad_files          cat $i/$j >> ad_files
1914      done      done
1915  done  done
1916    if test ! "x"$FS = "x.f" ; then
1917  cat <<EOF > adjoint_sed      cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f
1918  s/call adopen(/call adopen ( mythid,\\      mv -f ad_files_f ad_files
1919       \&           /g  fi
 s/call adclose(/call adclose( mythid,\\  
      \&           /g  
 s/call adread(/call adread ( mythid,\\  
      \&           /g  
 s/call adwrite(/call adwrite( mythid,\\  
      \&           /g  
   
 EOF  
1920    
1921  echo  echo
1922  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
1923  echo "  setting INCLUDES"  echo "  setting INCLUDES"
1924  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
1925      if ! test -d $i ; then      if test ! -d $i ; then
 #       INCLUDES="$INCLUDES -I$i"  
 #   else  
1926          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
1927      fi      fi
1928  done  done
# Line 1105  rm -rf .links.tmp Line 1932  rm -rf .links.tmp
1932  mkdir .links.tmp  mkdir .links.tmp
1933  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
1934  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
1935  echo -n 'SRCFILES = '    > srclist.inc  printf 'SRCFILES = '    > srclist.inc
1936  echo -n 'CSRCFILES = '   > csrclist.inc  printf 'CSRCFILES = '   > csrclist.inc
1937  echo -n 'F90SRCFILES = ' > f90srclist.inc  printf 'F90SRCFILES = ' > f90srclist.inc
1938  echo -n 'HEADERFILES = ' > hlist.inc  printf 'HEADERFILES = ' > hlist.inc
1939  echo -n 'AD_FLOW_FILES = ' > ad_flow_files.inc  printf 'AD_FLOW_FILES = ' > ad_flow_files.inc
1940  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
1941  for d in $alldirs ; do  for d in $alldirs ; do
1942      deplist=      deplist=
# Line 1118  for d in $alldirs ; do Line 1945  for d in $alldirs ; do
1945      for sf in $sfiles ; do      for sf in $sfiles ; do
1946          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
1947              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
1948                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`                  ignore_f=f
1949                  touch .links.tmp/$sf                  case $d/$sf in
1950                  deplist="$deplist $sf"                    ./$PACKAGES_DOT_H)
                 case $extn in  
                     F)  
                         echo    " \\"  >> srclist.inc  
                         echo -n " $sf" >> srclist.inc  
1951                          ;;                          ;;
1952                      F90)                    ./AD_CONFIG.h)
                         echo    " \\"  >> f90srclist.inc  
                         echo -n " $sf" >> f90srclist.inc  
1953                          ;;                          ;;
1954                      c)                    ./FC_NAMEMANGLE.h)
                         echo    " \\"  >> csrclist.inc  
                         echo -n " $sf" >> csrclist.inc  
1955                          ;;                          ;;
1956                      h)                    ./BUILD_INFO.h)
                         echo    " \\"  >> hlist.inc  
                         echo -n " $sf" >> hlist.inc  
1957                          ;;                          ;;
1958                      flow)                    *)
1959                          echo    " \\"  >> ad_flow_files.inc                          #  For the local directory *ONLY*,
1960                          echo -n " $sf" >> ad_flow_files.inc                          #  ignore all soft-links
1961                            if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
1962                                ignore_f=t
1963                            else
1964                                touch .links.tmp/$sf
1965                                deplist="$deplist $sf"
1966                            fi
1967                          ;;                          ;;
1968                  esac                  esac
1969                    if test "x$ignore_f" = xf ; then
1970                        extn=`echo $sf | $AWK -F. '{print $NF}'`
1971                        case $extn in
1972                            F)
1973                                echo    " \\"  >> srclist.inc
1974                                printf " $sf" >> srclist.inc
1975                                ;;
1976                            F90)
1977                                echo    " \\"  >> f90srclist.inc
1978                                printf " $sf" >> f90srclist.inc
1979                                ;;
1980                            c)
1981                                echo    " \\"  >> csrclist.inc
1982                                printf " $sf" >> csrclist.inc
1983                                ;;
1984                            h)
1985                                echo    " \\"  >> hlist.inc
1986                                printf " $sf" >> hlist.inc
1987                                ;;
1988                            flow)
1989                                echo    " \\"  >> ad_flow_files.inc
1990                                printf " $sf" >> ad_flow_files.inc
1991                                ;;
1992                        esac
1993                    fi
1994              fi              fi
1995          fi          fi
1996      done      done
# Line 1160  echo "" >> f90srclist.inc Line 2008  echo "" >> f90srclist.inc
2008  echo "" >> hlist.inc  echo "" >> hlist.inc
2009  echo "" >> ad_flow_files.inc  echo "" >> ad_flow_files.inc
2010    
2011  if test -e $MAKEFILE ; then  if test -f $MAKEFILE ; then
2012      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
2013  fi  fi
2014  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
# Line 1169  echo "#    $MACHINE" >> $MAKEFILE Line 2017  echo "#    $MACHINE" >> $MAKEFILE
2017  echo "# This makefile was generated automatically on" >> $MAKEFILE  echo "# This makefile was generated automatically on" >> $MAKEFILE
2018  echo "#    $THISDATE" >> $MAKEFILE  echo "#    $THISDATE" >> $MAKEFILE
2019  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2020  echo "#    $0 $@" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
2021  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2022  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2023    
2024    EXE_AD=$EXECUTABLE"_ad"
2025    EXE_FTL=$EXECUTABLE"_ftl"
2026    EXE_SVD=$EXECUTABLE"_svd"
2027    
2028  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2029    #
2030    # OPTFILE="$OPTFILE"
2031  #  #
2032  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
2033  # SOURCEDIRS   : Directories containing the source (.F) files  # SOURCEDIRS   : Directories containing the source (.F) files
# Line 1202  TOOLSDIR    = ${TOOLSDIR} Line 2057  TOOLSDIR    = ${TOOLSDIR}
2057    
2058  #eh3  new defines for the adjoint work  #eh3  new defines for the adjoint work
2059  AUTODIFF    = ${ROOTDIR}/pkg/autodiff  AUTODIFF    = ${ROOTDIR}/pkg/autodiff
2060    EXE_AD      = ${EXE_AD}
2061    EXE_FTL     = ${EXE_FTL}
2062    EXE_SVD     = ${EXE_SVD}
2063    
2064    ENABLED_PACKAGES = ${ENABLED_PACKAGES}
2065    DISABLED_PACKAGES = ${DISABLED_PACKAGES}
2066    
2067    # These files are created by Makefile
2068    SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h
2069    
2070  EOF  EOF
2071    
# Line 1220  KPP = ${KPP} Line 2084  KPP = ${KPP}
2084  FC = ${FC}  FC = ${FC}
2085  # Fortran compiler  # Fortran compiler
2086  F90C = ${F90C}  F90C = ${F90C}
2087    # C compiler
2088    CC = ${CC}
2089  # Link editor  # Link editor
2090  LINK = ${LINK}  LINK = ${LINK} ${LDADD}
2091    
2092  # Defines for CPP  # Defines for CPP
2093  DEFINES = ${DEFINES}  DEFINES = ${DEFINES}
# Line 1242  CFLAGS = ${CFLAGS} Line 2108  CFLAGS = ${CFLAGS}
2108  NOOPTFILES = ${NOOPTFILES}  NOOPTFILES = ${NOOPTFILES}
2109  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2110  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2111  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS}
2112  # Name of the Mekfile  # Name of the Mekfile
2113  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2114    
# Line 1253  cat csrclist.inc      >> $MAKEFILE Line 2119  cat csrclist.inc      >> $MAKEFILE
2119  cat f90srclist.inc    >> $MAKEFILE  cat f90srclist.inc    >> $MAKEFILE
2120  cat hlist.inc         >> $MAKEFILE  cat hlist.inc         >> $MAKEFILE
2121  cat ad_flow_files.inc >> $MAKEFILE  cat ad_flow_files.inc >> $MAKEFILE
2122  echo               >> $MAKEFILE  echo >> $MAKEFILE
2123  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE
2124  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE
2125  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
2126    echo >> $MAKEFILE
2127    echo '.SUFFIXES:' >> $MAKEFILE
2128    echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE
2129  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
2130  rm -f ad_flow_files.inc  rm -f ad_flow_files.inc
2131    
2132  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2133    
 .SUFFIXES:  
 .SUFFIXES: .o .f .p .F .c .F90 .f90  
   
2134  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
2135  \$(EXECUTABLE): \$(OBJFILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)
2136            @echo Creating \$@ ...
2137          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2138  depend:  depend:
2139          @make links          @make links
2140          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
2141          ${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2142            -rm -f makedepend.out
2143    
2144    lib: libmitgcmuv.a
2145    
2146    libmitgcmuv.a: \$(OBJFILES)
2147            ar rcv libmitgcmuv.a \$(OBJFILES)
2148    
2149  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
2150    
2151  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77FILES) \$(F90FILES)
2152    
# Line 1283  output.txt: \$(EXECUTABLE) Line 2155  output.txt: \$(EXECUTABLE)
2155          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
2156    
2157  clean:  clean:
2158          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl}          -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2159  Clean:  Clean:
2160          @make clean          @make clean
2161          @make cleanlinks          @make cleanlinks
2162          -rm -f Makefile.bak genmake_state genmake_optfile make.log          -rm -f \$(SPECIAL_FILES)
2163            -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak
2164  CLEAN:  CLEAN:
2165          @make Clean          @make Clean
2166          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2167          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2168          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2169          -rm -f \$(EXECUTABLE) output.txt          -rm -f \$(EXECUTABLE) output.txt STD*
2170    
2171  #eh3 Makefile: makefile  #eh3 Makefile: makefile
2172  makefile:  makefile:
2173          ${0} $@          $THIS_SCRIPT $G2ARGS
2174  cleanlinks:  cleanlinks:
2175          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2176    
2177  # The normal chain of rules is (  .F - .f - .o  )  # Special targets (SPECIAL_FILES) which are create by make
2178  .F.f:  ${PACKAGES_DOT_H}:
2179            @echo Creating \$@ ...
2180            @$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) > \$@
2181    AD_CONFIG.h:
2182            @echo Creating \$@ ...
2183            @$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 > \$@
2184    FC_NAMEMANGLE.h:
2185            @echo Creating \$@ ...
2186            echo "$FC_NAMEMANGLE" > \$@
2187    
2188    BUILD_INFO.h:
2189            @echo Creating \$@ ...
2190    EOF
2191    
2192    test ! "x$THISVER" = x  && echo "       -echo \"#define THISVER '$THISVER'\" > \$@"   >> $MAKEFILE
2193    test ! "x$THISUSER" = x && echo "       -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2194    test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2195    test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2196    
2197    cat >>$MAKEFILE <<EOF
2198    
2199    # The normal chain of rules is (  .F - .$FS - .o  )
2200    
2201    ## This nullifies any default implicit rules concerning these two file types:
2202    ## %.o : %.F
2203    
2204    .F.$FS:
2205          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2206  .f.o:  .$FS.o:
2207          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2208  .F90.f90:  .F90.$FS90:
2209          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2210  .f90.o:  .$FS90.o:
2211          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2212  .c.o:  .c.o:
2213          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) -c \$<
2214    
2215  # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2216  .F.p:  .F.p:
2217          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2218  .p.f:  .p.$FS:
2219          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
2220    
2221  #=========================================  #=========================================
# Line 1343  done Line 2242  done
2242    
2243  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
2244  echo >> $MAKEFILE  echo >> $MAKEFILE
2245  echo -n "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
2246  AD_FILES=`cat ad_files`  AD_FILES=`cat ad_files`
2247  for i in $AD_FILES ; do  for i in $AD_FILES ; do
2248      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
2249      echo -n " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
2250  done  done
2251  echo >> $MAKEFILE  echo >> $MAKEFILE
2252    rm -f ad_files
2253    
2254  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2255    
2256  ad_input_code.f: \$(F77FILES)  # ... AD ...
2257    adall: ad_taf
2258    adtaf: ad_taf_output.$FS
2259    adtamc: ad_tamc_output.$FS
2260    
2261    ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2262            @$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
2263            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2264            -rm -f ad_config.template
2265            @make \$(F77FILES)
2266          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2267          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS
2268    
2269  # ... AD ...  ad_taf_output.$FS: ad_input_code.$FS
2270  ad_taf_output.f: ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2271          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2272          cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f  
2273    adtafonly:
2274            \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2275            cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2276    
2277  ad_taf: ad_taf_output.o \$(OBJFILES)  ad_taf: ad_taf_output.o \$(OBJFILES)
2278          \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2279    
2280  ad_tamc_output.f: ad_input_code.f  ad_tamc_output.$FS: ad_input_code.$FS
2281          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2282          cat ad_input_code_ad.f | sed -f adjoint_sed > ad_tamc_output.f          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
2283    
2284  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2285          \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2286    
2287    adonlyfwd:
2288            patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2289    
2290    adtrick:
2291            patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2292    
2293  # ... FTL ...  # ... FTL ...
2294  ftl_taf_output.f: ad_input_code.f  ftlall: ftl_taf
2295          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f  ftltaf: ftl_taf_output.$FS
2296          cat ad_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f  ftltamc: ftl_tamc_output.$FS
2297    
2298    ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2299            @$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
2300            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2301            -rm -f ftl_config.template
2302            @make \$(F77FILES)
2303            @make \$(AD_FLOW_FILES)
2304            cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2305    
2306    ftl_taf_output.$FS: ftl_input_code.$FS
2307            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2308            cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2309    
2310    ftltafonly:
2311            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2312            cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2313    
2314  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
2315          \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2316    
2317  ftl_tamc_output.f: ad_input_code.f  ftl_tamc_output.$FS: ftl_input_code.$FS
2318          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2319          cat ad_input_code_ftl.f | sed -f adjoint_sed > ftl_tamc_output.f          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS
2320    
2321  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2322          \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2323    
2324    
2325  # ... SVD ...  # ... SVD ...
2326  svd_taf_output.f: ad_input_code.f  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
2327          \$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"
2328          cat ad_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f          @echo "--->>> Do make svdall afterwards to compile. <<<---"
2329    svdall: svd_touch svd_taf
2330  svd_taf: svd_taf_output.o \$(OBJFILES)  
2331          \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS)  svd_taf: \$(OBJFILES)
2332            \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS)
2333    
2334            @echo "--->>> Only COMPILE svd code! <<<---"
2335            @echo "--->>> Assumes you previously <<<---"
2336            @echo "--->>> did make svdtaf        <<<---"
2337    
2338    svd_touch:
2339            @echo "--->>> Only COMPILE svd code! <<<---"
2340            @echo "--->>> Assumes you previously <<<---"
2341            @echo "--->>> did make svdtaf        <<<---"
2342            touch ad_taf_output.$FS ftl_taf_output.$FS
2343            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
2344            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
2345            @$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
2346            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2347            -rm -f ftl_config.template
2348    
2349  #=========================================  #=========================================
2350    
# Line 1413  for i in $KPPFILES ; do Line 2361  for i in $KPPFILES ; do
2361      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
2362          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
2363      fi      fi
2364      echo "$base.f: $base.p" >> $MAKEFILE      echo "$base.$FS: $base.p" >> $MAKEFILE
2365  done  done
2366    
2367  echo "  Making list of NOOPTFILES"  echo "  Making list of NOOPTFILES"
# Line 1423  for i in $NOOPTFILES ; do Line 2371  for i in $NOOPTFILES ; do
2371      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
2372          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
2373      fi      fi
2374      echo "$base.o: $base.f" >> $MAKEFILE      echo "$base.o: $base.$FS" >> $MAKEFILE
2375      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
2376  done  done
2377    
# Line 1436  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 2384  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
2384    
2385  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
2386    
2387    # Create special header files
2388    $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"
2389    if test ! -f $PACKAGES_DOT_H ; then
2390        mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
2391    else
2392        cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H > /dev/null 2>&1
2393        RETVAL=$?
2394        if test "x$RETVAL" = x0 ; then
2395            rm -f $PACKAGES_DOT_H".tmp"
2396        else
2397            mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"
2398            mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
2399        fi
2400    fi
2401    if test ! -f AD_CONFIG.h ; then
2402        $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
2403    fi
2404    
2405    
2406  #  Write the "state" for future records  #  Write the "state" for future records
2407  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" != xf ; then
2408      echo -n "" > genmake_state      printf "" > genmake_state
2409      for i in $gm_state ; do      for i in $gm_state ; do
2410          t1="t2=\$$i"          t1="t2=\$$i"
2411          eval $t1          eval $t1

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.136

  ViewVC Help
Powered by ViewVC 1.1.22