/[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.214 by jmc, Sat Nov 6 19:03:41 2010 UTC revision 1.279 by jmc, Sat Jan 28 18:37:21 2017 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        -oad | --oad
23              Generate a Makefile for an OpenAD built
24    
25        -nocat4ad | -dog4ad | -ncad | -dad
26              do not concatenate (cat) source code sent to TAF
27              resulting in compilation of multiple files
28    
29      -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME      -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
30        -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME        -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
31            Use "NAME" as the adoptfile.  By default, the file at            Use "NAME" as the adoptfile.  By default, the file at
32            "tools/adjoint_options/adjoint_default" will be used.            "tools/adjoint_options/adjoint_oad" (for OpenAD built) or
33              "tools/adjoint_options/adjoint_default" will be used.
34    
35      -nooptfile | --nooptfile      -optfile NAME | --optfile NAME | -of NAME | --of NAME
       -optfile NAME | --optfile NAME | -of NAME | --of NAME  
36        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
37            Use "NAME" as the optfile.  By default, an attempt will be            Use "NAME" as the optfile.  By default, an attempt will be
38            made to find an appropriate "standard" optfile in the            made to find an appropriate "standard" optfile in the
39            tools/build_options/ directory.            tools/build_options/ directory.
40    
41      -pdepend NAME | --pdepend NAME      -pdepend NAME | --pdepend NAME
42        -pdepend=NAME | --pdepend=NAME        -pdepend=NAME | --pdepend=NAME
43            Get package dependency information from "NAME".            Get package dependency information from "NAME".
44    
45      -pgroups NAME | --pgroups NAME      -pgroups NAME | --pgroups NAME
46        -pgroups=NAME | --pgroups=NAME        -pgroups=NAME | --pgroups=NAME
47            Get the package groups information from "NAME".            Get the package groups information from "NAME".
48    
49      -bash NAME      -bash NAME
50            Explicitly specify the Bourne or BASH shell to use            Explicitly specify the Bourne or BASH shell to use
51    
52      -make NAME | -m NAME      -make NAME | -m NAME
53        --make=NAME | -m=NAME        --make=NAME | -m=NAME
54            Use "NAME" for the MAKE program. The default is "make" but            Use "NAME" for the MAKE program. The default is "make" but
55            many platforms, "gmake" is the preferred choice.            many platforms, "gmake" is the preferred choice.
56    
57      -makefile NAME | -mf NAME      -makefile NAME | -mf NAME
58        --makefile=NAME | -mf=NAME        --makefile=NAME | -mf=NAME
59            Call the makefile "NAME".  The default is "Makefile".            Call the makefile "NAME".  The default is "Makefile".
60    
61      -makedepend NAME | -md NAME      -makedepend NAME | -md NAME
62        --makedepend=NAME | -md=NAME        --makedepend=NAME | -md=NAME
63            Use "NAME" for the MAKEDEPEND program.            Use "NAME" for the MAKEDEPEND program.
64    
65      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
66        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
67            Specify the location of the MITgcm ROOTDIR as "NAME".            Specify the location of the MITgcm ROOTDIR as "NAME".
68            By default, genamke will try to find the location by            By default, genamke will try to find the location by
69            looking in parent directories (up to the 5th parent).            looking in parent directories (up to the 5th parent).
70    
71      -mods NAME | --mods NAME | -mo NAME | --mo NAME      -mods NAME | --mods NAME | -mo NAME | --mo NAME
72        -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME        -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME
73            Here, "NAME" specifies a list of directories that are            Here, "NAME" specifies a list of directories that are
74            used for additional source code.  Files found in the            used for additional source code.  Files found in the
75            "mods list" are given preference over files of the same            "mods list" are given preference over files of the same
76            name found elsewhere.            name found elsewhere.
77    
78      -disable NAME | --disable NAME      -disable NAME | --disable NAME
79        -disable=NAME | --disable=NAME        -disable=NAME | --disable=NAME
80            Here "NAME" specifies a list of packages that we don't            Here "NAME" specifies a list of packages that we don't
81            want to use.  If this violates package dependencies,            want to use.  If this violates package dependencies,
82            genamke will exit with an error message.            genamke will exit with an error message.
83    
84      -enable NAME | --enable NAME      -enable NAME | --enable NAME
85        -enable=NAME | --enable=NAME        -enable=NAME | --enable=NAME
86            Here "NAME" specifies a list of packages that we wish            Here "NAME" specifies a list of packages that we wish
87            to specifically enable.  If this violates package            to specifically enable.  If this violates package
88            dependencies, genamke will exit with an error message.            dependencies, genamke will exit with an error message.
89    
90      -standarddirs NAME | --standarddirs NAME      -standarddirs NAME | --standarddirs NAME
91        -standarddirs=NAME | --standarddirs=NAME        -standarddirs=NAME | --standarddirs=NAME
92            Here, "NAME" specifies a list of directories to be            Here, "NAME" specifies a list of directories to be
93            used as the "standard" code.            used as the "standard" code.
94    
95      -fortran NAME | --fortran NAME | -fc NAME | --fc NAME      -fortran NAME | --fortran NAME | -fc NAME | --fc NAME
96        -fc=NAME | --fc=NAME        -fc=NAME | --fc=NAME
97            Use "NAME" as the fortran compiler.  By default, genmake            Use "NAME" as the fortran compiler.  By default, genmake
98            will search for a working compiler by trying a list of            will search for a working compiler by trying a list of
99            "usual suspects" such as g77, f77, etc.            "usual suspects" such as g77, f77, etc.
100    
101      -cc NAME | --cc NAME | -cc=NAME | --cc=NAME      -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
102            Use "NAME" as the C compiler.  By default, genmake            Use "NAME" as the C compiler.  By default, genmake
103            will search for a working compiler by trying a list of            will search for a working compiler by trying a list of
104            "usual suspects" such as gcc, c89, cc, etc.            "usual suspects" such as gcc, c89, cc, etc.
   
     -[no]ieee | --[no]ieee  
           Do or don't use IEEE numerics.  Note that this option  
           *only* works if it is supported by the OPTFILE that  
           is being used.  
105    
106      -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4      -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4
107            Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW)            Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW)
108            *only* works if CPP_EEOPTIONS.h allows this.            *only* works if CPP_EEOPTIONS.h allows this.
109    
110      -ignoretime | -ignore_time | --ignoretime | --ignore_time      -ignoretime | -ignore_time | --ignoretime | --ignore_time
111            Ignore all the "wall clock" routines entirely.  This will            Ignore all the "wall clock" routines entirely.  This will
112            not in any way hurt the model results -- it simply means            not in any way hurt the model results -- it simply means
113            that the code that checks how long the model spends in            that the code that checks how long the model spends in
114            various routines will give junk values.            various routines will give junk values.
115    
116      -ts | --ts      -ts | --ts
117            Produce timing information per timestep            Produce timing information per timestep
118      -papis | --papis      -papis | --papis
119            Produce summary MFlop/s (and IPC) with PAPI per timestep            Produce summary MFlop/s (and IPC) with PAPI per timestep
120      -pcls | --pcls      -pcls | --pcls
121            Produce summary MFlop/s etc. with PCL per timestep            Produce summary MFlop/s etc. with PCL per timestep
122      -foolad | --foolad      -foolad | --foolad
123            Fool the AD code generator            Fool the AD code generator
124      -papi | --papi      -papi | --papi
125            Performance analysis with PAPI            Performance analysis with PAPI
126      -pcl | --pcl      -pcl | --pcl
127            Performance analysis with PCL            Performance analysis with PCL
128      -hpmt | --hpmt      -hpmt | --hpmt
129            Performance analysis with the HPM Toolkit            Performance analysis with the HPM Toolkit
130    
131      -gsl | --gsl      -ieee | --ieee
132            Use GSL to control floating point rounding and precision            use IEEE numerics.  Note that this option *only* works
133              if it is supported by the OPTFILE that is being used.
134      -devel | --devel      -devel | --devel
135            Add additional warning and debugging flags for development            Add additional warning and debugging flags for development
136              (if supported by the OPTFILE); also switch to IEEE numerics.
137        -gsl | --gsl
138              Use GSL to control floating point rounding and precision
139    
140      -mpi | --mpi      -mpi | --mpi
141            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
142      -mpi=PATH | --mpi=PATH      -mpi=PATH | --mpi=PATH
143            Include MPI header files and link to MPI libraries using MPI_ROOT            Include MPI header files and link to MPI libraries using MPI_ROOT
144            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
145            from \$PATH/lib and use binaries from \$PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
146    
147      -omp | --omp      -omp | --omp
148            Activate OpenMP code + use Compiler option OMPFLAG            Activate OpenMP code + use Compiler option OMPFLAG
149      -omp=OMPFLAG | --omp=OMPFLAG      -omp=OMPFLAG | --omp=OMPFLAG
150            Activate OpenMP code + use Compiler option OMPFLAG            Activate OpenMP code + use Compiler option OMPFLAG
151    
152      -es | --es | -embed-source | --embed-source      -es | --es | -embed-source | --embed-source
153            Embed a tarball containing the full source code            Embed a tarball containing the full source code
154            (including the Makefile, etc.) used to build the            (including the Makefile, etc.) used to build the
155            executable [off by default]            executable [off by default]
156    
157      -ds | --ds      -ds | --ds
158            Report genmake internal variables status (DUMPSTATE)            Report genmake internal variables status (DUMPSTATE)
159            to file "genmake_state" (for debug purpose)            to file "genmake_state" (for debug purpose)
160    
161    While it is most often a single word, the "NAME" variables specified    While it is most often a single word, the "NAME" variables specified
162    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 175  EOF Line 181  EOF
181  test_for_package_in_cpp_options() {  test_for_package_in_cpp_options() {
182      cpp_options=$1      cpp_options=$1
183      pkg=$2      pkg=$2
184      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg[ ]"      test_for_string_in_file $cpp_options "^ *# *define *\<ALLOW_$pkg\>"
185      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg[ ]"      test_for_string_in_file $cpp_options "^ *# *undef *\<ALLOW_$pkg\>"
186      test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg[ ]"      test_for_string_in_file $cpp_options "^ *# *define *\<DISABLE_$pkg\>"
187      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$"  
188  }  }
189    
190  # Search for particular CPP #cmds associated with MPI  # Search for particular CPP #cmds associated with MPI
191  # usage: test_for_mpi_in_cpp_eeoptions CPP_file  # usage: test_for_mpi_in_cpp_eeoptions CPP_file
192  test_for_mpi_in_cpp_eeoptions() {  test_for_mpi_in_cpp_eeoptions() {
193      cpp_options=$1      cpp_options=$1
194      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI[ ]"      test_for_string_in_file $cpp_options "^ *# *define *\<ALLOW_USE_MPI\>"
195      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$"  
196  }  }
197    
198  # 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 204  test_for_mpi_in_cpp_eeoptions() { Line 200  test_for_mpi_in_cpp_eeoptions() {
200  test_for_string_in_file() {  test_for_string_in_file() {
201      file=$1      file=$1
202      strng=$2      strng=$2
203      grep -i "$strng" $file > /dev/null 2>&1      grep "$strng" $file > /dev/null 2>&1
204      RETVAL=$?      RETVAL=$?
205      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
206          printf "Error: In $file there is an illegal line: "          printf "Error: In $file there is an illegal line: "
207          grep -i "$strng" $file          grep -i "$strng" $file
208          exit 99          exit 99
209      fi      fi
210      return 0      return 0
# Line 219  test_for_string_in_file() { Line 215  test_for_string_in_file() {
215  expand_pkg_groups() {  expand_pkg_groups() {
216      new_packages=      new_packages=
217      if test -r $PKG_GROUPS ; then      if test -r $PKG_GROUPS ; then
218          cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp          cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > $TMP.p1
219          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp          cat $TMP.p1 | $AWK '(NF>2 && $2==":"){ print $0 }' > $TMP.p2
220          matched=0          matched=0
221          for i in $PACKAGES ; do          for i in $PACKAGES ; do
222              line=`grep "^ *$i" ./p2.tmp`              line=`grep "^ *$i" $TMP.p2`
223              RETVAL=$?              RETVAL=$?
224              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
225                  matched=1                  matched=1
# Line 235  expand_pkg_groups() { Line 231  expand_pkg_groups() {
231              fi              fi
232          done          done
233          PACKAGES=$new_packages          PACKAGES=$new_packages
234          rm -f ./p[1,2].tmp          rm -f $TMP.p[1,2]
235          return $matched          return $matched
236      else      else
237          echo "Warning: can't read package groups definition file: $PKG_GROUPS"          echo "Warning: can't read package groups definition file: $PKG_GROUPS"
# Line 298  EOF Line 294  EOF
294  .F.$tfs:  .F.$tfs:
295          $LN \$< \$@          $LN \$< \$@
296  EOF  EOF
297      $MAKE "genmake_hello."$tfs > /dev/null 2>&1      $MAKE -f $MAKEFILE "genmake_hello."$tfs > /dev/null 2>&1
298      RETVAL=$?      RETVAL=$?
299      if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then      if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then
300          if test "x$FS" = x ; then          if test "x$FS" = x ; then
# Line 306  EOF Line 302  EOF
302              FS90='fr9'              FS90='fr9'
303              check_for_broken_Ff              check_for_broken_Ff
304          else          else
305              cat <<EOF 2>&1              echo "ERROR: test: '$MAKE -f $MAKEFILE genmake_hello.$tfs' Failed"
306  ERROR: Your file system cannot distinguish between *.F and *.f files              echo "       see simple makefile: '$MAKEFILE' (left here)"
307    (fails the "make/ln" test) and this program cannot find a suitable              echo "  Please check (1) your '$MAKE' command, (2) your '$LN' command"
308    replacement extension.  Please try a different build environment or              echo "           and (3) the allowed sufix '.F' and '.$tfs' in makefile"
309    contact the <MITgcm-support@mitgcm.org> list for help.              echo "  or contact the <MITgcm-support@mitgcm.org> list for help."
310                echo ""
 EOF  
311              exit -1              exit -1
312              return              return
313          fi          fi
# Line 336  look_for_makedepend()  { Line 331  look_for_makedepend()  {
331      #      #
332      #    1) a makedepend implementation shipped with the cyrus-imapd      #    1) a makedepend implementation shipped with the cyrus-imapd
333      #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/      #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
334      #      #    2) a local tools/xmakedepend shell script
     #    2) a known-buggy xmakedpend shell script  
335      #      #
336      #  So the choices are, in order:      #  So the choices are, in order:
     #  
337      #    1) use the user-specified program      #    1) use the user-specified program
338      #    2) use a system-wide default      #    2) use the local xmakedepend script (get all dependencies, but slower)
339      #    3) locally build and use the cyrus implementation      #    3) use a system-wide default
340      #    4) fall back to the buggy local xmakedpend script      #    4) locally build and use the cyrus makedepend
341        #             (faster, but can miss some dependencies)
342      #      #
343        echo >> $LOGFILE
344        echo "running: look_for_makedepend()" >> $LOGFILE
345        if test "x${MAKEDEPEND}" != x ; then
346            echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
347            RETVAL=$?
348            if test x"$RETVAL" = x0 ; then
349                build_cyrus_makedepend
350                RETVAL=$?
351                if test "x$RETVAL" != x0 ; then
352                    echo "WARNING: unable to build cyrus-makedepend. Try other 'makedepend'"
353                    MAKEDEPEND=
354                fi
355            else
356                echo "${MAKEDEPEND}" | grep 'tools.xmakedepend' > /dev/null 2>&1
357                RETVAL=$?
358                if test "x$RETVAL" = x0 ; then
359                    MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
360                fi
361                echo " -->     MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
362            fi
363        fi
364      if test "x${MAKEDEPEND}" = x ; then      if test "x${MAKEDEPEND}" = x ; then
         which makedepend > /dev/null 2>&1  
         RV0=$?  
365          test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"          test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"
366          #  echo 'MAKEFILE="'$MAKEFILE'"'          #  echo 'MAKEFILE="'$MAKEFILE'"'
367          cat <<EOF >> $MAKEFILE          cat <<EOF >> $MAKEFILE
# Line 364  EOF Line 377  EOF
377        stop        stop
378        end        end
379  EOF  EOF
380          makedepend genmake_tc.f > /dev/null 2>&1          $ROOTDIR/tools/xmakedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1
381          RV1=$?          RV1=$?
382            which makedepend > /dev/null 2>&1
383            RV2=$?
384            if test "x${RV2}" = x0 ; then
385                makedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1
386                RV3=$? ; loc_msg='not working.'
387            else RV3=$RV2 ; loc_msg='not found.'
388            fi
389          test -f $MAKEFILE  &&  rm -f $MAKEFILE          test -f $MAKEFILE  &&  rm -f $MAKEFILE
390          test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE          test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
391          if test "x${RV0}${RV1}" = x00 ; then          echo "  check makedepend (local: $RV1, system: $RV2, $RV3)"
392            if test "x${RV1}" = x0 ; then
393                MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
394                echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
395            elif test "x${RV3}" = x0 ; then
396                echo "    local tools/xmakedepend not working. Use system-default makedepend"
397              MAKEDEPEND=makedepend              MAKEDEPEND=makedepend
398                echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
399          else          else
400              echo "    a system-default makedepend was not found."              echo "    local tools/xmakedepend not working; system-default makedepend $loc_msg"
401                echo -n "    Try to build cyrus-makedepend ..."
402              #  Try to build the cyrus implementation              #  Try to build the cyrus implementation
403              build_cyrus_makedepend              build_cyrus_makedepend
404              RETVAL=$?              RETVAL=$?
405              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" = x0 ; then
406                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'                  echo "  Works"
407                else
408                    echo "  Fails" ; echo "" >> $LOGFILE
409                    echo "ERROR: no working makedepend found ; look_for_makedepend FAILED" | tee -a $LOGFILE
410                    echo ""
411                    exit -1
412                    return
413              fi              fi
             rm -f ./genmake_cy_md  
         fi  
     else  
         #  echo "MAKEDEPEND=${MAKEDEPEND}"  
         echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1  
         RETVAL=$?  
         if test x"$RETVAL" = x0 ; then  
             build_cyrus_makedepend  
414          fi          fi
415      fi      fi
416  }  }
417    
418  build_cyrus_makedepend()  {  build_cyrus_makedepend()  {
419        echo >> $LOGFILE
420        echo "running: build_cyrus_makedepend()" >> $LOGFILE
421      rm -f ./genmake_cy_md      rm -f ./genmake_cy_md
422      (      (
423          cd $ROOTDIR/tools/cyrus-imapd-makedepend  \          cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
424              &&  ./configure > /dev/null 2>&1  \              &&  ./configure > /dev/null 2>&1  \
425              &&  make > /dev/null 2>&1              &&  $MAKE > /dev/null 2>&1
426          if test -x ./makedepend.exe ; then          if test -x ./makedepend.exe ; then
427              $LN ./makedepend.exe ./makedepend              $LN ./makedepend.exe ./makedepend
428          fi          fi
# Line 407  build_cyrus_makedepend()  { Line 434  build_cyrus_makedepend()  {
434      rm -f ./genmake_cy_md      rm -f ./genmake_cy_md
435      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
436          MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'          MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
437            echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
438          return 0          return 0
439      else      else
440          echo "WARNING: unable to build cyrus-imapd-makedepend"          echo "WARNING: fail to build cyrus-imapd-makedepend" >> $LOGFILE
441          return 1          return 1
442      fi      fi
443  }  }
# Line 418  build_embed_encode() Line 446  build_embed_encode()
446  {  {
447      printf "  building the embed-encode utility...  "      printf "  building the embed-encode utility...  "
448      if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then      if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then
449          if test ! -d "$ROOTDIR/tools/embed_encode" ; then          if test ! -d "$ROOTDIR/tools/embed_encode" ; then
450              echo              echo
451              echo "    Error: can't locate \"$ROOTDIR/tools/embed_encode\""              echo "    Error: can't locate \"$ROOTDIR/tools/embed_encode\""
452              echo              echo
453              EMBED_SRC=f              EMBED_SRC=f
454              return 1              return 1
455          fi          fi
456          clist="cc gcc c89 $CC"          clist="cc gcc c89 $CC"
457          for ic in $clist ; do          for ic in $clist ; do
458              comm="$ic -o encode_files encode_files.c"              comm="$ic -o encode_files encode_files.c"
# Line 432  build_embed_encode() Line 460  build_embed_encode()
460              RETVAL=$?              RETVAL=$?
461              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
462                  echo "OK"                  echo "OK"
                 DEFINES="$DEFINES -DHAVE_EMBED_SRC"  
463                  return 0                  return 0
464              fi              fi
465          done          done
# Line 444  build_embed_encode() Line 471  build_embed_encode()
471          return 1          return 1
472      fi      fi
473      echo "OK"      echo "OK"
     DEFINES="$DEFINES -DHAVE_EMBED_SRC"  
474  }  }
475    
476  #  look for possible C compilers  #  look for possible C compilers
# Line 562  EOF Line 588  EOF
588      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
589          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
590          if test ! -r $OPTFILE ; then          if test ! -r $OPTFILE ; then
591               echo "  I looked for the file "$OPTFILE" but did not find it"               echo "  I looked for the file "$OPTFILE" but did not find it"
592          fi          fi
593      fi      fi
594    
595      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
# Line 581  Error: No options file was found in:  $R Line 607  Error: No options file was found in:  $R
607  EOF  EOF
608          exit 1          exit 1
609      fi      fi
610    }
611    
612    #  Do a local copy of MPI headers files (in local dir ./mpi_headers/) after
613    #  checking for additional included headers (in case of chain of included header)
614    mpi_headers_do_local_copy() {
615    
616        dBug=0
617        rm -rf ./mpi_headers
618        if test -d $MPIINCLUDEDIR ; then
619    
620            #----- check for additional headers (chain of included headers)
621            echo -n '  Check MPI headers ... '
622            listIni=$MPI_HEADER_FILES
623            echo $listIni | grep "\<mpif.h\>" > /dev/null 2>&1
624            outp=$?
625            #- always check mpif.h (the only mpi-header included in standard MITgcm code)
626            if test $outp != 0 ; then listIni="mpif.h $listIni" ; fi
627            if test $dBug = 1 ; then echo "listIni='$listIni'" ; fi
628    
629            doCheck=1 ; list2copy='' ; list2check=$listIni
630            while test $doCheck = 1 ; do
631              newList=''
632              for i in $list2check ; do
633                if test -f $MPIINCLUDEDIR/$i ; then
634                  newInc=`grep '^ *include ' $MPIINCLUDEDIR/$i | \
635                    sed -e 's/^ *include //' -e 's/\!.*$//' -e "s/'//g"  -e 's/\"//g'`
636                  if test $dBug = 1 ; then echo -n "checking $i : newInc='$newInc'" ; fi
637                  for j in $newInc ; do
638                    echo $listIni $list2copy $newList | grep "\<$j\>" > /dev/null 2>&1
639                    outp=$?
640                    if test $outp != 0 ; then
641                      if test $dBug = 1 ; then echo -n " ; adding $j" ; fi
642                      newList="$newList $j"
643                    fi
644                  done
645                  if test $dBug = 1 ; then echo "" ; fi
646                fi
647              done
648              if test "x$newList" = x ; then doCheck=0
649              else list2check=$newList ; list2copy="$list2copy $newList"
650              fi
651            done
652            list2copy="$MPI_HEADER_FILES $list2copy"
653            if test $dBug = 1 ; then echo "list2copy='$list2copy'" ; fi
654    
655  #     # look for possible MPI libraries          #----- create local mpi_headers dir if we have files to copy
656  #     mpi_libs=          mkListInc=`echo $list2copy | wc -w`
657  #     mpi_fort=`which mpif77 2>/dev/null`          if test $mkListInc != 0 ; then
658  #     RETVAL=$?            echo 'create local "./mpi_headers" dir'
659  #     if test "x${RETVAL}" = x0 ; then            mkdir -p ./mpi_headers
660  #       cat >>test.f <<EOF            INCLUDES="-I./mpi_headers $INCLUDES"
661  #       PROGRAM HELLO            mkListInc=1
662  #       DO 10, I=1,10          fi
663  #       PRINT *,'Hello World'          if test "x$LOCAL_MPI_HEADERS" != x ; then mkListInc=0 ; fi
664  #    10 CONTINUE  
665  #       STOP          #----- make local copy and update LOCAL_MPI_HEADERS (if not already set)
666  #       END          for i in $list2copy ; do
667  # EOF            if test -f $MPIINCLUDEDIR/$i ; then
668  #       eval "$mpi_fort -showme test.f > out"              cp -p $MPIINCLUDEDIR/$i ./mpi_headers
669  #       RETVAL=$?              if test $i = 'mpif.h' ; then
670  #       if test "x${RETVAL}" = x0 ; then                  perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h
671  #           a=`cat out`              fi
672  #           for i in $a ; do              if test $mkListInc = 2 ; then
673  #               case $i in                  LOCAL_MPI_HEADERS="$LOCAL_MPI_HEADERS ./mpi_headers/$i"
674  #                   -*)              fi
675  #                       mpi_libs="$mpi_libs $i" ;;              if test $mkListInc = 1 ; then
676  #               esac                  LOCAL_MPI_HEADERS="./mpi_headers/$i" ; mkListInc=2
677  #           done              fi
678  #           echo "The MPI libs appear to be:"            fi
679  #           echo "  "$mpi_libs          done
680  #       fi      else
681  #       rm -f test.f out          echo "WARNING: MPIINCLUDEDIR='$MPIINCLUDEDIR' is not a directory"
682  #     fi          echo "WARNING: => skip checking for MPI headers (no ./mpi_headers dir)"
683    #       exit -1
684        fi
685  }  }
686    
687  #  Parse the package dependency information  #  Parse the package dependency information
# Line 634  get_fortran_c_namemangling()  { Line 706  get_fortran_c_namemangling()  {
706    
707      #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""      #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
708      if test ! "x$FC_NAMEMANGLE" = x ; then      if test ! "x$FC_NAMEMANGLE" = x ; then
709          return 0          return 0
710      fi      fi
711      echo " running: get_fortran_c_namemangling()" >> $LOGFILE      echo " running: get_fortran_c_namemangling()" >> $LOGFILE
712    
# Line 766  EOF Line 838  EOF
838      RETVAL=$?      RETVAL=$?
839      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
840          HAVE_CLOC=t          HAVE_CLOC=t
         DEFINES="$DEFINES -DHAVE_CLOC"  
841      fi      fi
842      rm -f genmake_tc*      rm -f genmake_tc*
843      echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE      echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE
# Line 828  EOF Line 899  EOF
899      RETVAL=$?      RETVAL=$?
900      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
901          HAVE_SIGREG=t          HAVE_SIGREG=t
         DEFINES="$DEFINES -DHAVE_SIGREG"  
902      fi      fi
903      rm -f genmake_tc*      rm -f genmake_tc*
904      echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE      echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE
905  }  }
906    
907  check_HAVE_SETRLSTK()  {  check_HAVE_SETRLSTK()  {
     if test "x$HAVE_SETRLSTK" = xt ; then  
         DEFINES="$DEFINES -DHAVE_SETRLSTK"  
         return  
     fi    
908      if test ! "x$HAVE_SETRLSTK" = x ; then      if test ! "x$HAVE_SETRLSTK" = x ; then
909          return          return
910      fi      fi
# Line 876  EOF Line 942  EOF
942      RETVAL=$?      RETVAL=$?
943      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
944          HAVE_SETRLSTK=t          HAVE_SETRLSTK=t
         DEFINES="$DEFINES -DHAVE_SETRLSTK"  
945      fi      fi
946      rm -f genmake_tc*      rm -f genmake_tc*
947      echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE      echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE
# Line 923  EOF Line 988  EOF
988      RETVAL=$?      RETVAL=$?
989      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
990          HAVE_STAT=t          HAVE_STAT=t
         DEFINES="$DEFINES -DHAVE_STAT"  
991      fi      fi
992      rm -f genmake_tc*      rm -f genmake_tc*
993      echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE      echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE
# Line 939  check_netcdf_libs()  { Line 1003  check_netcdf_libs()  {
1003        program fgennc        program fgennc
1004  #include "netcdf.inc"  #include "netcdf.inc"
1005  EOF  EOF
1006      if test ! "x$MPI" = x ; then     #if test ! "x$MPI" = x ; then
1007          echo '#include "mpif.h"' >> genmake_tnc.F     #    echo '#include "mpif.h"' >> genmake_tnc.F
1008      fi     #fi
1009      cat <<EOF >> genmake_tnc.F      cat <<EOF >> genmake_tnc.F
1010        integer iret, ncid, xid        integer iret, ncid, xid
1011        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
# Line 1021  EOF Line 1085  EOF
1085      echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE      echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE
1086  }  }
1087    
1088    check_lapack_libs()  {
1089        if test "x$CHECK_FOR_LAPACK" = xf ; then return ; fi
1090        echo >> $LOGFILE
1091        echo "running: check_lapack_libs()" >> $LOGFILE
1092        cat <<EOF > genmake_tla.F
1093          program fgenla
1094          integer info
1095          integer ipiv( 2 )
1096          double precision ab( 4, 2 ), b( 2 )
1097          data ab / 0., 0., 1., 2., 0., 2., 1., 0. /
1098          data b / 1., 1. /
1099          call dgbsv( 2, 1, 1, 1, ab, 4, ipiv, b, 2, info )
1100          IF (info .NE. 0) write(*,*) 'Error:', info
1101          write(*,*) b
1102          end
1103    EOF
1104        echo "===  genmake_tla.F  >>>" > genmake_tla.log
1105        cat genmake_tla.F >> genmake_tla.log
1106        echo "<<<  genmake_tla.F  ===" >> genmake_tla.log
1107        RET_CPP=f
1108        COMM="cat genmake_tla.F | $CPP $DEFINES $INCLUDES"
1109        echo "$COMM" >> genmake_tla.log
1110        eval $COMM > genmake_tla.$FS 2>/dev/null  &&  RET_CPP=t
1111        if test "x$RET_CPP" = xf ; then
1112            echo "  WARNING: CPP failed to pre-process the lapack test." \
1113                >> genmake_tla.log
1114            echo "    Please check that \$INCLUDES is properly set." \
1115                >> genmake_tla.log
1116        fi
1117        echo "$FC $FFLAGS $FOPTIM -c genmake_tla.$FS  \ " >> genmake_tla.log
1118        echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tla.o $LIBS" >> genmake_tla.log
1119        $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1120            &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS >> genmake_tla.log 2>&1
1121        RET_COMPILE=$?
1122        cat genmake_tla.log >> $LOGFILE
1123    
1124        # test program execution not always possible (see check_netcdf_libs)
1125        #
1126        #test -x ./genmake_tla  &&  ./genmake_tla >> genmake_tla.log 2>&1
1127        #RETVAL=$?
1128        #if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
1129    
1130        if test "x$RET_COMPILE" = x0 ; then
1131            HAVE_LAPACK=t
1132            echo "check_lapack: successful" >> $LOGFILE
1133        else
1134            # try again with "-llapack" added to the libs
1135            echo "==> try again with added '-llapack'" > genmake_tla.log
1136            echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1137            echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1138            echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack" >> genmake_tla.log
1139            cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1140                &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1141                &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack >> genmake_tla.log 2>&1
1142            RET_COMPILE=$?
1143            echo >> $LOGFILE
1144            cat genmake_tla.log >> $LOGFILE
1145            if test "x$RET_COMPILE" = x0 ; then
1146                LIBS="$LIBS -llapack"
1147                HAVE_LAPACK=t
1148                echo "check_lapack: successful" >> $LOGFILE
1149            else
1150            # try again with "-lf77blas -lcblas" added to the libs
1151                echo "==> try again with added '-llapack -lf77blas -lcblas'" > genmake_tla.log
1152                echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1153                echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1154                echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas" >> genmake_tla.log
1155                cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1156                    &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1157                    &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas >> genmake_tla.log 2>&1
1158                RET_COMPILE=$?
1159                echo >> $LOGFILE
1160                cat genmake_tla.log >> $LOGFILE
1161                if test "x$RET_COMPILE" = x0 ; then
1162                    LIBS="$LIBS -llapack -lf77blas -lcblas"
1163                    HAVE_LAPACK=t
1164                    echo "check_lapack: successful" >> $LOGFILE
1165                else
1166                # try again with "-latlas" added to the libs
1167                    echo "==> try again with added '-llapack -lf77blas -lcblas -latlas'" > genmake_tla.log
1168                    echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1169                    echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1170                    echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas" >> genmake_tla.log
1171                    cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1172                        &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1173                        &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas >> genmake_tla.log 2>&1
1174                    RET_COMPILE=$?
1175                    echo >> $LOGFILE
1176                    cat genmake_tla.log >> $LOGFILE
1177                    if test "x$RET_COMPILE" = x0 ; then
1178                        LIBS="$LIBS -llapack -lf77blas -lcblas -latlas"
1179                        HAVE_LAPACK=t
1180                        echo "check_lapack: successful" >> $LOGFILE
1181                    fi
1182                fi
1183            fi
1184        fi
1185        rm -f genmake_tla*
1186        echo " --> set HAVE_LAPACK='$HAVE_LAPACK'" >> $LOGFILE
1187    }
1188    
1189    check_HAVE_FLUSH()  {
1190        if test ! "x$SKIP_CHECK_FLUSH" = x ; then
1191            return
1192        fi
1193        echo >> $LOGFILE
1194        echo "running: check_HAVE_FLUSH()" >> $LOGFILE
1195        cat <<EOF > genmake_tflsh.$FS
1196          program fgenflsh
1197          integer iounit
1198          character*9 fname
1199          iounit = 26
1200          fname = 'tmp.tflsh'
1201          open(iounit,FILE=fname,STATUS='unknown')
1202          write(iounit,*) 'genmake_tflsh: hello'
1203          call flush(iounit)
1204          close(iounit)
1205          end
1206    EOF
1207        echo "===  genmake_tflsh.$FS  >>>" > genmake_tflsh.log
1208        cat genmake_tflsh.$FS >> genmake_tflsh.log
1209        echo "<<<  genmake_tflsh.$FS  ===" >> genmake_tflsh.log
1210    
1211        echo "$FC $FFLAGS $FOPTIM -c genmake_tflsh.$FS  \ " >> genmake_tflsh.log
1212        echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tflsh.o $LIBS" >> genmake_tflsh.log
1213        $FC $FFLAGS $FOPTIM -c genmake_tflsh.$FS >> genmake_tflsh.log 2>&1  \
1214            &&  $LINK $FFLAGS $FOPTIM -o genmake_tflsh genmake_tflsh.o $LIBS >> genmake_tflsh.log 2>&1
1215        RET_COMPILE=$?
1216    
1217        if test "x$RET_COMPILE" = x0 ; then
1218            HAVE_FLUSH=t
1219            #cat genmake_tflsh.log >> $LOGFILE
1220            echo "  check_HAVE_FLUSH: successful" >> $LOGFILE
1221        else
1222            HAVE_FLUSH=f
1223            cat genmake_tflsh.log >> $LOGFILE
1224        fi
1225        rm -f genmake_tflsh*
1226        echo " --> set HAVE_FLUSH='$HAVE_FLUSH'" >> $LOGFILE
1227    }
1228    
1229  ###############################################################################  ###############################################################################
1230  #   Sequential part of script starts here  #   Sequential part of script starts here
# Line 1053  FOPTIM= Line 1257  FOPTIM=
1257  FEXTRAFLAGS=  FEXTRAFLAGS=
1258  USE_EXTENDED_SRC=  USE_EXTENDED_SRC=
1259  EXTENDED_SRC_FLAG=  EXTENDED_SRC_FLAG=
1260    GET_FC_VERSION=
1261  CFLAGS=  CFLAGS=
1262  KFLAGS1=  KFLAGS1=
1263  KFLAGS2=  KFLAGS2=
# Line 1077  GSL= Line 1282  GSL=
1282  DEVEL=  DEVEL=
1283  HAVE_TEST_L=  HAVE_TEST_L=
1284    
1285    # set this to "t" to enable lapack test
1286    CHECK_FOR_LAPACK=f
1287    
1288  # DEFINES checked by test compilation or command-line  # DEFINES checked by test compilation or command-line
1289  HAVE_SYSTEM=  HAVE_SYSTEM=
1290  HAVE_FDATE=  HAVE_FDATE=
# Line 1087  HAVE_STAT= Line 1295  HAVE_STAT=
1295  HAVE_NETCDF=  HAVE_NETCDF=
1296  HAVE_ETIME=  HAVE_ETIME=
1297  IGNORE_TIME=  IGNORE_TIME=
1298    HAVE_LAPACK=
1299    HAVE_FLUSH=
1300    
1301  MODS=  MODS=
1302  TOOLSDIR=  TOOLSDIR=
# Line 1094  SOURCEDIRS= Line 1304  SOURCEDIRS=
1304  INCLUDEDIRS=  INCLUDEDIRS=
1305  STANDARDDIRS="USE_THE_DEFAULT"  STANDARDDIRS="USE_THE_DEFAULT"
1306    
1307    #- local config file
1308    gm_local="genmake_local"
1309    
1310  G2ARGS=  G2ARGS=
1311  BASH=  BASH=
1312  PWD=`pwd`  PWD=`pwd`
# Line 1109  MACHINE=`uname -a` Line 1322  MACHINE=`uname -a`
1322  EXECUTABLE=  EXECUTABLE=
1323  EXEHOOK=  EXEHOOK=
1324  EXEDIR=  EXEDIR=
 PACKAGES_CONF=  
1325  IEEE=  IEEE=
1326  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
1327      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
# Line 1118  FS= Line 1330  FS=
1330  FS90=  FS90=
1331    
1332  AUTODIFF_PKG_USED=f  AUTODIFF_PKG_USED=f
1333    OPENAD=
1334  AD_OPTFILE=  AD_OPTFILE=
1335    CAT_SRC_FOR_TAF=1
1336  TAF=  TAF=
1337  AD_TAF_FLAGS=  AD_TAF_FLAGS=
1338  FTL_TAF_FLAGS=  FTL_TAF_FLAGS=
# Line 1130  FTL_TAF_FLAGS= Line 1344  FTL_TAF_FLAGS=
1344  SVD_TAMC_FLAGS=  SVD_TAMC_FLAGS=
1345  TAMC_EXTRA=  TAMC_EXTRA=
1346    
1347    DIVA=
1348    MPIINCLUDEDIR=
1349    MPI_HEADER_FILES=
1350    LOCAL_MPI_HEADERS=
1351    
1352  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1353  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"
1354  gm_s2="FC CC IEEE USE_R4 TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI OMP DUMPSTATE STANDARDDIRS"  gm_s2="PLATFORM OPTFILE MAKE MAKEFILE MAKEDEPEND FC CC MPI OMP USE_R4"
1355    gm_s3="FEXTRAFLAGS IEEE DEVEL GSL TS PAPIS PCLS PAPI PCL HPMT DUMPSTATE"
1356    
1357  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1358  gm_s3="LN S64 LINK MAKE PACKAGES INCLUDES FFLAGS FOPTIM FEXTRAFLAGS"  gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM"
1359  gm_s4="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
1360  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD THISHOST THISUSER THISDATE THISVER MACHINE"  gm_s6="PWD TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"
1361  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s7="TMP THISHOST THISUSER THISDATE THISVER MACHINE FC_NAMEMANGLE"
1362  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"
1363    
1364  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1365  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE OPENAD TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
1366  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"
1367  gm_s12="TAF_EXTRA TAMC_EXTRA"  gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES"
1368    
1369  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"
1370  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
1371    
1372  cat <<EOF  cat <<EOF
# Line 1165  LOGFILE="genmake.log" Line 1385  LOGFILE="genmake.log"
1385  rm -f genmake_state genmake_*optfile $LOGFILE  rm -f genmake_state genmake_*optfile $LOGFILE
1386    
1387  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  
1388    
1389  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
1390  #parse_options  #parse_options
# Line 1193  for ac_option in "$@" ; do Line 1403  for ac_option in "$@" ; do
1403      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
1404    
1405      case $ac_option in      case $ac_option in
1406            
1407          -help | --help | -h | --h)          -help | --help | -h | --h)
1408              usage ;;              usage ;;
1409            
         -nooptfile | --nooptfile)  
             OPTFILE="NONE" ;;  
1410          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
1411              ac_prev=OPTFILE ;;              ac_prev=OPTFILE ;;
1412          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
1413              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
1414            
1415            -oad | --oad)
1416                OPENAD="true" ; ALWAYS_USE_F90=1 ;;
1417            -nocat4ad | -dog4ad | -ncad | -dad)
1418                CAT_SRC_FOR_TAF=0 ;;
1419          -adoptfile | --adoptfile | -adof | --adof)          -adoptfile | --adoptfile | -adof | --adof)
1420              ac_prev=AD_OPTFILE ;;              ac_prev=AD_OPTFILE ;;
1421          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
1422              AD_OPTFILE=$ac_optarg ;;              AD_OPTFILE=$ac_optarg ;;
1423            
1424          -pdepend | --pdepend)          -pdepend | --pdepend)
1425              ac_prev=PKG_DEPEND ;;              ac_prev=PKG_DEPEND ;;
1426          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
1427              PKG_DEPEND=$ac_optarg ;;              PKG_DEPEND=$ac_optarg ;;
1428            
1429          -pgroups | --pgroups)          -pgroups | --pgroups)
1430              ac_prev=PKG_GROUPS ;;              ac_prev=PKG_GROUPS ;;
1431          -pgroups=* | --pgroups=*)          -pgroups=* | --pgroups=*)
1432              PKG_GROUPS=$ac_optarg ;;              PKG_GROUPS=$ac_optarg ;;
1433            
1434          -make | --make | -m | --m)          -make | --make | -m | --m)
1435              ac_prev=MAKE ;;              ac_prev=MAKE ;;
1436          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
1437              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
1438            
1439          -bash | --bash)          -bash | --bash)
1440              ac_prev=BASH ;;              ac_prev=BASH ;;
1441          -bash=* | --bash=*)          -bash=* | --bash=*)
1442              BASH=$ac_optarg ;;              BASH=$ac_optarg ;;
1443            
1444          -makedepend | --makedepend | -md | --md)          -makedepend | --makedepend | -md | --md)
1445              ac_prev=MAKEDEPEND ;;              ac_prev=MAKEDEPEND ;;
1446          -makedepend=* | --makedepend=* | -md=* | --md=*)          -makedepend=* | --makedepend=* | -md=* | --md=*)
1447              MAKEDEPEND=$ac_optarg ;;              MAKEDEPEND=$ac_optarg ;;
1448            
1449          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -mf | --mf)
1450              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
1451          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -mf=* | --mf=*)
1452              MAKEFILE=$ac_optarg ;;              MAKEFILE=$ac_optarg ;;
1453            
1454          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)
1455              echo "ERROR: The platform option has been removed.  Please specify"              echo "ERROR: The platform option has been removed.  Please specify"
1456              echo "  the build options using the \"optfile\" mechanism."              echo "  the build options using the \"optfile\" mechanism."
1457              echo              echo
1458              usage              usage
1459              ;;              ;;
1460            
1461          -rootdir | --rootdir | -rd | --rd)          -rootdir | --rootdir | -rd | --rd)
1462              ac_prev=ROOTDIR ;;              ac_prev=ROOTDIR ;;
1463          -rootdir=* | --rootdir=* | -rd=* | --rd=*)          -rootdir=* | --rootdir=* | -rd=* | --rd=*)
1464              ROOTDIR=$ac_optarg ;;              ROOTDIR=$ac_optarg ;;
1465            
1466          -mods | --mods | -mo | --mo)          -mods | --mods | -mo | --mo)
1467              ac_prev=MODS ;;              ac_prev=MODS ;;
1468          -mods=* | --mods=* | -mo=* | --mo=*)          -mods=* | --mods=* | -mo=* | --mo=*)
1469              MODS=$ac_optarg ;;              MODS=$ac_optarg ;;
1470            
1471          -disable | --disable)          -disable | --disable)
1472              ac_prev=DISABLE ;;              ac_prev=DISABLE ;;
1473          -disable=* | --disable=*)          -disable=* | --disable=*)
1474              DISABLE=$ac_optarg ;;              DISABLE=$ac_optarg ;;
1475            
1476          -enable | --enable)          -enable | --enable)
1477              ac_prev=ENABLE ;;              ac_prev=ENABLE ;;
1478          -enable=* | --enable=*)          -enable=* | --enable=*)
1479              ENABLE=$ac_optarg ;;              ENABLE=$ac_optarg ;;
1480            
1481          -standarddirs | --standarddirs)          -standarddirs | --standarddirs)
1482              ac_prev=STANDARDDIRS ;;              ac_prev=STANDARDDIRS ;;
1483          -standarddirs=* | --standarddirs=*)          -standarddirs=* | --standarddirs=*)
# Line 1275  for ac_option in "$@" ; do Line 1487  for ac_option in "$@" ; do
1487  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1488  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1489  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1490            
1491          -cc | --cc)          -cc | --cc)
1492              ac_prev=CC ;;              ac_prev=CC ;;
1493          -cc=* | --cc=*)          -cc=* | --cc=*)
1494              CC=$ac_optarg ;;              CC=$ac_optarg ;;
1495            
1496          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1497              ac_prev=FC ;;              ac_prev=FC ;;
1498          -fc=* | --fc=*)          -fc=* | --fc=*)
1499              FC=$ac_optarg ;;              FC=$ac_optarg ;;
1500            
1501          -fs | --fs)          -fs | --fs)
1502              ac_prev=FS ;;              ac_prev=FS ;;
1503          -fs=* | --fs=*)          -fs=* | --fs=*)
1504              FS=$ac_optarg ;;              FS=$ac_optarg ;;
1505            
1506          -fs90 | --fs90)          -fs90 | --fs90)
1507              ac_prev=FS90 ;;              ac_prev=FS90 ;;
1508          -fs90=* | --fs90=*)          -fs90=* | --fs90=*)
1509              FS90=$ac_optarg ;;              FS90=$ac_optarg ;;
           
         -ieee | --ieee)  
             IEEE=true ;;  
         -noieee | --noieee)  
             IEEE= ;;  
1510    
1511          -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )          -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )
1512              USE_R4=true ;;              USE_R4=true ;;
1513    
1514            -ieee | --ieee)
1515                IEEE=true ;;
1516            -noieee | --noieee)
1517                echo "Warning: ignore option '$ac_option' (default is already without '-ieee')" ;;
1518            -devel | --devel)
1519                IEEE=true ; DEVEL=true ;;
1520            -gsl | --gsl)
1521                GSL=true ;;
1522    
1523          -ts | --ts)          -ts | --ts)
1524              TS=true ;;              TS=true ;;
1525          -papis | --papis)          -papis | --papis)
# Line 1319  for ac_option in "$@" ; do Line 1535  for ac_option in "$@" ; do
1535          -hpmt | --hpmt)          -hpmt | --hpmt)
1536              HPMT=true ;;              HPMT=true ;;
1537    
         -gsl | --gsl)  
             GSL=true ;;  
   
         -devel | --devel)  
             DEVEL=true ;;  
   
1538          -mpi | --mpi)          -mpi | --mpi)
1539              MPI=true ;;              MPI=true ;;
1540          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
1541              MPIPATH=$ac_optarg              MPIPATH=$ac_optarg
1542              MPI=true ;;              MPI=true ;;
1543            
1544          -omp | --omp)          -omp | --omp)
1545              OMP=true ;;              OMP=true ;;
1546          -omp=* | --omp=*)          -omp=* | --omp=*)
1547              OMPFLAG=$ac_optarg              OMPFLAG=$ac_optarg
1548              OMP=true ;;              OMP=true ;;
1549            
1550          -ds | --ds)          -ds | --ds)
1551              DUMPSTATE=t ;;              DUMPSTATE=t ;;
1552            
1553            -extra_flag | --extra_flag)
1554                ac_prev=FEXTRAFLAGS ;;
1555            -extra_flag=* | --extra_flag=*)
1556                FEXTRAFLAGS=$ac_optarg ;;
1557    
1558          -taf_extra | --taf_extra)          -taf_extra | --taf_extra)
1559              ac_prev=TAF_EXTRA ;;              ac_prev=TAF_EXTRA ;;
1560          -taf_extra=* | --taf_extra=*)          -taf_extra=* | --taf_extra=*)
# Line 1349  for ac_option in "$@" ; do Line 1564  for ac_option in "$@" ; do
1564              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1565          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1566              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1567            
1568          -ignoretime | -ignore_time | --ignoretime | --ignore_time)          -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1569              IGNORE_TIME="-DIGNORE_TIME" ;;              IGNORE_TIME="-DIGNORE_TIME" ;;
1570    
# Line 1360  for ac_option in "$@" ; do Line 1575  for ac_option in "$@" ; do
1575              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
1576              usage              usage
1577              ;;              ;;
1578            
1579          *)          *)
1580              echo "Error: unrecognized argument: "$ac_option              echo "Error: unrecognized argument: "$ac_option
1581              usage              usage
1582              ;;              ;;
1583            
1584      esac      esac
1585    
1586  done  done
1587    
1588    #TMP=./genmk_$$
1589    #- try to put temporary files in system-local /tmp dir
1590    TMP=/tmp/genmk_${USER}_$$
1591    touch $TMP ; retVal=$?
1592    if [ $retVal -eq 0 ] ; then
1593      if test ! -r $TMP ; then TMP=./genmk_$$ ; fi
1594    else
1595      TMP=./genmk_$$
1596    fi
1597    rm -f $TMP
1598    #echo "  temp files: $TMP.*"
1599    
1600    printf "  getting local config information:  "
1601    if test -f $gm_local ; then
1602        echo "using $gm_local"
1603        . $gm_local
1604    else
1605        echo "none found"
1606    fi
1607    
1608  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1609      echo      echo
1610      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
1611      echo "  file.  This file format is no longer supported.  For directions on"      echo "  file.  This file format is no longer supported.  For directions on"
1612      echo "  how to setup and use the new \"genmake2\" script, please see:"      echo "  how to setup and use the new \"genmake2\" script, please see:"
1613      echo "    http://mitgcm.org/devel_HOWTO/"      echo "    http://mitgcm.org/public/devel_HOWTO/"
1614      echo "  and send an email to MITgcm-support@mitgcm.org if you need help."      echo "  and send an email to MITgcm-support@mitgcm.org if you need help."
1615      echo "WARNING: ignore \"./.genmakerc\" and continue."      echo "WARNING: ignore \"./.genmakerc\" and continue."
1616      echo      echo
# Line 1390  if test "x${ROOTDIR}" = x ; then Line 1625  if test "x${ROOTDIR}" = x ; then
1625          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
1626              if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then              if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
1627                  ROOTDIR=$d                  ROOTDIR=$d
1628                  printf "Warning:  ROOTDIR was not specified but there appears to be"                  printf "Warning: ROOTDIR was not specified ;"
1629                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."                  echo " try using a local copy of MITgcm found at \"$ROOTDIR\""
1630                  break                  break
1631              fi              fi
1632          done          done
# Line 1423  if test "x$MAKEFILE" = x ; then Line 1658  if test "x$MAKEFILE" = x ; then
1658      MAKEFILE="Makefile"      MAKEFILE="Makefile"
1659  fi  fi
1660    
1661  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:"
1662  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1663      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
1664          echo "Warning: no OPTFILE specified so we'll look for possible settings"          echo "Warning: no OPTFILE specified so we'll look for possible settings"
# Line 1452  if test "x$OPTFILE" != xNONE ; then Line 1687  if test "x$OPTFILE" != xNONE ; then
1687      fi      fi
1688  fi  fi
1689    
1690  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:"
1691  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1692      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" != x ; then
1693            AD_OPTFILE=$MITGCM_AD_OF
1694        elif test "x$OPENAD" = x ; then
1695          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
1696      else      else
1697          AD_OPTFILE=$MITGCM_AD_OF          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_oad
1698      fi      fi
1699  fi  fi
1700  if test "x${AD_OPTFILE}" != xNONE ; then  if test "x${AD_OPTFILE}" != xNONE ; then
# Line 1480  if test "x${AD_OPTFILE}" != xNONE ; then Line 1717  if test "x${AD_OPTFILE}" != xNONE ; then
1717  fi  fi
1718    
1719  #====================================================================  #====================================================================
1720    # Initialize INCLUDEDIRSMK from and optfile INCLUDEDIRS
1721    if test "x${INCLUDEDIRS}" != "x" ; then
1722     INCLUDEDIRSMK=${INCLUDEDIRS}
1723    fi
1724    
1725    #====================================================================
1726  #  Set default values if not set by the optfile  #  Set default values if not set by the optfile
1727  #  #
1728  #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
# Line 1498  Error: no Fortran compiler: please speci Line 1741  Error: no Fortran compiler: please speci
1741  EOF  EOF
1742      exit 1      exit 1
1743  fi  fi
1744    if test "x$GET_FC_VERSION" != x ; then
1745      echo "Get compiler version using: $FC $GET_FC_VERSION" >> $LOGFILE
1746      ff=`echo $FC | sed 's/ .*//'` ; xx=`echo $ff | sed 's/^./& /' | sed 's/ .*//'`
1747      if test $xx != '/' ; then which $ff >> $LOGFILE ; fi
1748      $FC $GET_FC_VERSION > genmake_fc_vers1 2> genmake_fc_vers2
1749      if test -s genmake_fc_vers1 ; then
1750        cat genmake_fc_vers1 >> $LOGFILE
1751      else
1752        cat genmake_fc_vers2 >> $LOGFILE
1753      fi
1754      echo "<-- compiler version ----" >> $LOGFILE
1755      rm -f genmake_fc_vers1 genmake_fc_vers2
1756    fi
1757    
1758  if test "x$CC" = x ; then  if test "x$CC" = x ; then
1759      look_for_C_compilers      look_for_C_compilers
# Line 1568  check_for_broken_Ff Line 1824  check_for_broken_Ff
1824    
1825  if test ! "x$MPI" = x ; then  if test ! "x$MPI" = x ; then
1826        echo "  Turning on MPI cpp macros"        echo "  Turning on MPI cpp macros"
1827        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI"
1828    #- To compile code older than checkpoint63s (2012/09/05), un-comment the following line:
1829    #     DEFINES="$DEFINES -DALWAYS_USE_MPI"
1830  fi  fi
1831  if test ! "x$OMP" = x ; then  if test ! "x$OMP" = x ; then
1832        echo "  Add OMPFLAG and turn on OpenMP cpp macros"        echo "  Add OMPFLAG and turn on OpenMP cpp macros"
# Line 1585  fi Line 1843  fi
1843  if test ! "x$TS" = x ; then  if test ! "x$TS" = x ; then
1844        echo "  Turning on timing per timestep"        echo "  Turning on timing per timestep"
1845        if test ! "x$FOOLAD" = x ; then        if test ! "x$FOOLAD" = x ; then
1846              DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"
1847        else        else
1848              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1849        fi        fi
# Line 1621  if test ! "x$PAPI" = x ; then Line 1879  if test ! "x$PAPI" = x ; then
1879            echo "  Sticking with PAPI flop summary per timestep!"            echo "  Sticking with PAPI flop summary per timestep!"
1880        else        else
1881            echo "  Turning on performance analysis with PAPI"            echo "  Turning on performance analysis with PAPI"
1882            echo "  Please make sure PAPIINC, PAPILIB are defined"            echo "  Please make sure PAPIINC, PAPILIB are defined"
1883            DEFINES="$DEFINES -DUSE_PAPI"            DEFINES="$DEFINES -DUSE_PAPI"
1884            INCLUDES="$INCLUDES $PAPIINC"            INCLUDES="$INCLUDES $PAPIINC"
1885            LIBS="$LIBS $PAPILIB"            LIBS="$LIBS $PAPILIB"
# Line 1633  if test ! "x$PCL" = x ; then Line 1891  if test ! "x$PCL" = x ; then
1891            echo "  Sticking with PCL flop summary per timestep!"            echo "  Sticking with PCL flop summary per timestep!"
1892        else        else
1893            echo "  Turning on performance analysis with PCL"            echo "  Turning on performance analysis with PCL"
1894            echo "  Please make sure PCLINC, PCLLIB are defined"            echo "  Please make sure PCLINC, PCLLIB are defined"
1895            DEFINES="$DEFINES -DUSE_PCL"            DEFINES="$DEFINES -DUSE_PCL"
1896            INCLUDES="$INCLUDES $PCLINC"            INCLUDES="$INCLUDES $PCLINC"
1897            LIBS="$LIBS $PCLLIB"            LIBS="$LIBS $PCLLIB"
# Line 1643  if test ! "x$HPMT" = x ; then Line 1901  if test ! "x$HPMT" = x ; then
1901        if test ! "x$PAPI" = x ; then        if test ! "x$PAPI" = x ; then
1902            echo "  PAPI and the HPM Toolkit cannot co-exist!"            echo "  PAPI and the HPM Toolkit cannot co-exist!"
1903            echo "  Sticking with PAPI!"            echo "  Sticking with PAPI!"
1904        else if test ! "x$PCL" = x ; then        else
1905            if test ! "x$PCL" = x ; then
1906            echo "  PCL and the HPM Toolkit cannot co-exist!"            echo "  PCL and the HPM Toolkit cannot co-exist!"
1907            echo "  Sticking with PCL!"            echo "  Sticking with PCL!"
1908        else          else
1909            echo "  Turning on performance analysis with the HPM Toolkit"            echo "  Turning on performance analysis with the HPM Toolkit"
1910            echo "  Please make sure HPMTINC, HPMTLIB are defined"            echo "  Please make sure HPMTINC, HPMTLIB are defined"
1911            DEFINES="$DEFINES -DUSE_LIBHPM"            DEFINES="$DEFINES -DUSE_LIBHPM"
1912            INCLUDES="$INCLUDES $HPMTINC"            INCLUDES="$INCLUDES $HPMTINC"
1913            LIBS="$LIBS $HPMTLIB"            LIBS="$LIBS $HPMTLIB"
1914        fi          fi
1915        fi        fi
1916  fi  fi
1917  if test ! "x$GSL" = x ; then  if test ! "x$GSL" = x ; then
# Line 1708  else Line 1967  else
1967  fi  fi
1968  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1969    
1970  printf "  Do we have the etime() command using $FC...  "  printf "  Do we have the etime() command using $FC... "
1971  cat > genmake_tcomp.$FS <<EOF  cat > genmake_tcomp_1.$FS <<EOF
1972        program hello        program hello
1973        REAL*4 ACTUAL, TARRAY(2)        REAL*4 actual, tarray(2)
1974        EXTERNAL ETIME        EXTERNAL ETIME
1975        REAL*4 ETIME        REAL*4 ETIME
1976        actual = etime( tarray )        actual = ETIME( tarray )
1977        print *, tarray        print *, tarray
1978        end        end
1979  EOF  EOF
1980  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp_1 genmake_tcomp_1.$FS > genmake_tcomp.log 2>&1
1981  RETVAL=$?  RETVAL=$?
1982  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1983      HAVE_ETIME=t      HAVE_ETIME='Fct'
1984      DEFINES="$DEFINES -DHAVE_ETIME"      DEFINES="$DEFINES -DHAVE_ETIME_FCT"
1985      echo "yes"      echo " yes (${HAVE_ETIME})"
1986  else  else
1987      cat > genmake_tcomp_2.$FS <<EOF
1988          program hello
1989          REAL*4 actual, tarray(2)
1990          actual = -999.
1991          call ETIME( tarray, actual )
1992          if ( actual.ge.0. ) then
1993            print *, 0, tarray, actual
1994          else
1995            print *, 1, tarray, actual
1996          endif
1997          end
1998    EOF
1999      $FC $FFLAGS -o genmake_tcomp_2 genmake_tcomp_2.$FS >> genmake_tcomp.log 2>&1
2000      RETVAL=$?
2001      if test "x$RETVAL" = x0 ; then
2002        echo -n 'c,'
2003        ./genmake_tcomp_2 > genmake_tcomp_2.out 2>&1
2004        RETVAL=$?
2005      fi
2006      if test "x$RETVAL" = x0 ; then
2007        echo -n 'r:'
2008        RETVAL=`cat genmake_tcomp_2.out | $AWK '{print $1}'`
2009      fi
2010      if test "x$RETVAL" = x0 ; then
2011        HAVE_ETIME='SbR'
2012        DEFINES="$DEFINES -DHAVE_ETIME_SBR"
2013        echo " yes (${HAVE_ETIME})"
2014      else
2015      HAVE_ETIME=      HAVE_ETIME=
2016      echo "no"      echo " no"
2017      fi
2018  fi  fi
2019    #mkdir chk_etime ; cp -p -f genmake_tcomp* chk_etime
2020  rm -f genmake_tcomp*  rm -f genmake_tcomp*
2021    
2022  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
2023  check_HAVE_CLOC  check_HAVE_CLOC
2024  if test "x$HAVE_CLOC" != x ; then  if test "x$HAVE_CLOC" != x ; then
2025        DEFINES="$DEFINES -DHAVE_CLOC"
2026      echo "yes"      echo "yes"
2027  else  else
2028      echo "no"      echo "no"
# Line 1747  rm -f genmake_t* Line 2037  rm -f genmake_t*
2037  printf "  Can we unlimit the stack size using $FC...  "  printf "  Can we unlimit the stack size using $FC...  "
2038  check_HAVE_SETRLSTK  check_HAVE_SETRLSTK
2039  if test "x$HAVE_SETRLSTK" = xt ; then  if test "x$HAVE_SETRLSTK" = xt ; then
2040        DEFINES="$DEFINES -DHAVE_SETRLSTK"
2041      echo "yes"      echo "yes"
2042  else  else
2043      echo "no"      echo "no"
# Line 1756  rm -f genmake_t* Line 2047  rm -f genmake_t*
2047  printf "  Can we register a signal handler using $FC...  "  printf "  Can we register a signal handler using $FC...  "
2048  check_HAVE_SIGREG  check_HAVE_SIGREG
2049  if test "x$HAVE_SIGREG" = xt ; then  if test "x$HAVE_SIGREG" = xt ; then
2050        DEFINES="$DEFINES -DHAVE_SIGREG"
2051      echo "yes"      echo "yes"
2052  else  else
2053      echo "no"      echo "no"
# Line 1765  rm -f genmake_t* Line 2057  rm -f genmake_t*
2057  printf "  Can we use stat() through C calls...  "  printf "  Can we use stat() through C calls...  "
2058  check_HAVE_STAT  check_HAVE_STAT
2059  if test "x$HAVE_STAT" != x ; then  if test "x$HAVE_STAT" != x ; then
2060        DEFINES="$DEFINES -DHAVE_STAT"
2061      echo "yes"      echo "yes"
2062  else  else
2063      echo "no"      echo "no"
# Line 1774  rm -f genmake_t* Line 2067  rm -f genmake_t*
2067  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
2068  check_netcdf_libs  check_netcdf_libs
2069  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
2070        DEFINES="$DEFINES -DHAVE_NETCDF"
2071        echo "yes"
2072    else
2073        echo "no"
2074    fi
2075    
2076    printf "  Can we create LAPACK-enabled binaries...  "
2077    check_lapack_libs
2078    if test "x$HAVE_LAPACK" != x ; then
2079        DEFINES="$DEFINES -DHAVE_LAPACK"
2080        echo "yes"
2081    else
2082        echo "no"
2083    fi
2084    
2085    printf "  Can we call FLUSH intrinsic subroutine...  "
2086    check_HAVE_FLUSH
2087    if test "x$HAVE_FLUSH" = xt ; then
2088        DEFINES="$DEFINES -DHAVE_FLUSH"
2089      echo "yes"      echo "yes"
2090  else  else
2091      echo "no"      echo "no"
2092  fi  fi
 DEFINES="$DEFINES $IGNORE_TIME"  
2093    
2094    DEFINES="$DEFINES $IGNORE_TIME"
2095  if test "x$EMBED_SRC" = xt ; then  if test "x$EMBED_SRC" = xt ; then
2096      build_embed_encode      build_embed_encode
2097  fi  fi
2098  if test "x$EMBED_SRC" = xt ; then  if test "x$EMBED_SRC" = xt ; then
2099      ENABLE="$ENABLE embed_files"      ENABLE="$ENABLE embed_files"
2100    #   DEFINES="$DEFINES -DHAVE_EMBED_SRC"
2101  fi  fi
2102    
2103  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
# Line 1798  for d in $MODS ; do Line 2111  for d in $MODS ; do
2111          printf "$d "          printf "$d "
2112          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
2113          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
2114            SOURCEDIRSMK="$SOURCEDIRSMK $d"
2115            INCLUDEDIRSMK="$INCLUDEDIRSMK $d"
2116      fi      fi
2117  done  done
2118  echo  echo
# Line 1821  fi Line 2136  fi
2136    
2137  if test "x${TOOLSDIR}" = x ; then  if test "x${TOOLSDIR}" = x ; then
2138      TOOLSDIR="$ROOTDIR/tools"      TOOLSDIR="$ROOTDIR/tools"
2139        TOOLSDIRMK='$(ROOTDIR)'"/tools"
2140    else
2141        TOOLSDIRMK=${TOOLSDIR}
2142  fi  fi
2143  if test ! -d ${TOOLSDIR} ; then  if test ! -d ${TOOLSDIR} ; then
2144      echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"
# Line 1962  else Line 2280  else
2280          exit 1          exit 1
2281      else      else
2282          echo "    using PKG_LIST=\"$PKG_LIST\""          echo "    using PKG_LIST=\"$PKG_LIST\""
2283          #  Strip the comments and add all the names          #  Strip the comments and add all the names
2284          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}'`
2285          RETVAL=$?          RETVAL=$?
2286          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
# Line 1983  if test "x${PKG_GROUPS}" != x ; then Line 2301  if test "x${PKG_GROUPS}" != x ; then
2301  fi  fi
2302    
2303  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
2304  echo "" > ./.tmp_pack  echo "" > $TMP.pack
2305  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2306      echo $i >> ./.tmp_pack      echo $i >> $TMP.pack
2307  done  done
2308  for i in `grep  "-" ./.tmp_pack` ; do  for i in `grep  "-" $TMP.pack` ; do
2309      j=`echo $i | sed 's/[-]//'`      j=`echo $i | sed 's/[-]//'`
2310      DISABLE="$DISABLE $j"      DISABLE="$DISABLE $j"
2311  done  done
# Line 2005  for p in $PACKAGES ; do Line 2323  for p in $PACKAGES ; do
2323  done  done
2324  PACKAGES="$pack"  PACKAGES="$pack"
2325  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
2326  echo "" > ./.tmp_pack  echo "" > $TMP.pack
2327  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
2328  # Test if each explicitly referenced package exists  # Test if each explicitly referenced package exists
2329  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2330      j=`echo $i | sed 's/[-+]//'`      j=`echo $i | sed 's/[-+]//'`
2331      if test ! -d "$ROOTDIR/pkg/$j" ; then      if test ! -d "$ROOTDIR/pkg/$j" ; then
2332          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
2333          exit 1          exit 1
2334      fi      fi
2335      echo $i >> ./.tmp_pack      echo $i >> $TMP.pack
2336  done  done
2337  PACKAGES=  PACKAGES=
2338  for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do  for i in `grep -v "-" $TMP.pack | sort | uniq` ; do
2339      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
2340  done  done
2341  rm -f ./.tmp_pack  rm -f $TMP.pack
2342  echo "    packages are: $PACKAGES"  echo "    packages are: $PACKAGES"
2343    
2344  #  Check for package MNC: if NetCDF is available, then build the MNC  #  Check for package MNC: if NetCDF is available, then build the MNC
# Line 2057  else Line 2375  else
2375          echo "Error: problem encountered while building source files in pkg/mnc:"          echo "Error: problem encountered while building source files in pkg/mnc:"
2376          cat make_mnc.errors 1>&2          cat make_mnc.errors 1>&2
2377          if test "x$mnc_in" = x0 ; then          if test "x$mnc_in" = x0 ; then
2378              exit 1              exit 1
2379          else          else
2380              DISABLE="$DISABLE mnc"              DISABLE="$DISABLE mnc"
2381          fi          fi
# Line 2090  EOF Line 2408  EOF
2408      fi      fi
2409  fi  fi
2410    
2411    #  Make sure the openad package is enabled if using OpenAD
2412    if test "x$OPENAD" != x ; then
2413        echo " $PACKAGES " | grep ' openad ' > /dev/null 2>&1
2414        RETVAL=$?
2415        if test "x$RETVAL" != x0 ; then
2416            cat <<EOF
2417    
2418    *********************************************************************
2419    ERROR: when generating an adjoint with OpenAD, the openad package
2420      must be enabled.  Please add it to packages.conf.
2421    *********************************************************************
2422    
2423    EOF
2424            exit 1
2425        fi
2426    fi
2427    
2428  if  test "x${PKG_DEPEND}" != x ; then  if  test "x${PKG_DEPEND}" != x ; then
2429    echo "  applying package dependency rules"    echo "  applying package dependency rules"
2430    ck=    ck=
# Line 2135  if  test "x${PKG_DEPEND}" != x ; then Line 2470  if  test "x${PKG_DEPEND}" != x ; then
2470    
2471          #  Do we need to add $dname according to the dependency rules?          #  Do we need to add $dname according to the dependency rules?
2472          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
2473              #echo "   " $pname ": need to add :" $dname              #echo "   " $pname ": need to add :" $dname
2474              in_dis="f"              in_dis="f"
2475              for dis in $DISABLE ; do              for dis in $DISABLE ; do
2476                  if test "x$dis" = "x$dname" ; then                  if test "x$dis" = "x$dname" ; then
# Line 2160  if  test "x${PKG_DEPEND}" != x ; then Line 2495  if  test "x${PKG_DEPEND}" != x ; then
2495              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
2496              exit 1              exit 1
2497          fi          fi
2498          i=`echo "$i + 1" | bc -l`          i=`echo "$i + 1" | bc -l`
2499          #i=$(( $i + 1 ))          #i=$(( $i + 1 ))
2500      done      done
2501      ck=$ck"t"      ck=$ck"t"
# Line 2169  if  test "x${PKG_DEPEND}" != x ; then Line 2504  if  test "x${PKG_DEPEND}" != x ; then
2504  fi  fi
2505  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2506      adr="$ROOTDIR/pkg/$i"      adr="$ROOTDIR/pkg/$i"
2507        adrmk='$(ROOTDIR)'"/pkg/$i"
2508      if test -d $adr ; then      if test -d $adr ; then
2509          SOURCEDIRS="$SOURCEDIRS $adr"          SOURCEDIRS="$SOURCEDIRS $adr"
2510          INCLUDEDIRS="$INCLUDEDIRS $adr"          INCLUDEDIRS="$INCLUDEDIRS $adr"
2511            SOURCEDIRSMK="$SOURCEDIRSMK $adrmk"
2512            INCLUDEDIRSMK="$INCLUDEDIRSMK $adrmk"
2513          if test "x$i" = xautodiff ; then          if test "x$i" = xautodiff ; then
2514              AUTODIFF_PKG_USED=t              AUTODIFF_PKG_USED=t
2515          fi          fi
# Line 2201  for n in $names ; do Line 2539  for n in $names ; do
2539          done          done
2540          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
2541              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
2542              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
2543          fi          fi
2544      fi      fi
2545  done  done
# Line 2214  for i in $PACKAGES ; do Line 2552  for i in $PACKAGES ; do
2552  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
2553      case $i in      case $i in
2554          aim_v23)          aim_v23)
2555              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
2556              echo "Warning: ALLOW_AIM is set to enable aim_v23."              echo "Warning: ALLOW_AIM is set to enable aim_v23."
2557              ;;              ;;
2558      esac      esac
# Line 2227  BUILDDIR=${BUILDDIR:-.} Line 2565  BUILDDIR=${BUILDDIR:-.}
2565  if test "x$STANDARDDIRS" != x ; then  if test "x$STANDARDDIRS" != x ; then
2566      for d in $STANDARDDIRS ; do      for d in $STANDARDDIRS ; do
2567          adr="$ROOTDIR/$d/src"          adr="$ROOTDIR/$d/src"
2568            adrmk='$(ROOTDIR)/'"$d/src"
2569          if test ! -d $adr ; then          if test ! -d $adr ; then
2570              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
2571              echo "  is correct and that you correctly specified the STANDARDDIRS option"              echo "  is correct and that you correctly specified the STANDARDDIRS option"
2572              exit 1              exit 1
2573          else          else
2574              SOURCEDIRS="$SOURCEDIRS $adr"              SOURCEDIRS="$SOURCEDIRS $adr"
2575                SOURCEDIRSMK="$SOURCEDIRSMK $adrmk"
2576          fi          fi
2577          adr="$ROOTDIR/$d/inc"          adr="$ROOTDIR/$d/inc"
2578            adrmk='$(ROOTDIR)/'"$d/inc"
2579          if test ! -d $adr ; then          if test ! -d $adr ; then
2580              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
2581              echo "  is correct and that you correctly specified the STANDARDDIRS option"              echo "  is correct and that you correctly specified the STANDARDDIRS option"
2582              exit 1              exit 1
2583          else          else
2584              INCLUDEDIRS="$INCLUDEDIRS $adr"              INCLUDEDIRS="$INCLUDEDIRS $adr"
2585                INCLUDEDIRSMK="$INCLUDEDIRSMK $adrmk"
2586          fi          fi
2587      done      done
2588  fi  fi
# Line 2256  for i in $spaths ; do Line 2598  for i in $spaths ; do
2598      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
2599          echo "    found CPP_OPTIONS=\"$try\""          echo "    found CPP_OPTIONS=\"$try\""
2600          CPP_OPTIONS="$try"          CPP_OPTIONS="$try"
2601          # 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
2602          for n in $names ; do          for n in $names ; do
2603              test_for_package_in_cpp_options $CPP_OPTIONS $n              test_for_package_in_cpp_options $CPP_OPTIONS $n
2604          done          done
2605      fi      fi
2606      try="$i/CPP_EEOPTIONS.h"      try="$i/CPP_EEOPTIONS.h"
2607      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
2608          echo "    found CPP_EEOPTIONS=\"$try\""          echo "    found CPP_EEOPTIONS=\"$try\""
2609          # 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
2610  #**** not yet enabled ****  #**** not yet enabled ****
2611  #        test_for_mpi_in_cpp_eeoptions $try  #        test_for_mpi_in_cpp_eeoptions $try
2612  #**** not yet enabled ****  #**** not yet enabled ****
# Line 2278  fi Line 2620  fi
2620    
2621  #  Here, we build the list of files to be "run through" the adjoint  #  Here, we build the list of files to be "run through" the adjoint
2622  #  compiler.  #  compiler.
2623  if test -f ./adSrcFiles.tmp ; then  if test -f $TMP.adSrcFiles ; then
2624      rm -f ./adSrcFiles.tmp      rm -f $TMP.adSrcFiles
2625  fi  fi
2626  echo "  Creating the list of files for the adjoint compiler."  echo "  Creating the list of files for the adjoint compiler."
2627  touch adSrcFiles.tmp  touch $TMP.adSrcFiles
2628  for i in $SOURCEDIRS ; do  for i in $SOURCEDIRS ; do
2629      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2630      for j in $list_files ; do      for j in $list_files ; do
2631          cat $i/$j >> adSrcFiles.tmp          cat $i/$j >> $TMP.adSrcFiles
2632      done      done
2633  done  done
2634  if test ! "x"$FS = "x.f" ; then  if test ! "x"$FS = "x.f" ; then
2635      cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f      cat $TMP.adSrcFiles | sed -e "s/\.f/.$FS/g" > $TMP.adSrcFiles_f
2636      mv -f adSrcFiles.tmp_f adSrcFiles.tmp      mv -f $TMP.adSrcFiles_f $TMP.adSrcFiles
2637  fi  fi
2638    
2639  echo  echo
# Line 2303  for i in $INCLUDEDIRS ; do Line 2645  for i in $INCLUDEDIRS ; do
2645      fi      fi
2646  done  done
2647    
2648  if test ! "x$DIVA" = x ; then  if test ! "x$DIVA" = x -a ! "x$MPI" = x ; then
2649      echo "  Creating the pseudo-MPI include directory"      if test ! "x$MPIINCLUDEDIR" = x ; then
2650      INCLUDES="-I./mpi_headers $INCLUDES"          #  Do a local copy of MPI headers files (in local dir ./mpi_headers/) after
2651      rm -rf ./mpi_headers          #   checking for additional included headers (in case of chain of included
2652      mkdir -p ./mpi_headers          #   header); also set LOCAL_MPI_HEADERS (if not already set)
2653            mpi_headers_do_local_copy
     if test "x$MPIINCLUDEDIR" = x ; then  
         if test "x$MPIHOME" = x ; then  
             MPIHOME='/usr'  
         fi  
         MPIINCLUDEDIR='$MPIHOME/include'  
     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  
     else  
         echo " We cannot create a copy of mpif.h!"  
 #       exit -1  
2654      fi      fi
2655  fi  fi
2656    
2657  echo "  Determining the list of source and include files"  echo "  Determining the list of source and include files"
2658  rm -rf .links.tmp  rm -rf $TMP.links
2659  mkdir .links.tmp  mkdir $TMP.links
2660  touch .links.tmp/foo  touch $TMP.links/foo
2661  if test ! -r ".links.tmp/foo" ; then  if test ! -r "$TMP.links/foo" ; then
2662      echo      echo
2663      echo "ERROR : something is wrong with your directory permissions or"      echo "ERROR : something is wrong with your directory permissions or"
2664      echo "   your user file-creation mask (\"umask\") since creating a"      echo "   your user file-creation mask (\"umask\") since creating a"
# Line 2348  if test ! -r ".links.tmp/foo" ; then Line 2674  if test ! -r ".links.tmp/foo" ; then
2674      echo      echo
2675      exit 1      exit 1
2676  fi  fi
2677  rm -f .links.tmp/foo  rm -f $TMP.links/foo
2678    
2679  if test "x$OPENAD" != x ; then  if test "x$OPENAD" != x ; then
2680      OAD_DONT_COMPILE="/dev/null"      OAD_DONT_COMPILE="/dev/null"
2681      OAD_DONT_TRANSFORM="/dev/null"      OAD_DONT_TRANSFORM="/dev/null"
2682      OAD_KEEP_ORIGINAL="/dev/null"      OAD_KEEP_ORIGINAL="/dev/null"
2683      OAD_CB2M_FILES="/dev/null"      OAD_CB2M_FILES="/dev/null"
2684        OADTOOLS="$TOOLSDIR/OAD_support"
2685        OADTOOLSMK='$(TOOLSDIR)/OAD_support'
2686      echo "  looking for dontCompile file:  "      echo "  looking for dontCompile file:  "
2687      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2688          if test -r $i"/dontCompile" ; then          if test -r $i"/dontCompile" ; then
2689              OAD_DONT_COMPILE=$i"/dontCompile"              OAD_DONT_COMPILE=$i"/dontCompile"
2690              echo "     found $OAD_DONT_COMPILE"              echo "     found $OAD_DONT_COMPILE"
# Line 2364  if test "x$OPENAD" != x ; then Line 2692  if test "x$OPENAD" != x ; then
2692          fi          fi
2693      done      done
2694      echo "  looking for dontTransform file:  "      echo "  looking for dontTransform file:  "
2695      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2696          if test -r $i"/dontTransform" ; then          if test -r $i"/dontTransform" ; then
2697              OAD_DONT_TRANSFORM=$i"/dontTransform"              OAD_DONT_TRANSFORM=$i"/dontTransform"
2698              echo "     found $OAD_DONT_TRANSFORM"              echo "     found $OAD_DONT_TRANSFORM"
# Line 2372  if test "x$OPENAD" != x ; then Line 2700  if test "x$OPENAD" != x ; then
2700          fi          fi
2701      done      done
2702      echo "  looking for keepOriginal file:  "      echo "  looking for keepOriginal file:  "
2703      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2704          if test -r $i"/keepOriginal" ; then          if test -r $i"/keepOriginal" ; then
2705              OAD_KEEP_ORIGINAL=$i"/keepOriginal"              OAD_KEEP_ORIGINAL=$i"/keepOriginal"
2706              echo "     found $OAD_KEEP_ORIGINAL"              echo "     found $OAD_KEEP_ORIGINAL"
# Line 2380  if test "x$OPENAD" != x ; then Line 2708  if test "x$OPENAD" != x ; then
2708          fi          fi
2709      done      done
2710      echo "  looking for cb2mFiles:  "      echo "  looking for cb2mFiles:  "
2711      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2712          if test -r $i"/cb2mFiles" ; then          if test -r $i"/cb2mFiles" ; then
2713              OAD_CB2M_FILES=$i"/cb2mFiles"              OAD_CB2M_FILES=$i"/cb2mFiles"
2714              echo "     found $OAD_CB2M_FILES"              echo "     found $OAD_CB2M_FILES"
# Line 2390  if test "x$OPENAD" != x ; then Line 2718  if test "x$OPENAD" != x ; then
2718      echo "   OpenAD exceptions:  "      echo "   OpenAD exceptions:  "
2719  fi  fi
2720    
2721  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > $TMP.srclinks
2722  echo "" >> srclinks.tmp  echo "" >> $TMP.srclinks
2723  printf 'F77_SRC_FILES = ' > F77srclist.tmp  printf 'F77_SRC_FILES = ' > $TMP.F77srclist
2724  printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp  printf 'NON_AD_F77_SRC_FILES = ' > $TMP.nonADF77srclist
2725  printf 'C_SRC_FILES = '   > csrclist.tmp  printf 'C_SRC_FILES = '   > $TMP.csrclist
2726  printf 'F90_SRC_FILES = ' > F90srclist.tmp  printf 'F90_SRC_FILES = ' > $TMP.F90srclist
2727  printf 'H_SRC_FILES = '   > hsrclist.tmp  printf 'H_SRC_FILES = '   > $TMP.hsrclist
2728  printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp  printf 'AD_FLOW_FILES = ' > $TMP.ad_flow_files
2729  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2730    alldirsmk=(${SOURCEDIRSMK} ${INCLUDEDIRSMK} ".")
2731    nd=0
2732  for d in $alldirs ; do  for d in $alldirs ; do
2733        dmk=${alldirsmk[${nd}]}
2734        nd=$((${nd}+1))
2735      deplist=      deplist=
2736      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
2737      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
# Line 2407  for d in $alldirs ; do Line 2739  for d in $alldirs ; do
2739          sfiles=`( echo $sfiles | grep -v _cb2m\. )`          sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2740      fi      fi
2741      for sf in $sfiles ; do      for sf in $sfiles ; do
2742          if test ! -r ".links.tmp/$sf" ; then          if test ! -r "$TMP.links/$sf" ; then
2743              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2744                  ignore_f=f                  ignore_f=f
2745                  case $d/$sf in                  case $d/$sf in
2746                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
2747                          ignore_f=t                          ignore_f=t
2748                          ;;                          ;;
2749                    ./AD_CONFIG.h)                    ./AD_CONFIG.h)
2750                          ignore_f=t                          ignore_f=t
2751                          ;;                          ;;
2752                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
2753                          ignore_f=t                          ignore_f=t
2754                          ;;                          ;;
2755                    ./BUILD_INFO.h)                    ./BUILD_INFO.h)
2756                          ignore_f=t                          ignore_f=t
2757                          ;;                          ;;
2758                    ./EMBEDDED_FILES.h)                    ./EMBEDDED_FILES.h)
2759                          ignore_f=t                          ignore_f=t
2760                          ;;                          ;;
2761                    *)                    *)
2762                          #  For the local directory *ONLY*,                          #  For the local directory *ONLY*,
2763                          #  ignore all soft-links                          #  ignore all soft-links
2764                          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
2765                              ignore_f=t                              ignore_f=t
2766                          else                          else
2767                              touch .links.tmp/$sf                              touch $TMP.links/$sf
2768                              deplist="$deplist $sf"                              deplist="$deplist $sf"
2769                          fi                          fi
2770                          ;;                          ;;
2771                  esac                  esac
2772                  if test "x$ignore_f" = xf ; then                  if test "x$ignore_f" = xf ; then
2773                      extn=`echo $sf | $AWK -F. '{print $NF}'`                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2774                      case $extn in                      case $extn in
2775                        F)                        F)
2776                          echo    " \\"  >> F77srclist.tmp                          echo    " \\"  >> $TMP.F77srclist
2777                          printf " $sf" >> F77srclist.tmp                          printf " $sf" >> $TMP.F77srclist
2778                          if test "x$OPENAD" != x ; then                          if test "x$OPENAD" = x ; then
2779                              basename=${sf%%.F}                              basename=${sf%%.F}
2780                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`                              isAD=`egrep ^$basename.f'[  ]*' $TMP.adSrcFiles`
2781                                if test -z "$isAD" ; then
2782                                    echo    " \\"  >> $TMP.nonADF77srclist
2783                                    printf " $sf" >> $TMP.nonADF77srclist
2784                                fi
2785                            else #- OpenAD case:
2786                                basename=${sf%%.F}
2787                                isAD=`egrep ^$basename.f'[  ]*' $TMP.adSrcFiles`
2788                              if test -z "$isAD" ; then                              if test -z "$isAD" ; then
2789                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`
2790                                  if test -z "$toBeIgnored" ; then                                  if test -z "$toBeIgnored" ; then
2791                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> $TMP.nonADF77srclist
2792                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> $TMP.nonADF77srclist
2793                                  else                                  else
2794                                      echo "    not to be compiled   :  $sf"                                      echo "    not to be compiled   :  $sf"
2795                                  fi                                  fi
# Line 2465  for d in $alldirs ; do Line 2804  for d in $alldirs ; do
2804                                      echo "    original to be kept  :  $sf"                                      echo "    original to be kept  :  $sf"
2805                                  fi                                  fi
2806                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2807                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> $TMP.nonADF77srclist
2808                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> $TMP.nonADF77srclist
2809                                  fi                                  fi
2810                              fi                              fi
2811                          fi                          fi
2812                          ;;                          ;;
2813                      F90)                      F90)
2814                          echo    " \\"  >> F90srclist.tmp                          echo    " \\"  >> $TMP.F90srclist
2815                          printf " $sf" >> F90srclist.tmp                          printf " $sf" >> $TMP.F90srclist
2816                          ;;                          ;;
2817                      c)                      c)
2818                          echo    " \\"  >> csrclist.tmp                          echo    " \\"  >> $TMP.csrclist
2819                          printf " $sf" >> csrclist.tmp                          printf " $sf" >> $TMP.csrclist
2820                          ;;                          ;;
2821                      h)                      h)
2822                          echo    " \\"  >> hsrclist.tmp                          echo    " \\"  >> $TMP.hsrclist
2823                          printf " $sf" >> hsrclist.tmp                          printf " $sf" >> $TMP.hsrclist
2824                          ;;                          ;;
2825                      flow)                      flow)
2826                          echo    " \\"  >> ad_flow_files.tmp                          echo    " \\"  >> $TMP.ad_flow_files
2827                          printf " $sf" >> ad_flow_files.tmp                          printf " $sf" >> $TMP.ad_flow_files
2828                          ;;                          ;;
2829                     esac                     esac
2830                  fi                  fi
# Line 2494  for d in $alldirs ; do Line 2833  for d in $alldirs ; do
2833      done      done
2834      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2835        if test "$d" != "." ; then        if test "$d" != "." ; then
2836          echo "" >> srclinks.tmp          echo "" >> $TMP.srclinks
2837          echo "#  These files are linked from $d" >> srclinks.tmp          echo "#  These files are linked from $dmk ( aka $d )" >> $TMP.srclinks
2838          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> $TMP.srclinks
2839  # We need to make sure that the link isn't already there.  # We need to make sure that the link isn't already there.
2840  # This may happen when make thinks that a header file has to be "remade"  # This may happen when make thinks that a header file has to be "remade"
2841  # because a module it depends on has changed.  In this case we do nothing.  # because a module it depends on has changed.  In this case we do nothing.
2842          printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp          printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $dmk >> $TMP.srclinks
2843        fi        fi
2844      fi      fi
2845  done  done
2846  rm -rf .links.tmp  rm -rf $TMP.links
2847  echo "" >> F77srclist.tmp  echo "" >> $TMP.F77srclist
2848  echo "" >> nonADF77srclist.tmp  echo "" >> $TMP.nonADF77srclist
2849  echo "" >> csrclist.tmp  echo "" >> $TMP.csrclist
2850  echo "" >> F90srclist.tmp  echo "" >> $TMP.F90srclist
2851  echo "" >> hsrclist.tmp  echo "" >> $TMP.hsrclist
2852  echo "" >> ad_flow_files.tmp  echo "" >> $TMP.ad_flow_files
2853    
2854  CMDLINE=$0  CMDLINE=$0
2855  for xx in "$@" ; do nw=`echo $xx | wc -w`  for xx in "$@" ; do nw=`echo $xx | wc -w`
2856      if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"      if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
2857                          else CMDLINE="$CMDLINE '$xx'" ; fi                          else CMDLINE="$CMDLINE '$xx'" ; fi
2858  done  done
2859    
2860  if test -f $MAKEFILE ; then  if test -f $MAKEFILE ; then
# Line 2549  cat >>$MAKEFILE <<EOF Line 2888  cat >>$MAKEFILE <<EOF
2888  # INCLUDES     : Directories searched for header files  # INCLUDES     : Directories searched for header files
2889  # DEFINES      : Macro definitions for CPP  # DEFINES      : Macro definitions for CPP
2890  # MAKEDEPEND   : Dependency generator  # MAKEDEPEND   : Dependency generator
 # KPP          : Special preprocessor command (specific to platform)  
 # KFLAGS       : Flags for KPP  
2891  # FC           : Fortran compiler command  # FC           : Fortran compiler command
2892  # FFLAGS       : Configuration/debugging options for FC  # FFLAGS       : Configuration/debugging options for FC
2893  # FOPTIM       : Optimization options for FC  # FOPTIM       : Optimization options for FC
# Line 2559  cat >>$MAKEFILE <<EOF Line 2896  cat >>$MAKEFILE <<EOF
2896    
2897  ROOTDIR     = ${ROOTDIR}  ROOTDIR     = ${ROOTDIR}
2898  BUILDDIR    = ${BUILDDIR}  BUILDDIR    = ${BUILDDIR}
2899  SOURCEDIRS  = ${SOURCEDIRS}  SOURCEDIRS  = ${SOURCEDIRSMK}
2900  INCLUDEDIRS = ${INCLUDEDIRS}  INCLUDEDIRS = ${INCLUDEDIRSMK}
2901  EXEDIR      = ${EXEDIR}  EXEDIR      = ${EXEDIR}
2902  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
2903  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIRMK}
2904    OADTOOLS    = ${OADTOOLSMK}
2905    
2906  #eh3  new defines for the adjoint work  #eh3  new defines for the adjoint work
2907  AUTODIFF    = ${ROOTDIR}/pkg/autodiff  AUTODIFF    = \$(ROOTDIR)/pkg/autodiff
2908  EXE_AD      = ${EXE_AD}  EXE_AD      = ${EXE_AD}
2909  EXE_FTL     = ${EXE_FTL}  EXE_FTL     = ${EXE_FTL}
2910  EXE_SVD     = ${EXE_SVD}  EXE_SVD     = ${EXE_SVD}
# Line 2584  else Line 2922  else
2922      echo "EMBEDDED_FILES = " >>$MAKEFILE      echo "EMBEDDED_FILES = " >>$MAKEFILE
2923  fi  fi
2924    
2925    # extract default cpp search path so we can pass it to makedepend
2926    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}'`
2927    
2928  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2929  # Unix ln (link)  # Unix ln (link)
2930  LN = ${LN}  LN = ${LN}
 # C preprocessor  
 CPP = cat \$< | ${S64} | ${CPP}  
2931  # Dependency generator  # Dependency generator
2932  MAKEDEPEND = ${MAKEDEPEND}  MAKEDEPEND = ${MAKEDEPEND}
2933  # Special preprocessor (KAP on DECs, FPP on Crays)  # Special preprocessor (KAP on DECs, FPP on Crays)
# Line 2606  LINK = ${LINK} ${LDADD} Line 2945  LINK = ${LINK} ${LDADD}
2945  DEFINES = ${DEFINES}  DEFINES = ${DEFINES}
2946  # Includes for CPP  # Includes for CPP
2947  INCLUDES = ${INCLUDES}  INCLUDES = ${INCLUDES}
2948    # default CPP includes for makedepend
2949    CPPINCLUDES = ${CPPINCLUDES}
2950  # Flags for KPP  # Flags for KPP
2951  KFLAGS1 = ${KFLAGS1}  KFLAGS1 = ${KFLAGS1}
2952  KFLAGS2 = ${KFLAGS2}  KFLAGS2 = ${KFLAGS2}
2953  # Optim./debug for FC  # Optim./debug for FC
2954  FFLAGS = ${FFLAGS} ${FEXTRAFLAGS}  FFLAGS = ${FFLAGS}
2955  FOPTIM = ${FOPTIM}  FOPTIM = ${FOPTIM} ${FEXTRAFLAGS}
2956  # Optim./debug for FC  # Optim./debug for FC
2957  F90FLAGS = ${F90FLAGS}  F90FLAGS = ${F90FLAGS}
2958  F90OPTIM = ${F90OPTIM}  F90OPTIM = ${F90OPTIM}
# Line 2623  NOOPTFILES = ${NOOPTFILES} Line 2964  NOOPTFILES = ${NOOPTFILES}
2964  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2965  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2966  LIBS = ${LIBS}  LIBS = ${LIBS}
2967  # Name of the Mekfile  # Name of the makefile
2968  MAKEFILE=${MAKEFILE}  MAKEFILE = ${MAKEFILE}
2969    # Name of the make program
2970    MAKE = ${MAKE}
2971    
2972  EOF  EOF
2973    
2974  cat F77srclist.tmp      >> $MAKEFILE  cat $TMP.F77srclist      >> $MAKEFILE
2975  cat nonADF77srclist.tmp >> $MAKEFILE  cat $TMP.nonADF77srclist >> $MAKEFILE
2976  cat csrclist.tmp        >> $MAKEFILE  cat $TMP.csrclist        >> $MAKEFILE
2977  cat F90srclist.tmp      >> $MAKEFILE  cat $TMP.F90srclist      >> $MAKEFILE
2978  cat hsrclist.tmp        >> $MAKEFILE  cat $TMP.hsrclist        >> $MAKEFILE
2979  cat ad_flow_files.tmp   >> $MAKEFILE  cat $TMP.ad_flow_files   >> $MAKEFILE
2980    
2981  rm -f F77srclist.tmp nonADF77srclist.tmp csrclist.tmp F90srclist.tmp hsrclist.tmp ad_flow_files.tmp  rm -f $TMP.F77srclist $TMP.nonADF77srclist $TMP.csrclist $TMP.F90srclist $TMP.hsrclist $TMP.ad_flow_files
2982    
2983  echo >> $MAKEFILE  echo >> $MAKEFILE
2984    
# Line 2648  echo >> $MAKEFILE Line 2991  echo >> $MAKEFILE
2991  echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE  echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE
2992  echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE  echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE
2993  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
2994  echo 'FLOFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE  echo 'FLOWFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE
2995  echo >> $MAKEFILE  echo >> $MAKEFILE
2996  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
2997  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
2998    
2999  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3000    
3001  all: \$(EXECUTABLE)  all: fwd_exe_target
3002    fwd_exe_target:
3003            @echo Update AD_CONFIG.h and make \$(EXECUTABLE)
3004            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Forward version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3005            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3006            @-rm -f ad_config.template
3007            \$(MAKE) -f \$(MAKEFILE) \$(EXECUTABLE)
3008    
3009  \$(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)
3010          @echo Creating \$@ ...          @echo Creating \$@ ...
3011          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
3012    
3013  depend:  depend:
3014          @make links          @\$(MAKE) -f \$(MAKEFILE) links
3015          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)          \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(CPPINCLUDES) \$(F77_SRC_FILES)
3016          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
3017          -rm -f makedepend.out          -rm -f makedepend.out
3018    
3019  lib: libmitgcmuv.a  lib: libmitgcmuv.a
3020    
3021  libmitgcmuv.a: \$(OBJFILES)  libmitgcmuv.a: \$(SPECIAL_FILES) \$(OBJFILES)
3022          ar rcv libmitgcmuv.a \$(OBJFILES)          ar rcv libmitgcmuv.a \$(OBJFILES)
3023          ar d   libmitgcmuv.a main.o          ar d   libmitgcmuv.a main.o
3024    
3025    obj: \$(OBJFILES)
3026    
3027  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)
3028    
3029  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
3030    
 output.txt: \$(EXECUTABLE)  
         @printf 'running ... '  
         @\$(EXECUTABLE) > \$@  
   
3031  # remove most of the files that "make" generates  # remove most of the files that "make" generates
3032  clean:  clean:
3033          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
# Line 2688  clean: Line 3037  clean:
3037    
3038  # remove most of the files that "make" and "make depend" generate  # remove most of the files that "make" and "make depend" generate
3039  Clean:  Clean:
3040          @make clean          @\$(MAKE) -f \$(MAKEFILE) clean
3041          @make cleanlinks          @\$(MAKE) -f \$(MAKEFILE) cleanlinks
3042          -rm -f \$(SPECIAL_FILES) f90mkdepend.log          -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old
3043          -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  
3044    
3045  # remove also the executable, files that "genmake2" generates (except Makefile)  # remove also the executable, files that "genmake2" generates (except Makefile)
3046  #         and output from a run (plus log files from testreport)  #         and output from a run (plus log files from testreport)
3047  CLEAN:  CLEAN:
3048          @make Clean          @\$(MAKE) -f \$(MAKEFILE) Clean
3049          -rm -f \$(EXECUTABLE) \$(EXE_AD) *.bak $MAKEFILE.old          -rm -f \$(EXECUTABLE) \$(EXE_AD) \$(EXE_FTL) *.bak
3050          -rm -f $LOGFILE genmake_state genmake_*optfile genmake.tr_log make.tr_log          -rm -f $LOGFILE genmake_state genmake_*optfile
3051            -rm -f SIZE.h.mpi genmake.tr_log make.tr_log
3052            -rm -rf mpi_headers mnc_test_*
3053          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
3054          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
3055          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
3056          -rm -f *.txt STD* *diagnostics.log datetime          -rm -f *.txt STDOUT.* STDERR.* *diagnostics.log *.[0-9][0-9][0-9][0-9].log
3057            -rm -f datetime costfinal divided.ctrl snapshot* output_adm.txt.diva_*
3058          -rm -f *_MIT_CE_000.opt0000 costfunction*0000          -rm -f *_MIT_CE_000.opt0000 costfunction*0000
3059          -rm -rf mnc_test_*          -rm -f oad_cp.[0-9][0-9][0-9].?????
3060    
3061  makefile:  makefile:
3062          $THIS_SCRIPT $G2ARGS          $THIS_SCRIPT $G2ARGS
# Line 2715  cleanlinks: Line 3066  cleanlinks:
3066  # Special targets (SPECIAL_FILES) which are created by make  # Special targets (SPECIAL_FILES) which are created by make
3067  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
3068          @echo Creating \$@ ...          @echo Creating \$@ ...
3069          @$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) > \$@
3070  AD_CONFIG.h:  AD_CONFIG.h:
3071          @echo Creating \$@ ...          @echo Creating \$@ ...
3072          @$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 > \$@
3073  FC_NAMEMANGLE.h:  FC_NAMEMANGLE.h:
3074          @echo Creating \$@ ...          @echo Creating \$@ ...
3075          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
# Line 2758  cat >>$MAKEFILE <<EOF Line 3109  cat >>$MAKEFILE <<EOF
3109  ## This nullifies any default implicit rules concerning these two file types:  ## This nullifies any default implicit rules concerning these two file types:
3110  ## %.o : %.F  ## %.o : %.F
3111    
3112    # C preprocessing and replacing the _d in constants:
3113    CPPCMD = cat \$< | ${CPP} \$(DEFINES) \$(INCLUDES) | ${S64}
3114    
3115  .F.$FS:  .F.$FS:
3116          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD)  > \$@
3117  .$FS.o:  .$FS.o:
3118          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
3119  .F.o:  .F.o:
3120          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
3121  .F90.$FS90:  .F90.$FS90:
3122          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD)  > \$@
3123  .FF90.f$FS90:  .FF90.f$FS90:
3124          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD)  > \$@
3125  .$FS90.o:  .$FS90.o:
3126          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
3127  .f$FS90.o:  .f$FS90.o:
# Line 2776  cat >>$MAKEFILE <<EOF Line 3130  cat >>$MAKEFILE <<EOF
3130  .c.o:  .c.o:
3131          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
3132  .flow.flowdir:  .flow.flowdir:
3133          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD) > \$@
3134    
3135  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
3136  .F.p:  .F.p:
3137          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD) > \$@
3138  .p.$FS:  .p.$FS:
3139          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
3140    
# Line 2799  TAF            = ${TAF} Line 3153  TAF            = ${TAF}
3153    
3154  TAF_EXTRA      = ${TAF_EXTRA}  TAF_EXTRA      = ${TAF_EXTRA}
3155  TAMC_EXTRA     = ${TAMC_EXTRA}  TAMC_EXTRA     = ${TAMC_EXTRA}
3156    LOCAL_MPI_HEADERS    = ${LOCAL_MPI_HEADERS}
3157    
3158  EOF  EOF
3159    
# Line 2816  done Line 3171  done
3171  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
3172  echo >> $MAKEFILE  echo >> $MAKEFILE
3173  printf "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
3174  AD_FILES=`cat adSrcFiles.tmp`  AD_FILES=`cat $TMP.adSrcFiles`
3175  for i in $AD_FILES ; do  for i in $AD_FILES ; do
3176      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
3177      printf " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
3178  done  done
3179  echo >> $MAKEFILE  echo >> $MAKEFILE
3180  rm -f adSrcFiles.tmp  rm -f $TMP.adSrcFiles
3181    
3182    if test $CAT_SRC_FOR_TAF = 0 ; then
3183    cat >>$MAKEFILE <<EOF
3184    
3185    # ... Utilities ...
3186    remove_comments:
3187            sed -i.bak -f \$(TOOLSDIR)/remove_comments_sed \$(AD_FILES)
3188            @-rm -f \$(AD_FILES:.$FS=.$FS.bak)
3189    adj_sed:
3190            sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_ad.$FS)
3191            @-rm -f \$(AD_FILES:.$FS=_ad.$FS.bak)
3192    ftl_sed:
3193            sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_tl.$FS)
3194            @-rm -f \$(AD_FILES:.$FS=_tl.$FS.bak)
3195    adobjfiles: \$(AD_FILES:.$FS=_ad.o)
3196    ftlobjfiles: \$(AD_FILES:.$FS=_tl.o)
3197    EOF
3198    fi
3199    
3200  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3201    
3202  # ... AD ...  # ... AD ...
3203  adall: \$(EXE_AD)  adall: ad_exe_target
3204  adtaf: ad_taf_output.$FS  adtaf: ad_taf_output.$FS
3205  adtamc: ad_tamc_output.$FS  adtamc: ad_tamc_output.$FS
3206    
3207  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES)  ad_exe_target:
3208          @$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)
3209            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3210            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3211            @-rm -f ad_config.template
3212            \$(MAKE) -f \$(MAKEFILE) \$(EXE_AD)
3213    
3214    ad_input_code.$FS: \$(AD_FILES) \$(AD_FLOW_FILES)
3215            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3216          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
3217          -rm -f ad_config.template          @-rm -f ad_config.template
3218          @make \$(F77_PP_SRC_FILES)          @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3219          @make \$(FLOFILES)          @\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)
3220          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
3221    
3222  ad_taf_output.$FS: ad_input_code.$FS  adtafonly:
3223          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3224          ls -l ad_input_code_ad.$FS          ls -l ad_input_code_ad.$FS
3225          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
3226    
3227  adtafonly:  EOF
3228    
3229    if test $CAT_SRC_FOR_TAF = 1 ; then
3230    cat >>$MAKEFILE <<EOF
3231    # ... send 1 file to TAF ...
3232    ad_taf_output.$FS: ad_input_code.$FS
3233            @-rm -f ad_input_code_ad.$FS ; echo ''
3234          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3235          ls -l ad_input_code_ad.$FS          ls -l ad_input_code_ad.$FS
3236          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
3237    
3238  \${EXE_AD}: ad_taf_output.o \$(OBJFILES)  \$(EXE_AD): \$(SPECIAL_FILES) \$(H_SRC_FILES) ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)
3239          \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)
3240    
3241  ad_tamc_output.$FS: ad_input_code.$FS  adobj: ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o)
         \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS  
         cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS  
3242    
3243  ad_tamc: ad_tamc_output.o \$(OBJFILES)  EOF
3244          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)  
3245    else
3246    cat >>$MAKEFILE <<EOF
3247    # ... send multiple files to TAF ...
3248    ad_taf_output.$FS: \$(AD_FLOW_FILES) \$(AD_FILES)
3249            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3250            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3251            @-rm -f ad_config.template
3252            @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3253            @\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)
3254            @-rm -f \$(AD_FILES:.$FS=_ad.$FS) \$(AD_FILES:.$FS=_ad.o); echo ''
3255            \$(MAKE) -f \$(MAKEFILE) remove_comments
3256            \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) \$(FLOWFILES) \$(AD_FILES)
3257            \$(MAKE) -f \$(MAKEFILE) adj_sed
3258            cat \$(AD_FILES:.$FS=_ad.$FS) > ad_taf_output.$FS
3259    
3260    \$(EXE_AD): \$(SPECIAL_FILES) \$(H_SRC_FILES) ad_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)
3261            \$(MAKE) -f \$(MAKEFILE) adobjfiles
3262            \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(AD_FILES:.$FS=_ad.o) \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)
3263    
3264    adobj: ad_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o)
3265            \$(MAKE) -f \$(MAKEFILE) adobjfiles
3266    
3267    EOF
3268    fi
3269    
3270    cat >>$MAKEFILE <<EOF
3271  adonlyfwd:  adonlyfwd:
3272          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
3273    
3274  adtrick:  adtrick:
3275          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
3276    
3277    ad_tamc_output.$FS: ad_input_code.$FS
3278            \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
3279            cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
3280    
3281    ad_tamc: ad_tamc_output.o \$(OBJFILES)
3282            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
3283    
3284  # ... FTL ...  # ... FTL ...
3285  ftlall: ftl_taf  ftlall: ftl_exe_target
3286  ftltaf: ftl_taf_output.$FS  ftltaf: ftl_taf_output.$FS
3287  ftltamc: ftl_tamc_output.$FS  ftltamc: ftl_tamc_output.$FS
3288    
3289  ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)  ftl_exe_target:
3290          @$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)
3291          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
3292          -rm -f ftl_config.template          @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3293          @make \$(F77_PP_SRC_FILES)          @-rm -f ad_config.template
3294          @make \$(AD_FLOW_FILES)          \$(MAKE) -f \$(MAKEFILE) \$(EXE_FTL)
         cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS  
3295    
3296  ftl_taf_output.$FS: ftl_input_code.$FS  ftl_input_code.$FS: \$(AD_FILES)
3297          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3298          ls -l ftl_input_code_ftl.$FS          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3299          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS          @-rm -f ad_config.template
3300            @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3301            @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3302            cat \$(AD_FLOW_FILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ftl_input_code.$FS
3303    
3304  ftltafonly:  ftltafonly:
3305          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3306          ls -l ftl_input_code_ftl.$FS          ls -l ftl_input_code_tl.$FS
3307          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS          cat ftl_input_code_tl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
3308    
3309    EOF
3310    
3311    if test $CAT_SRC_FOR_TAF = 1 ; then
3312    cat >>$MAKEFILE <<EOF
3313    # ... send 1 file to TAF ...
3314    ftl_taf_output.$FS: ftl_input_code.$FS
3315            @-rm -f ftl_input_code_tl.$FS ; echo ''
3316            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3317            ls -l ftl_input_code_tl.$FS
3318            cat ftl_input_code_tl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
3319    
3320    \$(EXE_FTL): \$(SPECIAL_FILES) \$(H_SRC_FILES) ftl_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)
3321            \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) ftl_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)
3322    
3323    EOF
3324    
3325    else
3326    cat >>$MAKEFILE <<EOF
3327    # ... send multiple files to TAF ...
3328    ftl_taf_output.$FS: \$(AD_FLOW_FILES) \$(AD_FILES)
3329            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3330            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3331            @-rm -f ad_config.template
3332            @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3333            @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3334            @-rm -f \$(AD_FILES:.$FS=_tl.$FS) \$(AD_FILES:.$FS=_tl.o); echo ''
3335            \$(MAKE) -f \$(MAKEFILE) remove_comments
3336            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) \$(AD_FLOW_FILES) \$(AD_FILES)
3337            \$(MAKE) -f \$(MAKEFILE) ftl_sed
3338            cat \$(AD_FILES:.$FS=_tl.$FS) > ftl_taf_output.$FS
3339    
3340    \$(EXE_FTL): \$(SPECIAL_FILES) \$(H_SRC_FILES) ftl_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)
3341            \$(MAKE) -f \$(MAKEFILE) ftlobjfiles
3342            \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(AD_FILES:.$FS=_tl.o) \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)
3343    
3344  ftl_taf: ftl_taf_output.o \$(OBJFILES)  EOF
3345          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)  fi
3346    
3347    cat >>$MAKEFILE <<EOF
3348  ftl_tamc_output.$FS: ftl_input_code.$FS  ftl_tamc_output.$FS: ftl_input_code.$FS
3349          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
3350          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS
# Line 2918  svd_touch: Line 3372  svd_touch:
3372          touch ad_taf_output.$FS ftl_taf_output.$FS          touch ad_taf_output.$FS ftl_taf_output.$FS
3373          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
3374          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
3375          @$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
3376          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
3377          -rm -f ftl_config.template          @-rm -f ad_config.template
3378    
3379  EOF  EOF
3380    
# Line 2933  if test "x$OPENAD" != x ; then Line 3387  if test "x$OPENAD" != x ; then
3387  # ============ begin OpenAD specific section ==============  # ============ begin OpenAD specific section ==============
3388    
3389  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3390    # ... OpenAD ...
3391    
3392  # all the source files linked from the various locations:  # all the source files linked from the various locations:
3393  ALL_LINKED_FILES= \  ALL_LINKED_FILES= \
# Line 2972  for i in `cat ${OAD_CB2M_FILES}` ; do Line 3427  for i in `cat ${OAD_CB2M_FILES}` ; do
3427    echo    " \\" >> $MAKEFILE    echo    " \\" >> $MAKEFILE
3428    printf " ${i}_mod.f$FS90" >> $MAKEFILE    printf " ${i}_mod.f$FS90" >> $MAKEFILE
3429  done  done
3430  AD_FILES=`cat adSrcFiles.tmp`  AD_FILES=`cat $TMP.adSrcFiles`
3431  for i in $AD_FILES ; do  for i in $AD_FILES ; do
3432    basename=${i%%.f}    basename=${i%%.f}
3433    toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`    toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`
# Line 2982  for i in $AD_FILES ; do Line 3437  for i in $AD_FILES ; do
3437    fi    fi
3438  done  done
3439  echo >> $MAKEFILE  echo >> $MAKEFILE
3440  rm -f adSrcFiles.tmp  rm -f $TMP.adSrcFiles
3441    
3442  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3443    
3444  adAll: \$(EXE_AD)  adAll: ad_exe_target
3445  .PHONY: adAll  .PHONY: adAll
3446    
3447    ad_exe_target:
3448            @echo Update AD_CONFIG.h and make \$(EXE_AD)
3449            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3450            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3451            @-rm -f ad_config.template
3452            \$(MAKE) -f \$(MAKEFILE) \$(EXE_AD)
3453    
3454  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))
3455    
3456  .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90)  .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90)
3457    
3458  .PHONY: adDepend  .PHONY: adDepend
3459  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)
3460          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)          \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
3461          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
3462          -rm -f makedepend.out          -rm -f makedepend.out
3463    
# Line 3004  w2f__types.F90 \ Line 3466  w2f__types.F90 \
3466  OAD_active.F90 \  OAD_active.F90 \
3467  OAD_cp.F90 \  OAD_cp.F90 \
3468  OAD_rev.F90 \  OAD_rev.F90 \
3469  OAD_tape.F90  OAD_tape.F90 \
3470    OAD_regular_cp.F90 \
3471    revolve.F90
3472    
3473  OPENAD_SUPPORT_C_SRC_FILES = \  OPENAD_SUPPORT_C_SRC_FILES = \
3474  iaddr.c \  iaddr.c \
# Line 3020  f95_test.out: f95_test_mods.f90 f95_test Line 3484  f95_test.out: f95_test_mods.f90 f95_test
3484          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
3485          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
3486    
3487  # 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  
3488    
3489  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)
3490    
3491  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)
3492    
3493  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)  
3494          \$(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  
3495    
3496  # create the module files  # create sources files modules from header files containing common blocks
3497  %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk  %_mod.FF90 : %.h \$(OADTOOLS)/cb2mGetModules.csh \$(OADTOOLS)/cb2mGetModules.awk
3498          ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk          \$(OADTOOLS)/cb2mGetModules.csh $< \$(OADTOOLS)/cb2mGetModules.awk
3499    
3500  # create the header files  # create new header files with USE statements for the new modules made above
3501  %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk  %_mod.h : %.h \$(OADTOOLS)/cb2mGetHeaders.csh \$(OADTOOLS)/cb2mGetHeaders.awk
3502          ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)          \$(OADTOOLS)/cb2mGetHeaders.csh $< \$(OADTOOLS)/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
3503    
3504  # 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
3505  %_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash  %_cb2m.FF90 : %.F \$(OADTOOLS)/cb2mUseModules.bash
3506          ../OAD_support/cb2mUseModules.bash $< ${MPI}          \$(OADTOOLS)/cb2mUseModules.bash $< ${MPI}
3507    
3508  # makefile debug rule  # makefile debug rule
3509  small_f: \$(CB2M_F90_PP_SRC_FILES)  small_f: \$(CB2M_F90_PP_SRC_FILES)
3510  .PHONY: small_f  .PHONY: small_f
3511    
 ad_output.txt: \$(EXE_AD)  
         @printf 'linking data files ... '  
         \$(LN) -f ../input_ad/data* ../input_ad/eedata .  
         \$(LN) -f ../../global_ocean.90x40x15/input/*.bin .  
         @printf 'running ... '  
         @./\$(EXE_AD) > \$@  
   
 CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)  
3512  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3513          cat \$^ > \$@          cat \$^ > \$@
3514    
 # 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 > \$@  
   
3515  # canonicalizer  # canonicalizer
3516  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)
3517          ./preProcess.py --timing --r8 -H -S \$< -o \$@          \${OPENADFORTTK_BASE}/tools/SourceProcessing/preProcess.py --timing --r8 -H -S  -o \$@ \$^
3518    
3519    # replace stop statements (to avoid the implied unstructured control flow)  with print statements
3520    ad_input_code_sf.pre.s2p.f90 : ad_input_code_sf.pre.f90
3521            cat \$< | sed -f \$(OADTOOLS)/stop2print.sed > ad_input_code_sf.pre.s2p.f90
3522    
3523  # F -> WHIRL  # F -> WHIRL
3524  # note that the canonicalized version cuts off at col 72  ad_input_code_sf.pre.s2p.B: ad_input_code_sf.pre.s2p.f90
3525  # 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 \$@  
3526    
3527  # WHIRL -> XAIF  # WHIRL -> XAIF
3528  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
3529          ./whirl2xaif -s -n --debug 1 -o \$@ \$<          \${OPENADFORTTK}/bin/whirl2xaif -s -n --debug 1 -o \$@ \$<
3530    
3531  # XAIF -> XAIF'  # XAIF -> XAIF'
3532  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
3533          ./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
3534    
3535  # XAIF' -> WHIRL'  # XAIF' -> WHIRL'
3536  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
3537          ./xaif2whirl --debug 1 ad_input_code_sf.w2f.pre.B \$<          \${OPENADFORTTK}/bin/xaif2whirl --debug 1 ad_input_code_sf.pre.s2p.B \$<
3538    
3539  # WHIRL' -> F'  # WHIRL' -> F'
3540  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
3541          ./whirl2f -FLIST:ftn_file=\$@ -openad \$<          \${OPEN64ROOT}/whirl2f/whirl2f -FLIST:ftn_file=\$@ -openad \$<
3542    
3543  # insert template directives  # insert template directives
3544  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
3545          ../OAD_support/insertTemplateDir.bash \$< \$@          \$(OADTOOLS)/insertTemplateDir.bash \$< \$@
3546    
3547  PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F  PPEXTRAS=\$(notdir \$(wildcard \$(OADTOOLS)/ad_template.*.F)) ad_inline.F
3548  # postprocess F'  # postprocess F'
3549  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
3550          # 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 ad_inline.f \$<
3551            # the target is a placeholder to trigger a single execution of the rule
3552          touch \$@          touch \$@
3553          # this step also creates the file postProcess.make but we cannot  # put this so make knows about the postprocessing output
3554          # 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 \$<  
3555    
3556  # setup some links  # link the XAIF schema files
3557  %.xsd:  %.xsd:
3558          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3559    
 mfef90:  
         \$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 .  
   
3560  # link the support files:  # link the support files:
3561  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES) \$(PPEXTRAS):
3562          \$(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 \$@  
3563    
3564  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
3565    
3566  # ============ end OpenAD specific section ==============  # ============ end OpenAD specific section ==============
3567    
# Line 3195  for i in $NOOPTFILES ; do Line 3597  for i in $NOOPTFILES ; do
3597  done  done
3598    
3599  echo "  Add rules for links"  echo "  Add rules for links"
3600  cat srclinks.tmp >> $MAKEFILE  cat $TMP.srclinks >> $MAKEFILE
3601  rm -f srclinks.tmp  rm -f $TMP.srclinks
3602    
3603  echo "  Adding makedepend marker"  echo "  Adding makedepend marker"
3604  printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE  printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE
# Line 3204  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 3606  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
3606  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
3607    
3608  # Create special header files  # Create special header files
3609  $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"
3610  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
3611      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
3612  else  else
# Line 3218  else Line 3620  else
3620      fi      fi
3621  fi  fi
3622  if test ! -f AD_CONFIG.h ; then  if test ! -f AD_CONFIG.h ; then
3623      $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
3624  fi  fi
3625    
3626  #  Write the "state" for future records  #  Write the "state" for future records
# Line 3227  if test "x$DUMPSTATE" = xt ; then Line 3629  if test "x$DUMPSTATE" = xt ; then
3629      for i in $gm_state ; do      for i in $gm_state ; do
3630          t1="t2=\$$i"          t1="t2=\$$i"
3631          eval $t1          eval $t1
3632          echo "$i='$t2'" >> genmake_state          echo "$i='$t2'" | sed -e 's/  */ /g' >> genmake_state
3633      done      done
3634  fi  fi

Legend:
Removed from v.1.214  
changed lines
  Added in v.1.279

  ViewVC Help
Powered by ViewVC 1.1.22