/[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.140 by ce107, Thu Dec 22 01:36:24 2005 UTC revision 1.237 by jmc, Fri Aug 24 23:41:17 2012 UTC
# Line 1  Line 1 
1  #! /usr/bin/env bash  #! /usr/bin/env bash
2  #  #
3  # $Header$  # $Header$
4    # $Name$
5  #  #
6  # Makefile generator for MITgcm UV codes  # Makefile generator for MITgcm UV codes
7  #   created  by cnh 03/98  #   created  by cnh 03/98
# Line 8  Line 9 
9  #   modified by aja 01/00  #   modified by aja 01/00
10  #   rewritten in bash by eh3 08/03  #   rewritten in bash by eh3 08/03
11    
12    #  Explain usage
13    usage()  {
14    cat <<EOF
15    
16    Usage: "$0" [OPTIONS]
17      where [OPTIONS] can be:
18    
19        -help | --help | -h | --h
20              Print this help message and exit.
21    
22        -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
23          -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
24              Use "NAME" as the adoptfile.  By default, the file at
25              "tools/adjoint_options/adjoint_default" will be used.
26    
27        -nooptfile | --nooptfile
28          -optfile NAME | --optfile NAME | -of NAME | --of NAME
29          -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
30              Use "NAME" as the optfile.  By default, an attempt will be
31              made to find an appropriate "standard" optfile in the
32              tools/build_options/ directory.
33    
34        -pdepend NAME | --pdepend NAME
35          -pdepend=NAME | --pdepend=NAME
36              Get package dependency information from "NAME".
37    
38        -pgroups NAME | --pgroups NAME
39          -pgroups=NAME | --pgroups=NAME
40              Get the package groups information from "NAME".
41    
42        -bash NAME
43              Explicitly specify the Bourne or BASH shell to use
44    
45        -make NAME | -m NAME
46          --make=NAME | -m=NAME
47              Use "NAME" for the MAKE program. The default is "make" but
48              many platforms, "gmake" is the preferred choice.
49    
50        -makefile NAME | -mf NAME
51          --makefile=NAME | -mf=NAME
52              Call the makefile "NAME".  The default is "Makefile".
53    
54        -makedepend NAME | -md NAME
55          --makedepend=NAME | -md=NAME
56              Use "NAME" for the MAKEDEPEND program.
57    
58        -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
59          -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
60              Specify the location of the MITgcm ROOTDIR as "NAME".
61              By default, genamke will try to find the location by
62              looking in parent directories (up to the 5th parent).
63    
64        -mods NAME | --mods NAME | -mo NAME | --mo NAME
65          -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME
66              Here, "NAME" specifies a list of directories that are
67              used for additional source code.  Files found in the
68              "mods list" are given preference over files of the same
69              name found elsewhere.
70    
71        -disable NAME | --disable NAME
72          -disable=NAME | --disable=NAME
73              Here "NAME" specifies a list of packages that we don't
74              want to use.  If this violates package dependencies,
75              genamke will exit with an error message.
76    
77        -enable NAME | --enable NAME
78          -enable=NAME | --enable=NAME
79              Here "NAME" specifies a list of packages that we wish
80              to specifically enable.  If this violates package
81              dependencies, genamke will exit with an error message.
82    
83        -standarddirs NAME | --standarddirs NAME
84          -standarddirs=NAME | --standarddirs=NAME
85              Here, "NAME" specifies a list of directories to be
86              used as the "standard" code.
87    
88        -fortran NAME | --fortran NAME | -fc NAME | --fc NAME
89          -fc=NAME | --fc=NAME
90              Use "NAME" as the fortran compiler.  By default, genmake
91              will search for a working compiler by trying a list of
92              "usual suspects" such as g77, f77, etc.
93    
94        -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
95              Use "NAME" as the C compiler.  By default, genmake
96              will search for a working compiler by trying a list of
97              "usual suspects" such as gcc, c89, cc, etc.
98    
99        -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4
100              Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW)
101              *only* works if CPP_EEOPTIONS.h allows this.
102    
103        -ignoretime | -ignore_time | --ignoretime | --ignore_time
104              Ignore all the "wall clock" routines entirely.  This will
105              not in any way hurt the model results -- it simply means
106              that the code that checks how long the model spends in
107              various routines will give junk values.
108    
109        -ts | --ts
110              Produce timing information per timestep
111        -papis | --papis
112              Produce summary MFlop/s (and IPC) with PAPI per timestep
113        -pcls | --pcls
114              Produce summary MFlop/s etc. with PCL per timestep
115        -foolad | --foolad
116              Fool the AD code generator
117        -papi | --papi
118              Performance analysis with PAPI
119        -pcl | --pcl
120              Performance analysis with PCL
121        -hpmt | --hpmt
122              Performance analysis with the HPM Toolkit
123    
124        -ieee | --ieee
125              use IEEE numerics.  Note that this option *only* works
126              if it is supported by the OPTFILE that is being used.
127        -devel | --devel
128              Add additional warning and debugging flags for development
129              (if supported by the OPTFILE); also switch to IEEE numerics.
130        -gsl | --gsl
131              Use GSL to control floating point rounding and precision
132    
133        -mpi | --mpi
134              Include MPI header files and link to MPI libraries
135        -mpi=PATH | --mpi=PATH
136              Include MPI header files and link to MPI libraries using MPI_ROOT
137              set to PATH. i.e. Include files from \$PATH/include, link to libraries
138              from \$PATH/lib and use binaries from \$PATH/bin.
139    
140        -omp | --omp
141              Activate OpenMP code + use Compiler option OMPFLAG
142        -omp=OMPFLAG | --omp=OMPFLAG
143              Activate OpenMP code + use Compiler option OMPFLAG
144    
145        -es | --es | -embed-source | --embed-source
146              Embed a tarball containing the full source code
147              (including the Makefile, etc.) used to build the
148              executable [off by default]
149    
150        -ds | --ds
151              Report genmake internal variables status (DUMPSTATE)
152              to file "genmake_state" (for debug purpose)
153    
154      While it is most often a single word, the "NAME" variables specified
155      above can in many cases be a space-delimited string such as:
156    
157        --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'
158        -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'
159        -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'
160    
161      which, depending upon your shell, may need to be single-quoted.
162    
163      For more detailed genmake documentation, please see:
164    
165        http://mitgcm.org/public/devel_HOWTO/
166    
167    EOF
168    
169        exit 1
170    }
171    
172  # Search for particular CPP #cmds associated with packages  # Search for particular CPP #cmds associated with packages
173  # usage: test_for_package_in_cpp_options CPP_file package_name  # usage: test_for_package_in_cpp_options CPP_file package_name
174  test_for_package_in_cpp_options() {  test_for_package_in_cpp_options() {
175      cpp_options=$1      cpp_options=$1
176      pkg=$2      pkg=$2
177      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg[ ]"
178      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg[ ]"
179      test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg[ ]"
180      test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg[ ]"
181        test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg$"
182        test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg$"
183        test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg$"
184        test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg$"
185  }  }
186    
187  # Search for particular CPP #cmds associated with MPI  # Search for particular CPP #cmds associated with MPI
188  # usage: test_for_mpi_in_cpp_eeoptions CPP_file  # usage: test_for_mpi_in_cpp_eeoptions CPP_file
189  test_for_mpi_in_cpp_eeoptions() {  test_for_mpi_in_cpp_eeoptions() {
190      cpp_options=$1      cpp_options=$1
191      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI[ ]"
192      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI[ ]"
193      test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI[ ]"
194      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI[ ]"
195        test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI$"
196        test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI$"
197        test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI$"
198        test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI$"
199  }  }
200    
201  # Search for particular string in a file. Return 1 if detected, 0 if not  # Search for particular string in a file. Return 1 if detected, 0 if not
# Line 38  test_for_string_in_file() { Line 207  test_for_string_in_file() {
207      RETVAL=$?      RETVAL=$?
208      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
209          printf "Error: In $file there is an illegal line: "          printf "Error: In $file there is an illegal line: "
210          grep -i "$strng" $file          grep -i "$strng" $file
211          return 1          exit 99
212      fi      fi
213      return 0      return 0
214  }  }
# Line 48  test_for_string_in_file() { Line 217  test_for_string_in_file() {
217  # the package list.  # the package list.
218  expand_pkg_groups() {  expand_pkg_groups() {
219      new_packages=      new_packages=
     PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"  
220      if test -r $PKG_GROUPS ; then      if test -r $PKG_GROUPS ; then
221          cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp          cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp
222          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp
# Line 59  expand_pkg_groups() { Line 227  expand_pkg_groups() {
227              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
228                  matched=1                  matched=1
229                  replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`                  replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
230                  echo "    replacing \"$i\" with: $replace"                  echo "    replacing \"$i\" with:$replace"
231                  new_packages="$new_packages $replace"                  new_packages="$new_packages $replace"
232              else              else
233                  new_packages="$new_packages $i"                  new_packages="$new_packages $i"
# Line 102  EOF Line 270  EOF
270              check_for_broken_Ff              check_for_broken_Ff
271          else          else
272              cat <<EOF 2>&1              cat <<EOF 2>&1
273  ERROR: Your file system cannot distinguish between *.F and *.f files  ERROR: Your file system cannot distinguish between *.F and *.f files
274    (fails the "cp" test) and this program cannot find a suitable    (fails the "cp" test) and this program cannot find a suitable
275    replacement extension.  Please try a different build environment or    replacement extension.  Please try a different build environment or
276    contact the <MITgcm-support@mitgcm.org> list for help.    contact the <MITgcm-support@mitgcm.org> list for help.
277    
278  EOF  EOF
# Line 129  EOF Line 297  EOF
297  .F.$tfs:  .F.$tfs:
298          $LN \$< \$@          $LN \$< \$@
299  EOF  EOF
300      $MAKE "genmake_hello."$tfs > /dev/null 2>&1      $MAKE -f $MAKEFILE "genmake_hello."$tfs > /dev/null 2>&1
301      RETVAL=$?      RETVAL=$?
302      if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then      if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then
303          if test "x$FS" = x ; then          if test "x$FS" = x ; then
# Line 137  EOF Line 305  EOF
305              FS90='fr9'              FS90='fr9'
306              check_for_broken_Ff              check_for_broken_Ff
307          else          else
308              cat <<EOF 2>&1              echo "ERROR: test: '$MAKE -f $MAKEFILE genmake_hello.$tfs' Failed"
309  ERROR: Your file system cannot distinguish between *.F and *.f files              echo "       see simple makefile: '$MAKEFILE' (left here)"
310    (fails the "make/ln" test) and this program cannot find a suitable              echo "  Please check (1) your '$MAKE' command, (2) your '$LN' command"
311    replacement extension.  Please try a different build environment or              echo "           and (3) the allowed sufix '.F' and '.$tfs' in makefile"
312    contact the <MITgcm-support@mitgcm.org> list for help.              echo "  or contact the <MITgcm-support@mitgcm.org> list for help."
313                echo ""
 EOF  
314              exit -1              exit -1
315              return              return
316          fi          fi
# Line 157  EOF Line 324  EOF
324      return      return
325  }  }
326    
   
327  look_for_makedepend()  {  look_for_makedepend()  {
328    
329      #  The "original" makedepend is part of the Imake system that is      #  The "original" makedepend is part of the Imake system that is
# Line 178  look_for_makedepend()  { Line 344  look_for_makedepend()  {
344      #    3) locally build and use the cyrus implementation      #    3) locally build and use the cyrus implementation
345      #    4) fall back to the buggy local xmakedpend script      #    4) fall back to the buggy local xmakedpend script
346      #      #
347        echo >> $LOGFILE
348        echo "running: look_for_makedepend()" >> $LOGFILE
349        if test "x${MAKEDEPEND}" != x ; then
350            echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
351            RETVAL=$?
352            if test x"$RETVAL" = x0 ; then
353                build_cyrus_makedepend
354                RETVAL=$?
355                if test "x$RETVAL" != x0 ; then
356                    echo "WARNING: unable to build cyrus-makedepend. Try 'makedepend'"
357                    MAKEDEPEND=
358                fi
359            else
360                echo "${MAKEDEPEND}" | grep 'tools.xmakedepend' > /dev/null 2>&1
361                RETVAL=$?
362                if test "x$RETVAL" = x0 ; then
363                    MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
364                fi
365                echo " -->     MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
366            fi
367        fi
368      if test "x${MAKEDEPEND}" = x ; then      if test "x${MAKEDEPEND}" = x ; then
369          which makedepend > /dev/null 2>&1          which makedepend > /dev/null 2>&1
370          RV0=$?          RV0=$?
# Line 186  look_for_makedepend()  { Line 373  look_for_makedepend()  {
373          cat <<EOF >> $MAKEFILE          cat <<EOF >> $MAKEFILE
374  #   THIS IS A TEST MAKEFILE GENERATED BY "genmake2"  #   THIS IS A TEST MAKEFILE GENERATED BY "genmake2"
375  #  #
376  #   Some "makedepend" implementations will die if they cannot  #   Some "makedepend" implementations will die if they cannot
377  #   find a Makefile -- so this file is here to gives them an  #   find a Makefile -- so this file is here to gives them an
378  #   empty one to find and parse.  #   empty one to find and parse.
379  EOF  EOF
380          cat <<EOF >> genmake_tc.f          cat <<EOF >> genmake_tc.f
# Line 196  EOF Line 383  EOF
383        stop        stop
384        end        end
385  EOF  EOF
386          makedepend genmake_tc.f > /dev/null 2>&1          makedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1
387          RV1=$?          RV1=$?
388          test -f $MAKEFILE  &&  rm -f $MAKEFILE          test -f $MAKEFILE  &&  rm -f $MAKEFILE
389          test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE          test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
390          if test "x${RV0}${RV1}" = x00 ; then          if test "x${RV0}${RV1}" = x00 ; then
391              MAKEDEPEND=makedepend              MAKEDEPEND=makedepend
392                echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
393          else          else
394              echo "    a system-default makedepend was not found."              echo "    system-default makedepend not found. Try to build cyrus-makedepend"
               
395              #  Try to build the cyrus implementation              #  Try to build the cyrus implementation
396              build_cyrus_makedepend              build_cyrus_makedepend
397              RETVAL=$?              RETVAL=$?
398              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
399                    echo "WARNING: unable to build cyrus-makedepend. Use local xmakedepend"
400                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
401                    echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
402              fi              fi
             rm -f ./genmake_cy_md  
         fi  
     else  
         #  echo "MAKEDEPEND=${MAKEDEPEND}"  
         echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1  
         RETVAL=$?  
         if test x"$RETVAL" = x0 ; then  
             build_cyrus_makedepend  
403          fi          fi
404      fi      fi
405  }  }
406    
   
407  build_cyrus_makedepend()  {  build_cyrus_makedepend()  {
408        echo >> $LOGFILE
409        echo "running: build_cyrus_makedepend()" >> $LOGFILE
410      rm -f ./genmake_cy_md      rm -f ./genmake_cy_md
411      (      (
412          cd $ROOTDIR/tools/cyrus-imapd-makedepend  \          cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
# Line 241  build_cyrus_makedepend()  { Line 423  build_cyrus_makedepend()  {
423      rm -f ./genmake_cy_md      rm -f ./genmake_cy_md
424      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
425          MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'          MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
426            echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
427          return 0          return 0
428      else      else
429          echo "WARNING: unable to build cyrus-imapd-makedepend"          echo "WARNING: fail to build cyrus-imapd-makedepend" >> $LOGFILE
430          return 1          return 1
431      fi      fi
432  }  }
433    
434  # Guess possible config options for this host  build_embed_encode()
435  find_possible_configs()  {  {
436        printf "  building the embed-encode utility...  "
437      tmp1=`uname`"_"`uname -m`      if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then
438      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`          if test ! -d "$ROOTDIR/tools/embed_encode" ; then
439      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`              echo
440      tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`              echo "    Error: can't locate \"$ROOTDIR/tools/embed_encode\""
441      tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`              echo
442      tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`              EMBED_SRC=f
443      PLATFORM=$tmp3              return 1
444      echo $PLATFORM | grep cygwin > /dev/null 2>&1  &&  PLATFORM=cygwin_ia32          fi
445      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`          clist="cc gcc c89 $CC"
446      echo "  The platform appears to be:  $PLATFORM"          for ic in $clist ; do
447                    comm="$ic -o encode_files encode_files.c"
448      echo "test" > test              ( cd $ROOTDIR/tools/embed_encode && $comm ) > /dev/null 2>&1
449      ln -s ./test link              RETVAL=$?
450      RETVAL=$?              if test "x$RETVAL" = x0 ; then
451      if test "x${RETVAL}" = x0 ; then                  echo "OK"
452          LN="ln -s"                  return 0
453      else              fi
454          echo "Error: \"ln -s\" does not appear to work on this system!"          done
455          echo "  For help, please contact <MITgcm-support@mitgcm.org>."          echo
456          exit 1          echo "    Error: unable to build $ROOTDIR/embed_encode/encode_files"
457      fi          echo "      so it has been disabled"
458      rm -f test link          echo
459            EMBED_SRC=f
460      if test "x$CPP" = x ; then          return 1
         CPP="cpp -traditional -P"  
461      fi      fi
462        echo "OK"
463    }
464    
465      look_for_makedepend  #  look for possible C compilers
466    look_for_C_compilers() {
467      #================================================================      echo >> $LOGFILE
468      #  look for possible C compilers      echo "running: look_for_C_compilers()" >> $LOGFILE
469      tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc"      rm -f ./genmake_hello.c  ./genmake_hello
470      p_CC=      cat >> genmake_hello.c << EOF
     for c in $tmp ; do  
         rm -f ./genmake_hello.c  ./genmake_hello  
         cat >> genmake_hello.c << EOF  
471  #include <stdio.h>  #include <stdio.h>
472  int main(int argc, char **argv) {  int main(int argc, char **argv) {
473    printf("Hello!\n");    printf("Hello!\n");
474    return 0;    return 0;
475  }  }
476  EOF  EOF
477          $c -o genmake_hello genmake_hello.c > /dev/null 2>&1      tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc icc"
478        p_CC=
479        for c in $tmp ; do
480            COMM="$c $CFLAGS -o genmake_hello genmake_hello.c"
481            echo $COMM >> $LOGFILE
482            $COMM >> $LOGFILE 2>&1
483          RETVAL=$?          RETVAL=$?
484          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
485                echo " $c test successful" >> $LOGFILE
486              p_CC="$p_CC $c"              p_CC="$p_CC $c"
487          fi          fi
488      done      done
# Line 311  Error: No C compilers were found in your Line 498  Error: No C compilers were found in your
498  EOF  EOF
499          exit 1          exit 1
500      else      else
501          echo "  The possible C compilers found in your path are:"          echo "  The possible C compilers found in your path are: $p_CC" | tee -a $LOGFILE
         echo "   "$p_CC  
502          if test "x$CC" = x ; then          if test "x$CC" = x ; then
503              CC=`echo $p_CC | $AWK '{print $1}'`              CC=`echo $p_CC | $AWK '{print $1}'`
504              echo "  Setting C compiler to: "$CC              echo "  Setting C compiler to: "$CC
505          fi          fi
506      fi      fi
507        echo " --> set CC='$CC'" >> $LOGFILE
508    }
509    
510    # Guess possible config options for this host
511    find_possible_optfile()  {
512    
513        echo >> $LOGFILE
514        echo "running: find_possible_optfile()" >> $LOGFILE
515        tmp1=`uname`"_"`uname -m`
516        tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
517        tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
518        tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
519        tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
520        tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
521        PLATFORM=$tmp3
522        echo $PLATFORM | grep cygwin > /dev/null 2>&1  &&  PLATFORM=cygwin_ia32
523        OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
524        echo "  The platform appears to be:  $PLATFORM" | tee -a $LOGFILE
525    
526      #================================================================      #================================================================
527      #  look for possible FORTRAN compilers      #  look for possible FORTRAN compilers
528      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 gfortran"      echo "  look for possible FORTRAN compilers" >> $LOGFILE
529        tmp="$MITGCM_FC $FC efc gfortran g77 f77 pgf77 pgf95 ifc ifort f90 f95 mpif77 mpf77 mpxlf95 g95"
530      p_FC=      p_FC=
531      for c in $tmp ; do      rm -f ./genmake_hello.f
532          rm -f ./hello.f ./hello      cat >> genmake_hello.f <<EOF
         cat >> hello.f <<EOF  
533        program hello        program hello
534        do i=1,3        do i=1,3
535          print *, 'hello world : ', i          print *, 'hello world : ', i
536        enddo        enddo
537        end        end
538  EOF  EOF
539          $c -o hello hello.f > /dev/null 2>&1      for f in $tmp ; do
540            COMM="$f -o genmake_hello genmake_hello.f"
541            echo $COMM >> $LOGFILE
542            $COMM >> $LOGFILE 2>&1
543          RETVAL=$?          RETVAL=$?
544          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
545              p_FC="$p_FC $c"              echo " $f test successful" >> $LOGFILE
546                p_FC="$p_FC $f"
547          fi          fi
548      done      done
549      rm -f ./hello.f ./hello      rm -f ./genmake_hello.f ./genmake_hello
550      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
551          cat 1>&2 <<EOF          cat 1>&2 <<EOF
552    
# Line 351  Error: No Fortran compilers were found i Line 559  Error: No Fortran compilers were found i
559  EOF  EOF
560          exit 1          exit 1
561      else      else
562          echo "  The possible FORTRAN compilers found in your path are:"          echo "  The possible FORTRAN compilers found in your path are: $p_FC" | tee -a $LOGFILE
         echo "   "$p_FC  
563      fi      fi
564    
565      #  Use the first of the compilers found in the current PATH      #  Use the first of the compilers found in the current PATH
# Line 361  EOF Line 568  EOF
568          for i in $p_FC ; do          for i in $p_FC ; do
569              OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i              OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
570              if test -r $OPTFILE ; then              if test -r $OPTFILE ; then
571                  echo "  Setting OPTFILE to: "$OPTFILE                  echo "  Setting OPTFILE to: "$OPTFILE | tee -a $LOGFILE
572                  break                  break
573              fi              fi
574          done          done
# Line 370  EOF Line 577  EOF
577      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
578          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
579          if test ! -r $OPTFILE ; then          if test ! -r $OPTFILE ; then
580               echo "  I looked for the file "$OPTFILE" but did not find it"               echo "  I looked for the file "$OPTFILE" but did not find it"
581          fi          fi
582      fi      fi
583  #    echo "  The options file:  $p_OF"  
 #    echo "    appears to match so we'll use it."  
 #   for i in $p_FC ; do  
 #p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i  
 #if test -r $p_OF ; then  
 #    OPTFILE=$p_OF  
 #    echo "  The options file:  $p_OF"  
 #    echo "    appears to match so we'll use it."  
 #    break  
 #fi  
 #   done  
584      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
585          cat 1>&2 <<EOF          cat 1>&2 <<EOF
586    
# Line 399  Error: No options file was found in:  $R Line 596  Error: No options file was found in:  $R
596  EOF  EOF
597          exit 1          exit 1
598      fi      fi
599        
600  #     # look for possible MPI libraries  #     # look for possible MPI libraries
601  #     mpi_libs=  #     mpi_libs=
602  #     mpi_fort=`which mpif77 2>/dev/null`  #     mpi_fort=`which mpif77 2>/dev/null`
# Line 418  EOF Line 615  EOF
615  #       if test "x${RETVAL}" = x0 ; then  #       if test "x${RETVAL}" = x0 ; then
616  #           a=`cat out`  #           a=`cat out`
617  #           for i in $a ; do  #           for i in $a ; do
618  #               case $i in  #               case $i in
619  #                   -*)  #                   -*)
620  #                       mpi_libs="$mpi_libs $i" ;;  #                       mpi_libs="$mpi_libs $i" ;;
621  #               esac  #               esac
# Line 428  EOF Line 625  EOF
625  #       fi  #       fi
626  #       rm -f test.f out  #       rm -f test.f out
627  #     fi  #     fi
   
628  }  }
629    
630  #  Parse the package dependency information  #  Parse the package dependency information
# Line 437  get_pdepend_list()  { Line 633  get_pdepend_list()  {
633      #  strip the comments and then convert the dependency file into      #  strip the comments and then convert the dependency file into
634      #  two arrays: PNAME, DNAME      #  two arrays: PNAME, DNAME
635      cat $1 | sed -e 's/#.*$//g' \      cat $1 | sed -e 's/#.*$//g' \
636          | $AWK 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \          | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
637          > ./.pd_tmp          > ./.pd_tmp
638        RETVAL=$?
639        if test ! "x${RETVAL}" = x0 ; then
640          echo "Error: unable to parse package dependencies -- please check PKG_DEPEND=\"$1\""
641          exit 1
642        fi
643      . ./.pd_tmp      . ./.pd_tmp
644      rm -f ./.pd_tmp      rm -f ./.pd_tmp
   
     printf "PNAME = "${}  
 }  
   
   
 #  Explain usage  
 usage()  {  
 cat <<EOF  
   
 Usage: "$0" [OPTIONS]  
   where [OPTIONS] can be:  
   
     -help | --help | -h | --h  
           Print this help message and exit.  
   
     -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME  
       -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME  
           Use "NAME" as the adoptfile.  By default, the file at  
           "tools/adjoint_options/adjoint_default" will be used.  
   
     -nooptfile | --nooptfile  
       -optfile NAME | --optfile NAME | -of NAME | --of NAME  
       -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME  
           Use "NAME" as the optfile.  By default, an attempt will be  
           made to find an appropriate "standard" optfile in the  
           tools/build_options/ directory.  
   
     -pdepend NAME | --pdepend NAME  
       -pdepend=NAME | --pdepend=NAME  
           Get package dependency information from "NAME".  
   
     -pdefault NAME | --pdefault NAME  
       -pdefault=NAME | --pdefault=NAME  
           Get the default package list from "NAME".  
   
     -make NAME | -m NAME  
       --make=NAME | -m=NAME  
           Use "NAME" for the MAKE program. The default is "make" but  
           many platforms, "gmake" is the preferred choice.  
   
     -makefile NAME | -mf NAME  
       --makefile=NAME | -mf=NAME  
           Call the makefile "NAME".  The default is "Makefile".  
   
     -makedepend NAME | -md NAME  
       --makedepend=NAME | -md=NAME  
           Use "NAME" for the MAKEDEPEND program.  
   
     -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME  
       -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME  
           Specify the location of the MITgcm ROOTDIR as "NAME".  
           By default, genamke will try to find the location by  
           looking in parent directories (up to the 5th parent).  
   
     -mods NAME | --mods NAME | -mo NAME | --mo NAME  
       -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME  
           Here, "NAME" specifies a list of directories that are  
           used for additional source code.  Files found in the  
           "mods list" are given preference over files of the same  
           name found elsewhere.  
   
     -disable NAME | --disable NAME  
       -disable=NAME | --disable=NAME  
           Here "NAME" specifies a list of packages that we don't  
           want to use.  If this violates package dependencies,  
           genamke will exit with an error message.  
   
     -enable NAME | --enable NAME  
       -enable=NAME | --enable=NAME  
           Here "NAME" specifies a list of packages that we wish  
           to specifically enable.  If this violates package  
           dependencies, genamke will exit with an error message.  
   
     -standarddirs NAME | --standarddirs NAME  
       -standarddirs=NAME | --standarddirs=NAME  
           Here, "NAME" specifies a list of directories to be  
           used as the "standard" code.  
   
     -fortran NAME | --fortran NAME | -fc NAME | --fc NAME  
       -fc=NAME | --fc=NAME  
           Use "NAME" as the fortran compiler.  By default, genmake  
           will search for a working compiler by trying a list of  
           "usual suspects" such as g77, f77, etc.  
   
     -cc NAME | --cc NAME | -cc=NAME | --cc=NAME  
           Use "NAME" as the C compiler.  By default, genmake  
           will search for a working compiler by trying a list of  
           "usual suspects" such as gcc, c89, cc, etc.  
   
     -[no]ieee | --[no]ieee  
           Do or don't use IEEE numerics.  Note that this option  
           *only* works if it is supported by the OPTFILE that  
           is being used.  
   
     -ts | --ts  
           Produce timing information per timestep  
     -papis | --papis  
           Produce summary MFlop/s with PAPI per timestep  
     -foolad | --foolad  
           Fool the AD code generator  
     -papi | --papi  
           Performance analysis with PAPI  
     -hpmt | --hpmt  
           Performance analysis with the HPM Toolkit  
   
     -gsl | --gsl  
           Use GSL to control floating point rounding and precision  
   
     -mpi | --mpi  
           Include MPI header files and link to MPI libraries  
     -mpi=PATH | --mpi=PATH  
           Include MPI header files and link to MPI libraries using MPI_ROOT  
           set to PATH. i.e. Include files from \$PATH/include, link to libraries  
           from \$PATH/lib and use binaries from \$PATH/bin.  
   
     -bash NAME  
           Explicitly specify the Bourne or BASH shell to use  
   
   While it is most often a single word, the "NAME" variables specified  
   above can in many cases be a space-delimited string such as:  
   
     --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'  
     -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'  
     -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'  
   
   which, depending upon your shell, may need to be single-quoted.  
   
   For more detailed genmake documentation, please see:  
   
     http://mitgcm.org/devel_HOWTO/  
   
 EOF  
   
     exit 1  
645  }  }
646    
647  #  Build a CPP macro to automate calling C routines from FORTRAN  #  Build a CPP macro to automate calling C routines from FORTRAN
# Line 582  get_fortran_c_namemangling()  { Line 649  get_fortran_c_namemangling()  {
649    
650      #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""      #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
651      if test ! "x$FC_NAMEMANGLE" = x ; then      if test ! "x$FC_NAMEMANGLE" = x ; then
652          return 0          return 0
653      fi      fi
654        echo " running: get_fortran_c_namemangling()" >> $LOGFILE
655    
656      default_nm="#define FC_NAMEMANGLE(X) X ## _"      default_nm="#define FC_NAMEMANGLE(X) X ## _"
657        
658      cat > genmake_test.c <<EOF      cat > genmake_test.c <<EOF
659  void tcall( char * string ) { tsub( string ); }  void tcall( char * string ) { tsub( string ); }
660  EOF  EOF
661      $MAKE genmake_test.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_test.c"
662        echo ' '$COMM >> $LOGFILE
663        $COMM >> $LOGFILE 2>&1
664      RETVAL=$?      RETVAL=$?
665      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
666          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
667          cat <<EOF>> genmake_errors          cat <<EOF>> $LOGFILE
668    
669  WARNING: C test compile fails   WARNING: C test compile fails
670  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
671  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
672  EOF  EOF
673          return 1          return 1
674      fi      fi
# Line 606  EOF Line 676  EOF
676      RETVAL=$?      RETVAL=$?
677      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
678          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
679          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
680    
681  WARNING: The "nm" command failed.   WARNING: The "nm" command failed.
682  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
683  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
684  EOF  EOF
685          return 1          return 1
686      fi      fi
# Line 620  EOF Line 690  EOF
690        call tsub( string )        call tsub( string )
691        end        end
692  EOF  EOF
693      $FC $FFLAGS -c genmake_tcomp.$FS >> genmake_warnings 2>&1      COMM="$FC $FFLAGS -c genmake_tcomp.$FS"
694        echo ' '$COMM >> $LOGFILE
695        $COMM >> $LOGFILE 2>&1
696      RETVAL=$?      RETVAL=$?
697      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
698          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
699          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
700    
701  WARNING: FORTRAN test compile fails -- please see "genmake_errors"   WARNING: FORTRAN test compile fails -- please see '$LOGFILE'
702  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
703  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
704  EOF  EOF
705          return 1          return 1
706      fi      fi
# Line 636  EOF Line 708  EOF
708      RETVAL=$?      RETVAL=$?
709      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
710          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
711          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
712    
713  WARNING: The "nm" command failed.   WARNING: The "nm" command failed.
714  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
715  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
716  EOF  EOF
717          return 1          return 1
718      fi      fi
# Line 666  EOF Line 738  EOF
738    
739      #  cleanup the testing files      #  cleanup the testing files
740      rm -f genmake_tcomp.* genmake_test.*      rm -f genmake_tcomp.* genmake_test.*
 }  
741    
742        echo " --> set FC_NAMEMANGLE='$FC_NAMEMANGLE'" >> $LOGFILE
743    }
744    
745  check_HAVE_CLOC()  {  check_HAVE_CLOC()  {
746        echo >> $LOGFILE
747        echo "running: check_HAVE_CLOC()" >> $LOGFILE
748      get_fortran_c_namemangling      get_fortran_c_namemangling
749      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
750  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 686  void FC_NAMEMANGLE(cloc) ( double *curti Line 761  void FC_NAMEMANGLE(cloc) ( double *curti
761   *curtim = *curtim/1.E6;   *curtim = *curtim/1.E6;
762  }  }
763  EOF  EOF
764      make genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
765        echo $COMM >> $LOGFILE
766        $COMM >> $LOGFILE 2>&1
767      RET_C=$?      RET_C=$?
768      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
769        program hello        program hello
# Line 696  EOF Line 773  EOF
773        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
774        end        end
775  EOF  EOF
776      $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
777        echo $COMM >> $LOGFILE
778        $COMM >> $LOGFILE 2>&1
779      RET_F=$?      RET_F=$?
780      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> $LOGFILE 2>&1
781      RETVAL=$?      RETVAL=$?
782      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
783          HAVE_CLOC=t          HAVE_CLOC=t
         DEFINES="$DEFINES -DHAVE_CLOC"  
784      fi      fi
785      rm -f genmake_tc*      rm -f genmake_tc*
786        echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE
787  }  }
788    
   
789  check_HAVE_SIGREG()  {  check_HAVE_SIGREG()  {
790        if test ! "x$HAVE_SIGREG" = x ; then
791            return
792        fi
793        echo >> $LOGFILE
794        echo "running: check_HAVE_SIGREG()" >> $LOGFILE
795      get_fortran_c_namemangling      get_fortran_c_namemangling
796      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
797  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 740  void FC_NAMEMANGLE(sigreg) (int * aip) Line 823  void FC_NAMEMANGLE(sigreg) (int * aip)
823      return;      return;
824  }  }
825  EOF  EOF
826      make genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
827        echo $COMM >> $LOGFILE
828        $COMM >> $LOGFILE 2>&1
829      RET_C=$?      RET_C=$?
830      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
831        program hello        program hello
# Line 750  EOF Line 835  EOF
835        call sigreg(anint)        call sigreg(anint)
836        end        end
837  EOF  EOF
838      echo >> genmake_warnings      cat genmake_tc_2.$FS >> $LOGFILE
     echo "running: check_HAVE_SIGREG()" >> genmake_warnings  
     cat genmake_tc_2.$FS >> genmake_warnings  
839      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
840      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
841      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
842      RETVAL=$?      RETVAL=$?
843      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
844          HAVE_SIGREG=t          HAVE_SIGREG=t
         DEFINES="$DEFINES -DHAVE_SIGREG"  
845      fi      fi
846      rm -f genmake_tc*      rm -f genmake_tc*
847        echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE
848  }  }
849    
   
850  check_HAVE_SETRLSTK()  {  check_HAVE_SETRLSTK()  {
851        if test ! "x$HAVE_SETRLSTK" = x ; then
852            return
853        fi
854        echo >> $LOGFILE
855        echo "running: check_HAVE_SETRLSTK()" >> $LOGFILE
856      get_fortran_c_namemangling      get_fortran_c_namemangling
857      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
858  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 781  void FC_NAMEMANGLE(setrlstk) () Line 868  void FC_NAMEMANGLE(setrlstk) ()
868      return;      return;
869  }  }
870  EOF  EOF
871      make genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
872        echo $COMM >> $LOGFILE
873        $COMM >> $LOGFILE 2>&1
874      RET_C=$?      RET_C=$?
875      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
876        program hello        program hello
# Line 789  EOF Line 878  EOF
878        call setrlstk()        call setrlstk()
879        end        end
880  EOF  EOF
881      echo >> genmake_warnings      cat genmake_tc_2.$FS >> $LOGFILE
     echo "running: check_HAVE_SETRLSTK()" >> genmake_warnings  
     cat genmake_tc_2.$FS >> genmake_warnings  
882      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
883      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
884      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
885      RETVAL=$?      RETVAL=$?
886      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
887          HAVE_SETRLSTK=t          HAVE_SETRLSTK=t
         DEFINES="$DEFINES -DHAVE_SETRLSTK"  
888      fi      fi
889      rm -f genmake_tc*      rm -f genmake_tc*
890        echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE
891  }  }
892    
   
893  check_HAVE_STAT()  {  check_HAVE_STAT()  {
894        echo >> $LOGFILE
895        echo "running: check_HAVE_STAT()" >> $LOGFILE
896      get_fortran_c_namemangling      get_fortran_c_namemangling
897      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
898  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 825  void FC_NAMEMANGLE(tfsize) ( int *nbyte Line 913  void FC_NAMEMANGLE(tfsize) ( int *nbyte
913          *nbyte = -1;          *nbyte = -1;
914  }  }
915  EOF  EOF
916      make genmake_tc_1.o >> genmake_tc.log 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
917        echo $COMM >> $LOGFILE
918        $COMM >> genmake_tc.log 2>&1
919      RET_C=$?      RET_C=$?
920      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
921        program hello        program hello
# Line 834  EOF Line 924  EOF
924        print *," HELLO WORLD", nbyte        print *," HELLO WORLD", nbyte
925        end        end
926  EOF  EOF
927      echo >> genmake_warnings      cat genmake_tc_2.$FS >> $LOGFILE
     echo "running: check_HAVE_STAT()" >> genmake_warnings  
     cat genmake_tc_2.$FS >> genmake_warnings  
928      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
929      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
930      $COMM >> genmake_tc.log 2>&1      $COMM >> genmake_tc.log 2>&1
931      RETVAL=$?      RETVAL=$?
932      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
933          HAVE_STAT=t          HAVE_STAT=t
         DEFINES="$DEFINES -DHAVE_STAT"  
934      fi      fi
935      rm -f genmake_tc*      rm -f genmake_tc*
936        echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE
937  }  }
938    
   
939  check_netcdf_libs()  {  check_netcdf_libs()  {
940      if test ! "x$SKIP_NETCDF_CHECK" = x ; then      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
941          return          return
942      fi      fi
943      echo >> genmake_warnings      echo >> $LOGFILE
944      echo "running: check_netcdf_libs()" >> genmake_warnings      echo "running: check_netcdf_libs()" >> $LOGFILE
945      cat <<EOF > genmake_tnc.F      cat <<EOF > genmake_tnc.F
946        program fgennc        program fgennc
947  #include "netcdf.inc"  #include "netcdf.inc"
# Line 872  EOF Line 959  EOF
959        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
960        end        end
961  EOF  EOF
962      echo "===  genmake_tnc.F  ===" > genmake_tnc.log      echo "===  genmake_tnc.F  >>>" > genmake_tnc.log
963      cat genmake_tnc.F >> genmake_tnc.log      cat genmake_tnc.F >> genmake_tnc.log
964      echo "===  genmake_tnc.F  ===" >> genmake_tnc.log      echo "<<<  genmake_tnc.F  ===" >> genmake_tnc.log
965      RET_CPP=f      RET_CPP=f
966      COMM="$CPP $DEFINES $INCLUDES genmake_tnc.F"      COMM="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES"
967      echo "$COMM" >> genmake_tnc.log      echo "$COMM" >> genmake_tnc.log
968      $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t      eval $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t
969      if test "x$RET_CPP" = xf ; then      if test "x$RET_CPP" = xf ; then
970          echo "  WARNING: CPP failed to pre-process the netcdf test." \          echo "  WARNING: CPP failed to pre-process the netcdf test." \
971              >> genmake_tnc.log              >> genmake_tnc.log
# Line 886  EOF Line 973  EOF
973              >> genmake_tnc.log              >> genmake_tnc.log
974      fi      fi
975      echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log      echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log
976      echo "  &&  $LINK -o genmake_tnc.o $LIBS" >> genmake_tnc.log      echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc.o $LIBS" >> genmake_tnc.log
977      $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \      $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
978          &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1          &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
979      RET_COMPILE=$?      RET_COMPILE=$?
980      cat genmake_tnc.log >> genmake_warnings      cat genmake_tnc.log >> $LOGFILE
981    
982      #EH3  Remove test program execution for machines that either disallow      #EH3  Remove test program execution for machines that either disallow
983      #EH3  execution or cannot support it (eg. cross-compilers)      #EH3  execution or cannot support it (eg. cross-compilers)
# Line 901  EOF Line 988  EOF
988    
989      if test "x$RET_COMPILE" = x0 ; then      if test "x$RET_COMPILE" = x0 ; then
990          HAVE_NETCDF=t          HAVE_NETCDF=t
991            echo "check_netcdf: successful" >> $LOGFILE
992      else      else
993          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
994          echo "try again with added '-lnetcdf'" > genmake_tnc.log          echo "==> try again with added '-lnetcdf'" > genmake_tnc.log
995          echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log          echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
996          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
997          echo " &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log          echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
998          $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \          cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null  \
999              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
1000              &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1              &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
1001          RET_COMPILE=$?          RET_COMPILE=$?
1002          cat genmake_tnc.log >> genmake_warnings          echo >> $LOGFILE
1003            cat genmake_tnc.log >> $LOGFILE
1004          if test "x$RET_COMPILE" = x0 ; then          if test "x$RET_COMPILE" = x0 ; then
1005              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
1006              HAVE_NETCDF=t              HAVE_NETCDF=t
1007                echo "check_netcdf: successful" >> $LOGFILE
1008            else
1009            # try again with "-lnetcdff" added to the libs
1010                echo "==> try again with added '-lnetcdff -lnetcdf'" > genmake_tnc.log
1011                echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
1012                echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
1013                echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
1014                cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null  \
1015                    &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
1016                    &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdff -lnetcdf >> genmake_tnc.log 2>&1
1017                RET_COMPILE=$?
1018                echo >> $LOGFILE
1019                cat genmake_tnc.log >> $LOGFILE
1020                if test "x$RET_COMPILE" = x0 ; then
1021                    LIBS="$LIBS -lnetcdff -lnetcdf"
1022                    HAVE_NETCDF=t
1023                    echo "check_netcdf: successful" >> $LOGFILE
1024                fi
1025          fi          fi
1026      fi      fi
1027      rm -f genmake_tnc*      rm -f genmake_tnc*
1028        echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE
1029  }  }
1030    
1031    check_lapack_libs()  {
1032        if test ! "x$SKIP_LAPACK_CHECK" = x ; then
1033            return
1034        fi
1035        echo >> $LOGFILE
1036        echo "running: check_lapack_libs()" >> $LOGFILE
1037        cat <<EOF > genmake_tla.F
1038          program fgenla
1039          integer info
1040          integer ipiv( 2 )
1041          double precision ab( 4, 2 ), b( 2 )
1042          data ab / 0., 0., 1., 2., 0., 2., 1., 0. /
1043          data b / 1., 1. /
1044          call dgbsv( 2, 1, 1, 1, ab, 4, ipiv, b, 2, info )
1045          IF (info .NE. 0) write(*,*) 'Error:', info
1046          write(*,*) b
1047          end
1048    EOF
1049        echo "===  genmake_tla.F  >>>" > genmake_tla.log
1050        cat genmake_tla.F >> genmake_tla.log
1051        echo "<<<  genmake_tla.F  ===" >> genmake_tla.log
1052        RET_CPP=f
1053        COMM="cat genmake_tla.F | $CPP $DEFINES $INCLUDES"
1054        echo "$COMM" >> genmake_tla.log
1055        eval $COMM > genmake_tla.$FS 2>/dev/null  &&  RET_CPP=t
1056        if test "x$RET_CPP" = xf ; then
1057            echo "  WARNING: CPP failed to pre-process the lapack test." \
1058                >> genmake_tla.log
1059            echo "    Please check that \$INCLUDES is properly set." \
1060                >> genmake_tla.log
1061        fi
1062        echo "$FC $FFLAGS $FOPTIM -c genmake_tla.$FS  \ " >> genmake_tla.log
1063        echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tla.o $LIBS" >> genmake_tla.log
1064        $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1065            &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS >> genmake_tla.log 2>&1
1066        RET_COMPILE=$?
1067        cat genmake_tla.log >> $LOGFILE
1068    
1069        # test program execution not always possible (see check_netcdf_libs)
1070        #
1071        #test -x ./genmake_tla  &&  ./genmake_tla >> genmake_tla.log 2>&1
1072        #RETVAL=$?
1073        #if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
1074    
1075        if test "x$RET_COMPILE" = x0 ; then
1076            HAVE_LAPACK=t
1077            echo "check_lapack: successful" >> $LOGFILE
1078        else
1079            # try again with "-llapack" added to the libs
1080            echo "==> try again with added '-llapack'" > genmake_tla.log
1081            echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1082            echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1083            echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack" >> genmake_tla.log
1084            cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1085                &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1086                &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack >> genmake_tla.log 2>&1
1087            RET_COMPILE=$?
1088            echo >> $LOGFILE
1089            cat genmake_tla.log >> $LOGFILE
1090            if test "x$RET_COMPILE" = x0 ; then
1091                LIBS="$LIBS -llapack"
1092                HAVE_LAPACK=t
1093                echo "check_lapack: successful" >> $LOGFILE
1094            else
1095            # try again with "-lf77blas -lcblas" added to the libs
1096                echo "==> try again with added '-llapack -lf77blas -lcblas'" > genmake_tla.log
1097                echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1098                echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1099                echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas" >> genmake_tla.log
1100                cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1101                    &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1102                    &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas >> genmake_tla.log 2>&1
1103                RET_COMPILE=$?
1104                echo >> $LOGFILE
1105                cat genmake_tla.log >> $LOGFILE
1106                if test "x$RET_COMPILE" = x0 ; then
1107                    LIBS="$LIBS -llapack -lf77blas -lcblas"
1108                    HAVE_LAPACK=t
1109                    echo "check_lapack: successful" >> $LOGFILE
1110                else
1111                # try again with "-latlas" added to the libs
1112                    echo "==> try again with added '-llapack -lf77blas -lcblas -latlas'" > genmake_tla.log
1113                    echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1114                    echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1115                    echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas" >> genmake_tla.log
1116                    cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1117                        &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1118                        &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas >> genmake_tla.log 2>&1
1119                    RET_COMPILE=$?
1120                    echo >> $LOGFILE
1121                    cat genmake_tla.log >> $LOGFILE
1122                    if test "x$RET_COMPILE" = x0 ; then
1123                        LIBS="$LIBS -llapack -lf77blas -lcblas -latlas"
1124                        HAVE_LAPACK=t
1125                        echo "check_lapack: successful" >> $LOGFILE
1126                    fi
1127                fi
1128            fi
1129        fi
1130        rm -f genmake_tla*
1131        echo " --> set HAVE_LAPACK='$HAVE_LAPACK'" >> $LOGFILE
1132    }
1133    
1134    
1135  ###############################################################################  ###############################################################################
# Line 943  ENABLE= Line 1153  ENABLE=
1153  DISABLE=  DISABLE=
1154  # MAKEFILE=  # MAKEFILE=
1155  # MAKEDEPEND=  # MAKEDEPEND=
1156  PDEPEND=  PKG_DEPEND=
1157  DUMPSTATE=t  PKG_GROUPS=
1158  PDEFAULT=  DUMPSTATE=f
1159  OPTFILE=  OPTFILE=
1160  INCLUDES="-I. $INCLUDES"  INCLUDES="-I. $INCLUDES"
1161  FFLAGS=  FFLAGS=
1162  FOPTIM=  FOPTIM=
1163    FEXTRAFLAGS=
1164    USE_EXTENDED_SRC=
1165    EXTENDED_SRC_FLAG=
1166    GET_FC_VERSION=
1167  CFLAGS=  CFLAGS=
1168  KFLAGS1=  KFLAGS1=
1169  KFLAGS2=  KFLAGS2=
# Line 960  NOOPTFILES= Line 1174  NOOPTFILES=
1174  NOOPTFLAGS=  NOOPTFLAGS=
1175  MPI=  MPI=
1176  MPIPATH=  MPIPATH=
1177    OMP=
1178    OMPFLAG=
1179    USE_R4=
1180  TS=  TS=
1181  PAPIS=  PAPIS=
1182    PCLS=
1183  FOOLAD=  FOOLAD=
1184  PAPI=  PAPI=
1185    PCL=
1186  HPMT=  HPMT=
1187  GSL=  GSL=
1188    DEVEL=
1189  HAVE_TEST_L=  HAVE_TEST_L=
1190    
1191  # DEFINES checked by test compilation or command-line  # DEFINES checked by test compilation or command-line
# Line 973  HAVE_SYSTEM= Line 1193  HAVE_SYSTEM=
1193  HAVE_FDATE=  HAVE_FDATE=
1194  FC_NAMEMANGLE=  FC_NAMEMANGLE=
1195  HAVE_CLOC=  HAVE_CLOC=
1196  HAVE_SETRLSTK=  # HAVE_SETRLSTK=
1197  HAVE_STAT=  HAVE_STAT=
1198  HAVE_NETCDF=  HAVE_NETCDF=
1199  HAVE_ETIME=  HAVE_ETIME=
1200  IGNORE_TIME=  IGNORE_TIME=
1201    HAVE_LAPACK=
1202    
1203  MODS=  MODS=
1204  TOOLSDIR=  TOOLSDIR=
# Line 985  SOURCEDIRS= Line 1206  SOURCEDIRS=
1206  INCLUDEDIRS=  INCLUDEDIRS=
1207  STANDARDDIRS="USE_THE_DEFAULT"  STANDARDDIRS="USE_THE_DEFAULT"
1208    
1209    #- local config file
1210    gm_local="genmake_local"
1211    
1212  G2ARGS=  G2ARGS=
1213  BASH=  BASH=
1214  PWD=`pwd`  PWD=`pwd`
1215  test "x$MAKE" = x  &&  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
1216  test "x$AWK" = x   &&  AWK=awk  test "x$AWK" = x   &&  AWK=awk
1217    EMBED_SRC=
1218  THISHOST=`hostname`  THISHOST=`hostname`
1219  THISCWD=`pwd`  THISCWD=`pwd`
1220  THISDATE=`date`  THISDATE=`date`
# Line 999  MACHINE=`uname -a` Line 1224  MACHINE=`uname -a`
1224  EXECUTABLE=  EXECUTABLE=
1225  EXEHOOK=  EXEHOOK=
1226  EXEDIR=  EXEDIR=
 PACKAGES_CONF=  
1227  IEEE=  IEEE=
1228  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
1229      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
# Line 1020  FTL_TAF_FLAGS= Line 1244  FTL_TAF_FLAGS=
1244  SVD_TAMC_FLAGS=  SVD_TAMC_FLAGS=
1245  TAMC_EXTRA=  TAMC_EXTRA=
1246    
   
1247  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1248  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PKG_DEPEND PKG_GROUPS DISABLE ENABLE MAKEFILE MAKEDEPEND PLATFORM"
1249  gm_s2="FC CPP IEEE TS PAPIS PAPI HPMT GSL MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CC MPI OMP USE_R4 TS PAPIS PCLS PAPI PCL HPMT IEEE DEVEL GSL FEXTRAFLAGS"
1250    gm_s3="ROOTDIR STANDARDDIRS MODS DUMPSTATE"
1251    
1252  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1253  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "  gm_s4="LN S64 LINK MAKE PACKAGES INCLUDES FFLAGS FOPTIM"
1254  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
1255  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"  gm_s6="TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"
1256  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s7="PWD THISHOST THISUSER THISDATE THISVER MACHINE"
1257  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"  gm_s8="FC_NAMEMANGLE HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME HAVE_LAPACK"
1258    
1259  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1260  gm_s10="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"
1261  gm_s11="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"
1262  gm_s12="TAF_EXTRA TAMC_EXTRA"  gm_s12="TAF_EXTRA TAMC_EXTRA"
1263    
1264  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7"  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8"
1265  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
1266    
1267  cat <<EOF  cat <<EOF
1268    
1269  GENMAKE :  GENMAKE :
1270    
1271  A program for GENerating MAKEfiles for the MITgcm project.  For a  A program for GENerating MAKEfiles for the MITgcm project.
1272  quick list of options, use "genmake -h" or for more detail see:     For a quick list of options, use "genmake2 -h"
1273    or for more detail see the Developer's HOWTO manual at:
1274    http://mitgcm.org/devel_HOWTO/     http://mitgcm.org/public/docs.html
1275    
1276  EOF  EOF
1277    
1278    LOGFILE="genmake.log"
1279    #- clean-up previous genmake logfiles:
1280    rm -f genmake_state genmake_*optfile $LOGFILE
1281    
1282  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
 gm_local="genmake_local"  
 for i in . $MODS ; do  
     if test -r $i/$gm_local ; then  
         . $i/$gm_local  
         break  
     fi  
 done  
 printf "  getting local config information:  "  
 if test -f $gm_local ; then  
     echo "using $gm_local"  
     . $gm_local  
     # echo "DISABLE=$DISABLE"  
     # echo "ENABLE=$ENABLE"  
 else  
     echo "none found"  
 fi  
1283    
1284  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
 #OPTIONS=  
 #n=0  
 #for i ; do  
 #   echo "$i  $n"  
 #   setvar="OPTIONS[$n]='$i'"  
 #   #  echo "  $setvar"  
 #   eval "$setvar"  
 #   n=$(( $n + 1 ))  
 #done  
1285  #parse_options  #parse_options
1286  ac_prev=  ac_prev=
1287  for ac_option in "$@" ; do  for ac_option in "$@" ; do
# Line 1091  for ac_option in "$@" ; do Line 1294  for ac_option in "$@" ; do
1294          ac_prev=          ac_prev=
1295          continue          continue
1296      fi      fi
1297        
1298      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
1299        
1300      case $ac_option in      case $ac_option in
1301            
1302          -help | --help | -h | --h)          -help | --help | -h | --h)
1303              usage ;;              usage ;;
1304            
1305          -nooptfile | --nooptfile)          -nooptfile | --nooptfile)
1306              OPTFILE="NONE" ;;              OPTFILE="NONE" ;;
1307          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
1308              ac_prev=OPTFILE ;;              ac_prev=OPTFILE ;;
1309          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
1310              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
1311            
1312          -adoptfile | --adoptfile | -adof | --adof)          -adoptfile | --adoptfile | -adof | --adof)
1313              ac_prev=AD_OPTFILE ;;              ac_prev=AD_OPTFILE ;;
1314          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
1315              AD_OPTFILE=$ac_optarg ;;              AD_OPTFILE=$ac_optarg ;;
1316            
1317          -pdepend | --pdepend)          -pdepend | --pdepend)
1318              ac_prev=PDEPEND ;;              ac_prev=PKG_DEPEND ;;
1319          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
1320              PDEPEND=$ac_optarg ;;              PKG_DEPEND=$ac_optarg ;;
1321            
1322          -pdefault | --pdefault)          -pgroups | --pgroups)
1323              ac_prev=PDEFAULT ;;              ac_prev=PKG_GROUPS ;;
1324          -pdefault=* | --pdefault=*)          -pgroups=* | --pgroups=*)
1325              PDEFAULT=$ac_optarg ;;              PKG_GROUPS=$ac_optarg ;;
1326            
1327          -make | --make | -m | --m)          -make | --make | -m | --m)
1328              ac_prev=MAKE ;;              ac_prev=MAKE ;;
1329          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
1330              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
1331            
1332          -bash | --bash)          -bash | --bash)
1333              ac_prev=BASH ;;              ac_prev=BASH ;;
1334          -bash=* | --bash=*)          -bash=* | --bash=*)
1335              BASH=$ac_optarg ;;              BASH=$ac_optarg ;;
1336            
1337          -makedepend | --makedepend | -md | --md)          -makedepend | --makedepend | -md | --md)
1338              ac_prev=MAKEDEPEND ;;              ac_prev=MAKEDEPEND ;;
1339          -makedepend=* | --makedepend=* | -md=* | --md=*)          -makedepend=* | --makedepend=* | -md=* | --md=*)
1340              MAKEDEPEND=$ac_optarg ;;              MAKEDEPEND=$ac_optarg ;;
1341            
1342          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -mf | --mf)
1343              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
1344          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -mf=* | --mf=*)
1345              MAKEFILE=$ac_optarg ;;              MAKEFILE=$ac_optarg ;;
1346            
1347          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)
1348              echo "ERROR: The platform option has been removed.  Please specify"              echo "ERROR: The platform option has been removed.  Please specify"
1349              echo "  the build options using the \"optfile\" mechanism."              echo "  the build options using the \"optfile\" mechanism."
1350              echo              echo
1351              usage              usage
1352              ;;              ;;
1353            
1354          -rootdir | --rootdir | -rd | --rd)          -rootdir | --rootdir | -rd | --rd)
1355              ac_prev=ROOTDIR ;;              ac_prev=ROOTDIR ;;
1356          -rootdir=* | --rootdir=* | -rd=* | --rd=*)          -rootdir=* | --rootdir=* | -rd=* | --rd=*)
1357              ROOTDIR=$ac_optarg ;;              ROOTDIR=$ac_optarg ;;
1358            
1359          -mods | --mods | -mo | --mo)          -mods | --mods | -mo | --mo)
1360              ac_prev=MODS ;;              ac_prev=MODS ;;
1361          -mods=* | --mods=* | -mo=* | --mo=*)          -mods=* | --mods=* | -mo=* | --mo=*)
1362              MODS=$ac_optarg ;;              MODS=$ac_optarg ;;
1363            
1364          -disable | --disable)          -disable | --disable)
1365              ac_prev=DISABLE ;;              ac_prev=DISABLE ;;
1366          -disable=* | --disable=*)          -disable=* | --disable=*)
1367              DISABLE=$ac_optarg ;;              DISABLE=$ac_optarg ;;
1368            
1369          -enable | --enable)          -enable | --enable)
1370              ac_prev=ENABLE ;;              ac_prev=ENABLE ;;
1371          -enable=* | --enable=*)          -enable=* | --enable=*)
1372              ENABLE=$ac_optarg ;;              ENABLE=$ac_optarg ;;
1373            
1374          -standarddirs | --standarddirs)          -standarddirs | --standarddirs)
1375              ac_prev=STANDARDDIRS ;;              ac_prev=STANDARDDIRS ;;
1376          -standarddirs=* | --standarddirs=*)          -standarddirs=* | --standarddirs=*)
# Line 1177  for ac_option in "$@" ; do Line 1380  for ac_option in "$@" ; do
1380  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1381  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1382  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1383            
1384          -cc | --cc)          -cc | --cc)
1385              ac_prev=CC ;;              ac_prev=CC ;;
1386          -cc=* | --cc=*)          -cc=* | --cc=*)
1387              CC=$ac_optarg ;;              CC=$ac_optarg ;;
1388            
1389          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1390              ac_prev=FC ;;              ac_prev=FC ;;
1391          -fc=* | --fc=*)          -fc=* | --fc=*)
1392              FC=$ac_optarg ;;              FC=$ac_optarg ;;
1393            
1394          -fs | --fs)          -fs | --fs)
1395              ac_prev=FS ;;              ac_prev=FS ;;
1396          -fs=* | --fs=*)          -fs=* | --fs=*)
1397              FS=$ac_optarg ;;              FS=$ac_optarg ;;
1398            
1399          -fs90 | --fs90)          -fs90 | --fs90)
1400              ac_prev=FS90 ;;              ac_prev=FS90 ;;
1401          -fs90=* | --fs90=*)          -fs90=* | --fs90=*)
1402              FS90=$ac_optarg ;;              FS90=$ac_optarg ;;
1403            
1404            -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )
1405                USE_R4=true ;;
1406    
1407          -ieee | --ieee)          -ieee | --ieee)
1408              IEEE=true ;;              IEEE=true ;;
1409          -noieee | --noieee)          -noieee | --noieee)
1410              IEEE= ;;              echo "Warning: ignore option '$ac_option' (default is already without '-ieee')" ;;
1411            -devel | --devel)
1412                IEEE=true ; DEVEL=true ;;
1413            -gsl | --gsl)
1414                GSL=true ;;
1415    
1416          -ts | --ts)          -ts | --ts)
1417              TS=true ;;              TS=true ;;
1418          -papis | --papis)          -papis | --papis)
1419              PAPIS=true ;;              PAPIS=true ;;
1420            -pcls | --pcls)
1421                PCLS=true ;;
1422          -foolad | --foolad)          -foolad | --foolad)
1423              FOOLAD=true ;;              FOOLAD=true ;;
1424          -papi | --papi)          -papi | --papi)
1425              PAPI=true ;;              PAPI=true ;;
1426            -pcl | --pcl)
1427                PCL=true ;;
1428          -hpmt | --hpmt)          -hpmt | --hpmt)
1429              HPMT=true ;;              HPMT=true ;;
1430    
         -gsl | --gsl)  
             GSL=true ;;  
   
1431          -mpi | --mpi)          -mpi | --mpi)
1432              MPI=true ;;              MPI=true ;;
1433          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
1434              MPIPATH=$ac_optarg              MPIPATH=$ac_optarg
1435              MPI=true ;;              MPI=true ;;
1436            
1437  #       -jam | --jam)          -omp | --omp)
1438  #           JAM=1 ;;              OMP=true ;;
1439  #       -nojam | --nojam)          -omp=* | --omp=*)
1440  #           JAM=0 ;;              OMPFLAG=$ac_optarg
1441                        OMP=true ;;
1442    
1443          -ds | --ds)          -ds | --ds)
1444              DUMPSTATE=t ;;              DUMPSTATE=t ;;
1445            
1446            -extra_flag | --extra_flag)
1447                ac_prev=FEXTRAFLAGS ;;
1448            -extra_flag=* | --extra_flag=*)
1449                FEXTRAFLAGS=$ac_optarg ;;
1450    
1451          -taf_extra | --taf_extra)          -taf_extra | --taf_extra)
1452              ac_prev=TAF_EXTRA ;;              ac_prev=TAF_EXTRA ;;
1453          -taf_extra=* | --taf_extra=*)          -taf_extra=* | --taf_extra=*)
# Line 1240  for ac_option in "$@" ; do Line 1457  for ac_option in "$@" ; do
1457              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1458          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1459              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1460            
1461          -ignoretime | -ignore_time | --ignoretime | --ignore_time)          -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1462              IGNORE_TIME="-DIGNORE_TIME" ;;              IGNORE_TIME="-DIGNORE_TIME" ;;
1463    
1464            -es | --es | -embed-source | --embed-source)
1465                EMBED_SRC=t ;;
1466    
1467          -*)          -*)
1468              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
1469              usage              usage
1470              ;;              ;;
1471            
1472          *)          *)
1473              echo "Error: unrecognized argument: "$ac_option              echo "Error: unrecognized argument: "$ac_option
1474              usage              usage
1475              ;;              ;;
1476            
1477      esac      esac
1478        
1479  done  done
1480    
1481    printf "  getting local config information:  "
1482    if test -f $gm_local ; then
1483        echo "using $gm_local"
1484        . $gm_local
1485    else
1486        echo "none found"
1487    fi
1488    
1489  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1490      echo      echo
1491      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
1492      echo "  file.  This file format is no longer supported.  Please see:"      echo "  file.  This file format is no longer supported.  For directions on"
1493      echo      echo "  how to setup and use the new \"genmake2\" script, please see:"
1494      echo "    http://mitgcm.org/devel_HOWTO/"      echo "    http://mitgcm.org/public/devel_HOWTO/"
1495        echo "  and send an email to MITgcm-support@mitgcm.org if you need help."
1496        echo "WARNING: ignore \"./.genmakerc\" and continue."
1497      echo      echo
     echo "  for directions on how to setup and use the new \"genmake2\" input"  
     echo "  files and send an email to MITgcm-support@mitgcm.org if you want help."  
     echo  
1498  fi  fi
1499    
1500  #  Find the MITgcm ${ROOTDIR}  #  Find the MITgcm ${ROOTDIR}
1501  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1502      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1503      if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesupp -a -d ../pkg ; then
1504          ROOTDIR=".."          ROOTDIR=".."
1505      else      else
1506          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
1507              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
1508                  ROOTDIR=$d                  ROOTDIR=$d
1509                  printf "Warning:  ROOTDIR was not specified but there appears to be"                  printf "Warning: ROOTDIR was not specified ;"
1510                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."                  echo " try using a local copy of MITgcm found at \"$ROOTDIR\""
1511                  break                  break
1512              fi              fi
1513          done          done
# Line 1299  if test ! -d ${ROOTDIR} ; then Line 1525  if test ! -d ${ROOTDIR} ; then
1525  fi  fi
1526    
1527  #  Find the MITgcm ${THISVER}  #  Find the MITgcm ${THISVER}
1528  if test -f "${ROOTDIR}/doc/tag-index" ; then  version_file="${ROOTDIR}/doc/tag-index"
1529      THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`  if test -f $version_file ; then
1530        THISVER=`$AWK '/^checkpoint/{print $1; exit}' $version_file`
1531    #-  remove ./BUILD_INFO.h file if older than version_file
1532        if test -f ./BUILD_INFO.h -a ./BUILD_INFO.h -ot $version_file ; then
1533            echo "  remove ./BUILD_INFO.h (older than ${version_file})"
1534            rm -f ./BUILD_INFO.h
1535        fi
1536  fi  fi
1537    
1538  if test "x$MAKEFILE" = x ; then  if test "x$MAKEFILE" = x ; then
1539      MAKEFILE="Makefile"      MAKEFILE="Makefile"
1540  fi  fi
1541    
1542  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:"
1543  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1544      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
1545          echo "Warning: no OPTFILE specified so we'll look for possible settings"          echo "Warning: no OPTFILE specified so we'll look for possible settings"
1546          printf "\n===  Searching for possible settings for OPTFILE  ===\n"          printf "\n===  Searching for possible settings for OPTFILE  ===\n"
1547          find_possible_configs          find_possible_optfile
1548      else      else
1549          OPTFILE=$MITGCM_OF          OPTFILE=$MITGCM_OF
1550      fi      fi
# Line 1327  if test "x$OPTFILE" != xNONE ; then Line 1559  if test "x$OPTFILE" != xNONE ; then
1559              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1560              exit 1              exit 1
1561          fi          fi
1562          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" = xt ; then
1563              cp -f $OPTFILE "genmake_optfile"              cp -f $OPTFILE "genmake_optfile"
1564          fi          fi
1565      else      else
# Line 1336  if test "x$OPTFILE" != xNONE ; then Line 1568  if test "x$OPTFILE" != xNONE ; then
1568      fi      fi
1569  fi  fi
1570    
1571  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:"
1572  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1573      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" = x ; then
1574          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
# Line 1354  if test "x${AD_OPTFILE}" != xNONE ; then Line 1586  if test "x${AD_OPTFILE}" != xNONE ; then
1586              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1587              exit 1              exit 1
1588          fi          fi
1589          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" = xt ; then
1590              cp -f $AD_OPTFILE "genmake_ad_optfile"              cp -f $AD_OPTFILE "genmake_ad_optfile"
1591          fi          fi
1592      else      else
# Line 1382  Error: no Fortran compiler: please speci Line 1614  Error: no Fortran compiler: please speci
1614  EOF  EOF
1615      exit 1      exit 1
1616  fi  fi
1617    if test "x$GET_FC_VERSION" != x ; then
1618      echo "Get compiler version using: $FC $GET_FC_VERSION" >> $LOGFILE
1619      ff=`echo $FC | sed 's/ .*//'` ; xx=`echo $ff | sed 's/^./& /' | sed 's/ .*//'`
1620      if test $xx != '/' ; then which $ff >> $LOGFILE ; fi
1621      $FC $GET_FC_VERSION > genmake_fc_vers1 2> genmake_fc_vers2
1622      if test -s genmake_fc_vers1 ; then
1623        cat genmake_fc_vers1 >> $LOGFILE
1624      else
1625        cat genmake_fc_vers2 >> $LOGFILE
1626      fi
1627      echo "<-- compiler version ----" >> $LOGFILE
1628      rm -f genmake_fc_vers1 genmake_fc_vers2
1629    fi
1630    
1631  if test "x$CC" = x ; then  if test "x$CC" = x ; then
1632      CC=cc      look_for_C_compilers
 #     cat <<EOF 1>&2  
 # Error: no C compiler: please specify using one of the following:  
 #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"  
 #   2) the "-cc=XXX" command-line option  
 #   3) the "./genmake_local" file  
 # EOF  
 #     exit 1  
1633  fi  fi
1634    
1635  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1636      LINK=$FC      LINK=$FC
1637  fi  fi
# Line 1399  if test "x$MAKE" = x ; then Line 1639  if test "x$MAKE" = x ; then
1639      MAKE="make"      MAKE="make"
1640  fi  fi
1641  if test "x$CPP" = x ; then  if test "x$CPP" = x ; then
1642      CPP=cpp      CPP="cpp -traditional -P"
1643  fi  fi
1644  #EH3 === UGLY ===  #EH3 === UGLY ===
1645  #  The following is an ugly little hack to check for $CPP in /lib/ and  #  The following is an ugly little hack to check for $CPP in /lib/ and
# Line 1426  EOF Line 1666  EOF
1666  else  else
1667      rm -f test_cpp      rm -f test_cpp
1668  fi  fi
1669    
1670  look_for_makedepend  look_for_makedepend
1671    
1672    #  Check that soft-link command is set and usable
1673  if test "x$LN" = x ; then  if test "x$LN" = x ; then
1674      LN="ln -s"      LN="ln -s"
1675  fi  fi
# Line 1436  RETVAL=$? Line 1679  RETVAL=$?
1679  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
1680      cat <<EOF 1>&2      cat <<EOF 1>&2
1681    
1682  Error: The command "ln -s" failed -- please specify a working soft-link  Error: The command "$LN" failed -- please specify a working soft-link
1683    command in the optfile.    command in the optfile.
1684    
1685  EOF  EOF
# Line 1456  if test ! "x$MPI" = x ; then Line 1699  if test ! "x$MPI" = x ; then
1699        echo "  Turning on MPI cpp macros"        echo "  Turning on MPI cpp macros"
1700        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1701  fi  fi
1702    if test ! "x$OMP" = x ; then
1703          echo "  Add OMPFLAG and turn on OpenMP cpp macros"
1704          FFLAGS="$FFLAGS $OMPFLAG"
1705          F90FLAGS="$F90FLAGS $OMPFLAG"
1706          DEFINES="$DEFINES -DUSE_OMP_THREADING"
1707    fi
1708    
1709    if test ! "x$USE_R4" = x ; then
1710          echo "  Turning on LET_RS_BE_REAL4 cpp flag"
1711          DEFINES="$DEFINES -DLET_RS_BE_REAL4"
1712    fi
1713    
1714  if test ! "x$TS" = x ; then  if test ! "x$TS" = x ; then
1715        echo "  Turning on timing per timestep"        echo "  Turning on timing per timestep"
1716        if test ! "x$FOOLAD" = x ; then        if test ! "x$FOOLAD" = x ; then
1717              DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"
1718        else        else
1719              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1720        fi        fi
1721          PACKAGES="$PACKAGES showflops"
1722  fi  fi
1723  if test ! "x$PAPIS" = x ; then  if test ! "x$PAPIS" = x ; then
1724        echo "  Turning on PAPI flop summary per timestep"        echo "  Turning on PAPI flop summary per timestep"
# Line 1475  if test ! "x$PAPIS" = x ; then Line 1730  if test ! "x$PAPIS" = x ; then
1730        fi        fi
1731        INCLUDES="$INCLUDES $PAPIINC"        INCLUDES="$INCLUDES $PAPIINC"
1732        LIBS="$LIBS $PAPILIB"        LIBS="$LIBS $PAPILIB"
1733          PACKAGES="$PACKAGES showflops"
1734    fi
1735    if test ! "x$PCLS" = x ; then
1736          echo "  Turning on PCL counter summary per timestep"
1737          echo "  Please make sure PCLINC, PCLLIB are defined"
1738          if test ! "x$FOOLAD" = x ; then
1739                DEFINES="$DEFINES -DUSE_PCL_FLOPS_SFP"
1740          else
1741                DEFINES="$DEFINES -DUSE_PCL_FLOPS"
1742          fi
1743          INCLUDES="$INCLUDES $PCLINC"
1744          LIBS="$LIBS $PCLLIB"
1745          PACKAGES="$PACKAGES showflops"
1746  fi  fi
1747  if test ! "x$PAPI" = x ; then  if test ! "x$PAPI" = x ; then
1748        if test ! "x$PAPIS" = x ; then        if test ! "x$PAPIS" = x ; then
# Line 1482  if test ! "x$PAPI" = x ; then Line 1750  if test ! "x$PAPI" = x ; then
1750            echo "  Sticking with PAPI flop summary per timestep!"            echo "  Sticking with PAPI flop summary per timestep!"
1751        else        else
1752            echo "  Turning on performance analysis with PAPI"            echo "  Turning on performance analysis with PAPI"
1753            echo "  Please make sure PAPIINC, PAPILIB are defined"            echo "  Please make sure PAPIINC, PAPILIB are defined"
1754            DEFINES="$DEFINES -DUSE_PAPI"            DEFINES="$DEFINES -DUSE_PAPI"
1755            INCLUDES="$INCLUDES $PAPIINC"            INCLUDES="$INCLUDES $PAPIINC"
1756            LIBS="$LIBS $PAPILIB"            LIBS="$LIBS $PAPILIB"
1757        fi        fi
1758  fi  fi
1759    if test ! "x$PCL" = x ; then
1760          if test ! "x$PCLS" = x ; then
1761              echo "  PCL performance analysis and flop summary per timestep cannot co-exist!"
1762              echo "  Sticking with PCL flop summary per timestep!"
1763          else
1764              echo "  Turning on performance analysis with PCL"
1765              echo "  Please make sure PCLINC, PCLLIB are defined"
1766              DEFINES="$DEFINES -DUSE_PCL"
1767              INCLUDES="$INCLUDES $PCLINC"
1768              LIBS="$LIBS $PCLLIB"
1769          fi
1770    fi
1771  if test ! "x$HPMT" = x ; then  if test ! "x$HPMT" = x ; then
1772        if test ! "x$PAPI" = x ; then        if test ! "x$PAPI" = x ; then
1773            echo "  PAPI and the HPM Toolkit cannot co-exist!"            echo "  PAPI and the HPM Toolkit cannot co-exist!"
1774            echo "  Sticking with PAPI!"            echo "  Sticking with PAPI!"
1775        else        else
1776            if test ! "x$PCL" = x ; then
1777              echo "  PCL and the HPM Toolkit cannot co-exist!"
1778              echo "  Sticking with PCL!"
1779            else
1780            echo "  Turning on performance analysis with the HPM Toolkit"            echo "  Turning on performance analysis with the HPM Toolkit"
1781            echo "  Please make sure HPMTINC, HPMTLIB are defined"            echo "  Please make sure HPMTINC, HPMTLIB are defined"
1782            DEFINES="$DEFINES -DUSE_LIBHPM"            DEFINES="$DEFINES -DUSE_LIBHPM"
1783            INCLUDES="$INCLUDES $HPMTINC"            INCLUDES="$INCLUDES $HPMTINC"
1784            LIBS="$LIBS $HPMTLIB"            LIBS="$LIBS $HPMTLIB"
1785            fi
1786        fi        fi
1787  fi  fi
1788  if test ! "x$GSL" = x ; then  if test ! "x$GSL" = x ; then
# Line 1507  if test ! "x$GSL" = x ; then Line 1792  if test ! "x$GSL" = x ; then
1792        INCLUDES="$INCLUDES $GSLINC"        INCLUDES="$INCLUDES $GSLINC"
1793        LIBS="$LIBS $GSLLIB"        LIBS="$LIBS $GSLLIB"
1794  fi  fi
1795    #- if USE_EXTENDED_SRC is set, add EXTENDED_SRC_FLAG to FFLAGS :
1796    if test ! "x$USE_EXTENDED_SRC" = x ; then
1797          FFLAGS="$FFLAGS $EXTENDED_SRC_FLAG"
1798          F90FIXEDFORMAT="$F90FIXEDFORMAT $EXTENDED_SRC_FLAG"
1799    fi
1800    
1801  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1802  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
# Line 1573  rm -f genmake_tcomp* Line 1863  rm -f genmake_tcomp*
1863  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1864  check_HAVE_CLOC  check_HAVE_CLOC
1865  if test "x$HAVE_CLOC" != x ; then  if test "x$HAVE_CLOC" != x ; then
1866        DEFINES="$DEFINES -DHAVE_CLOC"
1867      echo "yes"      echo "yes"
1868  else  else
1869      echo "no"      echo "no"
1870        if test "x$EMBED_SRC" = xt ; then
1871            echo "    WARNING: you requested file embedding but it has"
1872            echo "      been disabled since C code cannot be called"
1873            EMBED_SRC=
1874        fi
1875  fi  fi
1876  rm -f genmake_t*  rm -f genmake_t*
1877    
1878  printf "  Can we unlimit the stack size using $FC...  "  printf "  Can we unlimit the stack size using $FC...  "
1879  check_HAVE_SETRLSTK  check_HAVE_SETRLSTK
1880  if test "x$HAVE_SETRLSTK" != x ; then  if test "x$HAVE_SETRLSTK" = xt ; then
1881        DEFINES="$DEFINES -DHAVE_SETRLSTK"
1882      echo "yes"      echo "yes"
1883  else  else
1884      echo "no"      echo "no"
# Line 1590  rm -f genmake_t* Line 1887  rm -f genmake_t*
1887    
1888  printf "  Can we register a signal handler using $FC...  "  printf "  Can we register a signal handler using $FC...  "
1889  check_HAVE_SIGREG  check_HAVE_SIGREG
1890  if test "x$HAVE_SIGREG" != x ; then  if test "x$HAVE_SIGREG" = xt ; then
1891        DEFINES="$DEFINES -DHAVE_SIGREG"
1892      echo "yes"      echo "yes"
1893  else  else
1894      echo "no"      echo "no"
# Line 1600  rm -f genmake_t* Line 1898  rm -f genmake_t*
1898  printf "  Can we use stat() through C calls...  "  printf "  Can we use stat() through C calls...  "
1899  check_HAVE_STAT  check_HAVE_STAT
1900  if test "x$HAVE_STAT" != x ; then  if test "x$HAVE_STAT" != x ; then
1901        DEFINES="$DEFINES -DHAVE_STAT"
1902      echo "yes"      echo "yes"
1903  else  else
1904      echo "no"      echo "no"
# Line 1609  rm -f genmake_t* Line 1908  rm -f genmake_t*
1908  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1909  check_netcdf_libs  check_netcdf_libs
1910  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
1911        DEFINES="$DEFINES -DHAVE_NETCDF"
1912        echo "yes"
1913    else
1914        echo "no"
1915    fi
1916    
1917    printf "  Can we create LAPACK-enabled binaries...  "
1918    check_lapack_libs
1919    if test "x$HAVE_LAPACK" != x ; then
1920        DEFINES="$DEFINES -DHAVE_LAPACK"
1921      echo "yes"      echo "yes"
1922  else  else
1923      echo "no"      echo "no"
1924  fi  fi
1925  DEFINES="$DEFINES $IGNORE_TIME"  DEFINES="$DEFINES $IGNORE_TIME"
1926    
1927    if test "x$EMBED_SRC" = xt ; then
1928        build_embed_encode
1929    fi
1930    if test "x$EMBED_SRC" = xt ; then
1931        ENABLE="$ENABLE embed_files"
1932    #   DEFINES="$DEFINES -DHAVE_EMBED_SRC"
1933    fi
1934    
1935  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1936  printf "  Adding MODS directories:  "  printf "  Adding MODS directories: "
1937  for d in $MODS ; do  for d in $MODS ; do
1938      if test ! -d $d ; then      if test ! -d $d ; then
1939          echo          echo
1940          echo "Error: MODS directory \"$d\" not found!"          echo "Error: MODS directory \"$d\" not found!"
1941          exit 1          exit 1
1942      else      else
1943          printf " $d"          printf "$d "
1944          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1945          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
1946      fi      fi
1947  done  done
1948  echo  echo
1949    
1950  if test "x${PLATFORM}" = x ; then  #if test "x${PLATFORM}" = x ; then
1951      PLATFORM=$p_PLATFORM  #    PLATFORM=$p_PLATFORM
1952  fi  #fi
1953    
1954  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1955      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
# Line 1672  ERROR: neither of the two default script Line 1989  ERROR: neither of the two default script
1989      ${TOOLSDIR}/set64bitConst.sh      ${TOOLSDIR}/set64bitConst.sh
1990      ${TOOLSDIR}/set64bitConst.csh      ${TOOLSDIR}/set64bitConst.csh
1991    
1992    are working so please check paths or specify (with \$S64) a    are working so please check paths or specify (with \$S64) a
1993    working version of this script.    working version of this script.
1994    
1995  EOF  EOF
# Line 1684  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSD Line 2001  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSD
2001    
2002  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
2003    
2004    #  Set Standard Code Directories:
2005    if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
2006        STANDARDDIRS="eesupp model"
2007    fi
2008    #  if model in Standard-Code-Dir, add eesupp (needed to compile model)
2009    echo " $STANDARDDIRS " | grep ' model ' > /dev/null 2>&1
2010    ckM=$?
2011    echo " $STANDARDDIRS " | grep ' eesupp ' > /dev/null 2>&1
2012    ckE=$?
2013    if test $ckM = 0 -a $ckE = 1 ; then
2014        STANDARDDIRS="$STANDARDDIRS eesupp"
2015    fi
2016    
2017  #  We have a special set of source files in eesupp/src which are  #  We have a special set of source files in eesupp/src which are
2018  #  generated from some template source files. We'll make them first so  #  generated from some template source files. We'll make them first so
2019  #  they appear as regular source code  #  they appear as regular source code
2020  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
2021      echo "  Making source files in eesupp from templates"      echo "  Making source files in eesupp from templates"
2022      ( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1      ( cd $ROOTDIR"/eesupp/src/" && $MAKE clean_old && $MAKE \
2023        ) > make_eesupp.errors 2>&1
2024      RETVAL=$?      RETVAL=$?
2025      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
2026          rm -f make_eesupp.errors          rm -f make_eesupp.errors
# Line 1700  if test -r $ROOTDIR"/eesupp/src/Makefile Line 2031  if test -r $ROOTDIR"/eesupp/src/Makefile
2031      fi      fi
2032  fi  fi
2033    
2034  #same for exch2  #same for pkg/exch2 and pkg/regrid
2035  if test -r $ROOTDIR"/pkg/exch2/Makefile" ; then  for pdir in exch2 regrid ; do
2036      echo "  Making source files in exch2 from  templates"      if test -r $ROOTDIR"/pkg/${pdir}/Makefile" ; then
2037      ( cd $ROOTDIR"/pkg/exch2/" && $MAKE ) > make_exch2.errors 2>&1          echo "  Making source files in pkg/${pdir} from templates"
2038      RETVAL=$?          ( cd $ROOTDIR"/pkg/"${pdir} && $MAKE clean_old && $MAKE \
2039      if test "x${RETVAL}" = x0 ; then          ) > make_${pdir}.errors 2>&1
2040          rm -f make_exch2.errors          RETVAL=$?
2041      else          if test "x${RETVAL}" = x0 ; then
2042          echo "Error: problem encountered while building source files in exch2:"              rm -f make_${pdir}.errors
2043          cat make_exch2.errors 1>&2          else
2044          exit 1              echo "Error: problem encountered while building source files in pkg/${pdir}:"
2045                cat make_${pdir}.errors 1>&2
2046                exit 1
2047            fi
2048      fi      fi
2049  fi  done
2050    
2051  printf "\n===  Determining package settings  ===\n"  printf "\n===  Determining package settings  ===\n"
2052  if  test "x${PDEPEND}" = x ; then  if  test "x${PKG_DEPEND}" = x ; then
2053      tmp=$ROOTDIR"/pkg/pkg_depend"      tmp=$ROOTDIR"/pkg/pkg_depend"
2054      if test -r $tmp ; then      if test -r $tmp ; then PKG_DEPEND=$tmp ; fi
2055          PDEPEND=$tmp  fi
2056      else  if  test "x${PKG_DEPEND}" = x ; then
2057          echo "Warning:  No package dependency information was specified."          echo "Warning:  No package dependency information was specified."
2058          echo "  Please check that ROOTDIR/pkg/pkg_depend exists."          echo "  Please check that ROOTDIR/pkg/pkg_depend exists."
     fi  
2059  else  else
2060      if test ! -r ${PDEPEND} ; then      if test ! -r ${PKG_DEPEND} ; then
2061          echo "Error:  can't read package dependency info from PDEPEND=\"$PDEPEND\""          echo "Error:  can't read package dependency info from PKG_DEPEND=\"$PKG_DEPEND\""
2062          exit 1          exit 1
2063      fi      fi
2064        echo "  getting package dependency info from  $PKG_DEPEND"
2065    #  Strip the comments and then convert the dependency file into arrays: PNAME, DNAME
2066        get_pdepend_list $PKG_DEPEND
2067  fi  fi
2068  echo "  getting package dependency info from  $PDEPEND"  
2069  #  Strip the comments and then convert the dependency file into  # A default package groups file "$ROOTDIR/pkg/pkg_groups" is provided
2070  #  two arrays: PNAME, DNAME  #  to define the "default_pkg_list" and package groups (for convenience, one
2071  cat $PDEPEND | sed -e 's/#.*$//g' \  #  can specify a group of packages using names like "ocean" and "atmosphere").
2072      | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \  if test "x${PKG_GROUPS}" = x ; then
2073      > ./.pd_tmp      tmp=$ROOTDIR"/pkg/pkg_groups"
2074  RETVAL=$?      if test -r $tmp ; then PKG_GROUPS=$tmp ; fi
2075  if test ! "x${RETVAL}" = x0 ; then  fi
2076      echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""  if test "x${PKG_GROUPS}" = x ; then
2077      exit 1          echo "Warning:  No package groups information was specified."
2078            echo "  Please check that ROOTDIR/pkg/pkg_groups exists."
2079    else
2080        if test ! -r ${PKG_GROUPS} ; then
2081            echo "Error:  can't read package groups info from PKG_GROUPS=\"$PKG_GROUPS\""
2082            exit 1
2083        fi
2084        echo "  getting package groups info from      $PKG_GROUPS"
2085  fi  fi
 . ./.pd_tmp  
 rm -f ./.pd_tmp  
2086    
2087  #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"  #  Search for packages to compile.
2088  #  file should eventually be added so that, for convenience, one can  echo "  checking list of packages to compile:"
2089  #  specify groups of packages using names like "ocean" and "atmosphere".  PKG_LIST=
2090  echo "  checking default package list:  "  if test "x${PKG_LIST}" = x ; then
 if test "x${PDEFAULT}" = x ; then  
2091      for i in "." $MODS ; do      for i in "." $MODS ; do
2092          if test -r $i"/packages.conf" ; then          if test -r $i"/packages.conf" ; then
2093                  PDEFAULT=$i"/packages.conf"                  PKG_LIST=$i"/packages.conf"
2094                  break                  break
2095          fi          fi
2096      done      done
2097  fi  fi
2098  if test "x${PDEFAULT}" = x ; then  if test "x${PKG_LIST}" = x ; then
2099      PDEFAULT="$ROOTDIR/pkg/pkg_default"      pkg_list='default_pkg_list'
2100  fi      if test "x${PKG_GROUPS}" = x ; then
2101  if test "x${PDEFAULT}" = xNONE ; then          echo "Error:  need package groups info to expand pkg_list=\"$pkg_list\""
2102      echo "    default packages file disabled"          exit 1
2103        fi
2104  else  else
2105      if test ! -r $PDEFAULT ; then      if test ! -r $PKG_LIST ; then
2106          echo "Warning:  can't read default packages from PDEFAULT=\"$PDEFAULT\""          echo "Error:  can't read package list from PKG_LIST=\"$PKG_LIST\""
2107            exit 1
2108      else      else
2109          echo "    using PDEFAULT=\"$PDEFAULT\""          echo "    using PKG_LIST=\"$PKG_LIST\""
2110          #  Strip the comments and add all the names          #  Strip the comments and add all the names
2111          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`          pkg_list=`cat $PKG_LIST | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
2112          RETVAL=$?          RETVAL=$?
2113          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
2114              printf "Error: can't parse default package list "              printf "Error: can't parse package list "
2115              echo "-- please check PDEFAULT=\"$PDEFAULT\""              echo "-- please check PKG_LIST=\"$PKG_LIST\""
2116              exit 1              exit 1
2117          fi          fi
         for i in $def ; do  
             PACKAGES="$PACKAGES $i"  
         done  
         echo "    before group expansion packages are: $PACKAGES"  
         RET=1  
         while test $RET = 1 ; do expand_pkg_groups; RET=$?; done  
         echo "    after group expansion packages are:  $PACKAGES"  
2118      fi      fi
2119  fi  fi
2120    for i in $pkg_list ; do
2121        PACKAGES="$PACKAGES $i"
2122    done
2123    echo     "    before group expansion packages are:$PACKAGES"
2124    if test "x${PKG_GROUPS}" != x ; then
2125        RET=1
2126        while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
2127        echo "    after group expansion packages are: $PACKAGES"
2128    fi
2129    
2130  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
2131    echo "" > ./.tmp_pack
2132  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2133      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
2134  done  done
# Line 1811  PACKAGES="$PACKAGES $ENABLE" Line 2156  PACKAGES="$PACKAGES $ENABLE"
2156  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2157      j=`echo $i | sed 's/[-+]//'`      j=`echo $i | sed 's/[-+]//'`
2158      if test ! -d "$ROOTDIR/pkg/$j" ; then      if test ! -d "$ROOTDIR/pkg/$j" ; then
2159          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
2160          exit 1          exit 1
2161      fi      fi
2162      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
2163  done  done
# Line 1821  for i in `grep -v "-" ./.tmp_pack | sort Line 2166  for i in `grep -v "-" ./.tmp_pack | sort
2166      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
2167  done  done
2168  rm -f ./.tmp_pack  rm -f ./.tmp_pack
2169  echo "    packages are:  $PACKAGES"  echo "    packages are: $PACKAGES"
2170    
2171  #  Check availability of NetCDF and then either build the MNC template  #  Check for package MNC: if NetCDF is available, then build the MNC
2172  #  files or delete mnc from the list of available packages.  #  template files ; otherwise, delete mnc from the list of packages.
2173  echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1  echo " $PACKAGES " | grep ' mnc ' > /dev/null 2>&1
2174  RETVAL=$?  mnc_in=$?
2175  if test "x$RETVAL" = x0 ; then  if test "x$HAVE_NETCDF" != xt ; then
2176      if test "x$HAVE_NETCDF" != xt ; then      if test "x$mnc_in" = x0 ; then
2177          cat <<EOF          cat <<EOF
   
2178  *********************************************************************  *********************************************************************
2179  WARNING: the "mnc" package was enabled but tests failed to compile  WARNING: the "mnc" package was enabled but tests failed to compile
2180    NetCDF applications.  Please check that:    NetCDF applications.  Please check that:
2181    
2182    1) NetCDF is correctly installed for this compiler and    1) NetCDF is correctly installed for this compiler and
2183    2) the LIBS variable (within the "optfile") specifies the correct    2) the LIBS variable (within the "optfile") specifies the correct
2184         NetCDF library to link against.         NetCDF library to link against.
2185    
2186    Due to this failure, the "mnc" package is now DISABLED.    Due to this failure, the "mnc" package is now DISABLED.
2187  *********************************************************************  *********************************************************************
   
2188  EOF  EOF
2189          PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`          PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
2190          DISABLE="$DISABLE mnc"          DISABLE="$DISABLE mnc"
2191      else      else
2192          ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1      #  this prevent to add mnc (due to pdepend rules) if not available
2193          RETVAL=$?          DISABLE="$DISABLE mnc"
2194          if test "x${RETVAL}" = x0 ; then      fi
2195              rm -f make_mnc.errors  else
2196          else      # we have NetCDF, we try to build MNC template files
2197              echo "Error: problem encountered while building source files in pkg/mnc:"      ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
2198              cat make_mnc.errors 1>&2      RETVAL=$?
2199        if test "x${RETVAL}" = x0 ; then
2200            rm -f make_mnc.errors
2201        else
2202            echo "Error: problem encountered while building source files in pkg/mnc:"
2203            cat make_mnc.errors 1>&2
2204            if test "x$mnc_in" = x0 ; then
2205              exit 1              exit 1
2206            else
2207                DISABLE="$DISABLE mnc"
2208          fi          fi
2209      fi      fi
2210  fi  fi
2211    
2212  echo "  applying package dependency rules"  #  Check for package PROFILES: if NetCDF is not available,
2213  ck=  #  then delete profiles from the list of available packages.
2214  while test "x$ck" != xtt ; do  if test "x$HAVE_NETCDF" != xt ; then
2215        echo " $PACKAGES " | grep ' profiles ' > /dev/null 2>&1
2216        RETVAL=$?
2217        if test "x$RETVAL" = x0 ; then
2218            cat <<EOF
2219    *********************************************************************
2220    WARNING: the "profiles" package was enabled but tests failed to
2221      compile NetCDF applications.  Please check that:
2222    
2223      1) NetCDF is correctly installed for this compiler and
2224      2) the LIBS variable (within the "optfile") specifies the correct
2225           NetCDF library to link against.
2226    
2227      Due to this failure, the "profiles" package is now DISABLED.
2228    *********************************************************************
2229    EOF
2230            PACKAGES=`echo $PACKAGES | sed -e 's/profiles//g'`
2231            DISABLE="$DISABLE profiles"
2232        else
2233        #  this prevent to add profiles (due to pdepend rules) if not available
2234            DISABLE="$DISABLE profiles"
2235        fi
2236    fi
2237    
2238    #  Check for package RADTRANS: if LAPACK is not available,
2239    #  then issue a warning that the direct radtrans solver is not available.
2240    if test "x$HAVE_LAPACK" != xt ; then
2241        echo " $PACKAGES " | grep ' radtrans ' > /dev/null 2>&1
2242        RETVAL=$?
2243        if test "x$RETVAL" = x0 ; then
2244            cat <<EOF
2245    *********************************************************************
2246    WARNING: the "radtrans" package was enabled but tests failed to
2247      compile LAPACK applications.  This means that the direct radtrans
2248      solver is not available and compilation will fail if it is enabled.
2249      If you want to use the direct solver, please check that:
2250    
2251      1) LAPACK is correctly installed for this compiler and
2252      2) the LIBS variable (within the "optfile") specifies the correct
2253         LAPACK library to link against.
2254    *********************************************************************
2255    EOF
2256        fi
2257    fi
2258    
2259    if  test "x${PKG_DEPEND}" != x ; then
2260      echo "  applying package dependency rules"
2261      ck=
2262      while test "x$ck" != xtt ; do
2263      i=0      i=0
2264      # rtot=${#PNAME[@]}      # rtot=${#PNAME[@]}
2265      rtot=$nname      rtot=$nname
2266      while test $i -lt $rtot ; do      while test $i -le $rtot ; do
2267    
2268          #  Is $pname in the current $PACKAGES list?          #  Is $pname in the current $PACKAGES list?
2269          #  pname=${PNAME[$i]}          #  pname=${PNAME[$i]}
# Line 1876  while test "x$ck" != xtt ; do Line 2275  while test "x$ck" != xtt ; do
2275                  pin="t"                  pin="t"
2276              fi              fi
2277          done          done
2278            #  or in the current $STANDARDDIRS list?
2279            for p in $STANDARDDIRS ; do
2280                if test "x$p" = "x$pname" ; then pin="t" ; fi
2281            done
2282    
2283          #  Is the DNAME entry a (+) or (-) rule ?          #  Is the DNAME entry a (+) or (-) rule ?
2284          tmp="dname=\"\$DNAME_$i\""          tmp="dname=\"\$DNAME_$i\""
# Line 1898  while test "x$ck" != xtt ; do Line 2301  while test "x$ck" != xtt ; do
2301    
2302          #  Do we need to add $dname according to the dependency rules?          #  Do we need to add $dname according to the dependency rules?
2303          if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then          if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then
2304                #echo "   " $pname ": need to add :" $dname
2305              in_dis="f"              in_dis="f"
2306              for dis in $DISABLE ; do              for dis in $DISABLE ; do
2307                  if test "x$dis" = "x$dname" ; then                  if test "x$dis" = "x$dname" ; then
# Line 1918  while test "x$ck" != xtt ; do Line 2322  while test "x$ck" != xtt ; do
2322          #  Do we need to get rid of $dname according to the dependency rules?          #  Do we need to get rid of $dname according to the dependency rules?
2323          if test "x$pin" = xt -a "x$plus" = "x-" -a "x$din" = xt; then          if test "x$pin" = xt -a "x$plus" = "x-" -a "x$din" = xt; then
2324              echo "Error: can't satisfy package dependencies:"              echo "Error: can't satisfy package dependencies:"
2325              echo "  \"$pname\" was requested but is disallowed by"              echo "  \"$pname\" was requested but is disallowed by"
2326              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
2327              exit 1              exit 1
2328          fi          fi
2329          i=`echo "$i + 1" | bc -l`          i=`echo "$i + 1" | bc -l`
2330          #i=$(( $i + 1 ))          #i=$(( $i + 1 ))
2331      done      done
2332      ck=$ck"t"      ck=$ck"t"
2333  done    done
2334  echo "    packages are:  $PACKAGES"    echo "    packages are: $PACKAGES"
2335    fi
2336  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2337      adr="$ROOTDIR/pkg/$i"      adr="$ROOTDIR/pkg/$i"
2338      if test -d $adr ; then      if test -d $adr ; then
# Line 1944  done Line 2349  done
2349    
2350  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
2351  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
2352  #  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
2353  #  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
2354  #  file would eventually be split up so that all package-related #define  #  file would eventually be split up so that all package-related #define
2355  #  statements could be separated and handled only by genmake.  #  statements could be separated and handled only by genmake.
2356  names=`ls -1 "$ROOTDIR/pkg"`  names=`ls -1 "$ROOTDIR/pkg"`
# Line 1962  for n in $names ; do Line 2367  for n in $names ; do
2367          done          done
2368          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
2369              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
2370              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
2371          fi          fi
2372      fi      fi
2373  done  done
# Line 1973  for i in $PACKAGES ; do Line 2378  for i in $PACKAGES ; do
2378  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
2379    
2380  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
2381      case $i in      case $i in
2382          aim_v23)          aim_v23)
2383              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
2384              echo "Warning: ALLOW_AIM is set to enable aim_v23."              echo "Warning: ALLOW_AIM is set to enable aim_v23."
2385              ;;              ;;
2386      esac      esac
# Line 1983  for i in $PACKAGES ; do Line 2388  for i in $PACKAGES ; do
2388    
2389  done  done
2390    
2391  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS='$STANDARDDIRS'"
2392  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
 if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then  
     STANDARDDIRS="eesupp model"  
 fi  
2393  if test "x$STANDARDDIRS" != x ; then  if test "x$STANDARDDIRS" != x ; then
2394      for d in $STANDARDDIRS ; do      for d in $STANDARDDIRS ; do
2395          adr="$ROOTDIR/$d/src"          adr="$ROOTDIR/$d/src"
# Line 2020  for i in $spaths ; do Line 2422  for i in $spaths ; do
2422      if test -f $try -a -r $try -a "x$CPP_OPTIONS" = x ; then      if test -f $try -a -r $try -a "x$CPP_OPTIONS" = x ; then
2423          echo "    found CPP_OPTIONS=\"$try\""          echo "    found CPP_OPTIONS=\"$try\""
2424          CPP_OPTIONS="$try"          CPP_OPTIONS="$try"
2425          # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h          # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
2426          for n in $names ; do          for n in $names ; do
2427              test_for_package_in_cpp_options $CPP_OPTIONS $n              test_for_package_in_cpp_options $CPP_OPTIONS $n
2428          done          done
2429      fi      fi
2430      try="$i/CPP_EEOPTIONS.h"      try="$i/CPP_EEOPTIONS.h"
2431      if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" = x ; then      if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" = x ; then
2432          echo "    found CPP_EEOPTIONS=\"$try\""          echo "    found CPP_EEOPTIONS=\"$try\""
2433          # New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h          # New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h
2434  #**** not yet enabled ****  #**** not yet enabled ****
2435  #        test_for_mpi_in_cpp_eeoptions $try  #        test_for_mpi_in_cpp_eeoptions $try
2436  #**** not yet enabled ****  #**** not yet enabled ****
# Line 2042  fi Line 2444  fi
2444    
2445  #  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
2446  #  compiler.  #  compiler.
2447  if test -f ./ad_files ; then  if test -f ./adSrcFiles.tmp ; then
2448      rm -f ./ad_files      rm -f ./adSrcFiles.tmp
2449  fi  fi
2450  echo "  Creating the list of files for the adjoint compiler."  echo "  Creating the list of files for the adjoint compiler."
2451    touch adSrcFiles.tmp
2452  for i in $SOURCEDIRS ; do  for i in $SOURCEDIRS ; do
2453      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2454      for j in $list_files ; do      for j in $list_files ; do
2455          cat $i/$j >> ad_files          cat $i/$j >> adSrcFiles.tmp
2456      done      done
2457  done  done
2458  if test ! "x"$FS = "x.f" ; then  if test ! "x"$FS = "x.f" ; then
2459      cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f      cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f
2460      mv -f ad_files_f ad_files      mv -f adSrcFiles.tmp_f adSrcFiles.tmp
2461  fi  fi
2462    
2463  echo  echo
# Line 2078  if test ! "x$DIVA" = x ; then Line 2481  if test ! "x$DIVA" = x ; then
2481          fi          fi
2482          MPIINCLUDEDIR='$MPIHOME/include'          MPIINCLUDEDIR='$MPIHOME/include'
2483      fi      fi
2484        
2485      if test -r $MPIINCLUDEDIR/mpif.h ; then      if test -r $MPIINCLUDEDIR/mpif.h ; then
2486          for i in $MPI_HEADER_FILES; do          for i in $MPI_HEADER_FILES; do
2487              cp -p $MPIINCLUDEDIR/$i ./mpi_headers              cp -p $MPIINCLUDEDIR/$i ./mpi_headers
# Line 2087  if test ! "x$DIVA" = x ; then Line 2490  if test ! "x$DIVA" = x ; then
2490          perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h          perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h
2491      else      else
2492          echo " We cannot create a copy of mpif.h!"          echo " We cannot create a copy of mpif.h!"
2493          exit -1  #       exit -1
2494      fi      fi
2495  fi  fi
2496    
2497  echo "  Determining the list of source and include files"  echo "  Determining the list of source and include files"
2498  rm -rf .links.tmp  rm -rf .links.tmp
2499  mkdir .links.tmp  mkdir .links.tmp
2500    touch .links.tmp/foo
2501    if test ! -r ".links.tmp/foo" ; then
2502        echo
2503        echo "ERROR : something is wrong with your directory permissions or"
2504        echo "   your user file-creation mask (\"umask\") since creating a"
2505        echo "   sub-dir, touch-ing a file within it, and then reading it is"
2506        echo "   not working.  Please try setting your umask to something"
2507        echo "   sane such as:"
2508        echo
2509        echo "      umask 0002"
2510        echo
2511        echo "   and please verify that you have the proper permissions for"
2512        echo "   creating sub-directories and then reading files created"
2513        echo "   within them."
2514        echo
2515        exit 1
2516    fi
2517    rm -f .links.tmp/foo
2518    
2519    if test "x$OPENAD" != x ; then
2520        OAD_DONT_COMPILE="/dev/null"
2521        OAD_DONT_TRANSFORM="/dev/null"
2522        OAD_KEEP_ORIGINAL="/dev/null"
2523        OAD_CB2M_FILES="/dev/null"
2524        echo "  looking for dontCompile file:  "
2525        for i in "." $MODS ; do
2526            if test -r $i"/dontCompile" ; then
2527                OAD_DONT_COMPILE=$i"/dontCompile"
2528                echo "     found $OAD_DONT_COMPILE"
2529                break
2530            fi
2531        done
2532        echo "  looking for dontTransform file:  "
2533        for i in "." $MODS ; do
2534            if test -r $i"/dontTransform" ; then
2535                OAD_DONT_TRANSFORM=$i"/dontTransform"
2536                echo "     found $OAD_DONT_TRANSFORM"
2537                break
2538            fi
2539        done
2540        echo "  looking for keepOriginal file:  "
2541        for i in "." $MODS ; do
2542            if test -r $i"/keepOriginal" ; then
2543                OAD_KEEP_ORIGINAL=$i"/keepOriginal"
2544                echo "     found $OAD_KEEP_ORIGINAL"
2545                break
2546            fi
2547        done
2548        echo "  looking for cb2mFiles:  "
2549        for i in "." $MODS ; do
2550            if test -r $i"/cb2mFiles" ; then
2551                OAD_CB2M_FILES=$i"/cb2mFiles"
2552                echo "     found $OAD_CB2M_FILES"
2553                break
2554            fi
2555        done
2556        echo "   OpenAD exceptions:  "
2557    fi
2558    
2559  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
2560  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
2561  printf 'SRCFILES = '    > srclist.inc  printf 'F77_SRC_FILES = ' > F77srclist.tmp
2562  printf 'CSRCFILES = '   > csrclist.inc  printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp
2563  printf 'F90SRCFILES = ' > f90srclist.inc  printf 'C_SRC_FILES = '   > csrclist.tmp
2564  printf 'HEADERFILES = ' > hlist.inc  printf 'F90_SRC_FILES = ' > F90srclist.tmp
2565  printf 'AD_FLOW_FILES = ' > ad_flow_files.inc  printf 'H_SRC_FILES = '   > hsrclist.tmp
2566    printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp
2567  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2568  for d in $alldirs ; do  for d in $alldirs ; do
2569      deplist=      deplist=
2570      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
2571      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
2572        if test "x$OPENAD" != x ; then
2573            sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2574        fi
2575      for sf in $sfiles ; do      for sf in $sfiles ; do
2576          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
2577              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2578                  ignore_f=f                  ignore_f=f
2579                  case $d/$sf in                  case $d/$sf in
2580                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
2581                            ignore_f=t
2582                            ;;
2583                      ./AD_CONFIG.h)
2584                            ignore_f=t
2585                          ;;                          ;;
2586                    ./AD_CONFIG.h)                    ./FC_NAMEMANGLE.h)
2587                            ignore_f=t
2588                          ;;                          ;;
2589                    ./FC_NAMEMANGLE.h)                    ./BUILD_INFO.h)
2590                            ignore_f=t
2591                          ;;                          ;;
2592                    ./BUILD_INFO.h)                    ./EMBEDDED_FILES.h)
2593                            ignore_f=t
2594                          ;;                          ;;
2595                    *)                    *)
2596                          #  For the local directory *ONLY*,                          #  For the local directory *ONLY*,
2597                          #  ignore all soft-links                          #  ignore all soft-links
2598                          if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then                          if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
# Line 2129  for d in $alldirs ; do Line 2602  for d in $alldirs ; do
2602                              deplist="$deplist $sf"                              deplist="$deplist $sf"
2603                          fi                          fi
2604                          ;;                          ;;
2605                  esac                  esac
2606                  if test "x$ignore_f" = xf ; then                  if test "x$ignore_f" = xf ; then
2607                      extn=`echo $sf | $AWK -F. '{print $NF}'`                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2608                      case $extn in                      case $extn in
2609                          F)                        F)
2610                              echo    " \\"  >> srclist.inc                          echo    " \\"  >> F77srclist.tmp
2611                              printf " $sf" >> srclist.inc                          printf " $sf" >> F77srclist.tmp
2612                              ;;                          if test "x$OPENAD" != x ; then
2613                          F90)                              basename=${sf%%.F}
2614                              echo    " \\"  >> f90srclist.inc                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`
2615                              printf " $sf" >> f90srclist.inc                              if test -z "$isAD" ; then
2616                              ;;                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`
2617                          c)                                  if test -z "$toBeIgnored" ; then
2618                              echo    " \\"  >> csrclist.inc                                      echo    " \\"  >> nonADF77srclist.tmp
2619                              printf " $sf" >> csrclist.inc                                      printf " $sf" >> nonADF77srclist.tmp
2620                              ;;                                  else
2621                          h)                                      echo "    not to be compiled   :  $sf"
2622                              echo    " \\"  >> hlist.inc                                  fi
2623                              printf " $sf" >> hlist.inc                              else # file is initially listed as an AD file we want to exclude it
2624                              ;;                                   # or we want to retain the untransformed version
2625                          flow)                                  notToBeTransformed=`egrep ^$basename'[      ]*' ${OAD_DONT_TRANSFORM}`
2626                              echo    " \\"  >> ad_flow_files.inc                                  untransformedVersionToBeKept=`egrep ^$basename'[      ]*' ${OAD_KEEP_ORIGINAL}`
2627                              printf " $sf" >> ad_flow_files.inc                                  if test -n "$notToBeTransformed"; then
2628                              ;;                                      echo "    not to be transformed:  $sf"
2629                      esac                                  fi
2630                  fi                                  if test -n "$untransformedVersionToBeKept" ; then
2631                                        echo "    original to be kept  :  $sf"
2632                                    fi
2633                                    if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2634                                        echo    " \\"  >> nonADF77srclist.tmp
2635                                        printf " $sf" >> nonADF77srclist.tmp
2636                                    fi
2637                                fi
2638                            fi
2639                            ;;
2640                        F90)
2641                            echo    " \\"  >> F90srclist.tmp
2642                            printf " $sf" >> F90srclist.tmp
2643                            ;;
2644                        c)
2645                            echo    " \\"  >> csrclist.tmp
2646                            printf " $sf" >> csrclist.tmp
2647                            ;;
2648                        h)
2649                            echo    " \\"  >> hsrclist.tmp
2650                            printf " $sf" >> hsrclist.tmp
2651                            ;;
2652                        flow)
2653                            echo    " \\"  >> ad_flow_files.tmp
2654                            printf " $sf" >> ad_flow_files.tmp
2655                            ;;
2656                       esac
2657                    fi
2658              fi              fi
2659          fi          fi
2660      done      done
2661      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2662          if test "$d" != "." ; then
2663          echo "" >> srclinks.tmp          echo "" >> srclinks.tmp
2664          echo "#  These files are linked from $d" >> srclinks.tmp          echo "#  These files are linked from $d" >> srclinks.tmp
2665          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> srclinks.tmp
2666          printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp  # We need to make sure that the link isn't already there.
2667    # This may happen when make thinks that a header file has to be "remade"
2668    # because a module it depends on has changed.  In this case we do nothing.
2669            printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp
2670          fi
2671      fi      fi
2672  done  done
2673  rm -rf .links.tmp  rm -rf .links.tmp
2674  echo "" >> srclist.inc  echo "" >> F77srclist.tmp
2675  echo "" >> csrclist.inc  echo "" >> nonADF77srclist.tmp
2676  echo "" >> f90srclist.inc  echo "" >> csrclist.tmp
2677  echo "" >> hlist.inc  echo "" >> F90srclist.tmp
2678  echo "" >> ad_flow_files.inc  echo "" >> hsrclist.tmp
2679    echo "" >> ad_flow_files.tmp
2680    
2681    CMDLINE=$0
2682    for xx in "$@" ; do nw=`echo $xx | wc -w`
2683        if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
2684                            else CMDLINE="$CMDLINE '$xx'" ; fi
2685    done
2686    
2687  if test -f $MAKEFILE ; then  if test -f $MAKEFILE ; then
2688      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.old"
2689  fi  fi
2690  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
2691  echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE  echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE
# Line 2181  echo "#    $MACHINE" >> $MAKEFILE Line 2693  echo "#    $MACHINE" >> $MAKEFILE
2693  echo "# This makefile was generated automatically on" >> $MAKEFILE  echo "# This makefile was generated automatically on" >> $MAKEFILE
2694  echo "#    $THISDATE" >> $MAKEFILE  echo "#    $THISDATE" >> $MAKEFILE
2695  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2696  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $CMDLINE"  >> $MAKEFILE
2697  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2698  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2699    
# Line 2192  EXE_SVD=$EXECUTABLE"_svd" Line 2704  EXE_SVD=$EXECUTABLE"_svd"
2704  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2705  #  #
2706  # OPTFILE="$OPTFILE"  # OPTFILE="$OPTFILE"
2707  #  #
2708  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
2709  # SOURCEDIRS   : Directories containing the source (.F) files  # SOURCEDIRS   : Directories containing the source (.F) files
2710  # INCLUDEDIRS  : Directories containing the header-source (.h) files  # INCLUDEDIRS  : Directories containing the header-source (.h) files
# Line 2212  cat >>$MAKEFILE <<EOF Line 2724  cat >>$MAKEFILE <<EOF
2724  # LIBS         : Library flags /or/ additional optimization/debugging flags  # LIBS         : Library flags /or/ additional optimization/debugging flags
2725    
2726  ROOTDIR     = ${ROOTDIR}  ROOTDIR     = ${ROOTDIR}
2727  BUILDDIR    = ${BUILDDIR}    BUILDDIR    = ${BUILDDIR}
2728  SOURCEDIRS  = ${SOURCEDIRS}  SOURCEDIRS  = ${SOURCEDIRS}
2729  INCLUDEDIRS = ${INCLUDEDIRS}  INCLUDEDIRS = ${INCLUDEDIRS}
2730  EXEDIR      = ${EXEDIR}  EXEDIR      = ${EXEDIR}
# Line 2230  DISABLED_PACKAGES = ${DISABLED_PACKAGES} Line 2742  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
2742    
2743  # These files are created by Makefile  # These files are created by Makefile
2744  SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h  SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h
   
2745  EOF  EOF
2746    
2747  #  Note: figure out some way to add Hyades JAM libraries here  if test "x$EMBED_SRC" = xt ; then
2748        echo "EMBEDDED_FILES = EMBEDDED_FILES.h" >>$MAKEFILE
2749    else
2750        echo "EMBEDDED_FILES = " >>$MAKEFILE
2751    fi
2752    
2753  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2754  # Unix ln (link)  # Unix ln (link)
2755  LN = ${LN}  LN = ${LN}
# Line 2261  INCLUDES = ${INCLUDES} Line 2776  INCLUDES = ${INCLUDES}
2776  KFLAGS1 = ${KFLAGS1}  KFLAGS1 = ${KFLAGS1}
2777  KFLAGS2 = ${KFLAGS2}  KFLAGS2 = ${KFLAGS2}
2778  # Optim./debug for FC  # Optim./debug for FC
2779  FFLAGS = ${FFLAGS}  FFLAGS = ${FFLAGS} ${FEXTRAFLAGS}
2780  FOPTIM = ${FOPTIM}  FOPTIM = ${FOPTIM}
2781  # Optim./debug for FC  # Optim./debug for FC
2782  F90FLAGS = ${F90FLAGS}  F90FLAGS = ${F90FLAGS}
2783  F90OPTIM = ${F90OPTIM}  F90OPTIM = ${F90OPTIM}
2784    F90FIXEDFORMAT = ${F90FIXEDFORMAT}
2785  # Flags for CC  # Flags for CC
2786  CFLAGS = ${CFLAGS}  CFLAGS = ${CFLAGS}
2787  # Files that should not be optimized  # Files that should not be optimized
# Line 2273  NOOPTFILES = ${NOOPTFILES} Line 2789  NOOPTFILES = ${NOOPTFILES}
2789  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2790  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2791  LIBS = ${LIBS}  LIBS = ${LIBS}
2792  # Name of the Mekfile  # Name of the makefile
2793  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2794    
2795  EOF  EOF
2796    
2797  cat srclist.inc       >> $MAKEFILE  cat F77srclist.tmp      >> $MAKEFILE
2798  cat csrclist.inc      >> $MAKEFILE  cat nonADF77srclist.tmp >> $MAKEFILE
2799  cat f90srclist.inc    >> $MAKEFILE  cat csrclist.tmp        >> $MAKEFILE
2800  cat hlist.inc         >> $MAKEFILE  cat F90srclist.tmp      >> $MAKEFILE
2801  cat ad_flow_files.inc >> $MAKEFILE  cat hsrclist.tmp        >> $MAKEFILE
2802    cat ad_flow_files.tmp   >> $MAKEFILE
2803    
2804    rm -f F77srclist.tmp nonADF77srclist.tmp csrclist.tmp F90srclist.tmp hsrclist.tmp ad_flow_files.tmp
2805    
2806  echo >> $MAKEFILE  echo >> $MAKEFILE
2807  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE  
2808  echo 'F90FILES =  $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE  # add definitions for preprocessed sources
2809  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  # and note that not all systems allow case sensitive extensions
2810    # hence the $FS and $FS90 here.
2811    # for fixed format f90 files we use ff90 or FF90 resp
2812    # but these are not expected to be the original source files
2813    
2814    echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE
2815    echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE
2816    echo 'OBJFILES= $(F77_SRC_FILES:.F=.o) $(C_SRC_FILES:.c=.o) $(F90_SRC_FILES:.F90=.o)' >> $MAKEFILE
2817    echo 'FLOWFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE
2818  echo >> $MAKEFILE  echo >> $MAKEFILE
2819  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
2820  echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE  echo '.SUFFIXES: .o .'$FS' .p .F .c .f'$FS90' .'$FS90' .FF90 .F90 .flowdir .flow' >> $MAKEFILE
 rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc  
 rm -f ad_flow_files.inc  
2821    
2822  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2823    
2824  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
2825  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(EMBEDDED_FILES)
2826          @echo Creating \$@ ...          @echo Creating \$@ ...
2827          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2828    
2829  depend:  depend:
2830          @make links          @make -f \$(MAKEFILE) links
2831          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
2832          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2833          -rm -f makedepend.out          -rm -f makedepend.out
2834    
# Line 2309  lib: libmitgcmuv.a Line 2836  lib: libmitgcmuv.a
2836    
2837  libmitgcmuv.a: \$(OBJFILES)  libmitgcmuv.a: \$(OBJFILES)
2838          ar rcv libmitgcmuv.a \$(OBJFILES)          ar rcv libmitgcmuv.a \$(OBJFILES)
2839            ar d   libmitgcmuv.a main.o
2840    
2841  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  obj: \$(OBJFILES)
2842    
2843  small_f: \$(F77FILES) \$(F90FILES)  links: \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(SPECIAL_FILES)
2844    
2845    small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
2846    
2847  output.txt: \$(EXECUTABLE)  output.txt: \$(EXECUTABLE)
2848          @printf 'running ... '          @printf 'running ... '
2849          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
2850    
2851    # remove most of the files that "make" generates
2852  clean:  clean:
2853          -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2854            -rm -rf *.o
2855            -rm -rf *.$FS *.flowdir
2856            -rm -rf *.f$FS90 \$(AD_CLEAN) ad_input*
2857    
2858    # remove most of the files that "make" and "make depend" generate
2859  Clean:  Clean:
2860          @make clean          @make -f \$(MAKEFILE) clean
2861          @make cleanlinks          @make -f \$(MAKEFILE) cleanlinks
2862          -rm -f \$(SPECIAL_FILES)          -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old
2863          -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak          -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log taf_ftl.log
2864            -rm -f genmake_warnings genmake_errors make.log
2865    
2866    # remove also the executable, files that "genmake2" generates (except Makefile)
2867    #         and output from a run (plus log files from testreport)
2868  CLEAN:  CLEAN:
2869          @make Clean          @make -f \$(MAKEFILE) Clean
2870            -rm -f \$(EXECUTABLE) \$(EXE_AD) \$(EXE_FTL) *.bak
2871            -rm -f $LOGFILE genmake_state genmake_*optfile
2872            -rm -f SIZE.h.mpi genmake.tr_log make.tr_log
2873          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2874          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2875          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2876          -rm -f \$(EXECUTABLE) output.txt STD*          -rm -f *.txt STD* *diagnostics.log datetime
2877            -rm -f *_MIT_CE_000.opt0000 costfunction*0000
2878            -rm -rf mnc_test_*
2879    
 #eh3 Makefile: makefile  
2880  makefile:  makefile:
2881          $THIS_SCRIPT $G2ARGS          $THIS_SCRIPT $G2ARGS
2882  cleanlinks:  cleanlinks:
2883          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2884    
2885  # Special targets (SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are created by make
2886  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2887          @echo Creating \$@ ...          @echo Creating \$@ ...
2888          @$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) > \$@          @$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) > \$@
2889  AD_CONFIG.h:  AD_CONFIG.h:
2890          @echo Creating \$@ ...          @echo Creating \$@ ...
2891          @$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 > \$@          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > \$@
2892  FC_NAMEMANGLE.h:  FC_NAMEMANGLE.h:
2893          @echo Creating \$@ ...          @echo Creating \$@ ...
2894          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
# Line 2358  test ! "x$THISUSER" = x && echo "      -echo Line 2902  test ! "x$THISUSER" = x && echo "      -echo
2902  test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE  test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2903  test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE  test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2904    
2905    if test "x$EMBED_SRC" = xt ; then
2906        cat >>$MAKEFILE <<EOF
2907    
2908    decode_files.o : EMBEDDED_FILES.h
2909    
2910    ##  \$(F77_PP_SRC_FILES)
2911    all_fF.tar.gz : \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2912            @echo Creating \$@ ...
2913            -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2914            -rm -f all_fF.tar.gz
2915            -gzip all_fF.tar
2916    
2917    EMBEDDED_FILES.h : all_fF.tar.gz
2918            @echo Creating \$@ ...
2919            -\${ROOTDIR}/tools/embed_encode/encode_files EMBEDDED_FILES.h all_fF.tar.gz
2920    
2921    EOF
2922    fi
2923    
2924  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2925    
2926  # The normal chain of rules is (  .F - .$FS - .o  )  # The normal chain of rules is (  .F - .$FS - .o  )
# Line 2369  cat >>$MAKEFILE <<EOF Line 2932  cat >>$MAKEFILE <<EOF
2932          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2933  .$FS.o:  .$FS.o:
2934          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2935    .F.o:
2936            \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2937  .F90.$FS90:  .F90.$FS90:
2938          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2939    .FF90.f$FS90:
2940            \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2941  .$FS90.o:  .$FS90.o:
2942          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2943    .f$FS90.o:
2944            cp \$< \$(basename  \$<).f90
2945            \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$(F90FIXEDFORMAT) \$(basename  \$<).f90
2946  .c.o:  .c.o:
2947          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
2948    .flow.flowdir:
2949            \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2950    
2951  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2952  .F.p:  .F.p:
# Line 2382  cat >>$MAKEFILE <<EOF Line 2954  cat >>$MAKEFILE <<EOF
2954  .p.$FS:  .p.$FS:
2955          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
2956    
2957    EOF
2958    
2959  #=========================================  #=========================================
2960  #===  Automatic Differentiation Rules  ===  #===  Automatic Differentiation Rules  ===
2961    #===  for TAMC/TAF  ======================
2962    
2963    if test "x$OPENAD" = x ; then
2964    
2965    cat >>$MAKEFILE <<EOF
2966    
2967  TAMC           = ${TAMC}  TAMC           = ${TAMC}
2968  TAF            = ${TAF}  TAF            = ${TAF}
# Line 2398  ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF Line 2977  ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF
2977  ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"  ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
2978  for i in $ad_vars ; do  for i in $ad_vars ; do
2979      name=$i      name=$i
2980      t1="t2=\$"`echo $i`      t1="t2=\$"`echo "$i"`
2981      eval $t1      eval $t1
2982      printf "%-20s = " $name >> $MAKEFILE      printf "%-20s = " $name >> $MAKEFILE
2983      echo $t2 >> $MAKEFILE      echo "$t2" | sed -e 's| \+| |g' >> $MAKEFILE
2984  done  done
2985    
2986  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
2987  echo >> $MAKEFILE  echo >> $MAKEFILE
2988  printf "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
2989  AD_FILES=`cat ad_files`  AD_FILES=`cat adSrcFiles.tmp`
2990  for i in $AD_FILES ; do  for i in $AD_FILES ; do
2991      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
2992      printf " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
2993  done  done
2994  echo >> $MAKEFILE  echo >> $MAKEFILE
2995  rm -f ad_files  rm -f adSrcFiles.tmp
2996    
2997  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2998    
2999  # ... AD ...  # ... AD ...
3000  adall: ad_taf  adall: \$(EXE_AD)
3001  adtaf: ad_taf_output.$FS  adtaf: ad_taf_output.$FS
3002  adtamc: ad_tamc_output.$FS  adtamc: ad_tamc_output.$FS
3003    
3004  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES)
3005          @$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          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3006          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3007          -rm -f ad_config.template          -rm -f ad_config.template
3008          @make \$(F77FILES)          @make -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3009          @make \$(AD_FLOW_FILES)          @make -f \$(MAKEFILE) \$(FLOWFILES)
3010          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS          cat \$(FLOWFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS
3011    
3012  ad_taf_output.$FS: ad_input_code.$FS  ad_taf_output.$FS: ad_input_code.$FS
3013          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3014            ls -l ad_input_code_ad.$FS
3015          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
3016    
3017  adtafonly:  adtafonly:
3018          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3019            ls -l ad_input_code_ad.$FS
3020          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
3021    
3022  ad_taf: ad_taf_output.o \$(OBJFILES)  \${EXE_AD}: ad_taf_output.o \$(OBJFILES)
3023          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
3024    
3025  ad_tamc_output.$FS: ad_input_code.$FS  ad_tamc_output.$FS: ad_input_code.$FS
3026          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
3027          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
3028    
3029  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
3030          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
3031    
3032  adonlyfwd:  adonlyfwd:
3033          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
3034    
3035  adtrick:  adtrick:
3036          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
3037    
3038    adobj: ad_taf_output.o \$(OBJFILES)
3039    
3040  # ... FTL ...  # ... FTL ...
3041  ftlall: ftl_taf  ftlall: \$(EXE_FTL)
3042  ftltaf: ftl_taf_output.$FS  ftltaf: ftl_taf_output.$FS
3043  ftltamc: ftl_tamc_output.$FS  ftltamc: ftl_tamc_output.$FS
3044    
3045  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)
3046          @$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          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ftl_config.template
3047          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
3048          -rm -f ftl_config.template          -rm -f ftl_config.template
3049          @make \$(F77FILES)          @make -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3050          @make \$(AD_FLOW_FILES)          @make -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3051          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS          cat \$(AD_FLOW_FILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ftl_input_code.$FS
3052    
3053  ftl_taf_output.$FS: ftl_input_code.$FS  ftl_taf_output.$FS: ftl_input_code.$FS
3054          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3055            ls -l ftl_input_code_ftl.$FS
3056          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
3057    
3058  ftltafonly:  ftltafonly:
3059          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3060            ls -l ftl_input_code_ftl.$FS
3061          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
3062    
3063  ftl_taf: ftl_taf_output.o \$(OBJFILES)  \${EXE_FTL}: ftl_taf_output.o \$(OBJFILES)
3064          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
3065    
3066  ftl_tamc_output.$FS: ftl_input_code.$FS  ftl_tamc_output.$FS: ftl_input_code.$FS
3067          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
3068          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS
3069    
3070  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
3071          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
   
3072    
3073  # ... SVD ...  # ... SVD ...
3074  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
# Line 2506  svd_touch: Line 3090  svd_touch:
3090          touch ad_taf_output.$FS ftl_taf_output.$FS          touch ad_taf_output.$FS ftl_taf_output.$FS
3091          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
3092          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
3093          @$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          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ftl_config.template
3094          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
3095          -rm -f ftl_config.template          -rm -f ftl_config.template
3096    
3097  #=========================================  EOF
3098    
3099    fi
3100    
3101    #===  for OpenAD  ========================
3102    
3103    if test "x$OPENAD" != x ; then
3104    
3105    # ============ begin OpenAD specific section ==============
3106    
3107    cat >>$MAKEFILE <<EOF
3108    
3109    # all the source files linked from the various locations:
3110    ALL_LINKED_FILES= \
3111    \$(F77_SRC_FILES) \
3112    \$(C_SRC_FILES) \
3113    \$(H_SRC_FILES) \
3114    \$(F90_SRC_FILES) \
3115    \$(SPECIAL_FILES)
3116    
3117    ifndef OPENADROOT
3118      \$(error "Error:  environment variable OPENADROOT not defined!")
3119    endif
3120    
3121    ifndef XAIFSCHEMAROOT
3122      \$(error "Error:  environment variable XAIFSCHEMAROOT not defined!")
3123    endif
3124    
3125    ifndef XAIFBOOSTERROOT
3126      \$(error "Error:  environment variable XAIFBOOSTERROOT not defined!")
3127    endif
3128    
3129    EOF
3130    
3131    echo "  Add the source list for common block to module conversion "
3132    echo >> $MAKEFILE
3133    printf "CB2M_F90_SRC_NAMES = " >> $MAKEFILE
3134    for i in `cat ${OAD_CB2M_FILES}` ; do
3135      echo    " \\" >> $MAKEFILE
3136      printf " $i" >> $MAKEFILE
3137    done
3138    echo >> $MAKEFILE
3139    
3140    echo "  Add the source list for AD code generation"
3141    echo >> $MAKEFILE
3142    printf "AD_FILES = " >> $MAKEFILE
3143    for i in `cat ${OAD_CB2M_FILES}` ; do
3144      echo    " \\" >> $MAKEFILE
3145      printf " ${i}_mod.f$FS90" >> $MAKEFILE
3146    done
3147    AD_FILES=`cat adSrcFiles.tmp`
3148    for i in $AD_FILES ; do
3149      basename=${i%%.f}
3150      toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`
3151      if test -z "$toBeIgnored" ; then
3152        echo    " \\" >> $MAKEFILE
3153        printf " $i" >> $MAKEFILE
3154      fi
3155    done
3156    echo >> $MAKEFILE
3157    rm -f adSrcFiles.tmp
3158    
3159    cat >>$MAKEFILE <<EOF
3160    
3161    adAll: \$(EXE_AD)
3162    .PHONY: adAll
3163    
3164    CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))
3165    
3166    .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90)
3167    
3168    .PHONY: adDepend
3169    adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90)
3170            \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
3171            \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
3172            -rm -f makedepend.out
3173    
3174    OPENAD_SUPPORT_F90_SRC_FILES = \
3175    w2f__types.F90 \
3176    OAD_active.F90 \
3177    OAD_cp.F90 \
3178    OAD_rev.F90 \
3179    OAD_tape.F90
3180    
3181    OPENAD_SUPPORT_C_SRC_FILES = \
3182    iaddr.c \
3183    timeRatio.c
3184    
3185    f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)
3186            cat \$^ > \$@
3187    
3188    f95_test.f90: all_mods.xb.x2w.w2f.pp.f$FS90 \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
3189            cat \$^ > \$@
3190    
3191    f95_test.out: f95_test_mods.f90 f95_test.f90
3192            f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1
3193            f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1
3194    
3195    CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)
3196    
3197    AD_OBJ_FILES_S1=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o)  OAD_intrinsics_oad.o \$(CB2M_AD_FILES:.f$FS90=_oad.o)
3198    
3199    AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o)
3200    
3201    \$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.tag \$(AD_OBJ_FILES_S2)
3202            \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)
3203    
3204    # create sources files modules from header files containing common blocks
3205    %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk
3206            ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk
3207    
3208    # create new header files with USE statements for the new modules made above
3209    %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk
3210            ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
3211    
3212    # change the include directives of everybody to refer to  the new header files with the USE statements
3213    %_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash
3214            ../OAD_support/cb2mUseModules.bash $< ${MPI}
3215    
3216    # makefile debug rule
3217    small_f: \$(CB2M_F90_PP_SRC_FILES)
3218    .PHONY: small_f
3219    
3220    ad_output.txt: \$(EXE_AD)
3221            @printf 'linking data files ... '
3222            \$(LN) -f ../input_ad/data* ../input_ad/eedata .
3223            \$(LN) -f ../../global_ocean.90x40x15/input/*.bin .
3224            @printf 'running ... '
3225            @./\$(EXE_AD) > \$@
3226    
3227    ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3228            cat \$^ > \$@
3229    
3230    # canonicalizer
3231    ad_input_code_sf.pre.f90 : \$(CB2M_AD_FILES)
3232            \${OPENADFORTTK_BASE}/tools/SourceProcessing/preProcess.py --timing --r8 -H -S  -o \$@ \$^
3233    
3234    # replace stop statements (to avoid the implied unstructured control flow)  with print statements
3235    ad_input_code_sf.pre.s2p.f90 : ad_input_code_sf.pre.f90
3236            cat \$< | sed -f ../OAD_support/stop2print.sed > ad_input_code_sf.pre.s2p.f90
3237    
3238    # F -> WHIRL
3239    ad_input_code_sf.pre.s2p.B: ad_input_code_sf.pre.s2p.f90
3240            \${OPEN64ROOT}/crayf90/sgi/mfef90 -r8 -z -F ad_input_code_sf.pre.s2p.f90
3241    
3242    # WHIRL -> XAIF
3243    ad_input_code_sf.pre.s2p.xaif : ad_input_code_sf.pre.s2p.B
3244            \${OPENADFORTTK}/bin/whirl2xaif -s -n --debug 1 -o \$@ \$<
3245    
3246    # XAIF -> XAIF'
3247    ad_input_code_sf.pre.s2p.xb.xaif : ad_input_code_sf.pre.s2p.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd
3248            \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r
3249    
3250    # XAIF' -> WHIRL'
3251    ad_input_code_sf.pre.s2p.xb.x2w.B : ad_input_code_sf.pre.s2p.xb.xaif
3252            \${OPENADFORTTK}/bin/xaif2whirl --debug 1 ad_input_code_sf.pre.s2p.B \$<
3253    
3254    # WHIRL' -> F'
3255    ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.B
3256            \${OPEN64ROOT}/whirl2f/whirl2f -FLIST:ftn_file=\$@ -openad \$<
3257    
3258    # insert template directives
3259    ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 ../OAD_support/insertTemplateDir.bash
3260            ../OAD_support/insertTemplateDir.bash \$< \$@
3261    
3262    PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F
3263    # postprocess F'
3264    postProcess.tag: ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90 \$(PPEXTRAS:.F=.f) | w2f__types.f90
3265            \${OPENADFORTTK_BASE}/tools/SourceProcessing/postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed --separateOutput --pathSuffix "" --filenameSuffix "_oad" -m r -i ../OAD_support/ad_inline.f \$<
3266            # the target is a placeholder to trigger a single execution of the rule
3267            touch \$@
3268    # put this so make knows about the postprocessing output
3269    OAD_intrinsics_oad.f \$(CB2M_AD_FILES:.f$FS90=_oad.f): postProcess.tag
3270    
3271    # link the XAIF schema files
3272    %.xsd:
3273            \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3274    
3275    # link the support files:
3276    \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):
3277            \$(LN) ../OAD_support/\$@ .
3278    
3279    AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag \$(PPEXTRAS:.F=.f)
3280    
3281    # ============ end OpenAD specific section ==============
3282    
3283  EOF  EOF
3284    
3285    fi
3286    
3287    #=========================================
3288    
3289  if test "x$EXEHOOK" != x ; then  if test "x$EXEHOOK" != x ; then
3290      printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE      printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
3291  fi  fi
# Line 2549  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 3321  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
3321  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
3322    
3323  # Create special header files  # Create special header files
3324  $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"  $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"
3325  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
3326      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
3327  else  else
# Line 2563  else Line 3335  else
3335      fi      fi
3336  fi  fi
3337  if test ! -f AD_CONFIG.h ; then  if test ! -f AD_CONFIG.h ; then
3338      $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      $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > AD_CONFIG.h
3339  fi  fi
3340    
   
3341  #  Write the "state" for future records  #  Write the "state" for future records
3342  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" = xt ; then
3343      printf "" > genmake_state      printf "" > genmake_state
3344      for i in $gm_state ; do      for i in $gm_state ; do
3345          t1="t2=\$$i"          t1="t2=\$$i"
3346          eval $t1          eval $t1
3347          echo "$i='$t2'" >> genmake_state          echo "$i='$t2'" | sed -e 's/  */ /g' >> genmake_state
3348      done      done
3349  fi  fi

Legend:
Removed from v.1.140  
changed lines
  Added in v.1.237

  ViewVC Help
Powered by ViewVC 1.1.22