/[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.220 by jmc, Fri Jun 3 19:53:45 2011 UTC revision 1.252 by jmc, Mon Jul 22 19:11:31 2013 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.
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      -ieee | --ieee      -ieee | --ieee
125            use IEEE numerics.  Note that this option *only* works            use IEEE numerics.  Note that this option *only* works
126            if it is supported by the OPTFILE that is being used.            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.            (if supported by the OPTFILE); also switch to IEEE numerics.
130      -gsl | --gsl      -gsl | --gsl
131            Use GSL to control floating point rounding and precision            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 174  EOF Line 174  EOF
174  test_for_package_in_cpp_options() {  test_for_package_in_cpp_options() {
175      cpp_options=$1      cpp_options=$1
176      pkg=$2      pkg=$2
177      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg[ ]"      test_for_string_in_file $cpp_options "^ *# *define *\<ALLOW_$pkg\>"
178      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg[ ]"      test_for_string_in_file $cpp_options "^ *# *undef *\<ALLOW_$pkg\>"
179      test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg[ ]"      test_for_string_in_file $cpp_options "^ *# *define *\<DISABLE_$pkg\>"
180      test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg[ ]"      test_for_string_in_file $cpp_options "^ *# *undef *\<DISABLE_$pkg\>"
     test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg$"  
     test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg$"  
     test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg$"  
     test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg$"  
181  }  }
182    
183  # Search for particular CPP #cmds associated with MPI  # Search for particular CPP #cmds associated with MPI
184  # usage: test_for_mpi_in_cpp_eeoptions CPP_file  # usage: test_for_mpi_in_cpp_eeoptions CPP_file
185  test_for_mpi_in_cpp_eeoptions() {  test_for_mpi_in_cpp_eeoptions() {
186      cpp_options=$1      cpp_options=$1
187      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI[ ]"      test_for_string_in_file $cpp_options "^ *# *define *\<ALLOW_USE_MPI\>"
188      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI[ ]"      test_for_string_in_file $cpp_options "^ *# *undef *\<ALLOW_USE_MPI\>"
     test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI[ ]"  
     test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI[ ]"  
     test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI$"  
     test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI$"  
     test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI$"  
     test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI$"  
189  }  }
190    
191  # Search for particular string in a file. Return 1 if detected, 0 if not  # Search for particular string in a file. Return 1 if detected, 0 if not
# Line 203  test_for_mpi_in_cpp_eeoptions() { Line 193  test_for_mpi_in_cpp_eeoptions() {
193  test_for_string_in_file() {  test_for_string_in_file() {
194      file=$1      file=$1
195      strng=$2      strng=$2
196      grep -i "$strng" $file > /dev/null 2>&1      grep "$strng" $file > /dev/null 2>&1
197      RETVAL=$?      RETVAL=$?
198      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
199          printf "Error: In $file there is an illegal line: "          printf "Error: In $file there is an illegal line: "
200          grep -i "$strng" $file          grep -i "$strng" $file
201          exit 99          exit 99
202      fi      fi
203      return 0      return 0
# Line 297  EOF Line 287  EOF
287  .F.$tfs:  .F.$tfs:
288          $LN \$< \$@          $LN \$< \$@
289  EOF  EOF
290      $MAKE "genmake_hello."$tfs > /dev/null 2>&1      $MAKE -f $MAKEFILE "genmake_hello."$tfs > /dev/null 2>&1
291      RETVAL=$?      RETVAL=$?
292      if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then      if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then
293          if test "x$FS" = x ; then          if test "x$FS" = x ; then
# Line 305  EOF Line 295  EOF
295              FS90='fr9'              FS90='fr9'
296              check_for_broken_Ff              check_for_broken_Ff
297          else          else
298              cat <<EOF 2>&1              echo "ERROR: test: '$MAKE -f $MAKEFILE genmake_hello.$tfs' Failed"
299  ERROR: Your file system cannot distinguish between *.F and *.f files              echo "       see simple makefile: '$MAKEFILE' (left here)"
300    (fails the "make/ln" test) and this program cannot find a suitable              echo "  Please check (1) your '$MAKE' command, (2) your '$LN' command"
301    replacement extension.  Please try a different build environment or              echo "           and (3) the allowed sufix '.F' and '.$tfs' in makefile"
302    contact the <MITgcm-support@mitgcm.org> list for help.              echo "  or contact the <MITgcm-support@mitgcm.org> list for help."
303                echo ""
 EOF  
304              exit -1              exit -1
305              return              return
306          fi          fi
# Line 335  look_for_makedepend()  { Line 324  look_for_makedepend()  {
324      #      #
325      #    1) a makedepend implementation shipped with the cyrus-imapd      #    1) a makedepend implementation shipped with the cyrus-imapd
326      #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/      #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
327      #      #    2) a local tools/xmakedepend shell script
     #    2) a known-buggy xmakedpend shell script  
328      #      #
329      #  So the choices are, in order:      #  So the choices are, in order:
     #  
330      #    1) use the user-specified program      #    1) use the user-specified program
331      #    2) use a system-wide default      #    2) use the local xmakedepend script (get all dependencies, but slower)
332      #    3) locally build and use the cyrus implementation      #    3) use a system-wide default
333      #    4) fall back to the buggy local xmakedpend script      #    4) locally build and use the cyrus makedepend
334        #             (faster, but can miss some dependencies)
335      #      #
336      echo >> $LOGFILE      echo >> $LOGFILE
337      echo "running: look_for_makedepend()" >> $LOGFILE      echo "running: look_for_makedepend()" >> $LOGFILE
# Line 354  look_for_makedepend()  { Line 342  look_for_makedepend()  {
342              build_cyrus_makedepend              build_cyrus_makedepend
343              RETVAL=$?              RETVAL=$?
344              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
345                  echo "WARNING: unable to build cyrus-makedepend. Try 'makedepend'"                  echo "WARNING: unable to build cyrus-makedepend. Try other 'makedepend'"
346                  MAKEDEPEND=                  MAKEDEPEND=
347              fi              fi
348          else          else
349                echo "${MAKEDEPEND}" | grep 'tools.xmakedepend' > /dev/null 2>&1
350                RETVAL=$?
351                if test "x$RETVAL" = x0 ; then
352                    MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
353                fi
354              echo " -->     MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE              echo " -->     MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
355          fi          fi
356      fi      fi
357      if test "x${MAKEDEPEND}" = x ; then      if test "x${MAKEDEPEND}" = x ; then
         which makedepend > /dev/null 2>&1  
         RV0=$?  
358          test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"          test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"
359          #  echo 'MAKEFILE="'$MAKEFILE'"'          #  echo 'MAKEFILE="'$MAKEFILE'"'
360          cat <<EOF >> $MAKEFILE          cat <<EOF >> $MAKEFILE
# Line 379  EOF Line 370  EOF
370        stop        stop
371        end        end
372  EOF  EOF
373          makedepend genmake_tc.f > /dev/null 2>&1          $ROOTDIR/tools/xmakedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1
374          RV1=$?          RV1=$?
375            which makedepend > /dev/null 2>&1
376            RV2=$?
377            if test "x${RV2}" = x0 ; then
378                makedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1
379                RV3=$? ; loc_msg='not working.'
380            else RV3=$RV2 ; loc_msg='not found.'
381            fi
382          test -f $MAKEFILE  &&  rm -f $MAKEFILE          test -f $MAKEFILE  &&  rm -f $MAKEFILE
383          test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE          test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
384          if test "x${RV0}${RV1}" = x00 ; then          echo "  check makedepend (local: $RV1, system: $RV2, $RV3)"
385            if test "x${RV1}" = x0 ; then
386                MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
387                echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
388            elif test "x${RV3}" = x0 ; then
389                echo "    local tools/xmakedepend not working. Use system-default makedepend"
390              MAKEDEPEND=makedepend              MAKEDEPEND=makedepend
391              echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE              echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
392          else          else
393              echo "    system-default makedepend not found. Try to build cyrus-makedepend"              echo "    local tools/xmakedepend not working; system-default makedepend $loc_msg"
394                echo -n "    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"                  echo "  Works"
400                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'              else
401                  echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE                  echo "  Fails" ; echo "" >> $LOGFILE
402                    echo "ERROR: no working makedepend found ; look_for_makedepend FAILED" | tee -a $LOGFILE
403                    echo ""
404                    exit -1
405                    return
406              fi              fi
407          fi          fi
408      fi      fi
# Line 407  build_cyrus_makedepend()  { Line 415  build_cyrus_makedepend()  {
415      (      (
416          cd $ROOTDIR/tools/cyrus-imapd-makedepend  \          cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
417              &&  ./configure > /dev/null 2>&1  \              &&  ./configure > /dev/null 2>&1  \
418              &&  make > /dev/null 2>&1              &&  $MAKE > /dev/null 2>&1
419          if test -x ./makedepend.exe ; then          if test -x ./makedepend.exe ; then
420              $LN ./makedepend.exe ./makedepend              $LN ./makedepend.exe ./makedepend
421          fi          fi
# Line 431  build_embed_encode() Line 439  build_embed_encode()
439  {  {
440      printf "  building the embed-encode utility...  "      printf "  building the embed-encode utility...  "
441      if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then      if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then
442          if test ! -d "$ROOTDIR/tools/embed_encode" ; then          if test ! -d "$ROOTDIR/tools/embed_encode" ; then
443              echo              echo
444              echo "    Error: can't locate \"$ROOTDIR/tools/embed_encode\""              echo "    Error: can't locate \"$ROOTDIR/tools/embed_encode\""
445              echo              echo
446              EMBED_SRC=f              EMBED_SRC=f
447              return 1              return 1
448          fi          fi
449          clist="cc gcc c89 $CC"          clist="cc gcc c89 $CC"
450          for ic in $clist ; do          for ic in $clist ; do
451              comm="$ic -o encode_files encode_files.c"              comm="$ic -o encode_files encode_files.c"
# Line 445  build_embed_encode() Line 453  build_embed_encode()
453              RETVAL=$?              RETVAL=$?
454              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
455                  echo "OK"                  echo "OK"
                 DEFINES="$DEFINES -DHAVE_EMBED_SRC"  
456                  return 0                  return 0
457              fi              fi
458          done          done
# Line 457  build_embed_encode() Line 464  build_embed_encode()
464          return 1          return 1
465      fi      fi
466      echo "OK"      echo "OK"
     DEFINES="$DEFINES -DHAVE_EMBED_SRC"  
467  }  }
468    
469  #  look for possible C compilers  #  look for possible C compilers
# Line 575  EOF Line 581  EOF
581      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
582          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
583          if test ! -r $OPTFILE ; then          if test ! -r $OPTFILE ; then
584               echo "  I looked for the file "$OPTFILE" but did not find it"               echo "  I looked for the file "$OPTFILE" but did not find it"
585          fi          fi
586      fi      fi
587    
588      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
# Line 594  Error: No options file was found in:  $R Line 600  Error: No options file was found in:  $R
600  EOF  EOF
601          exit 1          exit 1
602      fi      fi
603    }
604    
605  #     # look for possible MPI libraries  #  Do a local copy of MPI headers files (in local dir ./mpi_headers/) after
606  #     mpi_libs=  #  checking for additional included headers (in case of chain of included header)
607  #     mpi_fort=`which mpif77 2>/dev/null`  mpi_headers_do_local_copy() {
608  #     RETVAL=$?  
609  #     if test "x${RETVAL}" = x0 ; then      dBug=0
610  #       cat >>test.f <<EOF      #----- check for additional headers (chain of included headers)
611  #       PROGRAM HELLO      listIni=$MPI_HEADER_FILES
612  #       DO 10, I=1,10      echo $listIni | grep "\<mpif.h\>" > /dev/null 2>&1
613  #       PRINT *,'Hello World'      outp=$?
614  #    10 CONTINUE      #- always check mpif.h (the only mpi-header included in standard MITgcm code)
615  #       STOP      if test $outp != 0 ; then listIni="mpif.h $listIni" ; fi
616  #       END      if test $dBug = 1 ; then echo "listIni='$listIni'" ; fi
617  # EOF      doCheck=1 ; list2copy='' ; list2check=$listIni
618  #       eval "$mpi_fort -showme test.f > out"      while test $doCheck = 1 ; do
619  #       RETVAL=$?          newList=''
620  #       if test "x${RETVAL}" = x0 ; then          for i in $list2check ; do
621  #           a=`cat out`           if test -f $MPIINCLUDEDIR/$i ; then
622  #           for i in $a ; do              newInc=`grep '^ *include ' $MPIINCLUDEDIR/$i | \
623  #               case $i in                  sed -e 's/^ *include //' -e 's/\!.*$//' -e "s/'//g"  -e 's/\"//g'`
624  #                   -*)             if test $dBug = 1 ; then echo -n "checking $i : newInc='$newInc'" ; fi
625  #                       mpi_libs="$mpi_libs $i" ;;             for j in $newInc ; do
626  #               esac               echo $listIni $list2copy $newList | grep "\<$j\>" > /dev/null 2>&1
627  #           done               outp=$?
628  #           echo "The MPI libs appear to be:"               if test $outp != 0 ; then
629  #           echo "  "$mpi_libs                  if test $dBug = 1 ; then echo -n " ; adding $j" ; fi
630  #       fi                  newList="$newList $j"
631  #       rm -f test.f out               fi
632  #     fi             done
633               if test $dBug = 1 ; then echo "" ; fi
634             fi
635            done
636            if test "x$newList" = x ; then doCheck=0
637            else list2check=$newList ; list2copy="$list2copy $newList"
638            fi
639        done
640        list2copy="$MPI_HEADER_FILES $list2copy"
641        if test $dBug = 1 ; then echo "list2copy='$list2copy'" ; fi
642        #----- make local copy and update LOCAL_MPI_HEADERS (if not already set)
643        mkListInc=0
644        for i in $list2copy ; do
645            if test -f $MPIINCLUDEDIR/$i ; then
646                cp -p $MPIINCLUDEDIR/$i ./mpi_headers
647                if test $i = 'mpif.h' ; then
648                    perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h
649                fi
650                if test $mkListInc = 1 ; then
651                    LOCAL_MPI_HEADERS="$LOCAL_MPI_HEADERS ./mpi_headers/$i"
652                fi
653                if test "x$LOCAL_MPI_HEADERS" = x ; then
654                    LOCAL_MPI_HEADERS="./mpi_headers/$i" ; mkListInc=1
655                fi
656            fi
657        done
658  }  }
659    
660  #  Parse the package dependency information  #  Parse the package dependency information
# Line 647  get_fortran_c_namemangling()  { Line 679  get_fortran_c_namemangling()  {
679    
680      #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""      #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
681      if test ! "x$FC_NAMEMANGLE" = x ; then      if test ! "x$FC_NAMEMANGLE" = x ; then
682          return 0          return 0
683      fi      fi
684      echo " running: get_fortran_c_namemangling()" >> $LOGFILE      echo " running: get_fortran_c_namemangling()" >> $LOGFILE
685    
# Line 779  EOF Line 811  EOF
811      RETVAL=$?      RETVAL=$?
812      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
813          HAVE_CLOC=t          HAVE_CLOC=t
         DEFINES="$DEFINES -DHAVE_CLOC"  
814      fi      fi
815      rm -f genmake_tc*      rm -f genmake_tc*
816      echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE      echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE
# Line 841  EOF Line 872  EOF
872      RETVAL=$?      RETVAL=$?
873      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
874          HAVE_SIGREG=t          HAVE_SIGREG=t
         DEFINES="$DEFINES -DHAVE_SIGREG"  
875      fi      fi
876      rm -f genmake_tc*      rm -f genmake_tc*
877      echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE      echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE
878  }  }
879    
880  check_HAVE_SETRLSTK()  {  check_HAVE_SETRLSTK()  {
     if test "x$HAVE_SETRLSTK" = xt ; then  
         DEFINES="$DEFINES -DHAVE_SETRLSTK"  
         return  
     fi    
881      if test ! "x$HAVE_SETRLSTK" = x ; then      if test ! "x$HAVE_SETRLSTK" = x ; then
882          return          return
883      fi      fi
# Line 889  EOF Line 915  EOF
915      RETVAL=$?      RETVAL=$?
916      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
917          HAVE_SETRLSTK=t          HAVE_SETRLSTK=t
         DEFINES="$DEFINES -DHAVE_SETRLSTK"  
918      fi      fi
919      rm -f genmake_tc*      rm -f genmake_tc*
920      echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE      echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE
# Line 936  EOF Line 961  EOF
961      RETVAL=$?      RETVAL=$?
962      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
963          HAVE_STAT=t          HAVE_STAT=t
         DEFINES="$DEFINES -DHAVE_STAT"  
964      fi      fi
965      rm -f genmake_tc*      rm -f genmake_tc*
966      echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE      echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE
# Line 952  check_netcdf_libs()  { Line 976  check_netcdf_libs()  {
976        program fgennc        program fgennc
977  #include "netcdf.inc"  #include "netcdf.inc"
978  EOF  EOF
979      if test ! "x$MPI" = x ; then     #if test ! "x$MPI" = x ; then
980          echo '#include "mpif.h"' >> genmake_tnc.F     #    echo '#include "mpif.h"' >> genmake_tnc.F
981      fi     #fi
982      cat <<EOF >> genmake_tnc.F      cat <<EOF >> genmake_tnc.F
983        integer iret, ncid, xid        integer iret, ncid, xid
984        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
# Line 1034  EOF Line 1058  EOF
1058      echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE      echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE
1059  }  }
1060    
1061    check_lapack_libs()  {
1062        if test ! "x$SKIP_LAPACK_CHECK" = x ; then
1063            return
1064        fi
1065        echo >> $LOGFILE
1066        echo "running: check_lapack_libs()" >> $LOGFILE
1067        cat <<EOF > genmake_tla.F
1068          program fgenla
1069          integer info
1070          integer ipiv( 2 )
1071          double precision ab( 4, 2 ), b( 2 )
1072          data ab / 0., 0., 1., 2., 0., 2., 1., 0. /
1073          data b / 1., 1. /
1074          call dgbsv( 2, 1, 1, 1, ab, 4, ipiv, b, 2, info )
1075          IF (info .NE. 0) write(*,*) 'Error:', info
1076          write(*,*) b
1077          end
1078    EOF
1079        echo "===  genmake_tla.F  >>>" > genmake_tla.log
1080        cat genmake_tla.F >> genmake_tla.log
1081        echo "<<<  genmake_tla.F  ===" >> genmake_tla.log
1082        RET_CPP=f
1083        COMM="cat genmake_tla.F | $CPP $DEFINES $INCLUDES"
1084        echo "$COMM" >> genmake_tla.log
1085        eval $COMM > genmake_tla.$FS 2>/dev/null  &&  RET_CPP=t
1086        if test "x$RET_CPP" = xf ; then
1087            echo "  WARNING: CPP failed to pre-process the lapack test." \
1088                >> genmake_tla.log
1089            echo "    Please check that \$INCLUDES is properly set." \
1090                >> genmake_tla.log
1091        fi
1092        echo "$FC $FFLAGS $FOPTIM -c genmake_tla.$FS  \ " >> genmake_tla.log
1093        echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tla.o $LIBS" >> genmake_tla.log
1094        $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1095            &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS >> genmake_tla.log 2>&1
1096        RET_COMPILE=$?
1097        cat genmake_tla.log >> $LOGFILE
1098    
1099        # test program execution not always possible (see check_netcdf_libs)
1100        #
1101        #test -x ./genmake_tla  &&  ./genmake_tla >> genmake_tla.log 2>&1
1102        #RETVAL=$?
1103        #if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
1104    
1105        if test "x$RET_COMPILE" = x0 ; then
1106            HAVE_LAPACK=t
1107            echo "check_lapack: successful" >> $LOGFILE
1108        else
1109            # try again with "-llapack" added to the libs
1110            echo "==> try again with added '-llapack'" > genmake_tla.log
1111            echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1112            echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1113            echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack" >> genmake_tla.log
1114            cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1115                &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1116                &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack >> genmake_tla.log 2>&1
1117            RET_COMPILE=$?
1118            echo >> $LOGFILE
1119            cat genmake_tla.log >> $LOGFILE
1120            if test "x$RET_COMPILE" = x0 ; then
1121                LIBS="$LIBS -llapack"
1122                HAVE_LAPACK=t
1123                echo "check_lapack: successful" >> $LOGFILE
1124            else
1125            # try again with "-lf77blas -lcblas" added to the libs
1126                echo "==> try again with added '-llapack -lf77blas -lcblas'" > genmake_tla.log
1127                echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1128                echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1129                echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas" >> genmake_tla.log
1130                cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1131                    &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1132                    &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas >> genmake_tla.log 2>&1
1133                RET_COMPILE=$?
1134                echo >> $LOGFILE
1135                cat genmake_tla.log >> $LOGFILE
1136                if test "x$RET_COMPILE" = x0 ; then
1137                    LIBS="$LIBS -llapack -lf77blas -lcblas"
1138                    HAVE_LAPACK=t
1139                    echo "check_lapack: successful" >> $LOGFILE
1140                else
1141                # try again with "-latlas" added to the libs
1142                    echo "==> try again with added '-llapack -lf77blas -lcblas -latlas'" > genmake_tla.log
1143                    echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1144                    echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1145                    echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas" >> genmake_tla.log
1146                    cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1147                        &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1148                        &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas >> genmake_tla.log 2>&1
1149                    RET_COMPILE=$?
1150                    echo >> $LOGFILE
1151                    cat genmake_tla.log >> $LOGFILE
1152                    if test "x$RET_COMPILE" = x0 ; then
1153                        LIBS="$LIBS -llapack -lf77blas -lcblas -latlas"
1154                        HAVE_LAPACK=t
1155                        echo "check_lapack: successful" >> $LOGFILE
1156                    fi
1157                fi
1158            fi
1159        fi
1160        rm -f genmake_tla*
1161        echo " --> set HAVE_LAPACK='$HAVE_LAPACK'" >> $LOGFILE
1162    }
1163    
1164    check_HAVE_FLUSH()  {
1165        if test ! "x$SKIP_CHECK_FLUSH" = x ; then
1166            return
1167        fi
1168        echo >> $LOGFILE
1169        echo "running: check_HAVE_FLUSH()" >> $LOGFILE
1170        cat <<EOF > genmake_tflsh.$FS
1171          program fgenflsh
1172          integer iounit
1173          character*9 fname
1174          iounit = 26
1175          fname = 'tmp.tflsh'
1176          open(iounit,FILE=fname,STATUS='unknown')
1177          write(iounit,*) 'genmake_tflsh: hello'
1178          call flush(iounit)
1179          close(iounit)
1180          end
1181    EOF
1182        echo "===  genmake_tflsh.$FS  >>>" > genmake_tflsh.log
1183        cat genmake_tflsh.$FS >> genmake_tflsh.log
1184        echo "<<<  genmake_tflsh.$FS  ===" >> genmake_tflsh.log
1185    
1186        echo "$FC $FFLAGS $FOPTIM -c genmake_tflsh.$FS  \ " >> genmake_tflsh.log
1187        echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tflsh.o $LIBS" >> genmake_tflsh.log
1188        $FC $FFLAGS $FOPTIM -c genmake_tflsh.$FS >> genmake_tflsh.log 2>&1  \
1189            &&  $LINK $FFLAGS $FOPTIM -o genmake_tflsh genmake_tflsh.o $LIBS >> genmake_tflsh.log 2>&1
1190        RET_COMPILE=$?
1191    
1192        if test "x$RET_COMPILE" = x0 ; then
1193            HAVE_FLUSH=t
1194            #cat genmake_tflsh.log >> $LOGFILE
1195            echo "  check_HAVE_FLUSH: successful" >> $LOGFILE
1196        else
1197            HAVE_FLUSH=f
1198            cat genmake_tflsh.log >> $LOGFILE
1199        fi
1200        rm -f genmake_tflsh*
1201        echo " --> set HAVE_FLUSH='$HAVE_FLUSH'" >> $LOGFILE
1202    }
1203    
1204  ###############################################################################  ###############################################################################
1205  #   Sequential part of script starts here  #   Sequential part of script starts here
# Line 1091  GSL= Line 1257  GSL=
1257  DEVEL=  DEVEL=
1258  HAVE_TEST_L=  HAVE_TEST_L=
1259    
1260    # comment this line out to enable lapack test
1261    SKIP_LAPACK_CHECK=t
1262    
1263  # DEFINES checked by test compilation or command-line  # DEFINES checked by test compilation or command-line
1264  HAVE_SYSTEM=  HAVE_SYSTEM=
1265  HAVE_FDATE=  HAVE_FDATE=
# Line 1101  HAVE_STAT= Line 1270  HAVE_STAT=
1270  HAVE_NETCDF=  HAVE_NETCDF=
1271  HAVE_ETIME=  HAVE_ETIME=
1272  IGNORE_TIME=  IGNORE_TIME=
1273    HAVE_LAPACK=
1274    HAVE_FLUSH=
1275    
1276  MODS=  MODS=
1277  TOOLSDIR=  TOOLSDIR=
# Line 1108  SOURCEDIRS= Line 1279  SOURCEDIRS=
1279  INCLUDEDIRS=  INCLUDEDIRS=
1280  STANDARDDIRS="USE_THE_DEFAULT"  STANDARDDIRS="USE_THE_DEFAULT"
1281    
1282    #- local config file
1283    gm_local="genmake_local"
1284    
1285  G2ARGS=  G2ARGS=
1286  BASH=  BASH=
1287  PWD=`pwd`  PWD=`pwd`
# Line 1123  MACHINE=`uname -a` Line 1297  MACHINE=`uname -a`
1297  EXECUTABLE=  EXECUTABLE=
1298  EXEHOOK=  EXEHOOK=
1299  EXEDIR=  EXEDIR=
 PACKAGES_CONF=  
1300  IEEE=  IEEE=
1301  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
1302      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
# Line 1144  FTL_TAF_FLAGS= Line 1317  FTL_TAF_FLAGS=
1317  SVD_TAMC_FLAGS=  SVD_TAMC_FLAGS=
1318  TAMC_EXTRA=  TAMC_EXTRA=
1319    
1320    DIVA=
1321    MPIINCLUDEDIR=
1322    MPI_HEADER_FILES=
1323    LOCAL_MPI_HEADERS=
1324    
1325  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1326  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"
1327  gm_s2="FC CC USE_R4 TS PAPIS PCLS PAPI PCL HPMT IEEE DEVEL GSL MPI OMP DUMPSTATE STANDARDDIRS"  gm_s2="PLATFORM OPTFILE MAKE MAKEFILE MAKEDEPEND FC CC MPI OMP USE_R4"
1328    gm_s3="FEXTRAFLAGS IEEE DEVEL GSL TS PAPIS PCLS PAPI PCL HPMT DUMPSTATE"
1329    
1330  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1331  gm_s3="LN S64 LINK MAKE PACKAGES INCLUDES FFLAGS FOPTIM FEXTRAFLAGS"  gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM"
1332  gm_s4="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
1333  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD THISHOST THISUSER THISDATE THISVER MACHINE"  gm_s6="PWD TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"
1334  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s7="THISHOST THISUSER THISDATE THISVER MACHINE FC_NAMEMANGLE"
1335  gm_s7="FC_NAMEMANGLE HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME"  gm_s8="HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME HAVE_LAPACK HAVE_FLUSH"
1336    
1337  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1338  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"
1339  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"
1340  gm_s12="TAF_EXTRA TAMC_EXTRA"  gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES"
1341    
1342  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"
1343  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
1344    
1345  cat <<EOF  cat <<EOF
# Line 1179  LOGFILE="genmake.log" Line 1358  LOGFILE="genmake.log"
1358  rm -f genmake_state genmake_*optfile $LOGFILE  rm -f genmake_state genmake_*optfile $LOGFILE
1359    
1360  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  
1361    
1362  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
1363  #parse_options  #parse_options
# Line 1207  for ac_option in "$@" ; do Line 1376  for ac_option in "$@" ; do
1376      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
1377    
1378      case $ac_option in      case $ac_option in
1379            
1380          -help | --help | -h | --h)          -help | --help | -h | --h)
1381              usage ;;              usage ;;
1382            
1383          -nooptfile | --nooptfile)          -nooptfile | --nooptfile)
1384              OPTFILE="NONE" ;;              OPTFILE="NONE" ;;
1385          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
1386              ac_prev=OPTFILE ;;              ac_prev=OPTFILE ;;
1387          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
1388              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
1389            
1390          -adoptfile | --adoptfile | -adof | --adof)          -adoptfile | --adoptfile | -adof | --adof)
1391              ac_prev=AD_OPTFILE ;;              ac_prev=AD_OPTFILE ;;
1392          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
1393              AD_OPTFILE=$ac_optarg ;;              AD_OPTFILE=$ac_optarg ;;
1394            
1395          -pdepend | --pdepend)          -pdepend | --pdepend)
1396              ac_prev=PKG_DEPEND ;;              ac_prev=PKG_DEPEND ;;
1397          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
1398              PKG_DEPEND=$ac_optarg ;;              PKG_DEPEND=$ac_optarg ;;
1399            
1400          -pgroups | --pgroups)          -pgroups | --pgroups)
1401              ac_prev=PKG_GROUPS ;;              ac_prev=PKG_GROUPS ;;
1402          -pgroups=* | --pgroups=*)          -pgroups=* | --pgroups=*)
1403              PKG_GROUPS=$ac_optarg ;;              PKG_GROUPS=$ac_optarg ;;
1404            
1405          -make | --make | -m | --m)          -make | --make | -m | --m)
1406              ac_prev=MAKE ;;              ac_prev=MAKE ;;
1407          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
1408              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
1409            
1410          -bash | --bash)          -bash | --bash)
1411              ac_prev=BASH ;;              ac_prev=BASH ;;
1412          -bash=* | --bash=*)          -bash=* | --bash=*)
1413              BASH=$ac_optarg ;;              BASH=$ac_optarg ;;
1414            
1415          -makedepend | --makedepend | -md | --md)          -makedepend | --makedepend | -md | --md)
1416              ac_prev=MAKEDEPEND ;;              ac_prev=MAKEDEPEND ;;
1417          -makedepend=* | --makedepend=* | -md=* | --md=*)          -makedepend=* | --makedepend=* | -md=* | --md=*)
1418              MAKEDEPEND=$ac_optarg ;;              MAKEDEPEND=$ac_optarg ;;
1419            
1420          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -mf | --mf)
1421              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
1422          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -mf=* | --mf=*)
1423              MAKEFILE=$ac_optarg ;;              MAKEFILE=$ac_optarg ;;
1424            
1425          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)
1426              echo "ERROR: The platform option has been removed.  Please specify"              echo "ERROR: The platform option has been removed.  Please specify"
1427              echo "  the build options using the \"optfile\" mechanism."              echo "  the build options using the \"optfile\" mechanism."
1428              echo              echo
1429              usage              usage
1430              ;;              ;;
1431            
1432          -rootdir | --rootdir | -rd | --rd)          -rootdir | --rootdir | -rd | --rd)
1433              ac_prev=ROOTDIR ;;              ac_prev=ROOTDIR ;;
1434          -rootdir=* | --rootdir=* | -rd=* | --rd=*)          -rootdir=* | --rootdir=* | -rd=* | --rd=*)
1435              ROOTDIR=$ac_optarg ;;              ROOTDIR=$ac_optarg ;;
1436            
1437          -mods | --mods | -mo | --mo)          -mods | --mods | -mo | --mo)
1438              ac_prev=MODS ;;              ac_prev=MODS ;;
1439          -mods=* | --mods=* | -mo=* | --mo=*)          -mods=* | --mods=* | -mo=* | --mo=*)
1440              MODS=$ac_optarg ;;              MODS=$ac_optarg ;;
1441            
1442          -disable | --disable)          -disable | --disable)
1443              ac_prev=DISABLE ;;              ac_prev=DISABLE ;;
1444          -disable=* | --disable=*)          -disable=* | --disable=*)
1445              DISABLE=$ac_optarg ;;              DISABLE=$ac_optarg ;;
1446            
1447          -enable | --enable)          -enable | --enable)
1448              ac_prev=ENABLE ;;              ac_prev=ENABLE ;;
1449          -enable=* | --enable=*)          -enable=* | --enable=*)
1450              ENABLE=$ac_optarg ;;              ENABLE=$ac_optarg ;;
1451            
1452          -standarddirs | --standarddirs)          -standarddirs | --standarddirs)
1453              ac_prev=STANDARDDIRS ;;              ac_prev=STANDARDDIRS ;;
1454          -standarddirs=* | --standarddirs=*)          -standarddirs=* | --standarddirs=*)
# Line 1289  for ac_option in "$@" ; do Line 1458  for ac_option in "$@" ; do
1458  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1459  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1460  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1461            
1462          -cc | --cc)          -cc | --cc)
1463              ac_prev=CC ;;              ac_prev=CC ;;
1464          -cc=* | --cc=*)          -cc=* | --cc=*)
1465              CC=$ac_optarg ;;              CC=$ac_optarg ;;
1466            
1467          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1468              ac_prev=FC ;;              ac_prev=FC ;;
1469          -fc=* | --fc=*)          -fc=* | --fc=*)
1470              FC=$ac_optarg ;;              FC=$ac_optarg ;;
1471            
1472          -fs | --fs)          -fs | --fs)
1473              ac_prev=FS ;;              ac_prev=FS ;;
1474          -fs=* | --fs=*)          -fs=* | --fs=*)
1475              FS=$ac_optarg ;;              FS=$ac_optarg ;;
1476            
1477          -fs90 | --fs90)          -fs90 | --fs90)
1478              ac_prev=FS90 ;;              ac_prev=FS90 ;;
1479          -fs90=* | --fs90=*)          -fs90=* | --fs90=*)
1480              FS90=$ac_optarg ;;              FS90=$ac_optarg ;;
1481            
1482          -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )          -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )
1483              USE_R4=true ;;              USE_R4=true ;;
1484    
# Line 1317  for ac_option in "$@" ; do Line 1486  for ac_option in "$@" ; do
1486              IEEE=true ;;              IEEE=true ;;
1487          -noieee | --noieee)          -noieee | --noieee)
1488              echo "Warning: ignore option '$ac_option' (default is already without '-ieee')" ;;              echo "Warning: ignore option '$ac_option' (default is already without '-ieee')" ;;
1489          -devel | --devel)          -devel | --devel)
1490              IEEE=true ; DEVEL=true ;;              IEEE=true ; DEVEL=true ;;
1491          -gsl | --gsl)          -gsl | --gsl)
1492              GSL=true ;;              GSL=true ;;
1493    
1494          -ts | --ts)          -ts | --ts)
# Line 1342  for ac_option in "$@" ; do Line 1511  for ac_option in "$@" ; do
1511          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
1512              MPIPATH=$ac_optarg              MPIPATH=$ac_optarg
1513              MPI=true ;;              MPI=true ;;
1514            
1515          -omp | --omp)          -omp | --omp)
1516              OMP=true ;;              OMP=true ;;
1517          -omp=* | --omp=*)          -omp=* | --omp=*)
1518              OMPFLAG=$ac_optarg              OMPFLAG=$ac_optarg
1519              OMP=true ;;              OMP=true ;;
1520            
1521          -ds | --ds)          -ds | --ds)
1522              DUMPSTATE=t ;;              DUMPSTATE=t ;;
1523            
1524            -extra_flag | --extra_flag)
1525                ac_prev=FEXTRAFLAGS ;;
1526            -extra_flag=* | --extra_flag=*)
1527                FEXTRAFLAGS=$ac_optarg ;;
1528    
1529          -taf_extra | --taf_extra)          -taf_extra | --taf_extra)
1530              ac_prev=TAF_EXTRA ;;              ac_prev=TAF_EXTRA ;;
1531          -taf_extra=* | --taf_extra=*)          -taf_extra=* | --taf_extra=*)
# Line 1361  for ac_option in "$@" ; do Line 1535  for ac_option in "$@" ; do
1535              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1536          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1537              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1538            
1539          -ignoretime | -ignore_time | --ignoretime | --ignore_time)          -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1540              IGNORE_TIME="-DIGNORE_TIME" ;;              IGNORE_TIME="-DIGNORE_TIME" ;;
1541    
# Line 1372  for ac_option in "$@" ; do Line 1546  for ac_option in "$@" ; do
1546              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
1547              usage              usage
1548              ;;              ;;
1549            
1550          *)          *)
1551              echo "Error: unrecognized argument: "$ac_option              echo "Error: unrecognized argument: "$ac_option
1552              usage              usage
1553              ;;              ;;
1554            
1555      esac      esac
1556    
1557  done  done
1558    
1559    printf "  getting local config information:  "
1560    if test -f $gm_local ; then
1561        echo "using $gm_local"
1562        . $gm_local
1563    else
1564        echo "none found"
1565    fi
1566    
1567  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1568      echo      echo
1569      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
# Line 1435  if test "x$MAKEFILE" = x ; then Line 1617  if test "x$MAKEFILE" = x ; then
1617      MAKEFILE="Makefile"      MAKEFILE="Makefile"
1618  fi  fi
1619    
1620  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:"
1621  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1622      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
1623          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 1464  if test "x$OPTFILE" != xNONE ; then Line 1646  if test "x$OPTFILE" != xNONE ; then
1646      fi      fi
1647  fi  fi
1648    
1649  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:"
1650  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1651      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" = x ; then
1652          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
# Line 1512  EOF Line 1694  EOF
1694  fi  fi
1695  if test "x$GET_FC_VERSION" != x ; then  if test "x$GET_FC_VERSION" != x ; then
1696    echo "Get compiler version using: $FC $GET_FC_VERSION" >> $LOGFILE    echo "Get compiler version using: $FC $GET_FC_VERSION" >> $LOGFILE
1697    $FC $GET_FC_VERSION >> $LOGFILE 2>&1    ff=`echo $FC | sed 's/ .*//'` ; xx=`echo $ff | sed 's/^./& /' | sed 's/ .*//'`
1698      if test $xx != '/' ; then which $ff >> $LOGFILE ; fi
1699      $FC $GET_FC_VERSION > genmake_fc_vers1 2> genmake_fc_vers2
1700      if test -s genmake_fc_vers1 ; then
1701        cat genmake_fc_vers1 >> $LOGFILE
1702      else
1703        cat genmake_fc_vers2 >> $LOGFILE
1704      fi
1705    echo "<-- compiler version ----" >> $LOGFILE    echo "<-- compiler version ----" >> $LOGFILE
1706      rm -f genmake_fc_vers1 genmake_fc_vers2
1707  fi  fi
1708    
1709  if test "x$CC" = x ; then  if test "x$CC" = x ; then
# Line 1585  check_for_broken_Ff Line 1775  check_for_broken_Ff
1775    
1776  if test ! "x$MPI" = x ; then  if test ! "x$MPI" = x ; then
1777        echo "  Turning on MPI cpp macros"        echo "  Turning on MPI cpp macros"
1778        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI"
1779    #- To compile code older than checkpoint63s (2012/09/05), un-comment the following line:
1780    #     DEFINES="$DEFINES -DALWAYS_USE_MPI"
1781  fi  fi
1782  if test ! "x$OMP" = x ; then  if test ! "x$OMP" = x ; then
1783        echo "  Add OMPFLAG and turn on OpenMP cpp macros"        echo "  Add OMPFLAG and turn on OpenMP cpp macros"
# Line 1602  fi Line 1794  fi
1794  if test ! "x$TS" = x ; then  if test ! "x$TS" = x ; then
1795        echo "  Turning on timing per timestep"        echo "  Turning on timing per timestep"
1796        if test ! "x$FOOLAD" = x ; then        if test ! "x$FOOLAD" = x ; then
1797              DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"
1798        else        else
1799              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1800        fi        fi
# Line 1638  if test ! "x$PAPI" = x ; then Line 1830  if test ! "x$PAPI" = x ; then
1830            echo "  Sticking with PAPI flop summary per timestep!"            echo "  Sticking with PAPI flop summary per timestep!"
1831        else        else
1832            echo "  Turning on performance analysis with PAPI"            echo "  Turning on performance analysis with PAPI"
1833            echo "  Please make sure PAPIINC, PAPILIB are defined"            echo "  Please make sure PAPIINC, PAPILIB are defined"
1834            DEFINES="$DEFINES -DUSE_PAPI"            DEFINES="$DEFINES -DUSE_PAPI"
1835            INCLUDES="$INCLUDES $PAPIINC"            INCLUDES="$INCLUDES $PAPIINC"
1836            LIBS="$LIBS $PAPILIB"            LIBS="$LIBS $PAPILIB"
# Line 1650  if test ! "x$PCL" = x ; then Line 1842  if test ! "x$PCL" = x ; then
1842            echo "  Sticking with PCL flop summary per timestep!"            echo "  Sticking with PCL flop summary per timestep!"
1843        else        else
1844            echo "  Turning on performance analysis with PCL"            echo "  Turning on performance analysis with PCL"
1845            echo "  Please make sure PCLINC, PCLLIB are defined"            echo "  Please make sure PCLINC, PCLLIB are defined"
1846            DEFINES="$DEFINES -DUSE_PCL"            DEFINES="$DEFINES -DUSE_PCL"
1847            INCLUDES="$INCLUDES $PCLINC"            INCLUDES="$INCLUDES $PCLINC"
1848            LIBS="$LIBS $PCLLIB"            LIBS="$LIBS $PCLLIB"
# Line 1660  if test ! "x$HPMT" = x ; then Line 1852  if test ! "x$HPMT" = x ; then
1852        if test ! "x$PAPI" = x ; then        if test ! "x$PAPI" = x ; then
1853            echo "  PAPI and the HPM Toolkit cannot co-exist!"            echo "  PAPI and the HPM Toolkit cannot co-exist!"
1854            echo "  Sticking with PAPI!"            echo "  Sticking with PAPI!"
1855        else if test ! "x$PCL" = x ; then        else
1856            if test ! "x$PCL" = x ; then
1857            echo "  PCL and the HPM Toolkit cannot co-exist!"            echo "  PCL and the HPM Toolkit cannot co-exist!"
1858            echo "  Sticking with PCL!"            echo "  Sticking with PCL!"
1859        else          else
1860            echo "  Turning on performance analysis with the HPM Toolkit"            echo "  Turning on performance analysis with the HPM Toolkit"
1861            echo "  Please make sure HPMTINC, HPMTLIB are defined"            echo "  Please make sure HPMTINC, HPMTLIB are defined"
1862            DEFINES="$DEFINES -DUSE_LIBHPM"            DEFINES="$DEFINES -DUSE_LIBHPM"
1863            INCLUDES="$INCLUDES $HPMTINC"            INCLUDES="$INCLUDES $HPMTINC"
1864            LIBS="$LIBS $HPMTLIB"            LIBS="$LIBS $HPMTLIB"
1865        fi          fi
1866        fi        fi
1867  fi  fi
1868  if test ! "x$GSL" = x ; then  if test ! "x$GSL" = x ; then
# Line 1750  rm -f genmake_tcomp* Line 1943  rm -f genmake_tcomp*
1943  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1944  check_HAVE_CLOC  check_HAVE_CLOC
1945  if test "x$HAVE_CLOC" != x ; then  if test "x$HAVE_CLOC" != x ; then
1946        DEFINES="$DEFINES -DHAVE_CLOC"
1947      echo "yes"      echo "yes"
1948  else  else
1949      echo "no"      echo "no"
# Line 1764  rm -f genmake_t* Line 1958  rm -f genmake_t*
1958  printf "  Can we unlimit the stack size using $FC...  "  printf "  Can we unlimit the stack size using $FC...  "
1959  check_HAVE_SETRLSTK  check_HAVE_SETRLSTK
1960  if test "x$HAVE_SETRLSTK" = xt ; then  if test "x$HAVE_SETRLSTK" = xt ; then
1961        DEFINES="$DEFINES -DHAVE_SETRLSTK"
1962      echo "yes"      echo "yes"
1963  else  else
1964      echo "no"      echo "no"
# Line 1773  rm -f genmake_t* Line 1968  rm -f genmake_t*
1968  printf "  Can we register a signal handler using $FC...  "  printf "  Can we register a signal handler using $FC...  "
1969  check_HAVE_SIGREG  check_HAVE_SIGREG
1970  if test "x$HAVE_SIGREG" = xt ; then  if test "x$HAVE_SIGREG" = xt ; then
1971        DEFINES="$DEFINES -DHAVE_SIGREG"
1972      echo "yes"      echo "yes"
1973  else  else
1974      echo "no"      echo "no"
# Line 1782  rm -f genmake_t* Line 1978  rm -f genmake_t*
1978  printf "  Can we use stat() through C calls...  "  printf "  Can we use stat() through C calls...  "
1979  check_HAVE_STAT  check_HAVE_STAT
1980  if test "x$HAVE_STAT" != x ; then  if test "x$HAVE_STAT" != x ; then
1981        DEFINES="$DEFINES -DHAVE_STAT"
1982      echo "yes"      echo "yes"
1983  else  else
1984      echo "no"      echo "no"
# Line 1791  rm -f genmake_t* Line 1988  rm -f genmake_t*
1988  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1989  check_netcdf_libs  check_netcdf_libs
1990  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
1991        DEFINES="$DEFINES -DHAVE_NETCDF"
1992        echo "yes"
1993    else
1994        echo "no"
1995    fi
1996    
1997    printf "  Can we create LAPACK-enabled binaries...  "
1998    check_lapack_libs
1999    if test "x$HAVE_LAPACK" != x ; then
2000        DEFINES="$DEFINES -DHAVE_LAPACK"
2001        echo "yes"
2002    else
2003        echo "no"
2004    fi
2005    
2006    printf "  Can we call FLUSH intrinsic subroutine...  "
2007    check_HAVE_FLUSH
2008    if test "x$HAVE_FLUSH" = xt ; then
2009        DEFINES="$DEFINES -DHAVE_FLUSH"
2010      echo "yes"      echo "yes"
2011  else  else
2012      echo "no"      echo "no"
2013  fi  fi
 DEFINES="$DEFINES $IGNORE_TIME"  
2014    
2015    DEFINES="$DEFINES $IGNORE_TIME"
2016  if test "x$EMBED_SRC" = xt ; then  if test "x$EMBED_SRC" = xt ; then
2017      build_embed_encode      build_embed_encode
2018  fi  fi
2019  if test "x$EMBED_SRC" = xt ; then  if test "x$EMBED_SRC" = xt ; then
2020      ENABLE="$ENABLE embed_files"      ENABLE="$ENABLE embed_files"
2021    #   DEFINES="$DEFINES -DHAVE_EMBED_SRC"
2022  fi  fi
2023    
2024  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
# Line 1979  else Line 2196  else
2196          exit 1          exit 1
2197      else      else
2198          echo "    using PKG_LIST=\"$PKG_LIST\""          echo "    using PKG_LIST=\"$PKG_LIST\""
2199          #  Strip the comments and add all the names          #  Strip the comments and add all the names
2200          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}'`
2201          RETVAL=$?          RETVAL=$?
2202          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
# Line 2029  for i in $PACKAGES ; do Line 2246  for i in $PACKAGES ; do
2246      j=`echo $i | sed 's/[-+]//'`      j=`echo $i | sed 's/[-+]//'`
2247      if test ! -d "$ROOTDIR/pkg/$j" ; then      if test ! -d "$ROOTDIR/pkg/$j" ; then
2248          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
2249          exit 1          exit 1
2250      fi      fi
2251      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
2252  done  done
# Line 2074  else Line 2291  else
2291          echo "Error: problem encountered while building source files in pkg/mnc:"          echo "Error: problem encountered while building source files in pkg/mnc:"
2292          cat make_mnc.errors 1>&2          cat make_mnc.errors 1>&2
2293          if test "x$mnc_in" = x0 ; then          if test "x$mnc_in" = x0 ; then
2294              exit 1              exit 1
2295          else          else
2296              DISABLE="$DISABLE mnc"              DISABLE="$DISABLE mnc"
2297          fi          fi
# Line 2107  EOF Line 2324  EOF
2324      fi      fi
2325  fi  fi
2326    
2327    #  Check for package RADTRANS: if LAPACK is not available,
2328    #  then issue a warning that the direct radtrans solver is not available.
2329    if test "x$HAVE_LAPACK" != xt ; then
2330        echo " $PACKAGES " | grep ' radtrans ' > /dev/null 2>&1
2331        RETVAL=$?
2332        if test "x$RETVAL" = x0 ; then
2333            cat <<EOF
2334    *********************************************************************
2335    WARNING: the "radtrans" package was enabled but tests failed to
2336      compile LAPACK applications.  This means that the direct radtrans
2337      solver is not available and compilation will fail if it is enabled.
2338      If you want to use the direct solver, please check that:
2339    
2340      1) LAPACK is correctly installed for this compiler and
2341      2) the LIBS variable (within the "optfile") specifies the correct
2342         LAPACK library to link against.
2343    *********************************************************************
2344    EOF
2345        fi
2346    fi
2347    
2348  if  test "x${PKG_DEPEND}" != x ; then  if  test "x${PKG_DEPEND}" != x ; then
2349    echo "  applying package dependency rules"    echo "  applying package dependency rules"
2350    ck=    ck=
# Line 2152  if  test "x${PKG_DEPEND}" != x ; then Line 2390  if  test "x${PKG_DEPEND}" != x ; then
2390    
2391          #  Do we need to add $dname according to the dependency rules?          #  Do we need to add $dname according to the dependency rules?
2392          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
2393              #echo "   " $pname ": need to add :" $dname              #echo "   " $pname ": need to add :" $dname
2394              in_dis="f"              in_dis="f"
2395              for dis in $DISABLE ; do              for dis in $DISABLE ; do
2396                  if test "x$dis" = "x$dname" ; then                  if test "x$dis" = "x$dname" ; then
# Line 2177  if  test "x${PKG_DEPEND}" != x ; then Line 2415  if  test "x${PKG_DEPEND}" != x ; then
2415              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
2416              exit 1              exit 1
2417          fi          fi
2418          i=`echo "$i + 1" | bc -l`          i=`echo "$i + 1" | bc -l`
2419          #i=$(( $i + 1 ))          #i=$(( $i + 1 ))
2420      done      done
2421      ck=$ck"t"      ck=$ck"t"
# Line 2218  for n in $names ; do Line 2456  for n in $names ; do
2456          done          done
2457          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
2458              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
2459              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
2460          fi          fi
2461      fi      fi
2462  done  done
# Line 2231  for i in $PACKAGES ; do Line 2469  for i in $PACKAGES ; do
2469  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
2470      case $i in      case $i in
2471          aim_v23)          aim_v23)
2472              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
2473              echo "Warning: ALLOW_AIM is set to enable aim_v23."              echo "Warning: ALLOW_AIM is set to enable aim_v23."
2474              ;;              ;;
2475      esac      esac
# Line 2273  for i in $spaths ; do Line 2511  for i in $spaths ; do
2511      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
2512          echo "    found CPP_OPTIONS=\"$try\""          echo "    found CPP_OPTIONS=\"$try\""
2513          CPP_OPTIONS="$try"          CPP_OPTIONS="$try"
2514          # 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
2515          for n in $names ; do          for n in $names ; do
2516              test_for_package_in_cpp_options $CPP_OPTIONS $n              test_for_package_in_cpp_options $CPP_OPTIONS $n
2517          done          done
2518      fi      fi
2519      try="$i/CPP_EEOPTIONS.h"      try="$i/CPP_EEOPTIONS.h"
2520      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
2521          echo "    found CPP_EEOPTIONS=\"$try\""          echo "    found CPP_EEOPTIONS=\"$try\""
2522          # 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
2523  #**** not yet enabled ****  #**** not yet enabled ****
2524  #        test_for_mpi_in_cpp_eeoptions $try  #        test_for_mpi_in_cpp_eeoptions $try
2525  #**** not yet enabled ****  #**** not yet enabled ****
# Line 2320  for i in $INCLUDEDIRS ; do Line 2558  for i in $INCLUDEDIRS ; do
2558      fi      fi
2559  done  done
2560    
2561  if test ! "x$DIVA" = x ; then  if test ! "x$DIVA" = x -a ! "x$MPI" = x ; then
2562      echo "  Creating the pseudo-MPI include directory"    if test ! "x$MPIINCLUDEDIR" = x ; then
2563      INCLUDES="-I./mpi_headers $INCLUDES"      if test -d $MPIINCLUDEDIR ; then
2564      rm -rf ./mpi_headers          echo "  Creating the pseudo-MPI include directory"
2565      mkdir -p ./mpi_headers          INCLUDES="-I./mpi_headers $INCLUDES"
2566            rm -rf ./mpi_headers
2567      if test "x$MPIINCLUDEDIR" = x ; then          mkdir -p ./mpi_headers
2568          if test "x$MPIHOME" = x ; then          #  Do a local copy of MPI headers files (in local dir ./mpi_headers/) after
2569              MPIHOME='/usr'          #   checking for additional included headers (in case of chain of included
2570          fi          #   header); also set LOCAL_MPI_HEADERS (if not already set)
2571          MPIINCLUDEDIR='$MPIHOME/include'          mpi_headers_do_local_copy
     fi  
   
     if test -r $MPIINCLUDEDIR/mpif.h ; then  
         for i in $MPI_HEADER_FILES; do  
             cp -p $MPIINCLUDEDIR/$i ./mpi_headers  
         done  
   
         perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h  
2572      else      else
2573          echo " We cannot create a copy of mpif.h!"          echo "WARNING: MPIINCLUDEDIR='$MPIINCLUDEDIR' is not a dir"
2574            echo "WARNING: ==> cannot create pseudo-MPI include directory"
2575  #       exit -1  #       exit -1
2576      fi      fi
2577      fi
2578  fi  fi
2579    
2580  echo "  Determining the list of source and include files"  echo "  Determining the list of source and include files"
# Line 2372  if test "x$OPENAD" != x ; then Line 2604  if test "x$OPENAD" != x ; then
2604      OAD_DONT_TRANSFORM="/dev/null"      OAD_DONT_TRANSFORM="/dev/null"
2605      OAD_KEEP_ORIGINAL="/dev/null"      OAD_KEEP_ORIGINAL="/dev/null"
2606      OAD_CB2M_FILES="/dev/null"      OAD_CB2M_FILES="/dev/null"
2607        OADTOOLS="$TOOLSDIR/OAD_support"
2608      echo "  looking for dontCompile file:  "      echo "  looking for dontCompile file:  "
2609      for i in "." $MODS ; do      for i in "." $MODS ; do
2610          if test -r $i"/dontCompile" ; then          if test -r $i"/dontCompile" ; then
# Line 2427  for d in $alldirs ; do Line 2660  for d in $alldirs ; do
2660          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
2661              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2662                  ignore_f=f                  ignore_f=f
2663                  case $d/$sf in                  case $d/$sf in
2664                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
2665                          ignore_f=t                          ignore_f=t
2666                          ;;                          ;;
2667                    ./AD_CONFIG.h)                    ./AD_CONFIG.h)
2668                          ignore_f=t                          ignore_f=t
2669                          ;;                          ;;
2670                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
2671                          ignore_f=t                          ignore_f=t
2672                          ;;                          ;;
2673                    ./BUILD_INFO.h)                    ./BUILD_INFO.h)
2674                          ignore_f=t                          ignore_f=t
2675                          ;;                          ;;
2676                    ./EMBEDDED_FILES.h)                    ./EMBEDDED_FILES.h)
2677                          ignore_f=t                          ignore_f=t
2678                          ;;                          ;;
2679                    *)                    *)
2680                          #  For the local directory *ONLY*,                          #  For the local directory *ONLY*,
2681                          #  ignore all soft-links                          #  ignore all soft-links
2682                          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 2453  for d in $alldirs ; do Line 2686  for d in $alldirs ; do
2686                              deplist="$deplist $sf"                              deplist="$deplist $sf"
2687                          fi                          fi
2688                          ;;                          ;;
2689                  esac                  esac
2690                  if test "x$ignore_f" = xf ; then                  if test "x$ignore_f" = xf ; then
2691                      extn=`echo $sf | $AWK -F. '{print $NF}'`                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2692                      case $extn in                      case $extn in
# Line 2500  for d in $alldirs ; do Line 2733  for d in $alldirs ; do
2733                          echo    " \\"  >> hsrclist.tmp                          echo    " \\"  >> hsrclist.tmp
2734                          printf " $sf" >> hsrclist.tmp                          printf " $sf" >> hsrclist.tmp
2735                          ;;                          ;;
2736                      flow)                      flow)
2737                          echo    " \\"  >> ad_flow_files.tmp                          echo    " \\"  >> ad_flow_files.tmp
2738                          printf " $sf" >> ad_flow_files.tmp                          printf " $sf" >> ad_flow_files.tmp
2739                          ;;                          ;;
# Line 2511  for d in $alldirs ; do Line 2744  for d in $alldirs ; do
2744      done      done
2745      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2746        if test "$d" != "." ; then        if test "$d" != "." ; then
2747          echo "" >> srclinks.tmp          echo "" >> srclinks.tmp
2748          echo "#  These files are linked from $d" >> srclinks.tmp          echo "#  These files are linked from $d" >> srclinks.tmp
2749          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> srclinks.tmp
2750  # 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 2532  echo "" >> ad_flow_files.tmp Line 2765  echo "" >> ad_flow_files.tmp
2765  CMDLINE=$0  CMDLINE=$0
2766  for xx in "$@" ; do nw=`echo $xx | wc -w`  for xx in "$@" ; do nw=`echo $xx | wc -w`
2767      if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"      if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
2768                          else CMDLINE="$CMDLINE '$xx'" ; fi                          else CMDLINE="$CMDLINE '$xx'" ; fi
2769  done  done
2770    
2771  if test -f $MAKEFILE ; then  if test -f $MAKEFILE ; then
# Line 2566  cat >>$MAKEFILE <<EOF Line 2799  cat >>$MAKEFILE <<EOF
2799  # INCLUDES     : Directories searched for header files  # INCLUDES     : Directories searched for header files
2800  # DEFINES      : Macro definitions for CPP  # DEFINES      : Macro definitions for CPP
2801  # MAKEDEPEND   : Dependency generator  # MAKEDEPEND   : Dependency generator
 # KPP          : Special preprocessor command (specific to platform)  
 # KFLAGS       : Flags for KPP  
2802  # FC           : Fortran compiler command  # FC           : Fortran compiler command
2803  # FFLAGS       : Configuration/debugging options for FC  # FFLAGS       : Configuration/debugging options for FC
2804  # FOPTIM       : Optimization options for FC  # FOPTIM       : Optimization options for FC
# Line 2581  INCLUDEDIRS = ${INCLUDEDIRS} Line 2812  INCLUDEDIRS = ${INCLUDEDIRS}
2812  EXEDIR      = ${EXEDIR}  EXEDIR      = ${EXEDIR}
2813  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
2814  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIR}
2815    OADTOOLS    = ${OADTOOLS}
2816    
2817  #eh3  new defines for the adjoint work  #eh3  new defines for the adjoint work
2818  AUTODIFF    = ${ROOTDIR}/pkg/autodiff  AUTODIFF    = ${ROOTDIR}/pkg/autodiff
# Line 2601  else Line 2833  else
2833      echo "EMBEDDED_FILES = " >>$MAKEFILE      echo "EMBEDDED_FILES = " >>$MAKEFILE
2834  fi  fi
2835    
2836    # extract default cpp search path so we can pass it to makedepend
2837    CPPINCLUDES=`cat /dev/null | $CPP -v 2>&1 | awk '/^End of search/{f=0}!/^\#/{if(f){printf " -I%s", $1;}}/^\#include "..." search start/{f=1}'`
2838    
2839  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2840  # Unix ln (link)  # Unix ln (link)
2841  LN = ${LN}  LN = ${LN}
 # C preprocessor  
 CPP = cat \$< | ${S64} | ${CPP}  
2842  # Dependency generator  # Dependency generator
2843  MAKEDEPEND = ${MAKEDEPEND}  MAKEDEPEND = ${MAKEDEPEND}
2844  # Special preprocessor (KAP on DECs, FPP on Crays)  # Special preprocessor (KAP on DECs, FPP on Crays)
# Line 2623  LINK = ${LINK} ${LDADD} Line 2856  LINK = ${LINK} ${LDADD}
2856  DEFINES = ${DEFINES}  DEFINES = ${DEFINES}
2857  # Includes for CPP  # Includes for CPP
2858  INCLUDES = ${INCLUDES}  INCLUDES = ${INCLUDES}
2859    # default CPP includes for makedepend
2860    CPPINCLUDES = ${CPPINCLUDES}
2861  # Flags for KPP  # Flags for KPP
2862  KFLAGS1 = ${KFLAGS1}  KFLAGS1 = ${KFLAGS1}
2863  KFLAGS2 = ${KFLAGS2}  KFLAGS2 = ${KFLAGS2}
# Line 2640  NOOPTFILES = ${NOOPTFILES} Line 2875  NOOPTFILES = ${NOOPTFILES}
2875  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2876  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2877  LIBS = ${LIBS}  LIBS = ${LIBS}
2878  # Name of the Mekfile  # Name of the makefile
2879  MAKEFILE=${MAKEFILE}  MAKEFILE = ${MAKEFILE}
2880    # Name of the make program
2881    MAKE = ${MAKE}
2882    
2883  EOF  EOF
2884    
# Line 2665  echo >> $MAKEFILE Line 2902  echo >> $MAKEFILE
2902  echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE  echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE
2903  echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE  echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE
2904  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
2905  echo 'FLOFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE  echo 'FLOWFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE
2906  echo >> $MAKEFILE  echo >> $MAKEFILE
2907  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
2908  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
2909    
2910  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2911    
2912  all: \$(EXECUTABLE)  all: fwd_exe_target
2913    fwd_exe_target:
2914            @echo Update AD_CONFIG.h and make \$(EXECUTABLE)
2915            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Forward version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
2916            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2917            @-rm -f ad_config.template
2918            \$(MAKE) -f \$(MAKEFILE) \$(EXECUTABLE)
2919    
2920  \$(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)
2921          @echo Creating \$@ ...          @echo Creating \$@ ...
2922          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2923    
2924  depend:  depend:
2925          @make links          @\$(MAKE) -f \$(MAKEFILE) links
2926          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)          \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(CPPINCLUDES) \$(F77_SRC_FILES)
2927          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2928          -rm -f makedepend.out          -rm -f makedepend.out
2929    
# Line 2688  libmitgcmuv.a: \$(OBJFILES) Line 2933  libmitgcmuv.a: \$(OBJFILES)
2933          ar rcv libmitgcmuv.a \$(OBJFILES)          ar rcv libmitgcmuv.a \$(OBJFILES)
2934          ar d   libmitgcmuv.a main.o          ar d   libmitgcmuv.a main.o
2935    
2936    obj: \$(OBJFILES)
2937    
2938  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)
2939    
2940  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
# Line 2705  clean: Line 2952  clean:
2952    
2953  # remove most of the files that "make" and "make depend" generate  # remove most of the files that "make" and "make depend" generate
2954  Clean:  Clean:
2955          @make clean          @\$(MAKE) -f \$(MAKEFILE) clean
2956          @make cleanlinks          @\$(MAKE) -f \$(MAKEFILE) cleanlinks
2957          -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old          -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old
2958          -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
         -rm -f genmake_warnings genmake_errors make.log  
2959    
2960  # remove also the executable, files that "genmake2" generates (except Makefile)  # remove also the executable, files that "genmake2" generates (except Makefile)
2961  #         and output from a run (plus log files from testreport)  #         and output from a run (plus log files from testreport)
2962  CLEAN:  CLEAN:
2963          @make Clean          @\$(MAKE) -f \$(MAKEFILE) Clean
2964          -rm -f \$(EXECUTABLE) \$(EXE_AD) *.bak          -rm -f \$(EXECUTABLE) \$(EXE_AD) \$(EXE_FTL) *.bak
2965          -rm -f $LOGFILE genmake_state genmake_*optfile          -rm -f $LOGFILE genmake_state genmake_*optfile
2966          -rm -f SIZE.h.mpi genmake.tr_log make.tr_log          -rm -f SIZE.h.mpi genmake.tr_log make.tr_log
2967            -rm -rf mpi_headers mnc_test_*
2968          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2969          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2970          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2971          -rm -f *.txt STD* *diagnostics.log datetime          -rm -f *.txt STDOUT.* STDERR.* *diagnostics.log *.[0-9][0-9][0-9][0-9].log
2972            -rm -f datetime costfinal divided.ctrl snapshot* output_adm.txt.diva_*
2973          -rm -f *_MIT_CE_000.opt0000 costfunction*0000          -rm -f *_MIT_CE_000.opt0000 costfunction*0000
2974          -rm -rf mnc_test_*          -rm -f oad_cp.000.[0-9][0-9][0-9][0-9][0-9]
2975    
2976  makefile:  makefile:
2977          $THIS_SCRIPT $G2ARGS          $THIS_SCRIPT $G2ARGS
# Line 2733  cleanlinks: Line 2981  cleanlinks:
2981  # Special targets (SPECIAL_FILES) which are created by make  # Special targets (SPECIAL_FILES) which are created by make
2982  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2983          @echo Creating \$@ ...          @echo Creating \$@ ...
2984          @$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) > \$@
2985  AD_CONFIG.h:  AD_CONFIG.h:
2986          @echo Creating \$@ ...          @echo Creating \$@ ...
2987          @$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 > \$@
2988  FC_NAMEMANGLE.h:  FC_NAMEMANGLE.h:
2989          @echo Creating \$@ ...          @echo Creating \$@ ...
2990          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
# Line 2776  cat >>$MAKEFILE <<EOF Line 3024  cat >>$MAKEFILE <<EOF
3024  ## This nullifies any default implicit rules concerning these two file types:  ## This nullifies any default implicit rules concerning these two file types:
3025  ## %.o : %.F  ## %.o : %.F
3026    
3027    # C preprocessing and replacing the _d in constants:
3028    CPPCMD = cat \$< | ${CPP} \$(DEFINES) \$(INCLUDES) | ${S64}
3029    
3030  .F.$FS:  .F.$FS:
3031          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD)  > \$@
3032  .$FS.o:  .$FS.o:
3033          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
3034  .F.o:  .F.o:
3035          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
3036  .F90.$FS90:  .F90.$FS90:
3037          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD)  > \$@
3038  .FF90.f$FS90:  .FF90.f$FS90:
3039          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD)  > \$@
3040  .$FS90.o:  .$FS90.o:
3041          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
3042  .f$FS90.o:  .f$FS90.o:
# Line 2794  cat >>$MAKEFILE <<EOF Line 3045  cat >>$MAKEFILE <<EOF
3045  .c.o:  .c.o:
3046          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
3047  .flow.flowdir:  .flow.flowdir:
3048          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD) > \$@
3049    
3050  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
3051  .F.p:  .F.p:
3052          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD) > \$@
3053  .p.$FS:  .p.$FS:
3054          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
3055    
# Line 2817  TAF            = ${TAF} Line 3068  TAF            = ${TAF}
3068    
3069  TAF_EXTRA      = ${TAF_EXTRA}  TAF_EXTRA      = ${TAF_EXTRA}
3070  TAMC_EXTRA     = ${TAMC_EXTRA}  TAMC_EXTRA     = ${TAMC_EXTRA}
3071    LOCAL_MPI_HEADERS    = ${LOCAL_MPI_HEADERS}
3072    
3073  EOF  EOF
3074    
# Line 2845  rm -f adSrcFiles.tmp Line 3097  rm -f adSrcFiles.tmp
3097  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3098    
3099  # ... AD ...  # ... AD ...
3100  adall: \$(EXE_AD)  adall: ad_exe_target
3101  adtaf: ad_taf_output.$FS  adtaf: ad_taf_output.$FS
3102  adtamc: ad_tamc_output.$FS  adtamc: ad_tamc_output.$FS
3103    
3104  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES)  ad_exe_target:
3105          @$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          @echo Update AD_CONFIG.h and make \$(EXE_AD)
3106            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3107            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3108            @-rm -f ad_config.template
3109            \$(MAKE) -f \$(MAKEFILE) \$(EXE_AD)
3110    
3111    ad_input_code.$FS: \$(AD_FILES) \$(AD_FLOW_FILES)
3112            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3113          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
3114          -rm -f ad_config.template          @-rm -f ad_config.template
3115          @make \$(F77_PP_SRC_FILES)          @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3116          @make \$(FLOFILES)          @\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)
3117          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
3118    
3119  ad_taf_output.$FS: ad_input_code.$FS  ad_taf_output.$FS: ad_input_code.$FS
3120          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
# Line 2867  adtafonly: Line 3126  adtafonly:
3126          ls -l ad_input_code_ad.$FS          ls -l ad_input_code_ad.$FS
3127          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
3128    
3129  \${EXE_AD}: ad_taf_output.o \$(OBJFILES)  \$(EXE_AD): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) ad_taf_output.o \$(OBJFILES) \$(EMBEDDED_FILES)
3130          \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
3131    
3132  ad_tamc_output.$FS: ad_input_code.$FS  ad_tamc_output.$FS: ad_input_code.$FS
# Line 2883  adonlyfwd: Line 3142  adonlyfwd:
3142  adtrick:  adtrick:
3143          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
3144    
3145    adobj: ad_taf_output.o \$(OBJFILES)
3146    
3147  # ... FTL ...  # ... FTL ...
3148  ftlall: ftl_taf  ftlall: ftl_exe_target
3149  ftltaf: ftl_taf_output.$FS  ftltaf: ftl_taf_output.$FS
3150  ftltamc: ftl_tamc_output.$FS  ftltamc: ftl_tamc_output.$FS
3151    
3152  ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)  ftl_exe_target:
3153          @$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          @echo Update AD_CONFIG.h and make \$(EXE_FTL)
3154          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3155          -rm -f ftl_config.template          @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3156          @make \$(F77_PP_SRC_FILES)          @-rm -f ad_config.template
3157          @make \$(AD_FLOW_FILES)          \$(MAKE) -f \$(MAKEFILE) \$(EXE_FTL)
3158          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS  
3159    ftl_input_code.$FS: \$(AD_FILES)
3160            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3161            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3162            @-rm -f ad_config.template
3163            @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3164            @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3165            cat \$(AD_FLOW_FILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ftl_input_code.$FS
3166    
3167  ftl_taf_output.$FS: ftl_input_code.$FS  ftl_taf_output.$FS: ftl_input_code.$FS
3168          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
# Line 2906  ftltafonly: Line 3174  ftltafonly:
3174          ls -l ftl_input_code_ftl.$FS          ls -l ftl_input_code_ftl.$FS
3175          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
3176    
3177  ftl_taf: ftl_taf_output.o \$(OBJFILES)  \$(EXE_FTL): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) ftl_taf_output.o \$(OBJFILES) \$(EMBEDDED_FILES)
3178          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
3179    
3180  ftl_tamc_output.$FS: ftl_input_code.$FS  ftl_tamc_output.$FS: ftl_input_code.$FS
3181          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
# Line 2936  svd_touch: Line 3204  svd_touch:
3204          touch ad_taf_output.$FS ftl_taf_output.$FS          touch ad_taf_output.$FS ftl_taf_output.$FS
3205          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
3206          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
3207          @$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
3208          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
3209          -rm -f ftl_config.template          @-rm -f ad_config.template
3210    
3211  EOF  EOF
3212    
# Line 3013  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod. Line 3281  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.
3281    
3282  .PHONY: adDepend  .PHONY: adDepend
3283  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)
3284          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)          \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
3285          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
3286          -rm -f makedepend.out          -rm -f makedepend.out
3287    
# Line 3022  w2f__types.F90 \ Line 3290  w2f__types.F90 \
3290  OAD_active.F90 \  OAD_active.F90 \
3291  OAD_cp.F90 \  OAD_cp.F90 \
3292  OAD_rev.F90 \  OAD_rev.F90 \
3293  OAD_tape.F90  OAD_tape.F90 \
3294    revolve.F90
3295    
3296  OPENAD_SUPPORT_C_SRC_FILES = \  OPENAD_SUPPORT_C_SRC_FILES = \
3297  iaddr.c \  iaddr.c \
# Line 3038  f95_test.out: f95_test_mods.f90 f95_test Line 3307  f95_test.out: f95_test_mods.f90 f95_test
3307          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
3308          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
3309    
3310  # 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  
3311    
3312  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)
3313    
3314  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)
3315    
3316  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)  
3317          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)
 else  
         touch \$@  
 endif  
   
 # makefile debug rule  
 openad: ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90  
 .PHONY: openad  
3318    
3319  # create the module files  # create sources files modules from header files containing common blocks
3320  %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk  %_mod.FF90 : %.h \${OADTOOLS}/cb2mGetModules.csh \${OADTOOLS}/cb2mGetModules.awk
3321          ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk          \${OADTOOLS}/cb2mGetModules.csh $< \${OADTOOLS}/cb2mGetModules.awk
3322    
3323  # create the header files  # create new header files with USE statements for the new modules made above
3324  %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk  %_mod.h : %.h \${OADTOOLS}/cb2mGetHeaders.csh \${OADTOOLS}/cb2mGetHeaders.awk
3325          ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)          \${OADTOOLS}/cb2mGetHeaders.csh $< \${OADTOOLS}/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
3326    
3327  # 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
3328  %_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash  %_cb2m.FF90 : %.F \${OADTOOLS}/cb2mUseModules.bash
3329          ../OAD_support/cb2mUseModules.bash $< ${MPI}          \${OADTOOLS}/cb2mUseModules.bash $< ${MPI}
3330    
3331  # makefile debug rule  # makefile debug rule
3332  small_f: \$(CB2M_F90_PP_SRC_FILES)  small_f: \$(CB2M_F90_PP_SRC_FILES)
# Line 3091  ad_output.txt: \$(EXE_AD) Line 3339  ad_output.txt: \$(EXE_AD)
3339          @printf 'running ... '          @printf 'running ... '
3340          @./\$(EXE_AD) > \$@          @./\$(EXE_AD) > \$@
3341    
 CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)  
3342  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3343          cat \$^ > \$@          cat \$^ > \$@
3344    
 # 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 > \$@  
   
3345  # canonicalizer  # canonicalizer
3346  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)
3347          ./preProcess.py --timing --r8 -H -S \$< -o \$@          \${OPENADFORTTK_BASE}/tools/SourceProcessing/preProcess.py --timing --r8 -H -S  -o \$@ \$^
3348    
3349    # replace stop statements (to avoid the implied unstructured control flow)  with print statements
3350    ad_input_code_sf.pre.s2p.f90 : ad_input_code_sf.pre.f90
3351            cat \$< | sed -f \${OADTOOLS}/stop2print.sed > ad_input_code_sf.pre.s2p.f90
3352    
3353  # F -> WHIRL  # F -> WHIRL
3354  # note that the canonicalized version cuts off at col 72  ad_input_code_sf.pre.s2p.B: ad_input_code_sf.pre.s2p.f90
3355  # 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 \$@  
3356    
3357  # WHIRL -> XAIF  # WHIRL -> XAIF
3358  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
3359          ./whirl2xaif -s -n --debug 1 -o \$@ \$<          \${OPENADFORTTK}/bin/whirl2xaif -s -n --debug 1 -o \$@ \$<
3360    
3361  # XAIF -> XAIF'  # XAIF -> XAIF'
3362  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
3363          ./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
3364    
3365  # XAIF' -> WHIRL'  # XAIF' -> WHIRL'
3366  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
3367          ./xaif2whirl --debug 1 ad_input_code_sf.w2f.pre.B \$<          \${OPENADFORTTK}/bin/xaif2whirl --debug 1 ad_input_code_sf.pre.s2p.B \$<
3368    
3369  # WHIRL' -> F'  # WHIRL' -> F'
3370  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
3371          ./whirl2f -FLIST:ftn_file=\$@ -openad \$<          \${OPEN64ROOT}/whirl2f/whirl2f -FLIST:ftn_file=\$@ -openad \$<
3372    
3373  # insert template directives  # insert template directives
3374  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 \${OADTOOLS}/insertTemplateDir.bash
3375          ../OAD_support/insertTemplateDir.bash \$< \$@          \${OADTOOLS}/insertTemplateDir.bash \$< \$@
3376    
3377  PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F  PPEXTRAS=\$(wildcard \${OADTOOLS}/ad_template.*.F) \${OADTOOLS}/ad_inline.F
3378  # postprocess F'  # postprocess F'
3379  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
3380          # 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 \${OADTOOLS}/ad_inline.f \$<
3381            # the target is a placeholder to trigger a single execution of the rule
3382          touch \$@          touch \$@
3383          # this step also creates the file postProcess.make but we cannot  # put this so make knows about the postprocessing output
3384          # 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 \$<  
3385    
3386  # setup some links  # link the XAIF schema files
3387  %.xsd:  %.xsd:
3388          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3389    
 mfef90:  
         \$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 .  
   
3390  # link the support files:  # link the support files:
3391  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):
3392          \$(LN) ../OAD_support/\$@ .          \$(LN) \${OADTOOLS}/\$@ .
   
 whirl2xaif xaif2whirl:  
         \$(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 \$@  
3393    
3394  AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.make postProcess.tag postProcess.comp \$(PPEXTRAS:.F=.f)  AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag \$(PPEXTRAS:.F=.f)
3395    
3396  # ============ end OpenAD specific section ==============  # ============ end OpenAD specific section ==============
3397    
# Line 3222  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 3436  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
3436  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
3437    
3438  # Create special header files  # Create special header files
3439  $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"
3440  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
3441      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
3442  else  else
# Line 3236  else Line 3450  else
3450      fi      fi
3451  fi  fi
3452  if test ! -f AD_CONFIG.h ; then  if test ! -f AD_CONFIG.h ; then
3453      $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
3454  fi  fi
3455    
3456  #  Write the "state" for future records  #  Write the "state" for future records
# Line 3245  if test "x$DUMPSTATE" = xt ; then Line 3459  if test "x$DUMPSTATE" = xt ; then
3459      for i in $gm_state ; do      for i in $gm_state ; do
3460          t1="t2=\$$i"          t1="t2=\$$i"
3461          eval $t1          eval $t1
3462          echo "$i='$t2'" >> genmake_state          echo "$i='$t2'" | sed -e 's/  */ /g' >> genmake_state
3463      done      done
3464  fi  fi

Legend:
Removed from v.1.220  
changed lines
  Added in v.1.252

  ViewVC Help
Powered by ViewVC 1.1.22