/[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.215 by jmc, Mon Dec 6 17:16:06 2010 UTC revision 1.238 by jmc, Tue Aug 28 21:11:22 2012 UTC
# Line 17  Usage: "$0" [OPTIONS] Line 17  Usage: "$0" [OPTIONS]
17    where [OPTIONS] can be:    where [OPTIONS] can be:
18    
19      -help | --help | -h | --h      -help | --help | -h | --h
20            Print this help message and exit.            Print this help message and exit.
21    
22      -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME      -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
23        -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME        -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
24            Use "NAME" as the adoptfile.  By default, the file at            Use "NAME" as the adoptfile.  By default, the file at
25            "tools/adjoint_options/adjoint_default" will be used.            "tools/adjoint_options/adjoint_default" will be used.
26    
27      -nooptfile | --nooptfile      -nooptfile | --nooptfile
28        -optfile NAME | --optfile NAME | -of NAME | --of NAME        -optfile NAME | --optfile NAME | -of NAME | --of NAME
29        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
30            Use "NAME" as the optfile.  By default, an attempt will be            Use "NAME" as the optfile.  By default, an attempt will be
31            made to find an appropriate "standard" optfile in the            made to find an appropriate "standard" optfile in the
32            tools/build_options/ directory.            tools/build_options/ directory.
33    
34      -pdepend NAME | --pdepend NAME      -pdepend NAME | --pdepend NAME
35        -pdepend=NAME | --pdepend=NAME        -pdepend=NAME | --pdepend=NAME
36            Get package dependency information from "NAME".            Get package dependency information from "NAME".
37    
38      -pgroups NAME | --pgroups NAME      -pgroups NAME | --pgroups NAME
39        -pgroups=NAME | --pgroups=NAME        -pgroups=NAME | --pgroups=NAME
40            Get the package groups information from "NAME".            Get the package groups information from "NAME".
41    
42      -bash NAME      -bash NAME
43            Explicitly specify the Bourne or BASH shell to use            Explicitly specify the Bourne or BASH shell to use
44    
45      -make NAME | -m NAME      -make NAME | -m NAME
46        --make=NAME | -m=NAME        --make=NAME | -m=NAME
47            Use "NAME" for the MAKE program. The default is "make" but            Use "NAME" for the MAKE program. The default is "make" but
48            many platforms, "gmake" is the preferred choice.            many platforms, "gmake" is the preferred choice.
49    
50      -makefile NAME | -mf NAME      -makefile NAME | -mf NAME
51        --makefile=NAME | -mf=NAME        --makefile=NAME | -mf=NAME
52            Call the makefile "NAME".  The default is "Makefile".            Call the makefile "NAME".  The default is "Makefile".
53    
54      -makedepend NAME | -md NAME      -makedepend NAME | -md NAME
55        --makedepend=NAME | -md=NAME        --makedepend=NAME | -md=NAME
56            Use "NAME" for the MAKEDEPEND program.            Use "NAME" for the MAKEDEPEND program.
57    
58      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
59        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
60            Specify the location of the MITgcm ROOTDIR as "NAME".            Specify the location of the MITgcm ROOTDIR as "NAME".
61            By default, genamke will try to find the location by            By default, genamke will try to find the location by
62            looking in parent directories (up to the 5th parent).            looking in parent directories (up to the 5th parent).
63    
64      -mods NAME | --mods NAME | -mo NAME | --mo NAME      -mods NAME | --mods NAME | -mo NAME | --mo NAME
65        -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME        -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME
66            Here, "NAME" specifies a list of directories that are            Here, "NAME" specifies a list of directories that are
67            used for additional source code.  Files found in the            used for additional source code.  Files found in the
68            "mods list" are given preference over files of the same            "mods list" are given preference over files of the same
69            name found elsewhere.            name found elsewhere.
70    
71      -disable NAME | --disable NAME      -disable NAME | --disable NAME
72        -disable=NAME | --disable=NAME        -disable=NAME | --disable=NAME
73            Here "NAME" specifies a list of packages that we don't            Here "NAME" specifies a list of packages that we don't
74            want to use.  If this violates package dependencies,            want to use.  If this violates package dependencies,
75            genamke will exit with an error message.            genamke will exit with an error message.
76    
77      -enable NAME | --enable NAME      -enable NAME | --enable NAME
78        -enable=NAME | --enable=NAME        -enable=NAME | --enable=NAME
79            Here "NAME" specifies a list of packages that we wish            Here "NAME" specifies a list of packages that we wish
80            to specifically enable.  If this violates package            to specifically enable.  If this violates package
81            dependencies, genamke will exit with an error message.            dependencies, genamke will exit with an error message.
82    
83      -standarddirs NAME | --standarddirs NAME      -standarddirs NAME | --standarddirs NAME
84        -standarddirs=NAME | --standarddirs=NAME        -standarddirs=NAME | --standarddirs=NAME
85            Here, "NAME" specifies a list of directories to be            Here, "NAME" specifies a list of directories to be
86            used as the "standard" code.            used as the "standard" code.
87    
88      -fortran NAME | --fortran NAME | -fc NAME | --fc NAME      -fortran NAME | --fortran NAME | -fc NAME | --fc NAME
89        -fc=NAME | --fc=NAME        -fc=NAME | --fc=NAME
90            Use "NAME" as the fortran compiler.  By default, genmake            Use "NAME" as the fortran compiler.  By default, genmake
91            will search for a working compiler by trying a list of            will search for a working compiler by trying a list of
92            "usual suspects" such as g77, f77, etc.            "usual suspects" such as g77, f77, etc.
93    
94      -cc NAME | --cc NAME | -cc=NAME | --cc=NAME      -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
95            Use "NAME" as the C compiler.  By default, genmake            Use "NAME" as the C compiler.  By default, genmake
96            will search for a working compiler by trying a list of            will search for a working compiler by trying a list of
97            "usual suspects" such as gcc, c89, cc, etc.            "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.  
98    
99      -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4      -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4
100            Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW)            Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW)
101            *only* works if CPP_EEOPTIONS.h allows this.            *only* works if CPP_EEOPTIONS.h allows this.
102    
103      -ignoretime | -ignore_time | --ignoretime | --ignore_time      -ignoretime | -ignore_time | --ignoretime | --ignore_time
104            Ignore all the "wall clock" routines entirely.  This will            Ignore all the "wall clock" routines entirely.  This will
105            not in any way hurt the model results -- it simply means            not in any way hurt the model results -- it simply means
106            that the code that checks how long the model spends in            that the code that checks how long the model spends in
107            various routines will give junk values.            various routines will give junk values.
108    
109      -ts | --ts      -ts | --ts
110            Produce timing information per timestep            Produce timing information per timestep
111      -papis | --papis      -papis | --papis
112            Produce summary MFlop/s (and IPC) with PAPI per timestep            Produce summary MFlop/s (and IPC) with PAPI per timestep
113      -pcls | --pcls      -pcls | --pcls
114            Produce summary MFlop/s etc. with PCL per timestep            Produce summary MFlop/s etc. with PCL per timestep
115      -foolad | --foolad      -foolad | --foolad
116            Fool the AD code generator            Fool the AD code generator
117      -papi | --papi      -papi | --papi
118            Performance analysis with PAPI            Performance analysis with PAPI
119      -pcl | --pcl      -pcl | --pcl
120            Performance analysis with PCL            Performance analysis with PCL
121      -hpmt | --hpmt      -hpmt | --hpmt
122            Performance analysis with the HPM Toolkit            Performance analysis with the HPM Toolkit
123    
124      -gsl | --gsl      -ieee | --ieee
125            Use GSL to control floating point rounding and precision            use IEEE numerics.  Note that this option *only* works
126              if it is supported by the OPTFILE that is being used.
127      -devel | --devel      -devel | --devel
128            Add additional warning and debugging flags for development            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      -mpi | --mpi
134            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
135      -mpi=PATH | --mpi=PATH      -mpi=PATH | --mpi=PATH
136            Include MPI header files and link to MPI libraries using MPI_ROOT            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            set to PATH. i.e. Include files from \$PATH/include, link to libraries
138            from \$PATH/lib and use binaries from \$PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
139    
140      -omp | --omp      -omp | --omp
141            Activate OpenMP code + use Compiler option OMPFLAG            Activate OpenMP code + use Compiler option OMPFLAG
142      -omp=OMPFLAG | --omp=OMPFLAG      -omp=OMPFLAG | --omp=OMPFLAG
143            Activate OpenMP code + use Compiler option OMPFLAG            Activate OpenMP code + use Compiler option OMPFLAG
144    
145      -es | --es | -embed-source | --embed-source      -es | --es | -embed-source | --embed-source
146            Embed a tarball containing the full source code            Embed a tarball containing the full source code
147            (including the Makefile, etc.) used to build the            (including the Makefile, etc.) used to build the
148            executable [off by default]            executable [off by default]
149    
150      -ds | --ds      -ds | --ds
151            Report genmake internal variables status (DUMPSTATE)            Report genmake internal variables status (DUMPSTATE)
152            to file "genmake_state" (for debug purpose)            to file "genmake_state" (for debug purpose)
153    
154    While it is most often a single word, the "NAME" variables specified    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:    above can in many cases be a space-delimited string such as:
# Line 208  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          exit 99          exit 99
212      fi      fi
213      return 0      return 0
# Line 298  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 306  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 346  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 364  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  \
413              &&  ./configure > /dev/null 2>&1  \              &&  ./configure > /dev/null 2>&1  \
414              &&  make > /dev/null 2>&1              &&  $MAKE > /dev/null 2>&1
415          if test -x ./makedepend.exe ; then          if test -x ./makedepend.exe ; then
416              $LN ./makedepend.exe ./makedepend              $LN ./makedepend.exe ./makedepend
417          fi          fi
# Line 407  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  }  }
# Line 418  build_embed_encode() Line 435  build_embed_encode()
435  {  {
436      printf "  building the embed-encode utility...  "      printf "  building the embed-encode utility...  "
437      if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then      if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then
438          if test ! -d "$ROOTDIR/tools/embed_encode" ; then          if test ! -d "$ROOTDIR/tools/embed_encode" ; then
439              echo              echo
440              echo "    Error: can't locate \"$ROOTDIR/tools/embed_encode\""              echo "    Error: can't locate \"$ROOTDIR/tools/embed_encode\""
441              echo              echo
442              EMBED_SRC=f              EMBED_SRC=f
443              return 1              return 1
444          fi          fi
445          clist="cc gcc c89 $CC"          clist="cc gcc c89 $CC"
446          for ic in $clist ; do          for ic in $clist ; do
447              comm="$ic -o encode_files encode_files.c"              comm="$ic -o encode_files encode_files.c"
# Line 432  build_embed_encode() Line 449  build_embed_encode()
449              RETVAL=$?              RETVAL=$?
450              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
451                  echo "OK"                  echo "OK"
                 DEFINES="$DEFINES -DHAVE_EMBED_SRC"  
452                  return 0                  return 0
453              fi              fi
454          done          done
# Line 444  build_embed_encode() Line 460  build_embed_encode()
460          return 1          return 1
461      fi      fi
462      echo "OK"      echo "OK"
     DEFINES="$DEFINES -DHAVE_EMBED_SRC"  
463  }  }
464    
465  #  look for possible C compilers  #  look for possible C compilers
# Line 562  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    
584      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
# Line 581  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
   
 #     # look for possible MPI libraries  
 #     mpi_libs=  
 #     mpi_fort=`which mpif77 2>/dev/null`  
 #     RETVAL=$?  
 #     if test "x${RETVAL}" = x0 ; then  
 #       cat >>test.f <<EOF  
 #       PROGRAM HELLO  
 #       DO 10, I=1,10  
 #       PRINT *,'Hello World'  
 #    10 CONTINUE  
 #       STOP  
 #       END  
 # EOF  
 #       eval "$mpi_fort -showme test.f > out"  
 #       RETVAL=$?  
 #       if test "x${RETVAL}" = x0 ; then  
 #           a=`cat out`  
 #           for i in $a ; do  
 #               case $i in  
 #                   -*)  
 #                       mpi_libs="$mpi_libs $i" ;;  
 #               esac  
 #           done  
 #           echo "The MPI libs appear to be:"  
 #           echo "  "$mpi_libs  
 #       fi  
 #       rm -f test.f out  
 #     fi  
599  }  }
600    
601  #  Parse the package dependency information  #  Parse the package dependency information
# Line 634  get_fortran_c_namemangling()  { Line 620  get_fortran_c_namemangling()  {
620    
621      #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""      #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
622      if test ! "x$FC_NAMEMANGLE" = x ; then      if test ! "x$FC_NAMEMANGLE" = x ; then
623          return 0          return 0
624      fi      fi
625      echo " running: get_fortran_c_namemangling()" >> $LOGFILE      echo " running: get_fortran_c_namemangling()" >> $LOGFILE
626    
# Line 766  EOF Line 752  EOF
752      RETVAL=$?      RETVAL=$?
753      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
754          HAVE_CLOC=t          HAVE_CLOC=t
         DEFINES="$DEFINES -DHAVE_CLOC"  
755      fi      fi
756      rm -f genmake_tc*      rm -f genmake_tc*
757      echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE      echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE
# Line 828  EOF Line 813  EOF
813      RETVAL=$?      RETVAL=$?
814      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
815          HAVE_SIGREG=t          HAVE_SIGREG=t
         DEFINES="$DEFINES -DHAVE_SIGREG"  
816      fi      fi
817      rm -f genmake_tc*      rm -f genmake_tc*
818      echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE      echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE
819  }  }
820    
821  check_HAVE_SETRLSTK()  {  check_HAVE_SETRLSTK()  {
     if test "x$HAVE_SETRLSTK" = xt ; then  
         DEFINES="$DEFINES -DHAVE_SETRLSTK"  
         return  
     fi    
822      if test ! "x$HAVE_SETRLSTK" = x ; then      if test ! "x$HAVE_SETRLSTK" = x ; then
823          return          return
824      fi      fi
# Line 876  EOF Line 856  EOF
856      RETVAL=$?      RETVAL=$?
857      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
858          HAVE_SETRLSTK=t          HAVE_SETRLSTK=t
         DEFINES="$DEFINES -DHAVE_SETRLSTK"  
859      fi      fi
860      rm -f genmake_tc*      rm -f genmake_tc*
861      echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE      echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE
# Line 923  EOF Line 902  EOF
902      RETVAL=$?      RETVAL=$?
903      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
904          HAVE_STAT=t          HAVE_STAT=t
         DEFINES="$DEFINES -DHAVE_STAT"  
905      fi      fi
906      rm -f genmake_tc*      rm -f genmake_tc*
907      echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE      echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE
# Line 1021  EOF Line 999  EOF
999      echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE      echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE
1000  }  }
1001    
1002    check_lapack_libs()  {
1003        if test ! "x$SKIP_LAPACK_CHECK" = x ; then
1004            return
1005        fi
1006        echo >> $LOGFILE
1007        echo "running: check_lapack_libs()" >> $LOGFILE
1008        cat <<EOF > genmake_tla.F
1009          program fgenla
1010          integer info
1011          integer ipiv( 2 )
1012          double precision ab( 4, 2 ), b( 2 )
1013          data ab / 0., 0., 1., 2., 0., 2., 1., 0. /
1014          data b / 1., 1. /
1015          call dgbsv( 2, 1, 1, 1, ab, 4, ipiv, b, 2, info )
1016          IF (info .NE. 0) write(*,*) 'Error:', info
1017          write(*,*) b
1018          end
1019    EOF
1020        echo "===  genmake_tla.F  >>>" > genmake_tla.log
1021        cat genmake_tla.F >> genmake_tla.log
1022        echo "<<<  genmake_tla.F  ===" >> genmake_tla.log
1023        RET_CPP=f
1024        COMM="cat genmake_tla.F | $CPP $DEFINES $INCLUDES"
1025        echo "$COMM" >> genmake_tla.log
1026        eval $COMM > genmake_tla.$FS 2>/dev/null  &&  RET_CPP=t
1027        if test "x$RET_CPP" = xf ; then
1028            echo "  WARNING: CPP failed to pre-process the lapack test." \
1029                >> genmake_tla.log
1030            echo "    Please check that \$INCLUDES is properly set." \
1031                >> genmake_tla.log
1032        fi
1033        echo "$FC $FFLAGS $FOPTIM -c genmake_tla.$FS  \ " >> genmake_tla.log
1034        echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tla.o $LIBS" >> genmake_tla.log
1035        $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1036            &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS >> genmake_tla.log 2>&1
1037        RET_COMPILE=$?
1038        cat genmake_tla.log >> $LOGFILE
1039    
1040        # test program execution not always possible (see check_netcdf_libs)
1041        #
1042        #test -x ./genmake_tla  &&  ./genmake_tla >> genmake_tla.log 2>&1
1043        #RETVAL=$?
1044        #if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
1045    
1046        if test "x$RET_COMPILE" = x0 ; then
1047            HAVE_LAPACK=t
1048            echo "check_lapack: successful" >> $LOGFILE
1049        else
1050            # try again with "-llapack" added to the libs
1051            echo "==> try again with added '-llapack'" > genmake_tla.log
1052            echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1053            echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1054            echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack" >> genmake_tla.log
1055            cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1056                &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1057                &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack >> genmake_tla.log 2>&1
1058            RET_COMPILE=$?
1059            echo >> $LOGFILE
1060            cat genmake_tla.log >> $LOGFILE
1061            if test "x$RET_COMPILE" = x0 ; then
1062                LIBS="$LIBS -llapack"
1063                HAVE_LAPACK=t
1064                echo "check_lapack: successful" >> $LOGFILE
1065            else
1066            # try again with "-lf77blas -lcblas" added to the libs
1067                echo "==> try again with added '-llapack -lf77blas -lcblas'" > genmake_tla.log
1068                echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1069                echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1070                echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas" >> genmake_tla.log
1071                cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1072                    &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1073                    &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas >> genmake_tla.log 2>&1
1074                RET_COMPILE=$?
1075                echo >> $LOGFILE
1076                cat genmake_tla.log >> $LOGFILE
1077                if test "x$RET_COMPILE" = x0 ; then
1078                    LIBS="$LIBS -llapack -lf77blas -lcblas"
1079                    HAVE_LAPACK=t
1080                    echo "check_lapack: successful" >> $LOGFILE
1081                else
1082                # try again with "-latlas" added to the libs
1083                    echo "==> try again with added '-llapack -lf77blas -lcblas -latlas'" > genmake_tla.log
1084                    echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1085                    echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1086                    echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas" >> genmake_tla.log
1087                    cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1088                        &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1089                        &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas >> genmake_tla.log 2>&1
1090                    RET_COMPILE=$?
1091                    echo >> $LOGFILE
1092                    cat genmake_tla.log >> $LOGFILE
1093                    if test "x$RET_COMPILE" = x0 ; then
1094                        LIBS="$LIBS -llapack -lf77blas -lcblas -latlas"
1095                        HAVE_LAPACK=t
1096                        echo "check_lapack: successful" >> $LOGFILE
1097                    fi
1098                fi
1099            fi
1100        fi
1101        rm -f genmake_tla*
1102        echo " --> set HAVE_LAPACK='$HAVE_LAPACK'" >> $LOGFILE
1103    }
1104    
1105    
1106  ###############################################################################  ###############################################################################
1107  #   Sequential part of script starts here  #   Sequential part of script starts here
# Line 1053  FOPTIM= Line 1134  FOPTIM=
1134  FEXTRAFLAGS=  FEXTRAFLAGS=
1135  USE_EXTENDED_SRC=  USE_EXTENDED_SRC=
1136  EXTENDED_SRC_FLAG=  EXTENDED_SRC_FLAG=
1137    GET_FC_VERSION=
1138  CFLAGS=  CFLAGS=
1139  KFLAGS1=  KFLAGS1=
1140  KFLAGS2=  KFLAGS2=
# Line 1087  HAVE_STAT= Line 1169  HAVE_STAT=
1169  HAVE_NETCDF=  HAVE_NETCDF=
1170  HAVE_ETIME=  HAVE_ETIME=
1171  IGNORE_TIME=  IGNORE_TIME=
1172    HAVE_LAPACK=
1173    
1174  MODS=  MODS=
1175  TOOLSDIR=  TOOLSDIR=
# Line 1094  SOURCEDIRS= Line 1177  SOURCEDIRS=
1177  INCLUDEDIRS=  INCLUDEDIRS=
1178  STANDARDDIRS="USE_THE_DEFAULT"  STANDARDDIRS="USE_THE_DEFAULT"
1179    
1180    #- local config file
1181    gm_local="genmake_local"
1182    
1183  G2ARGS=  G2ARGS=
1184  BASH=  BASH=
1185  PWD=`pwd`  PWD=`pwd`
# Line 1109  MACHINE=`uname -a` Line 1195  MACHINE=`uname -a`
1195  EXECUTABLE=  EXECUTABLE=
1196  EXEHOOK=  EXEHOOK=
1197  EXEDIR=  EXEDIR=
 PACKAGES_CONF=  
1198  IEEE=  IEEE=
1199  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
1200      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
# Line 1131  SVD_TAMC_FLAGS= Line 1216  SVD_TAMC_FLAGS=
1216  TAMC_EXTRA=  TAMC_EXTRA=
1217    
1218  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1219  gm_s1="OPTFILE PKG_DEPEND PKG_GROUPS MAKEFILE MAKEDEPEND PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="ROOTDIR STANDARDDIRS MODS PKG_DEPEND PKG_GROUPS DISABLE ENABLE"
1220  gm_s2="FC CC IEEE USE_R4 TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI OMP DUMPSTATE STANDARDDIRS"  gm_s2="PLATFORM OPTFILE MAKE MAKEFILE MAKEDEPEND FC CC MPI OMP USE_R4"
1221    gm_s3="FEXTRAFLAGS IEEE DEVEL GSL TS PAPIS PCLS PAPI PCL HPMT DUMPSTATE"
1222    
1223  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1224  gm_s3="LN S64 LINK MAKE PACKAGES INCLUDES FFLAGS FOPTIM FEXTRAFLAGS"  gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM"
1225  gm_s4="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
1226  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD THISHOST THISUSER THISDATE THISVER MACHINE"  gm_s6="TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"
1227  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s7="PWD THISHOST THISUSER THISDATE THISVER MACHINE"
1228  gm_s7="FC_NAMEMANGLE HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME"  gm_s8="FC_NAMEMANGLE HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME HAVE_LAPACK"
1229    
1230  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1231  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
1232  gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"  gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
1233  gm_s12="TAF_EXTRA TAMC_EXTRA"  gm_s12="TAF_EXTRA TAMC_EXTRA"
1234    
1235  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7"  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8"
1236  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
1237    
1238  cat <<EOF  cat <<EOF
# Line 1165  LOGFILE="genmake.log" Line 1251  LOGFILE="genmake.log"
1251  rm -f genmake_state genmake_*optfile $LOGFILE  rm -f genmake_state genmake_*optfile $LOGFILE
1252    
1253  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
 gm_local="genmake_local"  
 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  
1254    
1255  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
1256  #parse_options  #parse_options
# Line 1193  for ac_option in "$@" ; do Line 1269  for ac_option in "$@" ; do
1269      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
1270    
1271      case $ac_option in      case $ac_option in
1272            
1273          -help | --help | -h | --h)          -help | --help | -h | --h)
1274              usage ;;              usage ;;
1275            
1276          -nooptfile | --nooptfile)          -nooptfile | --nooptfile)
1277              OPTFILE="NONE" ;;              OPTFILE="NONE" ;;
1278          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
1279              ac_prev=OPTFILE ;;              ac_prev=OPTFILE ;;
1280          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
1281              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
1282            
1283          -adoptfile | --adoptfile | -adof | --adof)          -adoptfile | --adoptfile | -adof | --adof)
1284              ac_prev=AD_OPTFILE ;;              ac_prev=AD_OPTFILE ;;
1285          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
1286              AD_OPTFILE=$ac_optarg ;;              AD_OPTFILE=$ac_optarg ;;
1287            
1288          -pdepend | --pdepend)          -pdepend | --pdepend)
1289              ac_prev=PKG_DEPEND ;;              ac_prev=PKG_DEPEND ;;
1290          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
1291              PKG_DEPEND=$ac_optarg ;;              PKG_DEPEND=$ac_optarg ;;
1292            
1293          -pgroups | --pgroups)          -pgroups | --pgroups)
1294              ac_prev=PKG_GROUPS ;;              ac_prev=PKG_GROUPS ;;
1295          -pgroups=* | --pgroups=*)          -pgroups=* | --pgroups=*)
1296              PKG_GROUPS=$ac_optarg ;;              PKG_GROUPS=$ac_optarg ;;
1297            
1298          -make | --make | -m | --m)          -make | --make | -m | --m)
1299              ac_prev=MAKE ;;              ac_prev=MAKE ;;
1300          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
1301              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
1302            
1303          -bash | --bash)          -bash | --bash)
1304              ac_prev=BASH ;;              ac_prev=BASH ;;
1305          -bash=* | --bash=*)          -bash=* | --bash=*)
1306              BASH=$ac_optarg ;;              BASH=$ac_optarg ;;
1307            
1308          -makedepend | --makedepend | -md | --md)          -makedepend | --makedepend | -md | --md)
1309              ac_prev=MAKEDEPEND ;;              ac_prev=MAKEDEPEND ;;
1310          -makedepend=* | --makedepend=* | -md=* | --md=*)          -makedepend=* | --makedepend=* | -md=* | --md=*)
1311              MAKEDEPEND=$ac_optarg ;;              MAKEDEPEND=$ac_optarg ;;
1312            
1313          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -mf | --mf)
1314              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
1315          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -mf=* | --mf=*)
1316              MAKEFILE=$ac_optarg ;;              MAKEFILE=$ac_optarg ;;
1317            
1318          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)
1319              echo "ERROR: The platform option has been removed.  Please specify"              echo "ERROR: The platform option has been removed.  Please specify"
1320              echo "  the build options using the \"optfile\" mechanism."              echo "  the build options using the \"optfile\" mechanism."
1321              echo              echo
1322              usage              usage
1323              ;;              ;;
1324            
1325          -rootdir | --rootdir | -rd | --rd)          -rootdir | --rootdir | -rd | --rd)
1326              ac_prev=ROOTDIR ;;              ac_prev=ROOTDIR ;;
1327          -rootdir=* | --rootdir=* | -rd=* | --rd=*)          -rootdir=* | --rootdir=* | -rd=* | --rd=*)
1328              ROOTDIR=$ac_optarg ;;              ROOTDIR=$ac_optarg ;;
1329            
1330          -mods | --mods | -mo | --mo)          -mods | --mods | -mo | --mo)
1331              ac_prev=MODS ;;              ac_prev=MODS ;;
1332          -mods=* | --mods=* | -mo=* | --mo=*)          -mods=* | --mods=* | -mo=* | --mo=*)
1333              MODS=$ac_optarg ;;              MODS=$ac_optarg ;;
1334            
1335          -disable | --disable)          -disable | --disable)
1336              ac_prev=DISABLE ;;              ac_prev=DISABLE ;;
1337          -disable=* | --disable=*)          -disable=* | --disable=*)
1338              DISABLE=$ac_optarg ;;              DISABLE=$ac_optarg ;;
1339            
1340          -enable | --enable)          -enable | --enable)
1341              ac_prev=ENABLE ;;              ac_prev=ENABLE ;;
1342          -enable=* | --enable=*)          -enable=* | --enable=*)
1343              ENABLE=$ac_optarg ;;              ENABLE=$ac_optarg ;;
1344            
1345          -standarddirs | --standarddirs)          -standarddirs | --standarddirs)
1346              ac_prev=STANDARDDIRS ;;              ac_prev=STANDARDDIRS ;;
1347          -standarddirs=* | --standarddirs=*)          -standarddirs=* | --standarddirs=*)
# Line 1275  for ac_option in "$@" ; do Line 1351  for ac_option in "$@" ; do
1351  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1352  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1353  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1354            
1355          -cc | --cc)          -cc | --cc)
1356              ac_prev=CC ;;              ac_prev=CC ;;
1357          -cc=* | --cc=*)          -cc=* | --cc=*)
1358              CC=$ac_optarg ;;              CC=$ac_optarg ;;
1359            
1360          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1361              ac_prev=FC ;;              ac_prev=FC ;;
1362          -fc=* | --fc=*)          -fc=* | --fc=*)
1363              FC=$ac_optarg ;;              FC=$ac_optarg ;;
1364            
1365          -fs | --fs)          -fs | --fs)
1366              ac_prev=FS ;;              ac_prev=FS ;;
1367          -fs=* | --fs=*)          -fs=* | --fs=*)
1368              FS=$ac_optarg ;;              FS=$ac_optarg ;;
1369            
1370          -fs90 | --fs90)          -fs90 | --fs90)
1371              ac_prev=FS90 ;;              ac_prev=FS90 ;;
1372          -fs90=* | --fs90=*)          -fs90=* | --fs90=*)
1373              FS90=$ac_optarg ;;              FS90=$ac_optarg ;;
           
         -ieee | --ieee)  
             IEEE=true ;;  
         -noieee | --noieee)  
             IEEE= ;;  
1374    
1375          -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )          -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )
1376              USE_R4=true ;;              USE_R4=true ;;
1377    
1378            -ieee | --ieee)
1379                IEEE=true ;;
1380            -noieee | --noieee)
1381                echo "Warning: ignore option '$ac_option' (default is already without '-ieee')" ;;
1382            -devel | --devel)
1383                IEEE=true ; DEVEL=true ;;
1384            -gsl | --gsl)
1385                GSL=true ;;
1386    
1387          -ts | --ts)          -ts | --ts)
1388              TS=true ;;              TS=true ;;
1389          -papis | --papis)          -papis | --papis)
# Line 1319  for ac_option in "$@" ; do Line 1399  for ac_option in "$@" ; do
1399          -hpmt | --hpmt)          -hpmt | --hpmt)
1400              HPMT=true ;;              HPMT=true ;;
1401    
         -gsl | --gsl)  
             GSL=true ;;  
   
         -devel | --devel)  
             DEVEL=true ;;  
   
1402          -mpi | --mpi)          -mpi | --mpi)
1403              MPI=true ;;              MPI=true ;;
1404          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
1405              MPIPATH=$ac_optarg              MPIPATH=$ac_optarg
1406              MPI=true ;;              MPI=true ;;
1407            
1408          -omp | --omp)          -omp | --omp)
1409              OMP=true ;;              OMP=true ;;
1410          -omp=* | --omp=*)          -omp=* | --omp=*)
1411              OMPFLAG=$ac_optarg              OMPFLAG=$ac_optarg
1412              OMP=true ;;              OMP=true ;;
1413            
1414          -ds | --ds)          -ds | --ds)
1415              DUMPSTATE=t ;;              DUMPSTATE=t ;;
1416            
1417            -extra_flag | --extra_flag)
1418                ac_prev=FEXTRAFLAGS ;;
1419            -extra_flag=* | --extra_flag=*)
1420                FEXTRAFLAGS=$ac_optarg ;;
1421    
1422          -taf_extra | --taf_extra)          -taf_extra | --taf_extra)
1423              ac_prev=TAF_EXTRA ;;              ac_prev=TAF_EXTRA ;;
1424          -taf_extra=* | --taf_extra=*)          -taf_extra=* | --taf_extra=*)
# Line 1349  for ac_option in "$@" ; do Line 1428  for ac_option in "$@" ; do
1428              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1429          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1430              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1431            
1432          -ignoretime | -ignore_time | --ignoretime | --ignore_time)          -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1433              IGNORE_TIME="-DIGNORE_TIME" ;;              IGNORE_TIME="-DIGNORE_TIME" ;;
1434    
# Line 1360  for ac_option in "$@" ; do Line 1439  for ac_option in "$@" ; do
1439              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
1440              usage              usage
1441              ;;              ;;
1442            
1443          *)          *)
1444              echo "Error: unrecognized argument: "$ac_option              echo "Error: unrecognized argument: "$ac_option
1445              usage              usage
1446              ;;              ;;
1447            
1448      esac      esac
1449    
1450  done  done
1451    
1452    printf "  getting local config information:  "
1453    if test -f $gm_local ; then
1454        echo "using $gm_local"
1455        . $gm_local
1456    else
1457        echo "none found"
1458    fi
1459    
1460  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1461      echo      echo
1462      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
1463      echo "  file.  This file format is no longer supported.  For directions on"      echo "  file.  This file format is no longer supported.  For directions on"
1464      echo "  how to setup and use the new \"genmake2\" script, please see:"      echo "  how to setup and use the new \"genmake2\" script, please see:"
1465      echo "    http://mitgcm.org/devel_HOWTO/"      echo "    http://mitgcm.org/public/devel_HOWTO/"
1466      echo "  and send an email to MITgcm-support@mitgcm.org if you need help."      echo "  and send an email to MITgcm-support@mitgcm.org if you need help."
1467      echo "WARNING: ignore \"./.genmakerc\" and continue."      echo "WARNING: ignore \"./.genmakerc\" and continue."
1468      echo      echo
# Line 1390  if test "x${ROOTDIR}" = x ; then Line 1477  if test "x${ROOTDIR}" = x ; then
1477          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
1478              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
1479                  ROOTDIR=$d                  ROOTDIR=$d
1480                  printf "Warning:  ROOTDIR was not specified but there appears to be"                  printf "Warning: ROOTDIR was not specified ;"
1481                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."                  echo " try using a local copy of MITgcm found at \"$ROOTDIR\""
1482                  break                  break
1483              fi              fi
1484          done          done
# Line 1423  if test "x$MAKEFILE" = x ; then Line 1510  if test "x$MAKEFILE" = x ; then
1510      MAKEFILE="Makefile"      MAKEFILE="Makefile"
1511  fi  fi
1512    
1513  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:"
1514  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1515      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
1516          echo "Warning: no OPTFILE specified so we'll look for possible settings"          echo "Warning: no OPTFILE specified so we'll look for possible settings"
# Line 1452  if test "x$OPTFILE" != xNONE ; then Line 1539  if test "x$OPTFILE" != xNONE ; then
1539      fi      fi
1540  fi  fi
1541    
1542  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:"
1543  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1544      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" = x ; then
1545          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
# Line 1498  Error: no Fortran compiler: please speci Line 1585  Error: no Fortran compiler: please speci
1585  EOF  EOF
1586      exit 1      exit 1
1587  fi  fi
1588    if test "x$GET_FC_VERSION" != x ; then
1589      echo "Get compiler version using: $FC $GET_FC_VERSION" >> $LOGFILE
1590      ff=`echo $FC | sed 's/ .*//'` ; xx=`echo $ff | sed 's/^./& /' | sed 's/ .*//'`
1591      if test $xx != '/' ; then which $ff >> $LOGFILE ; fi
1592      $FC $GET_FC_VERSION > genmake_fc_vers1 2> genmake_fc_vers2
1593      if test -s genmake_fc_vers1 ; then
1594        cat genmake_fc_vers1 >> $LOGFILE
1595      else
1596        cat genmake_fc_vers2 >> $LOGFILE
1597      fi
1598      echo "<-- compiler version ----" >> $LOGFILE
1599      rm -f genmake_fc_vers1 genmake_fc_vers2
1600    fi
1601    
1602  if test "x$CC" = x ; then  if test "x$CC" = x ; then
1603      look_for_C_compilers      look_for_C_compilers
# Line 1585  fi Line 1685  fi
1685  if test ! "x$TS" = x ; then  if test ! "x$TS" = x ; then
1686        echo "  Turning on timing per timestep"        echo "  Turning on timing per timestep"
1687        if test ! "x$FOOLAD" = x ; then        if test ! "x$FOOLAD" = x ; then
1688              DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"
1689        else        else
1690              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1691        fi        fi
# Line 1621  if test ! "x$PAPI" = x ; then Line 1721  if test ! "x$PAPI" = x ; then
1721            echo "  Sticking with PAPI flop summary per timestep!"            echo "  Sticking with PAPI flop summary per timestep!"
1722        else        else
1723            echo "  Turning on performance analysis with PAPI"            echo "  Turning on performance analysis with PAPI"
1724            echo "  Please make sure PAPIINC, PAPILIB are defined"            echo "  Please make sure PAPIINC, PAPILIB are defined"
1725            DEFINES="$DEFINES -DUSE_PAPI"            DEFINES="$DEFINES -DUSE_PAPI"
1726            INCLUDES="$INCLUDES $PAPIINC"            INCLUDES="$INCLUDES $PAPIINC"
1727            LIBS="$LIBS $PAPILIB"            LIBS="$LIBS $PAPILIB"
# Line 1633  if test ! "x$PCL" = x ; then Line 1733  if test ! "x$PCL" = x ; then
1733            echo "  Sticking with PCL flop summary per timestep!"            echo "  Sticking with PCL flop summary per timestep!"
1734        else        else
1735            echo "  Turning on performance analysis with PCL"            echo "  Turning on performance analysis with PCL"
1736            echo "  Please make sure PCLINC, PCLLIB are defined"            echo "  Please make sure PCLINC, PCLLIB are defined"
1737            DEFINES="$DEFINES -DUSE_PCL"            DEFINES="$DEFINES -DUSE_PCL"
1738            INCLUDES="$INCLUDES $PCLINC"            INCLUDES="$INCLUDES $PCLINC"
1739            LIBS="$LIBS $PCLLIB"            LIBS="$LIBS $PCLLIB"
# Line 1643  if test ! "x$HPMT" = x ; then Line 1743  if test ! "x$HPMT" = x ; then
1743        if test ! "x$PAPI" = x ; then        if test ! "x$PAPI" = x ; then
1744            echo "  PAPI and the HPM Toolkit cannot co-exist!"            echo "  PAPI and the HPM Toolkit cannot co-exist!"
1745            echo "  Sticking with PAPI!"            echo "  Sticking with PAPI!"
1746        else if test ! "x$PCL" = x ; then        else
1747            if test ! "x$PCL" = x ; then
1748            echo "  PCL and the HPM Toolkit cannot co-exist!"            echo "  PCL and the HPM Toolkit cannot co-exist!"
1749            echo "  Sticking with PCL!"            echo "  Sticking with PCL!"
1750        else          else
1751            echo "  Turning on performance analysis with the HPM Toolkit"            echo "  Turning on performance analysis with the HPM Toolkit"
1752            echo "  Please make sure HPMTINC, HPMTLIB are defined"            echo "  Please make sure HPMTINC, HPMTLIB are defined"
1753            DEFINES="$DEFINES -DUSE_LIBHPM"            DEFINES="$DEFINES -DUSE_LIBHPM"
1754            INCLUDES="$INCLUDES $HPMTINC"            INCLUDES="$INCLUDES $HPMTINC"
1755            LIBS="$LIBS $HPMTLIB"            LIBS="$LIBS $HPMTLIB"
1756        fi          fi
1757        fi        fi
1758  fi  fi
1759  if test ! "x$GSL" = x ; then  if test ! "x$GSL" = x ; then
# Line 1733  rm -f genmake_tcomp* Line 1834  rm -f genmake_tcomp*
1834  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1835  check_HAVE_CLOC  check_HAVE_CLOC
1836  if test "x$HAVE_CLOC" != x ; then  if test "x$HAVE_CLOC" != x ; then
1837        DEFINES="$DEFINES -DHAVE_CLOC"
1838      echo "yes"      echo "yes"
1839  else  else
1840      echo "no"      echo "no"
# Line 1747  rm -f genmake_t* Line 1849  rm -f genmake_t*
1849  printf "  Can we unlimit the stack size using $FC...  "  printf "  Can we unlimit the stack size using $FC...  "
1850  check_HAVE_SETRLSTK  check_HAVE_SETRLSTK
1851  if test "x$HAVE_SETRLSTK" = xt ; then  if test "x$HAVE_SETRLSTK" = xt ; then
1852        DEFINES="$DEFINES -DHAVE_SETRLSTK"
1853      echo "yes"      echo "yes"
1854  else  else
1855      echo "no"      echo "no"
# Line 1756  rm -f genmake_t* Line 1859  rm -f genmake_t*
1859  printf "  Can we register a signal handler using $FC...  "  printf "  Can we register a signal handler using $FC...  "
1860  check_HAVE_SIGREG  check_HAVE_SIGREG
1861  if test "x$HAVE_SIGREG" = xt ; then  if test "x$HAVE_SIGREG" = xt ; then
1862        DEFINES="$DEFINES -DHAVE_SIGREG"
1863      echo "yes"      echo "yes"
1864  else  else
1865      echo "no"      echo "no"
# Line 1765  rm -f genmake_t* Line 1869  rm -f genmake_t*
1869  printf "  Can we use stat() through C calls...  "  printf "  Can we use stat() through C calls...  "
1870  check_HAVE_STAT  check_HAVE_STAT
1871  if test "x$HAVE_STAT" != x ; then  if test "x$HAVE_STAT" != x ; then
1872        DEFINES="$DEFINES -DHAVE_STAT"
1873      echo "yes"      echo "yes"
1874  else  else
1875      echo "no"      echo "no"
# Line 1774  rm -f genmake_t* Line 1879  rm -f genmake_t*
1879  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1880  check_netcdf_libs  check_netcdf_libs
1881  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
1882        DEFINES="$DEFINES -DHAVE_NETCDF"
1883        echo "yes"
1884    else
1885        echo "no"
1886    fi
1887    
1888    printf "  Can we create LAPACK-enabled binaries...  "
1889    check_lapack_libs
1890    if test "x$HAVE_LAPACK" != x ; then
1891        DEFINES="$DEFINES -DHAVE_LAPACK"
1892      echo "yes"      echo "yes"
1893  else  else
1894      echo "no"      echo "no"
# Line 1785  if test "x$EMBED_SRC" = xt ; then Line 1900  if test "x$EMBED_SRC" = xt ; then
1900  fi  fi
1901  if test "x$EMBED_SRC" = xt ; then  if test "x$EMBED_SRC" = xt ; then
1902      ENABLE="$ENABLE embed_files"      ENABLE="$ENABLE embed_files"
1903    #   DEFINES="$DEFINES -DHAVE_EMBED_SRC"
1904  fi  fi
1905    
1906  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
# Line 1962  else Line 2078  else
2078          exit 1          exit 1
2079      else      else
2080          echo "    using PKG_LIST=\"$PKG_LIST\""          echo "    using PKG_LIST=\"$PKG_LIST\""
2081          #  Strip the comments and add all the names          #  Strip the comments and add all the names
2082          pkg_list=`cat $PKG_LIST | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`          pkg_list=`cat $PKG_LIST | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
2083          RETVAL=$?          RETVAL=$?
2084          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
# Line 2012  for i in $PACKAGES ; do Line 2128  for i in $PACKAGES ; do
2128      j=`echo $i | sed 's/[-+]//'`      j=`echo $i | sed 's/[-+]//'`
2129      if test ! -d "$ROOTDIR/pkg/$j" ; then      if test ! -d "$ROOTDIR/pkg/$j" ; then
2130          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
2131          exit 1          exit 1
2132      fi      fi
2133      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
2134  done  done
# Line 2057  else Line 2173  else
2173          echo "Error: problem encountered while building source files in pkg/mnc:"          echo "Error: problem encountered while building source files in pkg/mnc:"
2174          cat make_mnc.errors 1>&2          cat make_mnc.errors 1>&2
2175          if test "x$mnc_in" = x0 ; then          if test "x$mnc_in" = x0 ; then
2176              exit 1              exit 1
2177          else          else
2178              DISABLE="$DISABLE mnc"              DISABLE="$DISABLE mnc"
2179          fi          fi
# Line 2090  EOF Line 2206  EOF
2206      fi      fi
2207  fi  fi
2208    
2209    #  Check for package RADTRANS: if LAPACK is not available,
2210    #  then issue a warning that the direct radtrans solver is not available.
2211    if test "x$HAVE_LAPACK" != xt ; then
2212        echo " $PACKAGES " | grep ' radtrans ' > /dev/null 2>&1
2213        RETVAL=$?
2214        if test "x$RETVAL" = x0 ; then
2215            cat <<EOF
2216    *********************************************************************
2217    WARNING: the "radtrans" package was enabled but tests failed to
2218      compile LAPACK applications.  This means that the direct radtrans
2219      solver is not available and compilation will fail if it is enabled.
2220      If you want to use the direct solver, please check that:
2221    
2222      1) LAPACK is correctly installed for this compiler and
2223      2) the LIBS variable (within the "optfile") specifies the correct
2224         LAPACK library to link against.
2225    *********************************************************************
2226    EOF
2227        fi
2228    fi
2229    
2230  if  test "x${PKG_DEPEND}" != x ; then  if  test "x${PKG_DEPEND}" != x ; then
2231    echo "  applying package dependency rules"    echo "  applying package dependency rules"
2232    ck=    ck=
# Line 2135  if  test "x${PKG_DEPEND}" != x ; then Line 2272  if  test "x${PKG_DEPEND}" != x ; then
2272    
2273          #  Do we need to add $dname according to the dependency rules?          #  Do we need to add $dname according to the dependency rules?
2274          if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then          if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then
2275              #echo "   " $pname ": need to add :" $dname              #echo "   " $pname ": need to add :" $dname
2276              in_dis="f"              in_dis="f"
2277              for dis in $DISABLE ; do              for dis in $DISABLE ; do
2278                  if test "x$dis" = "x$dname" ; then                  if test "x$dis" = "x$dname" ; then
# Line 2160  if  test "x${PKG_DEPEND}" != x ; then Line 2297  if  test "x${PKG_DEPEND}" != x ; then
2297              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
2298              exit 1              exit 1
2299          fi          fi
2300          i=`echo "$i + 1" | bc -l`          i=`echo "$i + 1" | bc -l`
2301          #i=$(( $i + 1 ))          #i=$(( $i + 1 ))
2302      done      done
2303      ck=$ck"t"      ck=$ck"t"
# Line 2201  for n in $names ; do Line 2338  for n in $names ; do
2338          done          done
2339          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
2340              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
2341              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
2342          fi          fi
2343      fi      fi
2344  done  done
# Line 2214  for i in $PACKAGES ; do Line 2351  for i in $PACKAGES ; do
2351  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
2352      case $i in      case $i in
2353          aim_v23)          aim_v23)
2354              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
2355              echo "Warning: ALLOW_AIM is set to enable aim_v23."              echo "Warning: ALLOW_AIM is set to enable aim_v23."
2356              ;;              ;;
2357      esac      esac
# Line 2256  for i in $spaths ; do Line 2393  for i in $spaths ; do
2393      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
2394          echo "    found CPP_OPTIONS=\"$try\""          echo "    found CPP_OPTIONS=\"$try\""
2395          CPP_OPTIONS="$try"          CPP_OPTIONS="$try"
2396          # 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
2397          for n in $names ; do          for n in $names ; do
2398              test_for_package_in_cpp_options $CPP_OPTIONS $n              test_for_package_in_cpp_options $CPP_OPTIONS $n
2399          done          done
2400      fi      fi
2401      try="$i/CPP_EEOPTIONS.h"      try="$i/CPP_EEOPTIONS.h"
2402      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
2403          echo "    found CPP_EEOPTIONS=\"$try\""          echo "    found CPP_EEOPTIONS=\"$try\""
2404          # 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
2405  #**** not yet enabled ****  #**** not yet enabled ****
2406  #        test_for_mpi_in_cpp_eeoptions $try  #        test_for_mpi_in_cpp_eeoptions $try
2407  #**** not yet enabled ****  #**** not yet enabled ****
# Line 2410  for d in $alldirs ; do Line 2547  for d in $alldirs ; do
2547          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
2548              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2549                  ignore_f=f                  ignore_f=f
2550                  case $d/$sf in                  case $d/$sf in
2551                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
2552                          ignore_f=t                          ignore_f=t
2553                          ;;                          ;;
2554                    ./AD_CONFIG.h)                    ./AD_CONFIG.h)
2555                          ignore_f=t                          ignore_f=t
2556                          ;;                          ;;
2557                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
2558                          ignore_f=t                          ignore_f=t
2559                          ;;                          ;;
2560                    ./BUILD_INFO.h)                    ./BUILD_INFO.h)
2561                          ignore_f=t                          ignore_f=t
2562                          ;;                          ;;
2563                    ./EMBEDDED_FILES.h)                    ./EMBEDDED_FILES.h)
2564                          ignore_f=t                          ignore_f=t
2565                          ;;                          ;;
2566                    *)                    *)
2567                          #  For the local directory *ONLY*,                          #  For the local directory *ONLY*,
2568                          #  ignore all soft-links                          #  ignore all soft-links
2569                          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 2436  for d in $alldirs ; do Line 2573  for d in $alldirs ; do
2573                              deplist="$deplist $sf"                              deplist="$deplist $sf"
2574                          fi                          fi
2575                          ;;                          ;;
2576                  esac                  esac
2577                  if test "x$ignore_f" = xf ; then                  if test "x$ignore_f" = xf ; then
2578                      extn=`echo $sf | $AWK -F. '{print $NF}'`                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2579                      case $extn in                      case $extn in
# Line 2483  for d in $alldirs ; do Line 2620  for d in $alldirs ; do
2620                          echo    " \\"  >> hsrclist.tmp                          echo    " \\"  >> hsrclist.tmp
2621                          printf " $sf" >> hsrclist.tmp                          printf " $sf" >> hsrclist.tmp
2622                          ;;                          ;;
2623                      flow)                      flow)
2624                          echo    " \\"  >> ad_flow_files.tmp                          echo    " \\"  >> ad_flow_files.tmp
2625                          printf " $sf" >> ad_flow_files.tmp                          printf " $sf" >> ad_flow_files.tmp
2626                          ;;                          ;;
# Line 2494  for d in $alldirs ; do Line 2631  for d in $alldirs ; do
2631      done      done
2632      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2633        if test "$d" != "." ; then        if test "$d" != "." ; then
2634          echo "" >> srclinks.tmp          echo "" >> srclinks.tmp
2635          echo "#  These files are linked from $d" >> srclinks.tmp          echo "#  These files are linked from $d" >> srclinks.tmp
2636          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> srclinks.tmp
2637  # We need to make sure that the link isn't already there.  # We need to make sure that the link isn't already there.
# Line 2515  echo "" >> ad_flow_files.tmp Line 2652  echo "" >> ad_flow_files.tmp
2652  CMDLINE=$0  CMDLINE=$0
2653  for xx in "$@" ; do nw=`echo $xx | wc -w`  for xx in "$@" ; do nw=`echo $xx | wc -w`
2654      if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"      if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
2655                          else CMDLINE="$CMDLINE '$xx'" ; fi                          else CMDLINE="$CMDLINE '$xx'" ; fi
2656  done  done
2657    
2658  if test -f $MAKEFILE ; then  if test -f $MAKEFILE ; then
# Line 2549  cat >>$MAKEFILE <<EOF Line 2686  cat >>$MAKEFILE <<EOF
2686  # INCLUDES     : Directories searched for header files  # INCLUDES     : Directories searched for header files
2687  # DEFINES      : Macro definitions for CPP  # DEFINES      : Macro definitions for CPP
2688  # MAKEDEPEND   : Dependency generator  # MAKEDEPEND   : Dependency generator
 # KPP          : Special preprocessor command (specific to platform)  
 # KFLAGS       : Flags for KPP  
2689  # FC           : Fortran compiler command  # FC           : Fortran compiler command
2690  # FFLAGS       : Configuration/debugging options for FC  # FFLAGS       : Configuration/debugging options for FC
2691  # FOPTIM       : Optimization options for FC  # FOPTIM       : Optimization options for FC
# Line 2623  NOOPTFILES = ${NOOPTFILES} Line 2758  NOOPTFILES = ${NOOPTFILES}
2758  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2759  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2760  LIBS = ${LIBS}  LIBS = ${LIBS}
2761  # Name of the Mekfile  # Name of the makefile
2762  MAKEFILE=${MAKEFILE}  MAKEFILE = ${MAKEFILE}
2763    # Name of the make program
2764    MAKE = ${MAKE}
2765    
2766  EOF  EOF
2767    
# Line 2648  echo >> $MAKEFILE Line 2785  echo >> $MAKEFILE
2785  echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE  echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE
2786  echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE  echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE
2787  echo 'OBJFILES= $(F77_SRC_FILES:.F=.o) $(C_SRC_FILES:.c=.o) $(F90_SRC_FILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES= $(F77_SRC_FILES:.F=.o) $(C_SRC_FILES:.c=.o) $(F90_SRC_FILES:.F90=.o)' >> $MAKEFILE
2788  echo 'FLOFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE  echo 'FLOWFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE
2789  echo >> $MAKEFILE  echo >> $MAKEFILE
2790  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
2791  echo '.SUFFIXES: .o .'$FS' .p .F .c .f'$FS90' .'$FS90' .FF90 .F90 .flowdir .flow' >> $MAKEFILE  echo '.SUFFIXES: .o .'$FS' .p .F .c .f'$FS90' .'$FS90' .FF90 .F90 .flowdir .flow' >> $MAKEFILE
2792    
2793  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2794    
2795  all: \$(EXECUTABLE)  all: fwd_exe_target
2796    fwd_exe_target:
2797            @echo Update AD_CONFIG.h and make \$(EXECUTABLE)
2798            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Forward version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
2799            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2800            @-rm -f ad_config.template
2801            \$(MAKE) -f \$(MAKEFILE) \$(EXECUTABLE)
2802    
2803  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(EMBEDDED_FILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(EMBEDDED_FILES)
2804          @echo Creating \$@ ...          @echo Creating \$@ ...
2805          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2806    
2807  depend:  depend:
2808          @make links          @\$(MAKE) -f \$(MAKEFILE) links
2809          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)          \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
2810          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2811          -rm -f makedepend.out          -rm -f makedepend.out
2812    
# Line 2671  libmitgcmuv.a: \$(OBJFILES) Line 2816  libmitgcmuv.a: \$(OBJFILES)
2816          ar rcv libmitgcmuv.a \$(OBJFILES)          ar rcv libmitgcmuv.a \$(OBJFILES)
2817          ar d   libmitgcmuv.a main.o          ar d   libmitgcmuv.a main.o
2818    
2819    obj: \$(OBJFILES)
2820    
2821  links: \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(SPECIAL_FILES)  links: \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(SPECIAL_FILES)
2822    
2823  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
# Line 2688  clean: Line 2835  clean:
2835    
2836  # remove most of the files that "make" and "make depend" generate  # remove most of the files that "make" and "make depend" generate
2837  Clean:  Clean:
2838          @make clean          @\$(MAKE) -f \$(MAKEFILE) clean
2839          @make cleanlinks          @\$(MAKE) -f \$(MAKEFILE) cleanlinks
2840          -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old          -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old
2841          -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log          -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log taf_ftl.log
2842          -rm -f genmake_warnings genmake_errors make.log          -rm -f genmake_warnings genmake_errors make.log
2843    
2844  # remove also the executable, files that "genmake2" generates (except Makefile)  # remove also the executable, files that "genmake2" generates (except Makefile)
2845  #         and output from a run (plus log files from testreport)  #         and output from a run (plus log files from testreport)
2846  CLEAN:  CLEAN:
2847          @make Clean          @\$(MAKE) -f \$(MAKEFILE) Clean
2848          -rm -f \$(EXECUTABLE) \$(EXE_AD) *.bak          -rm -f \$(EXECUTABLE) \$(EXE_AD) \$(EXE_FTL) *.bak
2849          -rm -f $LOGFILE genmake_state genmake_*optfile genmake.tr_log make.tr_log          -rm -f $LOGFILE genmake_state genmake_*optfile
2850            -rm -f SIZE.h.mpi genmake.tr_log make.tr_log
2851          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2852          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2853          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
# Line 2715  cleanlinks: Line 2863  cleanlinks:
2863  # Special targets (SPECIAL_FILES) which are created by make  # Special targets (SPECIAL_FILES) which are created by make
2864  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2865          @echo Creating \$@ ...          @echo Creating \$@ ...
2866          @$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 -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@
2867  AD_CONFIG.h:  AD_CONFIG.h:
2868          @echo Creating \$@ ...          @echo Creating \$@ ...
2869          @$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 "Default version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > \$@
2870  FC_NAMEMANGLE.h:  FC_NAMEMANGLE.h:
2871          @echo Creating \$@ ...          @echo Creating \$@ ...
2872          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
# Line 2827  rm -f adSrcFiles.tmp Line 2975  rm -f adSrcFiles.tmp
2975  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2976    
2977  # ... AD ...  # ... AD ...
2978  adall: \$(EXE_AD)  adall: ad_exe_target
2979  adtaf: ad_taf_output.$FS  adtaf: ad_taf_output.$FS
2980  adtamc: ad_tamc_output.$FS  adtamc: ad_tamc_output.$FS
2981    
2982    ad_exe_target:
2983            @echo Update AD_CONFIG.h and make \$(EXE_AD)
2984            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
2985            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2986            @-rm -f ad_config.template
2987            \$(MAKE) -f \$(MAKEFILE) \$(EXE_AD)
2988    
2989  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES)  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES)
2990          @$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 "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
2991          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2992          -rm -f ad_config.template          @-rm -f ad_config.template
2993          @make \$(F77_PP_SRC_FILES)          @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
2994          @make \$(FLOFILES)          @\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)
2995          cat \$(FLOFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS          cat \$(FLOWFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS
2996    
2997  ad_taf_output.$FS: ad_input_code.$FS  ad_taf_output.$FS: ad_input_code.$FS
2998          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
# Line 2865  adonlyfwd: Line 3020  adonlyfwd:
3020  adtrick:  adtrick:
3021          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
3022    
3023    adobj: ad_taf_output.o \$(OBJFILES)
3024    
3025  # ... FTL ...  # ... FTL ...
3026  ftlall: ftl_taf  ftlall: ftl_exe_target
3027  ftltaf: ftl_taf_output.$FS  ftltaf: ftl_taf_output.$FS
3028  ftltamc: ftl_tamc_output.$FS  ftltamc: ftl_tamc_output.$FS
3029    
3030    ftl_exe_target:
3031            @echo Update AD_CONFIG.h and make \$(EXE_FTL)
3032            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3033            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3034            @-rm -f ad_config.template
3035            \$(MAKE) -f \$(MAKEFILE) \$(EXE_FTL)
3036    
3037  ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)  ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)
3038          @$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 "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3039          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3040          -rm -f ftl_config.template          @-rm -f ad_config.template
3041          @make \$(F77_PP_SRC_FILES)          @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3042          @make \$(AD_FLOW_FILES)          @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3043          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
3044    
3045  ftl_taf_output.$FS: ftl_input_code.$FS  ftl_taf_output.$FS: ftl_input_code.$FS
3046          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
# Line 2888  ftltafonly: Line 3052  ftltafonly:
3052          ls -l ftl_input_code_ftl.$FS          ls -l ftl_input_code_ftl.$FS
3053          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
3054    
3055  ftl_taf: ftl_taf_output.o \$(OBJFILES)  \${EXE_FTL}: ftl_taf_output.o \$(OBJFILES)
3056          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
3057    
3058  ftl_tamc_output.$FS: ftl_input_code.$FS  ftl_tamc_output.$FS: ftl_input_code.$FS
3059          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
# Line 2918  svd_touch: Line 3082  svd_touch:
3082          touch ad_taf_output.$FS ftl_taf_output.$FS          touch ad_taf_output.$FS ftl_taf_output.$FS
3083          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
3084          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
3085          @$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 "SVD version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3086          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3087          -rm -f ftl_config.template          @-rm -f ad_config.template
3088    
3089  EOF  EOF
3090    
# Line 2995  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod. Line 3159  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.
3159    
3160  .PHONY: adDepend  .PHONY: adDepend
3161  adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90)  adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90)
3162          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)          \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
3163          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
3164          -rm -f makedepend.out          -rm -f makedepend.out
3165    
# Line 3020  f95_test.out: f95_test_mods.f90 f95_test Line 3184  f95_test.out: f95_test_mods.f90 f95_test
3184          f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1          f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1
3185          f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1          f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1
3186    
3187  # the file included below is created by the  CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)
 # postProcessor and its inclusion sets the  
 # variable POSTPROCESSEDFILES  
 # used below. Because the file is made during  
 # make it won't be read until the second (recursive)  
 # invocation in the rule below  
 -include postProcess.make  
3188    
3189  AD_OBJ_FILES_S1=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) \$(POSTPROCESSEDFILES:.f$FS90=.o)  AD_OBJ_FILES_S1=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o)  OAD_intrinsics_oad.o \$(CB2M_AD_FILES:.f$FS90=_oad.o)
3190    
3191  AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o)  AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o)
3192    
3193  postProcess.comp: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.tag \$(AD_OBJ_FILES_S1)  \$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.tag \$(AD_OBJ_FILES_S2)
 ifeq (\$(MAKELEVEL),0)  
         \$(MAKE) adAll  
 else  
         touch \$@  
 endif  
   
 \$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.comp \$(AD_OBJ_FILES_S2)  
 ifeq (\$(MAKELEVEL),1)  
3194          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)
 else  
         touch \$@  
 endif  
3195    
3196  # makefile debug rule  # create sources files modules from header files containing common blocks
 openad: ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90  
 .PHONY: openad  
   
 # create the module files  
3197  %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk  %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk
3198          ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk          ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk
3199    
3200  # create the header files  # create new header files with USE statements for the new modules made above
3201  %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk  %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk
3202          ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)          ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
3203    
3204  # change everybody else to use the new module files:  # change the include directives of everybody to refer to  the new header files with the USE statements
3205  %_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash  %_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash
3206          ../OAD_support/cb2mUseModules.bash $< ${MPI}          ../OAD_support/cb2mUseModules.bash $< ${MPI}
3207    
# Line 3073  ad_output.txt: \$(EXE_AD) Line 3216  ad_output.txt: \$(EXE_AD)
3216          @printf 'running ... '          @printf 'running ... '
3217          @./\$(EXE_AD) > \$@          @./\$(EXE_AD) > \$@
3218    
 CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)  
3219  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3220          cat \$^ > \$@          cat \$^ > \$@
3221    
 # strip all comments and blanks to reduce  
 # the file size in order to reduce perl's memory requirements  
 ad_input_code_sf.f$FS90 : ad_input_code.f$FS90  
         cat \$^ | sed -f ../OAD_support/strip.sed | sed -f ../OAD_support/stop2print.sed > \$@  
   
 # mfef90 preprocessing  
 # expand statement functions  
 # expose mfef90 specific substring handling  
 # add the w2f__types module  
 ad_input_code_sf.w2f.f$FS90: ad_input_code_sf.f$FS90 mfef90 whirl2f whirl2f_be w2f__types.f90  
         ./mfef90 -r8 -z -F -N132 \$<  
         mv \$<.B \$(basename \$<).B  
         ./whirl2f -openad \$(basename \$<).B  
         cat w2f__types.f90 \$(basename \$<).w2f.f > \$@  
   
3222  # canonicalizer  # canonicalizer
3223  ad_input_code_sf.w2f.pre.f$FS90: ad_input_code_sf.w2f.f$FS90 preProcess.py  ad_input_code_sf.pre.f90 : \$(CB2M_AD_FILES)
3224          ./preProcess.py --timing --r8 -H -S \$< -o \$@          \${OPENADFORTTK_BASE}/tools/SourceProcessing/preProcess.py --timing --r8 -H -S  -o \$@ \$^
3225    
3226    # replace stop statements (to avoid the implied unstructured control flow)  with print statements
3227    ad_input_code_sf.pre.s2p.f90 : ad_input_code_sf.pre.f90
3228            cat \$< | sed -f ../OAD_support/stop2print.sed > ad_input_code_sf.pre.s2p.f90
3229    
3230  # F -> WHIRL  # F -> WHIRL
3231  # note that the canonicalized version cuts off at col 72  ad_input_code_sf.pre.s2p.B: ad_input_code_sf.pre.s2p.f90
3232  # doing this also for string constants which is ok as long          \${OPEN64ROOT}/crayf90/sgi/mfef90 -r8 -z -F ad_input_code_sf.pre.s2p.f90
 # as we are in fixed mode and cut of exactly there.  
 # Otherwise mfef90 patches in spaces to fill up to 72 (or 132)  
 # characters respectively.  
 ad_input_code_sf.w2f.pre.B: ad_input_code_sf.w2f.pre.f$FS90 mfef90  
         ./mfef90 -r8 -z -F \$<  
         mv \$<.B \$@  
3233    
3234  # WHIRL -> XAIF  # WHIRL -> XAIF
3235  ad_input_code_sf.w2f.pre.xaif : ad_input_code_sf.w2f.pre.B whirl2xaif  ad_input_code_sf.pre.s2p.xaif : ad_input_code_sf.pre.s2p.B
3236          ./whirl2xaif -s -n --debug 1 -o \$@ \$<          \${OPENADFORTTK}/bin/whirl2xaif -s -n --debug 1 -o \$@ \$<
3237    
3238  # XAIF -> XAIF'  # XAIF -> XAIF'
3239  ad_input_code_sf.w2f.pre.xb.xaif : ad_input_code_sf.w2f.pre.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd oadDriver  ad_input_code_sf.pre.s2p.xb.xaif : ad_input_code_sf.pre.s2p.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd
3240          ./oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r          \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r
3241    
3242  # XAIF' -> WHIRL'  # XAIF' -> WHIRL'
3243  ad_input_code_sf.w2f.pre.xb.x2w.B : ad_input_code_sf.w2f.pre.xb.xaif xaif2whirl  ad_input_code_sf.pre.s2p.xb.x2w.B : ad_input_code_sf.pre.s2p.xb.xaif
3244          ./xaif2whirl --debug 1 ad_input_code_sf.w2f.pre.B \$<          \${OPENADFORTTK}/bin/xaif2whirl --debug 1 ad_input_code_sf.pre.s2p.B \$<
3245    
3246  # WHIRL' -> F'  # WHIRL' -> F'
3247  ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.B whirl2f whirl2f_be  ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.B
3248          ./whirl2f -FLIST:ftn_file=\$@ -openad \$<          \${OPEN64ROOT}/whirl2f/whirl2f -FLIST:ftn_file=\$@ -openad \$<
3249    
3250  # insert template directives  # insert template directives
3251  ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90 ../OAD_support/insertTemplateDir.bash  ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 ../OAD_support/insertTemplateDir.bash
3252          ../OAD_support/insertTemplateDir.bash \$< \$@          ../OAD_support/insertTemplateDir.bash \$< \$@
3253    
3254  PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F  PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F
3255  # postprocess F'  # postprocess F'
3256  postProcess.tag: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 postProcess.py \$(PPEXTRAS:.F=.f)  postProcess.tag: ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90 \$(PPEXTRAS:.F=.f) | w2f__types.f90
3257          # the target is a placeholder to signal execution of the rule          \${OPENADFORTTK_BASE}/tools/SourceProcessing/postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed --separateOutput --pathSuffix "" --filenameSuffix "_oad" -m r -i ../OAD_support/ad_inline.f \$<
3258            # the target is a placeholder to trigger a single execution of the rule
3259          touch \$@          touch \$@
3260          # this step also creates the file postProcess.make but we cannot  # put this so make knows about the postprocessing output
3261          # name it as the target or else make will try to remake it for  OAD_intrinsics_oad.f \$(CB2M_AD_FILES:.f$FS90=_oad.f): postProcess.tag
         # the include directive above for any rule, e.g. make clean  
         ./postProcess.py --progress --timing --outputFormat=fixed -m r -i ../OAD_support/ad_inline.f --width 4 \$<  
3262    
3263  # setup some links  # link the XAIF schema files
3264  %.xsd:  %.xsd:
3265          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3266    
 mfef90:  
         \$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 .  
   
3267  # link the support files:  # link the support files:
3268  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):
3269          \$(LN) ../OAD_support/\$@ .          \$(LN) ../OAD_support/\$@ .
3270    
3271  whirl2xaif xaif2whirl:  AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag \$(PPEXTRAS:.F=.f)
         \$(LN) \${OPENADFORTTK}/bin/\$@ .  
   
 preProcess.py postProcess.py:  
         \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ .  
   
 whirl2f whirl2f_be:  
         \$(LN) \${OPEN64ROOT}/whirl2f/\$@ .  
   
 oadDriver:  
         \$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver \$@  
   
 AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.make postProcess.tag postProcess.comp \$(PPEXTRAS:.F=.f)  
3272    
3273  # ============ end OpenAD specific section ==============  # ============ end OpenAD specific section ==============
3274    
# Line 3204  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 3313  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
3313  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
3314    
3315  # Create special header files  # Create special header files
3316  $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 -bPACKAGES_CONFIG_H "Disabled packages:" $DISABLED_PACKAGES " " "Enabled packages:" $ENABLED_PACKAGES > $PACKAGES_DOT_H".tmp"
3317  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
3318      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
3319  else  else
# Line 3218  else Line 3327  else
3327      fi      fi
3328  fi  fi
3329  if test ! -f AD_CONFIG.h ; then  if test ! -f AD_CONFIG.h ; then
3330      $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 "Default version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > AD_CONFIG.h
3331  fi  fi
3332    
3333  #  Write the "state" for future records  #  Write the "state" for future records
# Line 3227  if test "x$DUMPSTATE" = xt ; then Line 3336  if test "x$DUMPSTATE" = xt ; then
3336      for i in $gm_state ; do      for i in $gm_state ; do
3337          t1="t2=\$$i"          t1="t2=\$$i"
3338          eval $t1          eval $t1
3339          echo "$i='$t2'" >> genmake_state          echo "$i='$t2'" | sed -e 's/  */ /g' >> genmake_state
3340      done      done
3341  fi  fi

Legend:
Removed from v.1.215  
changed lines
  Added in v.1.238

  ViewVC Help
Powered by ViewVC 1.1.22