/[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.230 by jmc, Sat Jun 23 23:21:43 2012 UTC revision 1.272 by heimbach, Fri Jul 3 21:33:55 2015 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      -nooptfile | --nooptfile
36        -optfile NAME | --optfile NAME | -of NAME | --of NAME        -optfile NAME | --optfile NAME | -of NAME | --of NAME
37        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
38            Use "NAME" as the optfile.  By default, an attempt will be            Use "NAME" as the optfile.  By default, an attempt will be
39            made to find an appropriate "standard" optfile in the            made to find an appropriate "standard" optfile in the
40            tools/build_options/ directory.            tools/build_options/ directory.
41    
42      -pdepend NAME | --pdepend NAME      -pdepend NAME | --pdepend NAME
43        -pdepend=NAME | --pdepend=NAME        -pdepend=NAME | --pdepend=NAME
44            Get package dependency information from "NAME".            Get package dependency information from "NAME".
45    
46      -pgroups NAME | --pgroups NAME      -pgroups NAME | --pgroups NAME
47        -pgroups=NAME | --pgroups=NAME        -pgroups=NAME | --pgroups=NAME
48            Get the package groups information from "NAME".            Get the package groups information from "NAME".
49    
50      -bash NAME      -bash NAME
51            Explicitly specify the Bourne or BASH shell to use            Explicitly specify the Bourne or BASH shell to use
52    
53      -make NAME | -m NAME      -make NAME | -m NAME
54        --make=NAME | -m=NAME        --make=NAME | -m=NAME
55            Use "NAME" for the MAKE program. The default is "make" but            Use "NAME" for the MAKE program. The default is "make" but
56            many platforms, "gmake" is the preferred choice.            many platforms, "gmake" is the preferred choice.
57    
58      -makefile NAME | -mf NAME      -makefile NAME | -mf NAME
59        --makefile=NAME | -mf=NAME        --makefile=NAME | -mf=NAME
60            Call the makefile "NAME".  The default is "Makefile".            Call the makefile "NAME".  The default is "Makefile".
61    
62      -makedepend NAME | -md NAME      -makedepend NAME | -md NAME
63        --makedepend=NAME | -md=NAME        --makedepend=NAME | -md=NAME
64            Use "NAME" for the MAKEDEPEND program.            Use "NAME" for the MAKEDEPEND program.
65    
66      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
67        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
68            Specify the location of the MITgcm ROOTDIR as "NAME".            Specify the location of the MITgcm ROOTDIR as "NAME".
69            By default, genamke will try to find the location by            By default, genamke will try to find the location by
70            looking in parent directories (up to the 5th parent).            looking in parent directories (up to the 5th parent).
71    
72      -mods NAME | --mods NAME | -mo NAME | --mo NAME      -mods NAME | --mods NAME | -mo NAME | --mo NAME
73        -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME        -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME
74            Here, "NAME" specifies a list of directories that are            Here, "NAME" specifies a list of directories that are
75            used for additional source code.  Files found in the            used for additional source code.  Files found in the
76            "mods list" are given preference over files of the same            "mods list" are given preference over files of the same
77            name found elsewhere.            name found elsewhere.
78    
79      -disable NAME | --disable NAME      -disable NAME | --disable NAME
80        -disable=NAME | --disable=NAME        -disable=NAME | --disable=NAME
81            Here "NAME" specifies a list of packages that we don't            Here "NAME" specifies a list of packages that we don't
82            want to use.  If this violates package dependencies,            want to use.  If this violates package dependencies,
83            genamke will exit with an error message.            genamke will exit with an error message.
84    
85      -enable NAME | --enable NAME      -enable NAME | --enable NAME
86        -enable=NAME | --enable=NAME        -enable=NAME | --enable=NAME
87            Here "NAME" specifies a list of packages that we wish            Here "NAME" specifies a list of packages that we wish
88            to specifically enable.  If this violates package            to specifically enable.  If this violates package
89            dependencies, genamke will exit with an error message.            dependencies, genamke will exit with an error message.
90    
91      -standarddirs NAME | --standarddirs NAME      -standarddirs NAME | --standarddirs NAME
92        -standarddirs=NAME | --standarddirs=NAME        -standarddirs=NAME | --standarddirs=NAME
93            Here, "NAME" specifies a list of directories to be            Here, "NAME" specifies a list of directories to be
94            used as the "standard" code.            used as the "standard" code.
95    
96      -fortran NAME | --fortran NAME | -fc NAME | --fc NAME      -fortran NAME | --fortran NAME | -fc NAME | --fc NAME
97        -fc=NAME | --fc=NAME        -fc=NAME | --fc=NAME
98            Use "NAME" as the fortran compiler.  By default, genmake            Use "NAME" as the fortran compiler.  By default, genmake
99            will search for a working compiler by trying a list of            will search for a working compiler by trying a list of
100            "usual suspects" such as g77, f77, etc.            "usual suspects" such as g77, f77, etc.
101    
102      -cc NAME | --cc NAME | -cc=NAME | --cc=NAME      -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
103            Use "NAME" as the C compiler.  By default, genmake            Use "NAME" as the C compiler.  By default, genmake
104            will search for a working compiler by trying a list of            will search for a working compiler by trying a list of
105            "usual suspects" such as gcc, c89, cc, etc.            "usual suspects" such as gcc, c89, cc, etc.
106    
107      -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4      -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4
108            Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW)            Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW)
109            *only* works if CPP_EEOPTIONS.h allows this.            *only* works if CPP_EEOPTIONS.h allows this.
110    
111      -ignoretime | -ignore_time | --ignoretime | --ignore_time      -ignoretime | -ignore_time | --ignoretime | --ignore_time
112            Ignore all the "wall clock" routines entirely.  This will            Ignore all the "wall clock" routines entirely.  This will
113            not in any way hurt the model results -- it simply means            not in any way hurt the model results -- it simply means
114            that the code that checks how long the model spends in            that the code that checks how long the model spends in
115            various routines will give junk values.            various routines will give junk values.
116    
117      -ts | --ts      -ts | --ts
118            Produce timing information per timestep            Produce timing information per timestep
119      -papis | --papis      -papis | --papis
120            Produce summary MFlop/s (and IPC) with PAPI per timestep            Produce summary MFlop/s (and IPC) with PAPI per timestep
121      -pcls | --pcls      -pcls | --pcls
122            Produce summary MFlop/s etc. with PCL per timestep            Produce summary MFlop/s etc. with PCL per timestep
123      -foolad | --foolad      -foolad | --foolad
124            Fool the AD code generator            Fool the AD code generator
125      -papi | --papi      -papi | --papi
126            Performance analysis with PAPI            Performance analysis with PAPI
127      -pcl | --pcl      -pcl | --pcl
128            Performance analysis with PCL            Performance analysis with PCL
129      -hpmt | --hpmt      -hpmt | --hpmt
130            Performance analysis with the HPM Toolkit            Performance analysis with the HPM Toolkit
131    
132      -ieee | --ieee      -ieee | --ieee
133            use IEEE numerics.  Note that this option *only* works            use IEEE numerics.  Note that this option *only* works
134            if it is supported by the OPTFILE that is being used.            if it is supported by the OPTFILE that is being used.
135      -devel | --devel      -devel | --devel
136            Add additional warning and debugging flags for development            Add additional warning and debugging flags for development
137            (if supported by the OPTFILE); also switch to IEEE numerics.            (if supported by the OPTFILE); also switch to IEEE numerics.
138      -gsl | --gsl      -gsl | --gsl
139            Use GSL to control floating point rounding and precision            Use GSL to control floating point rounding and precision
140    
141      -mpi | --mpi      -mpi | --mpi
142            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
143      -mpi=PATH | --mpi=PATH      -mpi=PATH | --mpi=PATH
144            Include MPI header files and link to MPI libraries using MPI_ROOT            Include MPI header files and link to MPI libraries using MPI_ROOT
145            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
146            from \$PATH/lib and use binaries from \$PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
147    
148      -omp | --omp      -omp | --omp
149            Activate OpenMP code + use Compiler option OMPFLAG            Activate OpenMP code + use Compiler option OMPFLAG
150      -omp=OMPFLAG | --omp=OMPFLAG      -omp=OMPFLAG | --omp=OMPFLAG
151            Activate OpenMP code + use Compiler option OMPFLAG            Activate OpenMP code + use Compiler option OMPFLAG
152    
153      -es | --es | -embed-source | --embed-source      -es | --es | -embed-source | --embed-source
154            Embed a tarball containing the full source code            Embed a tarball containing the full source code
155            (including the Makefile, etc.) used to build the            (including the Makefile, etc.) used to build the
156            executable [off by default]            executable [off by default]
157    
158      -ds | --ds      -ds | --ds
159            Report genmake internal variables status (DUMPSTATE)            Report genmake internal variables status (DUMPSTATE)
160            to file "genmake_state" (for debug purpose)            to file "genmake_state" (for debug purpose)
161    
162    While it is most often a single word, the "NAME" variables specified    While it is most often a single word, the "NAME" variables specified
163    above can in many cases be a space-delimited string such as:    above can in many cases be a space-delimited string such as:
# Line 174  EOF Line 182  EOF
182  test_for_package_in_cpp_options() {  test_for_package_in_cpp_options() {
183      cpp_options=$1      cpp_options=$1
184      pkg=$2      pkg=$2
185      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg[ ]"      test_for_string_in_file $cpp_options "^ *# *define *\<ALLOW_$pkg\>"
186      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg[ ]"      test_for_string_in_file $cpp_options "^ *# *undef *\<ALLOW_$pkg\>"
187      test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg[ ]"      test_for_string_in_file $cpp_options "^ *# *define *\<DISABLE_$pkg\>"
188      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$"  
189  }  }
190    
191  # Search for particular CPP #cmds associated with MPI  # Search for particular CPP #cmds associated with MPI
192  # usage: test_for_mpi_in_cpp_eeoptions CPP_file  # usage: test_for_mpi_in_cpp_eeoptions CPP_file
193  test_for_mpi_in_cpp_eeoptions() {  test_for_mpi_in_cpp_eeoptions() {
194      cpp_options=$1      cpp_options=$1
195      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI[ ]"      test_for_string_in_file $cpp_options "^ *# *define *\<ALLOW_USE_MPI\>"
196      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$"  
197  }  }
198    
199  # Search for particular string in a file. Return 1 if detected, 0 if not  # Search for particular string in a file. Return 1 if detected, 0 if not
# Line 203  test_for_mpi_in_cpp_eeoptions() { Line 201  test_for_mpi_in_cpp_eeoptions() {
201  test_for_string_in_file() {  test_for_string_in_file() {
202      file=$1      file=$1
203      strng=$2      strng=$2
204      grep -i "$strng" $file > /dev/null 2>&1      grep "$strng" $file > /dev/null 2>&1
205      RETVAL=$?      RETVAL=$?
206      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
207          printf "Error: In $file there is an illegal line: "          printf "Error: In $file there is an illegal line: "
208          grep -i "$strng" $file          grep -i "$strng" $file
209          exit 99          exit 99
210      fi      fi
211      return 0      return 0
# Line 218  test_for_string_in_file() { Line 216  test_for_string_in_file() {
216  expand_pkg_groups() {  expand_pkg_groups() {
217      new_packages=      new_packages=
218      if test -r $PKG_GROUPS ; then      if test -r $PKG_GROUPS ; then
219          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
220          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp          cat $TMP.p1 | $AWK '(NF>2 && $2==":"){ print $0 }' > $TMP.p2
221          matched=0          matched=0
222          for i in $PACKAGES ; do          for i in $PACKAGES ; do
223              line=`grep "^ *$i" ./p2.tmp`              line=`grep "^ *$i" $TMP.p2`
224              RETVAL=$?              RETVAL=$?
225              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
226                  matched=1                  matched=1
# Line 234  expand_pkg_groups() { Line 232  expand_pkg_groups() {
232              fi              fi
233          done          done
234          PACKAGES=$new_packages          PACKAGES=$new_packages
235          rm -f ./p[1,2].tmp          rm -f $TMP.p[1,2]
236          return $matched          return $matched
237      else      else
238          echo "Warning: can't read package groups definition file: $PKG_GROUPS"          echo "Warning: can't read package groups definition file: $PKG_GROUPS"
# Line 305  EOF Line 303  EOF
303              FS90='fr9'              FS90='fr9'
304              check_for_broken_Ff              check_for_broken_Ff
305          else          else
306              cat <<EOF 2>&1              echo "ERROR: test: '$MAKE -f $MAKEFILE genmake_hello.$tfs' Failed"
307  ERROR: Your file system cannot distinguish between *.F and *.f files              echo "       see simple makefile: '$MAKEFILE' (left here)"
308    (fails the "make/ln" test) and this program cannot find a suitable              echo "  Please check (1) your '$MAKE' command, (2) your '$LN' command"
309    replacement extension.  Please try a different build environment or              echo "           and (3) the allowed sufix '.F' and '.$tfs' in makefile"
310    contact the <MITgcm-support@mitgcm.org> list for help.              echo "  or contact the <MITgcm-support@mitgcm.org> list for help."
311                echo ""
 EOF  
312              exit -1              exit -1
313              return              return
314          fi          fi
# Line 335  look_for_makedepend()  { Line 332  look_for_makedepend()  {
332      #      #
333      #    1) a makedepend implementation shipped with the cyrus-imapd      #    1) a makedepend implementation shipped with the cyrus-imapd
334      #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/      #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
335      #      #    2) a local tools/xmakedepend shell script
     #    2) a known-buggy xmakedpend shell script  
336      #      #
337      #  So the choices are, in order:      #  So the choices are, in order:
     #  
338      #    1) use the user-specified program      #    1) use the user-specified program
339      #    2) use a system-wide default      #    2) use the local xmakedepend script (get all dependencies, but slower)
340      #    3) locally build and use the cyrus implementation      #    3) use a system-wide default
341      #    4) fall back to the buggy local xmakedpend script      #    4) locally build and use the cyrus makedepend
342        #             (faster, but can miss some dependencies)
343      #      #
344      echo >> $LOGFILE      echo >> $LOGFILE
345      echo "running: look_for_makedepend()" >> $LOGFILE      echo "running: look_for_makedepend()" >> $LOGFILE
# Line 354  look_for_makedepend()  { Line 350  look_for_makedepend()  {
350              build_cyrus_makedepend              build_cyrus_makedepend
351              RETVAL=$?              RETVAL=$?
352              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
353                  echo "WARNING: unable to build cyrus-makedepend. Try 'makedepend'"                  echo "WARNING: unable to build cyrus-makedepend. Try other 'makedepend'"
354                  MAKEDEPEND=                  MAKEDEPEND=
355              fi              fi
356          else          else
# Line 367  look_for_makedepend()  { Line 363  look_for_makedepend()  {
363          fi          fi
364      fi      fi
365      if test "x${MAKEDEPEND}" = x ; then      if test "x${MAKEDEPEND}" = x ; then
         which makedepend > /dev/null 2>&1  
         RV0=$?  
366          test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"          test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"
367          #  echo 'MAKEFILE="'$MAKEFILE'"'          #  echo 'MAKEFILE="'$MAKEFILE'"'
368          cat <<EOF >> $MAKEFILE          cat <<EOF >> $MAKEFILE
# Line 384  EOF Line 378  EOF
378        stop        stop
379        end        end
380  EOF  EOF
381          makedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1          $ROOTDIR/tools/xmakedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1
382          RV1=$?          RV1=$?
383            which makedepend > /dev/null 2>&1
384            RV2=$?
385            if test "x${RV2}" = x0 ; then
386                makedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1
387                RV3=$? ; loc_msg='not working.'
388            else RV3=$RV2 ; loc_msg='not found.'
389            fi
390          test -f $MAKEFILE  &&  rm -f $MAKEFILE          test -f $MAKEFILE  &&  rm -f $MAKEFILE
391          test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE          test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
392          if test "x${RV0}${RV1}" = x00 ; then          echo "  check makedepend (local: $RV1, system: $RV2, $RV3)"
393            if test "x${RV1}" = x0 ; then
394                MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
395                echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
396            elif test "x${RV3}" = x0 ; then
397                echo "    local tools/xmakedepend not working. Use system-default makedepend"
398              MAKEDEPEND=makedepend              MAKEDEPEND=makedepend
399              echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE              echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
400          else          else
401              echo "    system-default makedepend not found. Try to build cyrus-makedepend"              echo "    local tools/xmakedepend not working; system-default makedepend $loc_msg"
402                echo -n "    Try to build cyrus-makedepend ..."
403              #  Try to build the cyrus implementation              #  Try to build the cyrus implementation
404              build_cyrus_makedepend              build_cyrus_makedepend
405              RETVAL=$?              RETVAL=$?
406              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" = x0 ; then
407                  echo "WARNING: unable to build cyrus-makedepend. Use local xmakedepend"                  echo "  Works"
408                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'              else
409                  echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE                  echo "  Fails" ; echo "" >> $LOGFILE
410                    echo "ERROR: no working makedepend found ; look_for_makedepend FAILED" | tee -a $LOGFILE
411                    echo ""
412                    exit -1
413                    return
414              fi              fi
415          fi          fi
416      fi      fi
# Line 412  build_cyrus_makedepend()  { Line 423  build_cyrus_makedepend()  {
423      (      (
424          cd $ROOTDIR/tools/cyrus-imapd-makedepend  \          cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
425              &&  ./configure > /dev/null 2>&1  \              &&  ./configure > /dev/null 2>&1  \
426              &&  make > /dev/null 2>&1              &&  $MAKE > /dev/null 2>&1
427          if test -x ./makedepend.exe ; then          if test -x ./makedepend.exe ; then
428              $LN ./makedepend.exe ./makedepend              $LN ./makedepend.exe ./makedepend
429          fi          fi
# Line 436  build_embed_encode() Line 447  build_embed_encode()
447  {  {
448      printf "  building the embed-encode utility...  "      printf "  building the embed-encode utility...  "
449      if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then      if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then
450          if test ! -d "$ROOTDIR/tools/embed_encode" ; then          if test ! -d "$ROOTDIR/tools/embed_encode" ; then
451              echo              echo
452              echo "    Error: can't locate \"$ROOTDIR/tools/embed_encode\""              echo "    Error: can't locate \"$ROOTDIR/tools/embed_encode\""
453              echo              echo
454              EMBED_SRC=f              EMBED_SRC=f
455              return 1              return 1
456          fi          fi
457          clist="cc gcc c89 $CC"          clist="cc gcc c89 $CC"
458          for ic in $clist ; do          for ic in $clist ; do
459              comm="$ic -o encode_files encode_files.c"              comm="$ic -o encode_files encode_files.c"
# Line 578  EOF Line 589  EOF
589      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
590          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
591          if test ! -r $OPTFILE ; then          if test ! -r $OPTFILE ; then
592               echo "  I looked for the file "$OPTFILE" but did not find it"               echo "  I looked for the file "$OPTFILE" but did not find it"
593          fi          fi
594      fi      fi
595    
596      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
# Line 597  Error: No options file was found in:  $R Line 608  Error: No options file was found in:  $R
608  EOF  EOF
609          exit 1          exit 1
610      fi      fi
611    }
612    
613    #  Do a local copy of MPI headers files (in local dir ./mpi_headers/) after
614    #  checking for additional included headers (in case of chain of included header)
615    mpi_headers_do_local_copy() {
616    
617        dBug=0
618        rm -rf ./mpi_headers
619        if test -d $MPIINCLUDEDIR ; then
620    
621            #----- check for additional headers (chain of included headers)
622            echo -n '  Check MPI headers ... '
623            listIni=$MPI_HEADER_FILES
624            echo $listIni | grep "\<mpif.h\>" > /dev/null 2>&1
625            outp=$?
626            #- always check mpif.h (the only mpi-header included in standard MITgcm code)
627            if test $outp != 0 ; then listIni="mpif.h $listIni" ; fi
628            if test $dBug = 1 ; then echo "listIni='$listIni'" ; fi
629    
630            doCheck=1 ; list2copy='' ; list2check=$listIni
631            while test $doCheck = 1 ; do
632              newList=''
633              for i in $list2check ; do
634                if test -f $MPIINCLUDEDIR/$i ; then
635                  newInc=`grep '^ *include ' $MPIINCLUDEDIR/$i | \
636                    sed -e 's/^ *include //' -e 's/\!.*$//' -e "s/'//g"  -e 's/\"//g'`
637                  if test $dBug = 1 ; then echo -n "checking $i : newInc='$newInc'" ; fi
638                  for j in $newInc ; do
639                    echo $listIni $list2copy $newList | grep "\<$j\>" > /dev/null 2>&1
640                    outp=$?
641                    if test $outp != 0 ; then
642                      if test $dBug = 1 ; then echo -n " ; adding $j" ; fi
643                      newList="$newList $j"
644                    fi
645                  done
646                  if test $dBug = 1 ; then echo "" ; fi
647                fi
648              done
649              if test "x$newList" = x ; then doCheck=0
650              else list2check=$newList ; list2copy="$list2copy $newList"
651              fi
652            done
653            list2copy="$MPI_HEADER_FILES $list2copy"
654            if test $dBug = 1 ; then echo "list2copy='$list2copy'" ; fi
655    
656  #     # look for possible MPI libraries          #----- create local mpi_headers dir if we have files to copy
657  #     mpi_libs=          mkListInc=`echo $list2copy | wc -w`
658  #     mpi_fort=`which mpif77 2>/dev/null`          if test $mkListInc != 0 ; then
659  #     RETVAL=$?            echo 'create local "./mpi_headers" dir'
660  #     if test "x${RETVAL}" = x0 ; then            mkdir -p ./mpi_headers
661  #       cat >>test.f <<EOF            INCLUDES="-I./mpi_headers $INCLUDES"
662  #       PROGRAM HELLO            mkListInc=1
663  #       DO 10, I=1,10          fi
664  #       PRINT *,'Hello World'          if test "x$LOCAL_MPI_HEADERS" != x ; then mkListInc=0 ; fi
665  #    10 CONTINUE  
666  #       STOP          #----- make local copy and update LOCAL_MPI_HEADERS (if not already set)
667  #       END          for i in $list2copy ; do
668  # EOF            if test -f $MPIINCLUDEDIR/$i ; then
669  #       eval "$mpi_fort -showme test.f > out"              cp -p $MPIINCLUDEDIR/$i ./mpi_headers
670  #       RETVAL=$?              if test $i = 'mpif.h' ; then
671  #       if test "x${RETVAL}" = x0 ; then                  perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h
672  #           a=`cat out`              fi
673  #           for i in $a ; do              if test $mkListInc = 2 ; then
674  #               case $i in                  LOCAL_MPI_HEADERS="$LOCAL_MPI_HEADERS ./mpi_headers/$i"
675  #                   -*)              fi
676  #                       mpi_libs="$mpi_libs $i" ;;              if test $mkListInc = 1 ; then
677  #               esac                  LOCAL_MPI_HEADERS="./mpi_headers/$i" ; mkListInc=2
678  #           done              fi
679  #           echo "The MPI libs appear to be:"            fi
680  #           echo "  "$mpi_libs          done
681  #       fi      else
682  #       rm -f test.f out          echo "WARNING: MPIINCLUDEDIR='$MPIINCLUDEDIR' is not a directory"
683  #     fi          echo "WARNING: => skip checking for MPI headers (no ./mpi_headers dir)"
684    #       exit -1
685        fi
686  }  }
687    
688  #  Parse the package dependency information  #  Parse the package dependency information
# Line 650  get_fortran_c_namemangling()  { Line 707  get_fortran_c_namemangling()  {
707    
708      #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""      #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
709      if test ! "x$FC_NAMEMANGLE" = x ; then      if test ! "x$FC_NAMEMANGLE" = x ; then
710          return 0          return 0
711      fi      fi
712      echo " running: get_fortran_c_namemangling()" >> $LOGFILE      echo " running: get_fortran_c_namemangling()" >> $LOGFILE
713    
# Line 947  check_netcdf_libs()  { Line 1004  check_netcdf_libs()  {
1004        program fgennc        program fgennc
1005  #include "netcdf.inc"  #include "netcdf.inc"
1006  EOF  EOF
1007      if test ! "x$MPI" = x ; then     #if test ! "x$MPI" = x ; then
1008          echo '#include "mpif.h"' >> genmake_tnc.F     #    echo '#include "mpif.h"' >> genmake_tnc.F
1009      fi     #fi
1010      cat <<EOF >> genmake_tnc.F      cat <<EOF >> genmake_tnc.F
1011        integer iret, ncid, xid        integer iret, ncid, xid
1012        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
# Line 1029  EOF Line 1086  EOF
1086      echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE      echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE
1087  }  }
1088    
1089    check_lapack_libs()  {
1090        if test "x$CHECK_FOR_LAPACK" = xf ; then return ; fi
1091        echo >> $LOGFILE
1092        echo "running: check_lapack_libs()" >> $LOGFILE
1093        cat <<EOF > genmake_tla.F
1094          program fgenla
1095          integer info
1096          integer ipiv( 2 )
1097          double precision ab( 4, 2 ), b( 2 )
1098          data ab / 0., 0., 1., 2., 0., 2., 1., 0. /
1099          data b / 1., 1. /
1100          call dgbsv( 2, 1, 1, 1, ab, 4, ipiv, b, 2, info )
1101          IF (info .NE. 0) write(*,*) 'Error:', info
1102          write(*,*) b
1103          end
1104    EOF
1105        echo "===  genmake_tla.F  >>>" > genmake_tla.log
1106        cat genmake_tla.F >> genmake_tla.log
1107        echo "<<<  genmake_tla.F  ===" >> genmake_tla.log
1108        RET_CPP=f
1109        COMM="cat genmake_tla.F | $CPP $DEFINES $INCLUDES"
1110        echo "$COMM" >> genmake_tla.log
1111        eval $COMM > genmake_tla.$FS 2>/dev/null  &&  RET_CPP=t
1112        if test "x$RET_CPP" = xf ; then
1113            echo "  WARNING: CPP failed to pre-process the lapack test." \
1114                >> genmake_tla.log
1115            echo "    Please check that \$INCLUDES is properly set." \
1116                >> genmake_tla.log
1117        fi
1118        echo "$FC $FFLAGS $FOPTIM -c genmake_tla.$FS  \ " >> genmake_tla.log
1119        echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tla.o $LIBS" >> genmake_tla.log
1120        $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1121            &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS >> genmake_tla.log 2>&1
1122        RET_COMPILE=$?
1123        cat genmake_tla.log >> $LOGFILE
1124    
1125        # test program execution not always possible (see check_netcdf_libs)
1126        #
1127        #test -x ./genmake_tla  &&  ./genmake_tla >> genmake_tla.log 2>&1
1128        #RETVAL=$?
1129        #if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
1130    
1131        if test "x$RET_COMPILE" = x0 ; then
1132            HAVE_LAPACK=t
1133            echo "check_lapack: successful" >> $LOGFILE
1134        else
1135            # try again with "-llapack" added to the libs
1136            echo "==> try again with added '-llapack'" > genmake_tla.log
1137            echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1138            echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1139            echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack" >> genmake_tla.log
1140            cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1141                &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1142                &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack >> genmake_tla.log 2>&1
1143            RET_COMPILE=$?
1144            echo >> $LOGFILE
1145            cat genmake_tla.log >> $LOGFILE
1146            if test "x$RET_COMPILE" = x0 ; then
1147                LIBS="$LIBS -llapack"
1148                HAVE_LAPACK=t
1149                echo "check_lapack: successful" >> $LOGFILE
1150            else
1151            # try again with "-lf77blas -lcblas" added to the libs
1152                echo "==> try again with added '-llapack -lf77blas -lcblas'" > genmake_tla.log
1153                echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1154                echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1155                echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas" >> genmake_tla.log
1156                cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1157                    &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1158                    &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas >> genmake_tla.log 2>&1
1159                RET_COMPILE=$?
1160                echo >> $LOGFILE
1161                cat genmake_tla.log >> $LOGFILE
1162                if test "x$RET_COMPILE" = x0 ; then
1163                    LIBS="$LIBS -llapack -lf77blas -lcblas"
1164                    HAVE_LAPACK=t
1165                    echo "check_lapack: successful" >> $LOGFILE
1166                else
1167                # try again with "-latlas" added to the libs
1168                    echo "==> try again with added '-llapack -lf77blas -lcblas -latlas'" > genmake_tla.log
1169                    echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1170                    echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1171                    echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas" >> genmake_tla.log
1172                    cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1173                        &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1174                        &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas >> genmake_tla.log 2>&1
1175                    RET_COMPILE=$?
1176                    echo >> $LOGFILE
1177                    cat genmake_tla.log >> $LOGFILE
1178                    if test "x$RET_COMPILE" = x0 ; then
1179                        LIBS="$LIBS -llapack -lf77blas -lcblas -latlas"
1180                        HAVE_LAPACK=t
1181                        echo "check_lapack: successful" >> $LOGFILE
1182                    fi
1183                fi
1184            fi
1185        fi
1186        rm -f genmake_tla*
1187        echo " --> set HAVE_LAPACK='$HAVE_LAPACK'" >> $LOGFILE
1188    }
1189    
1190    check_HAVE_FLUSH()  {
1191        if test ! "x$SKIP_CHECK_FLUSH" = x ; then
1192            return
1193        fi
1194        echo >> $LOGFILE
1195        echo "running: check_HAVE_FLUSH()" >> $LOGFILE
1196        cat <<EOF > genmake_tflsh.$FS
1197          program fgenflsh
1198          integer iounit
1199          character*9 fname
1200          iounit = 26
1201          fname = 'tmp.tflsh'
1202          open(iounit,FILE=fname,STATUS='unknown')
1203          write(iounit,*) 'genmake_tflsh: hello'
1204          call flush(iounit)
1205          close(iounit)
1206          end
1207    EOF
1208        echo "===  genmake_tflsh.$FS  >>>" > genmake_tflsh.log
1209        cat genmake_tflsh.$FS >> genmake_tflsh.log
1210        echo "<<<  genmake_tflsh.$FS  ===" >> genmake_tflsh.log
1211    
1212        echo "$FC $FFLAGS $FOPTIM -c genmake_tflsh.$FS  \ " >> genmake_tflsh.log
1213        echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tflsh.o $LIBS" >> genmake_tflsh.log
1214        $FC $FFLAGS $FOPTIM -c genmake_tflsh.$FS >> genmake_tflsh.log 2>&1  \
1215            &&  $LINK $FFLAGS $FOPTIM -o genmake_tflsh genmake_tflsh.o $LIBS >> genmake_tflsh.log 2>&1
1216        RET_COMPILE=$?
1217    
1218        if test "x$RET_COMPILE" = x0 ; then
1219            HAVE_FLUSH=t
1220            #cat genmake_tflsh.log >> $LOGFILE
1221            echo "  check_HAVE_FLUSH: successful" >> $LOGFILE
1222        else
1223            HAVE_FLUSH=f
1224            cat genmake_tflsh.log >> $LOGFILE
1225        fi
1226        rm -f genmake_tflsh*
1227        echo " --> set HAVE_FLUSH='$HAVE_FLUSH'" >> $LOGFILE
1228    }
1229    
1230  ###############################################################################  ###############################################################################
1231  #   Sequential part of script starts here  #   Sequential part of script starts here
# Line 1086  GSL= Line 1283  GSL=
1283  DEVEL=  DEVEL=
1284  HAVE_TEST_L=  HAVE_TEST_L=
1285    
1286    # set this to "t" to enable lapack test
1287    CHECK_FOR_LAPACK=f
1288    
1289  # DEFINES checked by test compilation or command-line  # DEFINES checked by test compilation or command-line
1290  HAVE_SYSTEM=  HAVE_SYSTEM=
1291  HAVE_FDATE=  HAVE_FDATE=
# Line 1096  HAVE_STAT= Line 1296  HAVE_STAT=
1296  HAVE_NETCDF=  HAVE_NETCDF=
1297  HAVE_ETIME=  HAVE_ETIME=
1298  IGNORE_TIME=  IGNORE_TIME=
1299    HAVE_LAPACK=
1300    HAVE_FLUSH=
1301    
1302  MODS=  MODS=
1303  TOOLSDIR=  TOOLSDIR=
# Line 1103  SOURCEDIRS= Line 1305  SOURCEDIRS=
1305  INCLUDEDIRS=  INCLUDEDIRS=
1306  STANDARDDIRS="USE_THE_DEFAULT"  STANDARDDIRS="USE_THE_DEFAULT"
1307    
1308    #- local config file
1309    gm_local="genmake_local"
1310    
1311  G2ARGS=  G2ARGS=
1312  BASH=  BASH=
1313  PWD=`pwd`  PWD=`pwd`
# Line 1126  FS= Line 1331  FS=
1331  FS90=  FS90=
1332    
1333  AUTODIFF_PKG_USED=f  AUTODIFF_PKG_USED=f
1334    OPENAD=
1335    OPENAD_DIVA=
1336  AD_OPTFILE=  AD_OPTFILE=
1337    CAT_SRC_FOR_TAF=1
1338  TAF=  TAF=
1339  AD_TAF_FLAGS=  AD_TAF_FLAGS=
1340  FTL_TAF_FLAGS=  FTL_TAF_FLAGS=
# Line 1138  FTL_TAF_FLAGS= Line 1346  FTL_TAF_FLAGS=
1346  SVD_TAMC_FLAGS=  SVD_TAMC_FLAGS=
1347  TAMC_EXTRA=  TAMC_EXTRA=
1348    
1349    DIVA=
1350    MPIINCLUDEDIR=
1351    MPI_HEADER_FILES=
1352    LOCAL_MPI_HEADERS=
1353    
1354  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1355  gm_s1="OPTFILE PKG_DEPEND PKG_GROUPS DISABLE ENABLE MAKEFILE MAKEDEPEND PLATFORM"  gm_s1="ROOTDIR STANDARDDIRS MODS PKG_DEPEND PKG_GROUPS DISABLE ENABLE"
1356  gm_s2="FC CC MPI OMP USE_R4 TS PAPIS PCLS PAPI PCL HPMT IEEE DEVEL GSL FEXTRAFLAGS"  gm_s2="PLATFORM OPTFILE MAKE MAKEFILE MAKEDEPEND FC CC MPI OMP USE_R4"
1357  gm_s3="ROOTDIR STANDARDDIRS MODS DUMPSTATE"  gm_s3="FEXTRAFLAGS IEEE DEVEL GSL TS PAPIS PCLS PAPI PCL HPMT DUMPSTATE"
1358    
1359  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1360  gm_s4="LN S64 LINK MAKE PACKAGES INCLUDES FFLAGS FOPTIM"  gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM"
1361  gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
1362  gm_s6="TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"  gm_s6="PWD TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"
1363  gm_s7="PWD THISHOST THISUSER THISDATE THISVER MACHINE"  gm_s7="TMP THISHOST THISUSER THISDATE THISVER MACHINE FC_NAMEMANGLE"
1364  gm_s8="FC_NAMEMANGLE HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME"  gm_s8="HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME HAVE_LAPACK HAVE_FLUSH"
1365    
1366  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1367  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"
1368  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"
1369  gm_s12="TAF_EXTRA TAMC_EXTRA"  gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES"
1370    
1371  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8"  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8"
1372  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
# Line 1174  LOGFILE="genmake.log" Line 1387  LOGFILE="genmake.log"
1387  rm -f genmake_state genmake_*optfile $LOGFILE  rm -f genmake_state genmake_*optfile $LOGFILE
1388    
1389  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  
1390    
1391  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
1392  #parse_options  #parse_options
# Line 1202  for ac_option in "$@" ; do Line 1405  for ac_option in "$@" ; do
1405      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
1406    
1407      case $ac_option in      case $ac_option in
1408            
1409          -help | --help | -h | --h)          -help | --help | -h | --h)
1410              usage ;;              usage ;;
1411            
1412          -nooptfile | --nooptfile)          -nooptfile | --nooptfile)
1413              OPTFILE="NONE" ;;              OPTFILE="NONE" ;;
1414          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
1415              ac_prev=OPTFILE ;;              ac_prev=OPTFILE ;;
1416          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
1417              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
1418            
1419            -oad | --oad)
1420                OPENAD="true" ; ALWAYS_USE_F90=1 ;;
1421            -nocat4ad | -dog4ad | -ncad | -dad)
1422                CAT_SRC_FOR_TAF=0 ;;
1423          -adoptfile | --adoptfile | -adof | --adof)          -adoptfile | --adoptfile | -adof | --adof)
1424              ac_prev=AD_OPTFILE ;;              ac_prev=AD_OPTFILE ;;
1425          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
1426              AD_OPTFILE=$ac_optarg ;;              AD_OPTFILE=$ac_optarg ;;
1427            
1428            -diva | --diva)
1429                OPENAD_DIVA="ALLOW_OPENAD_DIVA=" ;;
1430    
1431          -pdepend | --pdepend)          -pdepend | --pdepend)
1432              ac_prev=PKG_DEPEND ;;              ac_prev=PKG_DEPEND ;;
1433          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
1434              PKG_DEPEND=$ac_optarg ;;              PKG_DEPEND=$ac_optarg ;;
1435            
1436          -pgroups | --pgroups)          -pgroups | --pgroups)
1437              ac_prev=PKG_GROUPS ;;              ac_prev=PKG_GROUPS ;;
1438          -pgroups=* | --pgroups=*)          -pgroups=* | --pgroups=*)
1439              PKG_GROUPS=$ac_optarg ;;              PKG_GROUPS=$ac_optarg ;;
1440            
1441          -make | --make | -m | --m)          -make | --make | -m | --m)
1442              ac_prev=MAKE ;;              ac_prev=MAKE ;;
1443          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
1444              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
1445            
1446          -bash | --bash)          -bash | --bash)
1447              ac_prev=BASH ;;              ac_prev=BASH ;;
1448          -bash=* | --bash=*)          -bash=* | --bash=*)
1449              BASH=$ac_optarg ;;              BASH=$ac_optarg ;;
1450            
1451          -makedepend | --makedepend | -md | --md)          -makedepend | --makedepend | -md | --md)
1452              ac_prev=MAKEDEPEND ;;              ac_prev=MAKEDEPEND ;;
1453          -makedepend=* | --makedepend=* | -md=* | --md=*)          -makedepend=* | --makedepend=* | -md=* | --md=*)
1454              MAKEDEPEND=$ac_optarg ;;              MAKEDEPEND=$ac_optarg ;;
1455            
1456          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -mf | --mf)
1457              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
1458          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -mf=* | --mf=*)
1459              MAKEFILE=$ac_optarg ;;              MAKEFILE=$ac_optarg ;;
1460            
1461          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)
1462              echo "ERROR: The platform option has been removed.  Please specify"              echo "ERROR: The platform option has been removed.  Please specify"
1463              echo "  the build options using the \"optfile\" mechanism."              echo "  the build options using the \"optfile\" mechanism."
1464              echo              echo
1465              usage              usage
1466              ;;              ;;
1467            
1468          -rootdir | --rootdir | -rd | --rd)          -rootdir | --rootdir | -rd | --rd)
1469              ac_prev=ROOTDIR ;;              ac_prev=ROOTDIR ;;
1470          -rootdir=* | --rootdir=* | -rd=* | --rd=*)          -rootdir=* | --rootdir=* | -rd=* | --rd=*)
1471              ROOTDIR=$ac_optarg ;;              ROOTDIR=$ac_optarg ;;
1472            
1473          -mods | --mods | -mo | --mo)          -mods | --mods | -mo | --mo)
1474              ac_prev=MODS ;;              ac_prev=MODS ;;
1475          -mods=* | --mods=* | -mo=* | --mo=*)          -mods=* | --mods=* | -mo=* | --mo=*)
1476              MODS=$ac_optarg ;;              MODS=$ac_optarg ;;
1477            
1478          -disable | --disable)          -disable | --disable)
1479              ac_prev=DISABLE ;;              ac_prev=DISABLE ;;
1480          -disable=* | --disable=*)          -disable=* | --disable=*)
1481              DISABLE=$ac_optarg ;;              DISABLE=$ac_optarg ;;
1482            
1483          -enable | --enable)          -enable | --enable)
1484              ac_prev=ENABLE ;;              ac_prev=ENABLE ;;
1485          -enable=* | --enable=*)          -enable=* | --enable=*)
1486              ENABLE=$ac_optarg ;;              ENABLE=$ac_optarg ;;
1487            
1488          -standarddirs | --standarddirs)          -standarddirs | --standarddirs)
1489              ac_prev=STANDARDDIRS ;;              ac_prev=STANDARDDIRS ;;
1490          -standarddirs=* | --standarddirs=*)          -standarddirs=* | --standarddirs=*)
# Line 1284  for ac_option in "$@" ; do Line 1494  for ac_option in "$@" ; do
1494  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1495  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1496  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1497            
1498          -cc | --cc)          -cc | --cc)
1499              ac_prev=CC ;;              ac_prev=CC ;;
1500          -cc=* | --cc=*)          -cc=* | --cc=*)
1501              CC=$ac_optarg ;;              CC=$ac_optarg ;;
1502            
1503          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1504              ac_prev=FC ;;              ac_prev=FC ;;
1505          -fc=* | --fc=*)          -fc=* | --fc=*)
1506              FC=$ac_optarg ;;              FC=$ac_optarg ;;
1507            
1508          -fs | --fs)          -fs | --fs)
1509              ac_prev=FS ;;              ac_prev=FS ;;
1510          -fs=* | --fs=*)          -fs=* | --fs=*)
1511              FS=$ac_optarg ;;              FS=$ac_optarg ;;
1512            
1513          -fs90 | --fs90)          -fs90 | --fs90)
1514              ac_prev=FS90 ;;              ac_prev=FS90 ;;
1515          -fs90=* | --fs90=*)          -fs90=* | --fs90=*)
1516              FS90=$ac_optarg ;;              FS90=$ac_optarg ;;
1517            
1518          -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )          -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )
1519              USE_R4=true ;;              USE_R4=true ;;
1520    
# Line 1312  for ac_option in "$@" ; do Line 1522  for ac_option in "$@" ; do
1522              IEEE=true ;;              IEEE=true ;;
1523          -noieee | --noieee)          -noieee | --noieee)
1524              echo "Warning: ignore option '$ac_option' (default is already without '-ieee')" ;;              echo "Warning: ignore option '$ac_option' (default is already without '-ieee')" ;;
1525          -devel | --devel)          -devel | --devel)
1526              IEEE=true ; DEVEL=true ;;              IEEE=true ; DEVEL=true ;;
1527          -gsl | --gsl)          -gsl | --gsl)
1528              GSL=true ;;              GSL=true ;;
1529    
1530          -ts | --ts)          -ts | --ts)
# Line 1337  for ac_option in "$@" ; do Line 1547  for ac_option in "$@" ; do
1547          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
1548              MPIPATH=$ac_optarg              MPIPATH=$ac_optarg
1549              MPI=true ;;              MPI=true ;;
1550            
1551          -omp | --omp)          -omp | --omp)
1552              OMP=true ;;              OMP=true ;;
1553          -omp=* | --omp=*)          -omp=* | --omp=*)
1554              OMPFLAG=$ac_optarg              OMPFLAG=$ac_optarg
1555              OMP=true ;;              OMP=true ;;
1556            
1557          -ds | --ds)          -ds | --ds)
1558              DUMPSTATE=t ;;              DUMPSTATE=t ;;
1559            
1560          -extra_flag | --extra_flag)          -extra_flag | --extra_flag)
1561              ac_prev=FEXTRAFLAGS ;;              ac_prev=FEXTRAFLAGS ;;
1562          -extra_flag=* | --extra_flag=*)          -extra_flag=* | --extra_flag=*)
1563              FEXTRAFLAGS=$ac_optarg ;;              FEXTRAFLAGS=$ac_optarg ;;
1564            
1565          -taf_extra | --taf_extra)          -taf_extra | --taf_extra)
1566              ac_prev=TAF_EXTRA ;;              ac_prev=TAF_EXTRA ;;
1567          -taf_extra=* | --taf_extra=*)          -taf_extra=* | --taf_extra=*)
# Line 1361  for ac_option in "$@" ; do Line 1571  for ac_option in "$@" ; do
1571              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1572          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1573              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1574            
1575          -ignoretime | -ignore_time | --ignoretime | --ignore_time)          -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1576              IGNORE_TIME="-DIGNORE_TIME" ;;              IGNORE_TIME="-DIGNORE_TIME" ;;
1577    
# Line 1372  for ac_option in "$@" ; do Line 1582  for ac_option in "$@" ; do
1582              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
1583              usage              usage
1584              ;;              ;;
1585            
1586          *)          *)
1587              echo "Error: unrecognized argument: "$ac_option              echo "Error: unrecognized argument: "$ac_option
1588              usage              usage
1589              ;;              ;;
1590            
1591      esac      esac
1592    
1593  done  done
1594    
1595    #TMP=./genmk_$$
1596    #- try to put temporary files in system-local /tmp dir
1597    TMP=/tmp/genmk_${USER}_$$
1598    touch $TMP ; retVal=$?
1599    if [ $retVal -eq 0 ] ; then
1600      if test ! -r $TMP ; then TMP=./genmk_$$ ; fi
1601    else
1602      TMP=./genmk_$$
1603    fi
1604    rm -f $TMP
1605    #echo "  temp files: $TMP.*"
1606    
1607    printf "  getting local config information:  "
1608    if test -f $gm_local ; then
1609        echo "using $gm_local"
1610        . $gm_local
1611    else
1612        echo "none found"
1613    fi
1614    
1615  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1616      echo      echo
1617      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
# Line 1466  fi Line 1696  fi
1696    
1697  echo "  getting AD_OPTFILE information:"  echo "  getting AD_OPTFILE information:"
1698  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1699      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" != x ; then
1700            AD_OPTFILE=$MITGCM_AD_OF
1701        elif test "x$OPENAD" = x ; then
1702          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
1703      else      else
1704          AD_OPTFILE=$MITGCM_AD_OF          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_oad
1705      fi      fi
1706  fi  fi
1707  if test "x${AD_OPTFILE}" != xNONE ; then  if test "x${AD_OPTFILE}" != xNONE ; then
# Line 1593  check_for_broken_Ff Line 1825  check_for_broken_Ff
1825    
1826  if test ! "x$MPI" = x ; then  if test ! "x$MPI" = x ; then
1827        echo "  Turning on MPI cpp macros"        echo "  Turning on MPI cpp macros"
1828        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI"
1829    #- To compile code older than checkpoint63s (2012/09/05), un-comment the following line:
1830    #     DEFINES="$DEFINES -DALWAYS_USE_MPI"
1831  fi  fi
1832  if test ! "x$OMP" = x ; then  if test ! "x$OMP" = x ; then
1833        echo "  Add OMPFLAG and turn on OpenMP cpp macros"        echo "  Add OMPFLAG and turn on OpenMP cpp macros"
# Line 1610  fi Line 1844  fi
1844  if test ! "x$TS" = x ; then  if test ! "x$TS" = x ; then
1845        echo "  Turning on timing per timestep"        echo "  Turning on timing per timestep"
1846        if test ! "x$FOOLAD" = x ; then        if test ! "x$FOOLAD" = x ; then
1847              DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"
1848        else        else
1849              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1850        fi        fi
# Line 1646  if test ! "x$PAPI" = x ; then Line 1880  if test ! "x$PAPI" = x ; then
1880            echo "  Sticking with PAPI flop summary per timestep!"            echo "  Sticking with PAPI flop summary per timestep!"
1881        else        else
1882            echo "  Turning on performance analysis with PAPI"            echo "  Turning on performance analysis with PAPI"
1883            echo "  Please make sure PAPIINC, PAPILIB are defined"            echo "  Please make sure PAPIINC, PAPILIB are defined"
1884            DEFINES="$DEFINES -DUSE_PAPI"            DEFINES="$DEFINES -DUSE_PAPI"
1885            INCLUDES="$INCLUDES $PAPIINC"            INCLUDES="$INCLUDES $PAPIINC"
1886            LIBS="$LIBS $PAPILIB"            LIBS="$LIBS $PAPILIB"
# Line 1658  if test ! "x$PCL" = x ; then Line 1892  if test ! "x$PCL" = x ; then
1892            echo "  Sticking with PCL flop summary per timestep!"            echo "  Sticking with PCL flop summary per timestep!"
1893        else        else
1894            echo "  Turning on performance analysis with PCL"            echo "  Turning on performance analysis with PCL"
1895            echo "  Please make sure PCLINC, PCLLIB are defined"            echo "  Please make sure PCLINC, PCLLIB are defined"
1896            DEFINES="$DEFINES -DUSE_PCL"            DEFINES="$DEFINES -DUSE_PCL"
1897            INCLUDES="$INCLUDES $PCLINC"            INCLUDES="$INCLUDES $PCLINC"
1898            LIBS="$LIBS $PCLLIB"            LIBS="$LIBS $PCLLIB"
# Line 1668  if test ! "x$HPMT" = x ; then Line 1902  if test ! "x$HPMT" = x ; then
1902        if test ! "x$PAPI" = x ; then        if test ! "x$PAPI" = x ; then
1903            echo "  PAPI and the HPM Toolkit cannot co-exist!"            echo "  PAPI and the HPM Toolkit cannot co-exist!"
1904            echo "  Sticking with PAPI!"            echo "  Sticking with PAPI!"
1905        else if test ! "x$PCL" = x ; then        else
1906            if test ! "x$PCL" = x ; then
1907            echo "  PCL and the HPM Toolkit cannot co-exist!"            echo "  PCL and the HPM Toolkit cannot co-exist!"
1908            echo "  Sticking with PCL!"            echo "  Sticking with PCL!"
1909        else          else
1910            echo "  Turning on performance analysis with the HPM Toolkit"            echo "  Turning on performance analysis with the HPM Toolkit"
1911            echo "  Please make sure HPMTINC, HPMTLIB are defined"            echo "  Please make sure HPMTINC, HPMTLIB are defined"
1912            DEFINES="$DEFINES -DUSE_LIBHPM"            DEFINES="$DEFINES -DUSE_LIBHPM"
1913            INCLUDES="$INCLUDES $HPMTINC"            INCLUDES="$INCLUDES $HPMTINC"
1914            LIBS="$LIBS $HPMTLIB"            LIBS="$LIBS $HPMTLIB"
1915        fi          fi
1916        fi        fi
1917  fi  fi
1918  if test ! "x$GSL" = x ; then  if test ! "x$GSL" = x ; then
# Line 1808  if test "x$HAVE_NETCDF" != x ; then Line 2043  if test "x$HAVE_NETCDF" != x ; then
2043  else  else
2044      echo "no"      echo "no"
2045  fi  fi
 DEFINES="$DEFINES $IGNORE_TIME"  
2046    
2047    printf "  Can we create LAPACK-enabled binaries...  "
2048    check_lapack_libs
2049    if test "x$HAVE_LAPACK" != x ; then
2050        DEFINES="$DEFINES -DHAVE_LAPACK"
2051        echo "yes"
2052    else
2053        echo "no"
2054    fi
2055    
2056    printf "  Can we call FLUSH intrinsic subroutine...  "
2057    check_HAVE_FLUSH
2058    if test "x$HAVE_FLUSH" = xt ; then
2059        DEFINES="$DEFINES -DHAVE_FLUSH"
2060        echo "yes"
2061    else
2062        echo "no"
2063    fi
2064    
2065    DEFINES="$DEFINES $IGNORE_TIME"
2066  if test "x$EMBED_SRC" = xt ; then  if test "x$EMBED_SRC" = xt ; then
2067      build_embed_encode      build_embed_encode
2068  fi  fi
# Line 1993  else Line 2246  else
2246          exit 1          exit 1
2247      else      else
2248          echo "    using PKG_LIST=\"$PKG_LIST\""          echo "    using PKG_LIST=\"$PKG_LIST\""
2249          #  Strip the comments and add all the names          #  Strip the comments and add all the names
2250          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}'`
2251          RETVAL=$?          RETVAL=$?
2252          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
# Line 2014  if test "x${PKG_GROUPS}" != x ; then Line 2267  if test "x${PKG_GROUPS}" != x ; then
2267  fi  fi
2268    
2269  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
2270  echo "" > ./.tmp_pack  echo "" > $TMP.pack
2271  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2272      echo $i >> ./.tmp_pack      echo $i >> $TMP.pack
2273  done  done
2274  for i in `grep  "-" ./.tmp_pack` ; do  for i in `grep  "-" $TMP.pack` ; do
2275      j=`echo $i | sed 's/[-]//'`      j=`echo $i | sed 's/[-]//'`
2276      DISABLE="$DISABLE $j"      DISABLE="$DISABLE $j"
2277  done  done
# Line 2036  for p in $PACKAGES ; do Line 2289  for p in $PACKAGES ; do
2289  done  done
2290  PACKAGES="$pack"  PACKAGES="$pack"
2291  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
2292  echo "" > ./.tmp_pack  echo "" > $TMP.pack
2293  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
2294  # Test if each explicitly referenced package exists  # Test if each explicitly referenced package exists
2295  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2296      j=`echo $i | sed 's/[-+]//'`      j=`echo $i | sed 's/[-+]//'`
2297      if test ! -d "$ROOTDIR/pkg/$j" ; then      if test ! -d "$ROOTDIR/pkg/$j" ; then
2298          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
2299          exit 1          exit 1
2300      fi      fi
2301      echo $i >> ./.tmp_pack      echo $i >> $TMP.pack
2302  done  done
2303  PACKAGES=  PACKAGES=
2304  for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do  for i in `grep -v "-" $TMP.pack | sort | uniq` ; do
2305      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
2306  done  done
2307  rm -f ./.tmp_pack  rm -f $TMP.pack
2308  echo "    packages are: $PACKAGES"  echo "    packages are: $PACKAGES"
2309    
2310  #  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 2088  else Line 2341  else
2341          echo "Error: problem encountered while building source files in pkg/mnc:"          echo "Error: problem encountered while building source files in pkg/mnc:"
2342          cat make_mnc.errors 1>&2          cat make_mnc.errors 1>&2
2343          if test "x$mnc_in" = x0 ; then          if test "x$mnc_in" = x0 ; then
2344              exit 1              exit 1
2345          else          else
2346              DISABLE="$DISABLE mnc"              DISABLE="$DISABLE mnc"
2347          fi          fi
# Line 2121  EOF Line 2374  EOF
2374      fi      fi
2375  fi  fi
2376    
2377    #  Make sure the openad package is enabled if using OpenAD
2378    if test "x$OPENAD" != x ; then
2379        echo " $PACKAGES " | grep ' openad ' > /dev/null 2>&1
2380        RETVAL=$?
2381        if test "x$RETVAL" != x0 ; then
2382            cat <<EOF
2383    
2384    *********************************************************************
2385    ERROR: when generating an adjoint with OpenAD, the openad package
2386      must be enabled.  Please add it to packages.conf.
2387    *********************************************************************
2388    
2389    EOF
2390            exit 1
2391        fi
2392    fi
2393    
2394  if  test "x${PKG_DEPEND}" != x ; then  if  test "x${PKG_DEPEND}" != x ; then
2395    echo "  applying package dependency rules"    echo "  applying package dependency rules"
2396    ck=    ck=
# Line 2166  if  test "x${PKG_DEPEND}" != x ; then Line 2436  if  test "x${PKG_DEPEND}" != x ; then
2436    
2437          #  Do we need to add $dname according to the dependency rules?          #  Do we need to add $dname according to the dependency rules?
2438          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
2439              #echo "   " $pname ": need to add :" $dname              #echo "   " $pname ": need to add :" $dname
2440              in_dis="f"              in_dis="f"
2441              for dis in $DISABLE ; do              for dis in $DISABLE ; do
2442                  if test "x$dis" = "x$dname" ; then                  if test "x$dis" = "x$dname" ; then
# Line 2191  if  test "x${PKG_DEPEND}" != x ; then Line 2461  if  test "x${PKG_DEPEND}" != x ; then
2461              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
2462              exit 1              exit 1
2463          fi          fi
2464          i=`echo "$i + 1" | bc -l`          i=`echo "$i + 1" | bc -l`
2465          #i=$(( $i + 1 ))          #i=$(( $i + 1 ))
2466      done      done
2467      ck=$ck"t"      ck=$ck"t"
# Line 2232  for n in $names ; do Line 2502  for n in $names ; do
2502          done          done
2503          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
2504              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
2505              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
2506          fi          fi
2507      fi      fi
2508  done  done
# Line 2245  for i in $PACKAGES ; do Line 2515  for i in $PACKAGES ; do
2515  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
2516      case $i in      case $i in
2517          aim_v23)          aim_v23)
2518              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
2519              echo "Warning: ALLOW_AIM is set to enable aim_v23."              echo "Warning: ALLOW_AIM is set to enable aim_v23."
2520              ;;              ;;
2521      esac      esac
# Line 2287  for i in $spaths ; do Line 2557  for i in $spaths ; do
2557      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
2558          echo "    found CPP_OPTIONS=\"$try\""          echo "    found CPP_OPTIONS=\"$try\""
2559          CPP_OPTIONS="$try"          CPP_OPTIONS="$try"
2560          # 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
2561          for n in $names ; do          for n in $names ; do
2562              test_for_package_in_cpp_options $CPP_OPTIONS $n              test_for_package_in_cpp_options $CPP_OPTIONS $n
2563          done          done
2564      fi      fi
2565      try="$i/CPP_EEOPTIONS.h"      try="$i/CPP_EEOPTIONS.h"
2566      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
2567          echo "    found CPP_EEOPTIONS=\"$try\""          echo "    found CPP_EEOPTIONS=\"$try\""
2568          # 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
2569  #**** not yet enabled ****  #**** not yet enabled ****
2570  #        test_for_mpi_in_cpp_eeoptions $try  #        test_for_mpi_in_cpp_eeoptions $try
2571  #**** not yet enabled ****  #**** not yet enabled ****
# Line 2309  fi Line 2579  fi
2579    
2580  #  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
2581  #  compiler.  #  compiler.
2582  if test -f ./adSrcFiles.tmp ; then  if test -f $TMP.adSrcFiles ; then
2583      rm -f ./adSrcFiles.tmp      rm -f $TMP.adSrcFiles
2584  fi  fi
2585  echo "  Creating the list of files for the adjoint compiler."  echo "  Creating the list of files for the adjoint compiler."
2586  touch adSrcFiles.tmp  touch $TMP.adSrcFiles
2587  for i in $SOURCEDIRS ; do  for i in $SOURCEDIRS ; do
2588      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2589      for j in $list_files ; do      for j in $list_files ; do
2590          cat $i/$j >> adSrcFiles.tmp          cat $i/$j >> $TMP.adSrcFiles
2591      done      done
2592  done  done
2593  if test ! "x"$FS = "x.f" ; then  if test ! "x"$FS = "x.f" ; then
2594      cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f      cat $TMP.adSrcFiles | sed -e "s/\.f/.$FS/g" > $TMP.adSrcFiles_f
2595      mv -f adSrcFiles.tmp_f adSrcFiles.tmp      mv -f $TMP.adSrcFiles_f $TMP.adSrcFiles
2596  fi  fi
2597    
2598  echo  echo
# Line 2334  for i in $INCLUDEDIRS ; do Line 2604  for i in $INCLUDEDIRS ; do
2604      fi      fi
2605  done  done
2606    
2607  if test ! "x$DIVA" = x ; then  if test ! "x$DIVA" = x -a ! "x$MPI" = x ; then
2608      echo "  Creating the pseudo-MPI include directory"      if test ! "x$MPIINCLUDEDIR" = x ; then
2609      INCLUDES="-I./mpi_headers $INCLUDES"          #  Do a local copy of MPI headers files (in local dir ./mpi_headers/) after
2610      rm -rf ./mpi_headers          #   checking for additional included headers (in case of chain of included
2611      mkdir -p ./mpi_headers          #   header); also set LOCAL_MPI_HEADERS (if not already set)
2612            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  
2613      fi      fi
2614  fi  fi
2615    
2616  echo "  Determining the list of source and include files"  echo "  Determining the list of source and include files"
2617  rm -rf .links.tmp  rm -rf $TMP.links
2618  mkdir .links.tmp  mkdir $TMP.links
2619  touch .links.tmp/foo  touch $TMP.links/foo
2620  if test ! -r ".links.tmp/foo" ; then  if test ! -r "$TMP.links/foo" ; then
2621      echo      echo
2622      echo "ERROR : something is wrong with your directory permissions or"      echo "ERROR : something is wrong with your directory permissions or"
2623      echo "   your user file-creation mask (\"umask\") since creating a"      echo "   your user file-creation mask (\"umask\") since creating a"
# Line 2379  if test ! -r ".links.tmp/foo" ; then Line 2633  if test ! -r ".links.tmp/foo" ; then
2633      echo      echo
2634      exit 1      exit 1
2635  fi  fi
2636  rm -f .links.tmp/foo  rm -f $TMP.links/foo
2637    
2638  if test "x$OPENAD" != x ; then  if test "x$OPENAD" != x ; then
2639      OAD_DONT_COMPILE="/dev/null"      OAD_DONT_COMPILE="/dev/null"
2640      OAD_DONT_TRANSFORM="/dev/null"      OAD_DONT_TRANSFORM="/dev/null"
2641      OAD_KEEP_ORIGINAL="/dev/null"      OAD_KEEP_ORIGINAL="/dev/null"
2642      OAD_CB2M_FILES="/dev/null"      OAD_CB2M_FILES="/dev/null"
2643        OADTOOLS="$TOOLSDIR/OAD_support"
2644      echo "  looking for dontCompile file:  "      echo "  looking for dontCompile file:  "
2645      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2646          if test -r $i"/dontCompile" ; then          if test -r $i"/dontCompile" ; then
2647              OAD_DONT_COMPILE=$i"/dontCompile"              OAD_DONT_COMPILE=$i"/dontCompile"
2648              echo "     found $OAD_DONT_COMPILE"              echo "     found $OAD_DONT_COMPILE"
# Line 2395  if test "x$OPENAD" != x ; then Line 2650  if test "x$OPENAD" != x ; then
2650          fi          fi
2651      done      done
2652      echo "  looking for dontTransform file:  "      echo "  looking for dontTransform file:  "
2653      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2654          if test -r $i"/dontTransform" ; then          if test -r $i"/dontTransform" ; then
2655              OAD_DONT_TRANSFORM=$i"/dontTransform"              OAD_DONT_TRANSFORM=$i"/dontTransform"
2656              echo "     found $OAD_DONT_TRANSFORM"              echo "     found $OAD_DONT_TRANSFORM"
# Line 2403  if test "x$OPENAD" != x ; then Line 2658  if test "x$OPENAD" != x ; then
2658          fi          fi
2659      done      done
2660      echo "  looking for keepOriginal file:  "      echo "  looking for keepOriginal file:  "
2661      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2662          if test -r $i"/keepOriginal" ; then          if test -r $i"/keepOriginal" ; then
2663              OAD_KEEP_ORIGINAL=$i"/keepOriginal"              OAD_KEEP_ORIGINAL=$i"/keepOriginal"
2664              echo "     found $OAD_KEEP_ORIGINAL"              echo "     found $OAD_KEEP_ORIGINAL"
# Line 2411  if test "x$OPENAD" != x ; then Line 2666  if test "x$OPENAD" != x ; then
2666          fi          fi
2667      done      done
2668      echo "  looking for cb2mFiles:  "      echo "  looking for cb2mFiles:  "
2669      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2670          if test -r $i"/cb2mFiles" ; then          if test -r $i"/cb2mFiles" ; then
2671              OAD_CB2M_FILES=$i"/cb2mFiles"              OAD_CB2M_FILES=$i"/cb2mFiles"
2672              echo "     found $OAD_CB2M_FILES"              echo "     found $OAD_CB2M_FILES"
# Line 2421  if test "x$OPENAD" != x ; then Line 2676  if test "x$OPENAD" != x ; then
2676      echo "   OpenAD exceptions:  "      echo "   OpenAD exceptions:  "
2677  fi  fi
2678    
2679  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > $TMP.srclinks
2680  echo "" >> srclinks.tmp  echo "" >> $TMP.srclinks
2681  printf 'F77_SRC_FILES = ' > F77srclist.tmp  printf 'F77_SRC_FILES = ' > $TMP.F77srclist
2682  printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp  printf 'NON_AD_F77_SRC_FILES = ' > $TMP.nonADF77srclist
2683  printf 'C_SRC_FILES = '   > csrclist.tmp  printf 'C_SRC_FILES = '   > $TMP.csrclist
2684  printf 'F90_SRC_FILES = ' > F90srclist.tmp  printf 'F90_SRC_FILES = ' > $TMP.F90srclist
2685  printf 'H_SRC_FILES = '   > hsrclist.tmp  printf 'H_SRC_FILES = '   > $TMP.hsrclist
2686  printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp  printf 'AD_FLOW_FILES = ' > $TMP.ad_flow_files
2687  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2688  for d in $alldirs ; do  for d in $alldirs ; do
2689      deplist=      deplist=
# Line 2438  for d in $alldirs ; do Line 2693  for d in $alldirs ; do
2693          sfiles=`( echo $sfiles | grep -v _cb2m\. )`          sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2694      fi      fi
2695      for sf in $sfiles ; do      for sf in $sfiles ; do
2696          if test ! -r ".links.tmp/$sf" ; then          if test ! -r "$TMP.links/$sf" ; then
2697              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2698                  ignore_f=f                  ignore_f=f
2699                  case $d/$sf in                  case $d/$sf in
2700                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
2701                          ignore_f=t                          ignore_f=t
2702                          ;;                          ;;
2703                    ./AD_CONFIG.h)                    ./AD_CONFIG.h)
2704                          ignore_f=t                          ignore_f=t
2705                          ;;                          ;;
2706                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
2707                          ignore_f=t                          ignore_f=t
2708                          ;;                          ;;
2709                    ./BUILD_INFO.h)                    ./BUILD_INFO.h)
2710                          ignore_f=t                          ignore_f=t
2711                          ;;                          ;;
2712                    ./EMBEDDED_FILES.h)                    ./EMBEDDED_FILES.h)
2713                          ignore_f=t                          ignore_f=t
2714                          ;;                          ;;
2715                    *)                    *)
2716                          #  For the local directory *ONLY*,                          #  For the local directory *ONLY*,
2717                          #  ignore all soft-links                          #  ignore all soft-links
2718                          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
2719                              ignore_f=t                              ignore_f=t
2720                          else                          else
2721                              touch .links.tmp/$sf                              touch $TMP.links/$sf
2722                              deplist="$deplist $sf"                              deplist="$deplist $sf"
2723                          fi                          fi
2724                          ;;                          ;;
2725                  esac                  esac
2726                  if test "x$ignore_f" = xf ; then                  if test "x$ignore_f" = xf ; then
2727                      extn=`echo $sf | $AWK -F. '{print $NF}'`                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2728                      case $extn in                      case $extn in
2729                        F)                        F)
2730                          echo    " \\"  >> F77srclist.tmp                          echo    " \\"  >> $TMP.F77srclist
2731                          printf " $sf" >> F77srclist.tmp                          printf " $sf" >> $TMP.F77srclist
2732                          if test "x$OPENAD" != x ; then                          if test "x$OPENAD" = x ; then
2733                                basename=${sf%%.F}
2734                                isAD=`egrep ^$basename.f'[  ]*' $TMP.adSrcFiles`
2735                                if test -z "$isAD" ; then
2736                                    echo    " \\"  >> $TMP.nonADF77srclist
2737                                    printf " $sf" >> $TMP.nonADF77srclist
2738                                fi
2739                            else #- OpenAD case:
2740                              basename=${sf%%.F}                              basename=${sf%%.F}
2741                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`                              isAD=`egrep ^$basename.f'[  ]*' $TMP.adSrcFiles`
2742                              if test -z "$isAD" ; then                              if test -z "$isAD" ; then
2743                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`
2744                                  if test -z "$toBeIgnored" ; then                                  if test -z "$toBeIgnored" ; then
2745                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> $TMP.nonADF77srclist
2746                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> $TMP.nonADF77srclist
2747                                  else                                  else
2748                                      echo "    not to be compiled   :  $sf"                                      echo "    not to be compiled   :  $sf"
2749                                  fi                                  fi
# Line 2496  for d in $alldirs ; do Line 2758  for d in $alldirs ; do
2758                                      echo "    original to be kept  :  $sf"                                      echo "    original to be kept  :  $sf"
2759                                  fi                                  fi
2760                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2761                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> $TMP.nonADF77srclist
2762                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> $TMP.nonADF77srclist
2763                                  fi                                  fi
2764                              fi                              fi
2765                          fi                          fi
2766                          ;;                          ;;
2767                      F90)                      F90)
2768                          echo    " \\"  >> F90srclist.tmp                          echo    " \\"  >> $TMP.F90srclist
2769                          printf " $sf" >> F90srclist.tmp                          printf " $sf" >> $TMP.F90srclist
2770                          ;;                          ;;
2771                      c)                      c)
2772                          echo    " \\"  >> csrclist.tmp                          echo    " \\"  >> $TMP.csrclist
2773                          printf " $sf" >> csrclist.tmp                          printf " $sf" >> $TMP.csrclist
2774                          ;;                          ;;
2775                      h)                      h)
2776                          echo    " \\"  >> hsrclist.tmp                          echo    " \\"  >> $TMP.hsrclist
2777                          printf " $sf" >> hsrclist.tmp                          printf " $sf" >> $TMP.hsrclist
2778                          ;;                          ;;
2779                      flow)                      flow)
2780                          echo    " \\"  >> ad_flow_files.tmp                          echo    " \\"  >> $TMP.ad_flow_files
2781                          printf " $sf" >> ad_flow_files.tmp                          printf " $sf" >> $TMP.ad_flow_files
2782                          ;;                          ;;
2783                     esac                     esac
2784                  fi                  fi
# Line 2525  for d in $alldirs ; do Line 2787  for d in $alldirs ; do
2787      done      done
2788      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2789        if test "$d" != "." ; then        if test "$d" != "." ; then
2790          echo "" >> srclinks.tmp          echo "" >> $TMP.srclinks
2791          echo "#  These files are linked from $d" >> srclinks.tmp          echo "#  These files are linked from $d" >> $TMP.srclinks
2792          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> $TMP.srclinks
2793  # We need to make sure that the link isn't already there.  # We need to make sure that the link isn't already there.
2794  # 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"
2795  # 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.
2796          printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp          printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> $TMP.srclinks
2797        fi        fi
2798      fi      fi
2799  done  done
2800  rm -rf .links.tmp  rm -rf $TMP.links
2801  echo "" >> F77srclist.tmp  echo "" >> $TMP.F77srclist
2802  echo "" >> nonADF77srclist.tmp  echo "" >> $TMP.nonADF77srclist
2803  echo "" >> csrclist.tmp  echo "" >> $TMP.csrclist
2804  echo "" >> F90srclist.tmp  echo "" >> $TMP.F90srclist
2805  echo "" >> hsrclist.tmp  echo "" >> $TMP.hsrclist
2806  echo "" >> ad_flow_files.tmp  echo "" >> $TMP.ad_flow_files
2807    
2808  CMDLINE=$0  CMDLINE=$0
2809  for xx in "$@" ; do nw=`echo $xx | wc -w`  for xx in "$@" ; do nw=`echo $xx | wc -w`
2810      if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"      if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
2811                          else CMDLINE="$CMDLINE '$xx'" ; fi                          else CMDLINE="$CMDLINE '$xx'" ; fi
2812  done  done
2813    
2814  if test -f $MAKEFILE ; then  if test -f $MAKEFILE ; then
# Line 2580  cat >>$MAKEFILE <<EOF Line 2842  cat >>$MAKEFILE <<EOF
2842  # INCLUDES     : Directories searched for header files  # INCLUDES     : Directories searched for header files
2843  # DEFINES      : Macro definitions for CPP  # DEFINES      : Macro definitions for CPP
2844  # MAKEDEPEND   : Dependency generator  # MAKEDEPEND   : Dependency generator
 # KPP          : Special preprocessor command (specific to platform)  
 # KFLAGS       : Flags for KPP  
2845  # FC           : Fortran compiler command  # FC           : Fortran compiler command
2846  # FFLAGS       : Configuration/debugging options for FC  # FFLAGS       : Configuration/debugging options for FC
2847  # FOPTIM       : Optimization options for FC  # FOPTIM       : Optimization options for FC
# Line 2595  INCLUDEDIRS = ${INCLUDEDIRS} Line 2855  INCLUDEDIRS = ${INCLUDEDIRS}
2855  EXEDIR      = ${EXEDIR}  EXEDIR      = ${EXEDIR}
2856  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
2857  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIR}
2858    OADTOOLS    = ${OADTOOLS}
2859    
2860  #eh3  new defines for the adjoint work  #eh3  new defines for the adjoint work
2861  AUTODIFF    = ${ROOTDIR}/pkg/autodiff  AUTODIFF    = ${ROOTDIR}/pkg/autodiff
# Line 2615  else Line 2876  else
2876      echo "EMBEDDED_FILES = " >>$MAKEFILE      echo "EMBEDDED_FILES = " >>$MAKEFILE
2877  fi  fi
2878    
2879    # extract default cpp search path so we can pass it to makedepend
2880    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}'`
2881    
2882  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2883  # Unix ln (link)  # Unix ln (link)
2884  LN = ${LN}  LN = ${LN}
 # C preprocessor  
 CPP = cat \$< | ${S64} | ${CPP}  
2885  # Dependency generator  # Dependency generator
2886  MAKEDEPEND = ${MAKEDEPEND}  MAKEDEPEND = ${MAKEDEPEND}
2887  # Special preprocessor (KAP on DECs, FPP on Crays)  # Special preprocessor (KAP on DECs, FPP on Crays)
# Line 2632  F90C = ${F90C} Line 2894  F90C = ${F90C}
2894  CC = ${CC}  CC = ${CC}
2895  # Link editor  # Link editor
2896  LINK = ${LINK} ${LDADD}  LINK = ${LINK} ${LDADD}
2897    export $OPENAD_DIVA
2898    
2899  # Defines for CPP  # Defines for CPP
2900  DEFINES = ${DEFINES}  DEFINES = ${DEFINES}
2901  # Includes for CPP  # Includes for CPP
2902  INCLUDES = ${INCLUDES}  INCLUDES = ${INCLUDES}
2903    # default CPP includes for makedepend
2904    CPPINCLUDES = ${CPPINCLUDES}
2905  # Flags for KPP  # Flags for KPP
2906  KFLAGS1 = ${KFLAGS1}  KFLAGS1 = ${KFLAGS1}
2907  KFLAGS2 = ${KFLAGS2}  KFLAGS2 = ${KFLAGS2}
2908  # Optim./debug for FC  # Optim./debug for FC
2909  FFLAGS = ${FFLAGS} ${FEXTRAFLAGS}  FFLAGS = ${FFLAGS}
2910  FOPTIM = ${FOPTIM}  FOPTIM = ${FOPTIM} ${FEXTRAFLAGS}
2911  # Optim./debug for FC  # Optim./debug for FC
2912  F90FLAGS = ${F90FLAGS}  F90FLAGS = ${F90FLAGS}
2913  F90OPTIM = ${F90OPTIM}  F90OPTIM = ${F90OPTIM}
# Line 2655  NOOPTFLAGS = ${NOOPTFLAGS} Line 2920  NOOPTFLAGS = ${NOOPTFLAGS}
2920  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2921  LIBS = ${LIBS}  LIBS = ${LIBS}
2922  # Name of the makefile  # Name of the makefile
2923  MAKEFILE=${MAKEFILE}  MAKEFILE = ${MAKEFILE}
2924    # Name of the make program
2925    MAKE = ${MAKE}
2926    
2927  EOF  EOF
2928    
2929  cat F77srclist.tmp      >> $MAKEFILE  cat $TMP.F77srclist      >> $MAKEFILE
2930  cat nonADF77srclist.tmp >> $MAKEFILE  cat $TMP.nonADF77srclist >> $MAKEFILE
2931  cat csrclist.tmp        >> $MAKEFILE  cat $TMP.csrclist        >> $MAKEFILE
2932  cat F90srclist.tmp      >> $MAKEFILE  cat $TMP.F90srclist      >> $MAKEFILE
2933  cat hsrclist.tmp        >> $MAKEFILE  cat $TMP.hsrclist        >> $MAKEFILE
2934  cat ad_flow_files.tmp   >> $MAKEFILE  cat $TMP.ad_flow_files   >> $MAKEFILE
2935    
2936  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
2937    
2938  echo >> $MAKEFILE  echo >> $MAKEFILE
2939    
# Line 2679  echo >> $MAKEFILE Line 2946  echo >> $MAKEFILE
2946  echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE  echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE
2947  echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE  echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE
2948  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
2949  echo 'FLOFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE  echo 'FLOWFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE
2950  echo >> $MAKEFILE  echo >> $MAKEFILE
2951  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
2952  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
2953    
2954  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2955    
2956  all: \$(EXECUTABLE)  all: fwd_exe_target
2957    fwd_exe_target:
2958            @echo Update AD_CONFIG.h and make \$(EXECUTABLE)
2959            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Forward version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
2960            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2961            @-rm -f ad_config.template
2962            \$(MAKE) -f \$(MAKEFILE) \$(EXECUTABLE)
2963    
2964  \$(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)
2965          @echo Creating \$@ ...          @echo Creating \$@ ...
2966          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2967    
2968  depend:  depend:
2969          @make -f \$(MAKEFILE) links          @\$(MAKE) -f \$(MAKEFILE) links
2970          \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)          \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(CPPINCLUDES) \$(F77_SRC_FILES)
2971          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2972          -rm -f makedepend.out          -rm -f makedepend.out
2973    
# Line 2709  links: \$(F77_SRC_FILES) \$(C_SRC_FILES) Line 2983  links: \$(F77_SRC_FILES) \$(C_SRC_FILES)
2983    
2984  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
2985    
 output.txt: \$(EXECUTABLE)  
         @printf 'running ... '  
         @\$(EXECUTABLE) > \$@  
   
2986  # remove most of the files that "make" generates  # remove most of the files that "make" generates
2987  clean:  clean:
2988          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
# Line 2722  clean: Line 2992  clean:
2992    
2993  # remove most of the files that "make" and "make depend" generate  # remove most of the files that "make" and "make depend" generate
2994  Clean:  Clean:
2995          @make -f \$(MAKEFILE) clean          @\$(MAKE) -f \$(MAKEFILE) clean
2996          @make -f \$(MAKEFILE) cleanlinks          @\$(MAKE) -f \$(MAKEFILE) cleanlinks
2997          -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old          -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old
2998          -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  
2999    
3000  # remove also the executable, files that "genmake2" generates (except Makefile)  # remove also the executable, files that "genmake2" generates (except Makefile)
3001  #         and output from a run (plus log files from testreport)  #         and output from a run (plus log files from testreport)
3002  CLEAN:  CLEAN:
3003          @make -f \$(MAKEFILE) Clean          @\$(MAKE) -f \$(MAKEFILE) Clean
3004          -rm -f \$(EXECUTABLE) \$(EXE_AD) *.bak          -rm -f \$(EXECUTABLE) \$(EXE_AD) \$(EXE_FTL) *.bak
3005          -rm -f $LOGFILE genmake_state genmake_*optfile          -rm -f $LOGFILE genmake_state genmake_*optfile
3006          -rm -f SIZE.h.mpi genmake.tr_log make.tr_log          -rm -f SIZE.h.mpi genmake.tr_log make.tr_log
3007            -rm -rf mpi_headers mnc_test_*
3008          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
3009          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
3010          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
3011          -rm -f *.txt STD* *diagnostics.log datetime          -rm -f *.txt STDOUT.* STDERR.* *diagnostics.log *.[0-9][0-9][0-9][0-9].log
3012            -rm -f datetime costfinal divided.ctrl snapshot* output_adm.txt.diva_*
3013          -rm -f *_MIT_CE_000.opt0000 costfunction*0000          -rm -f *_MIT_CE_000.opt0000 costfunction*0000
3014          -rm -rf mnc_test_*          -rm -f oad_cp.[0-9][0-9][0-9].?????
3015    
3016  makefile:  makefile:
3017          $THIS_SCRIPT $G2ARGS          $THIS_SCRIPT $G2ARGS
# Line 2750  cleanlinks: Line 3021  cleanlinks:
3021  # Special targets (SPECIAL_FILES) which are created by make  # Special targets (SPECIAL_FILES) which are created by make
3022  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
3023          @echo Creating \$@ ...          @echo Creating \$@ ...
3024          @$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) > \$@
3025  AD_CONFIG.h:  AD_CONFIG.h:
3026          @echo Creating \$@ ...          @echo Creating \$@ ...
3027          @$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 > \$@
3028  FC_NAMEMANGLE.h:  FC_NAMEMANGLE.h:
3029          @echo Creating \$@ ...          @echo Creating \$@ ...
3030          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
# Line 2793  cat >>$MAKEFILE <<EOF Line 3064  cat >>$MAKEFILE <<EOF
3064  ## This nullifies any default implicit rules concerning these two file types:  ## This nullifies any default implicit rules concerning these two file types:
3065  ## %.o : %.F  ## %.o : %.F
3066    
3067    # C preprocessing and replacing the _d in constants:
3068    CPPCMD = cat \$< | ${CPP} \$(DEFINES) \$(INCLUDES) | ${S64}
3069    
3070  .F.$FS:  .F.$FS:
3071          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD)  > \$@
3072  .$FS.o:  .$FS.o:
3073          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
3074  .F.o:  .F.o:
3075          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
3076  .F90.$FS90:  .F90.$FS90:
3077          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD)  > \$@
3078  .FF90.f$FS90:  .FF90.f$FS90:
3079          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD)  > \$@
3080  .$FS90.o:  .$FS90.o:
3081          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
3082  .f$FS90.o:  .f$FS90.o:
# Line 2811  cat >>$MAKEFILE <<EOF Line 3085  cat >>$MAKEFILE <<EOF
3085  .c.o:  .c.o:
3086          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
3087  .flow.flowdir:  .flow.flowdir:
3088          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD) > \$@
3089    
3090  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
3091  .F.p:  .F.p:
3092          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD) > \$@
3093  .p.$FS:  .p.$FS:
3094          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
3095    
# Line 2834  TAF            = ${TAF} Line 3108  TAF            = ${TAF}
3108    
3109  TAF_EXTRA      = ${TAF_EXTRA}  TAF_EXTRA      = ${TAF_EXTRA}
3110  TAMC_EXTRA     = ${TAMC_EXTRA}  TAMC_EXTRA     = ${TAMC_EXTRA}
3111    LOCAL_MPI_HEADERS    = ${LOCAL_MPI_HEADERS}
3112    
3113  EOF  EOF
3114    
# Line 2851  done Line 3126  done
3126  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
3127  echo >> $MAKEFILE  echo >> $MAKEFILE
3128  printf "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
3129  AD_FILES=`cat adSrcFiles.tmp`  AD_FILES=`cat $TMP.adSrcFiles`
3130  for i in $AD_FILES ; do  for i in $AD_FILES ; do
3131      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
3132      printf " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
3133  done  done
3134  echo >> $MAKEFILE  echo >> $MAKEFILE
3135  rm -f adSrcFiles.tmp  rm -f $TMP.adSrcFiles
3136    
3137    if test $CAT_SRC_FOR_TAF = 0 ; then
3138    cat >>$MAKEFILE <<EOF
3139    
3140    # ... Utilities ...
3141    remove_comments:
3142            sed -i.bak -f \$(TOOLSDIR)/remove_comments_sed \$(AD_FILES)
3143            @-rm -f \$(AD_FILES:.$FS=.$FS.bak)
3144    adj_sed:
3145            sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_ad.$FS)
3146            @-rm -f \$(AD_FILES:.$FS=_ad.$FS.bak)
3147    ftl_sed:
3148            sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_tl.$FS)
3149            @-rm -f \$(AD_FILES:.$FS=_tl.$FS.bak)
3150    adobjfiles: \$(AD_FILES:.$FS=_ad.o)
3151    ftlobjfiles: \$(AD_FILES:.$FS=_tl.o)
3152    EOF
3153    fi
3154    
3155  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3156    
3157  # ... AD ...  # ... AD ...
3158  adall: \$(EXE_AD)  adall: ad_exe_target
3159  adtaf: ad_taf_output.$FS  adtaf: ad_taf_output.$FS
3160  adtamc: ad_tamc_output.$FS  adtamc: ad_tamc_output.$FS
3161    
3162  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES)  ad_exe_target:
3163          @$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)
3164            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3165            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3166            @-rm -f ad_config.template
3167            \$(MAKE) -f \$(MAKEFILE) \$(EXE_AD)
3168    
3169    ad_input_code.$FS: \$(AD_FILES) \$(AD_FLOW_FILES)
3170            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3171          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
3172          -rm -f ad_config.template          @-rm -f ad_config.template
3173          @make -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)          @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3174          @make -f \$(MAKEFILE) \$(FLOFILES)          @\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)
3175          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
3176    
3177  ad_taf_output.$FS: ad_input_code.$FS  adtafonly:
3178          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3179          ls -l ad_input_code_ad.$FS          ls -l ad_input_code_ad.$FS
3180          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
3181    
3182  adtafonly:  EOF
3183    
3184    if test $CAT_SRC_FOR_TAF = 1 ; then
3185    cat >>$MAKEFILE <<EOF
3186    # ... send 1 file to TAF ...
3187    ad_taf_output.$FS: ad_input_code.$FS
3188            @-rm -f ad_input_code_ad.$FS ; echo ''
3189          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3190          ls -l ad_input_code_ad.$FS          ls -l ad_input_code_ad.$FS
3191          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
3192    
3193  \${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)
3194          \$(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)
3195    
3196  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  
3197    
3198  ad_tamc: ad_tamc_output.o \$(OBJFILES)  EOF
3199          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)  
3200    else
3201    cat >>$MAKEFILE <<EOF
3202    # ... send multiple files to TAF ...
3203    ad_taf_output.$FS: \$(AD_FLOW_FILES) \$(AD_FILES)
3204            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3205            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3206            @-rm -f ad_config.template
3207            @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3208            @\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)
3209            @-rm -f \$(AD_FILES:.$FS=_ad.$FS) \$(AD_FILES:.$FS=_ad.o); echo ''
3210            \$(MAKE) -f \$(MAKEFILE) remove_comments
3211            \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) \$(FLOWFILES) \$(AD_FILES)
3212            \$(MAKE) -f \$(MAKEFILE) adj_sed
3213            cat \$(AD_FILES:.$FS=_ad.$FS) > ad_taf_output.$FS
3214    
3215    \$(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)
3216            \$(MAKE) -f \$(MAKEFILE) adobjfiles
3217            \$(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)
3218    
3219    adobj: ad_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o)
3220            \$(MAKE) -f \$(MAKEFILE) adobjfiles
3221    
3222    EOF
3223    fi
3224    
3225    cat >>$MAKEFILE <<EOF
3226  adonlyfwd:  adonlyfwd:
3227          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
3228    
3229  adtrick:  adtrick:
3230          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
3231    
3232  adobj: ad_taf_output.o \$(OBJFILES)  ad_tamc_output.$FS: ad_input_code.$FS
3233            \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
3234            cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
3235    
3236    ad_tamc: ad_tamc_output.o \$(OBJFILES)
3237            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
3238    
3239  # ... FTL ...  # ... FTL ...
3240  ftlall: ftl_taf  ftlall: ftl_exe_target
3241  ftltaf: ftl_taf_output.$FS  ftltaf: ftl_taf_output.$FS
3242  ftltamc: ftl_tamc_output.$FS  ftltamc: ftl_tamc_output.$FS
3243    
3244  ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)  ftl_exe_target:
3245          @$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)
3246          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
3247          -rm -f ftl_config.template          @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3248          @make -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)          @-rm -f ad_config.template
3249          @make -f \$(MAKEFILE) \$(AD_FLOW_FILES)          \$(MAKE) -f \$(MAKEFILE) \$(EXE_FTL)
         cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS  
3250    
3251  ftl_taf_output.$FS: ftl_input_code.$FS  ftl_input_code.$FS: \$(AD_FILES)
3252          \$(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
3253          ls -l ftl_input_code_ftl.$FS          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3254          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS          @-rm -f ad_config.template
3255            @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3256            @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3257            cat \$(AD_FLOW_FILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ftl_input_code.$FS
3258    
3259  ftltafonly:  ftltafonly:
3260          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3261          ls -l ftl_input_code_ftl.$FS          ls -l ftl_input_code_tl.$FS
3262          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
3263    
3264    EOF
3265    
3266  ftl_taf: ftl_taf_output.o \$(OBJFILES)  if test $CAT_SRC_FOR_TAF = 1 ; then
3267          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)  cat >>$MAKEFILE <<EOF
3268    # ... send 1 file to TAF ...
3269    ftl_taf_output.$FS: ftl_input_code.$FS
3270            @-rm -f ftl_input_code_tl.$FS ; echo ''
3271            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3272            ls -l ftl_input_code_tl.$FS
3273            cat ftl_input_code_tl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
3274    
3275    \$(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)
3276            \$(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)
3277    
3278    EOF
3279    
3280    else
3281    cat >>$MAKEFILE <<EOF
3282    # ... send multiple files to TAF ...
3283    ftl_taf_output.$FS: \$(AD_FLOW_FILES) \$(AD_FILES)
3284            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3285            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3286            @-rm -f ad_config.template
3287            @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3288            @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3289            @-rm -f \$(AD_FILES:.$FS=_tl.$FS) \$(AD_FILES:.$FS=_tl.o); echo ''
3290            \$(MAKE) -f \$(MAKEFILE) remove_comments
3291            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) \$(AD_FLOW_FILES) \$(AD_FILES)
3292            \$(MAKE) -f \$(MAKEFILE) ftl_sed
3293            cat \$(AD_FILES:.$FS=_tl.$FS) > ftl_taf_output.$FS
3294    
3295    \$(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)
3296            \$(MAKE) -f \$(MAKEFILE) ftlobjfiles
3297            \$(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)
3298    
3299    EOF
3300    fi
3301    
3302    cat >>$MAKEFILE <<EOF
3303  ftl_tamc_output.$FS: ftl_input_code.$FS  ftl_tamc_output.$FS: ftl_input_code.$FS
3304          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
3305          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 2955  svd_touch: Line 3327  svd_touch:
3327          touch ad_taf_output.$FS ftl_taf_output.$FS          touch ad_taf_output.$FS ftl_taf_output.$FS
3328          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
3329          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
3330          @$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
3331          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
3332          -rm -f ftl_config.template          @-rm -f ad_config.template
3333    
3334  EOF  EOF
3335    
# Line 2970  if test "x$OPENAD" != x ; then Line 3342  if test "x$OPENAD" != x ; then
3342  # ============ begin OpenAD specific section ==============  # ============ begin OpenAD specific section ==============
3343    
3344  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3345    # ... OpenAD ...
3346    
3347  # all the source files linked from the various locations:  # all the source files linked from the various locations:
3348  ALL_LINKED_FILES= \  ALL_LINKED_FILES= \
# Line 3009  for i in `cat ${OAD_CB2M_FILES}` ; do Line 3382  for i in `cat ${OAD_CB2M_FILES}` ; do
3382    echo    " \\" >> $MAKEFILE    echo    " \\" >> $MAKEFILE
3383    printf " ${i}_mod.f$FS90" >> $MAKEFILE    printf " ${i}_mod.f$FS90" >> $MAKEFILE
3384  done  done
3385  AD_FILES=`cat adSrcFiles.tmp`  AD_FILES=`cat $TMP.adSrcFiles`
3386  for i in $AD_FILES ; do  for i in $AD_FILES ; do
3387    basename=${i%%.f}    basename=${i%%.f}
3388    toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`    toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`
# Line 3019  for i in $AD_FILES ; do Line 3392  for i in $AD_FILES ; do
3392    fi    fi
3393  done  done
3394  echo >> $MAKEFILE  echo >> $MAKEFILE
3395  rm -f adSrcFiles.tmp  rm -f $TMP.adSrcFiles
3396    
3397  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3398    
3399  adAll: \$(EXE_AD)  adAll: ad_exe_target
3400  .PHONY: adAll  .PHONY: adAll
3401    
3402    ad_exe_target:
3403            @echo Update AD_CONFIG.h and make \$(EXE_AD)
3404            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3405            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3406            @-rm -f ad_config.template
3407            \$(MAKE) -f \$(MAKEFILE) \$(EXE_AD)
3408    
3409  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))
3410    
3411  .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)
# Line 3041  w2f__types.F90 \ Line 3421  w2f__types.F90 \
3421  OAD_active.F90 \  OAD_active.F90 \
3422  OAD_cp.F90 \  OAD_cp.F90 \
3423  OAD_rev.F90 \  OAD_rev.F90 \
3424  OAD_tape.F90  OAD_tape.F90 \
3425    OAD_regular_cp.F90 \
3426    revolve.F90
3427    
3428  OPENAD_SUPPORT_C_SRC_FILES = \  OPENAD_SUPPORT_C_SRC_FILES = \
3429  iaddr.c \  iaddr.c \
# Line 3057  f95_test.out: f95_test_mods.f90 f95_test Line 3439  f95_test.out: f95_test_mods.f90 f95_test
3439          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
3440          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
3441    
3442  # 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  
3443    
3444  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)
3445    
3446  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)
3447    
3448  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)  
3449          \$(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  
3450    
3451  # create the module files  # create sources files modules from header files containing common blocks
3452  %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk  %_mod.FF90 : %.h \${OADTOOLS}/cb2mGetModules.csh \${OADTOOLS}/cb2mGetModules.awk
3453          ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk          \${OADTOOLS}/cb2mGetModules.csh $< \${OADTOOLS}/cb2mGetModules.awk
3454    
3455  # create the header files  # create new header files with USE statements for the new modules made above
3456  %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk  %_mod.h : %.h \${OADTOOLS}/cb2mGetHeaders.csh \${OADTOOLS}/cb2mGetHeaders.awk
3457          ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)          \${OADTOOLS}/cb2mGetHeaders.csh $< \${OADTOOLS}/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
3458    
3459  # 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
3460  %_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash  %_cb2m.FF90 : %.F \${OADTOOLS}/cb2mUseModules.bash
3461          ../OAD_support/cb2mUseModules.bash $< ${MPI}          \${OADTOOLS}/cb2mUseModules.bash $< ${MPI}
3462    
3463  # makefile debug rule  # makefile debug rule
3464  small_f: \$(CB2M_F90_PP_SRC_FILES)  small_f: \$(CB2M_F90_PP_SRC_FILES)
3465  .PHONY: small_f  .PHONY: small_f
3466    
 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)  
3467  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3468          cat \$^ > \$@          cat \$^ > \$@
3469    
 # 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 > \$@  
   
3470  # canonicalizer  # canonicalizer
3471  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)
3472          ./preProcess.py --timing --r8 -H -S \$< -o \$@          \${OPENADFORTTK_BASE}/tools/SourceProcessing/preProcess.py --timing --r8 -H -S  -o \$@ \$^
3473    
3474    # replace stop statements (to avoid the implied unstructured control flow)  with print statements
3475    ad_input_code_sf.pre.s2p.f90 : ad_input_code_sf.pre.f90
3476            cat \$< | sed -f \${OADTOOLS}/stop2print.sed > ad_input_code_sf.pre.s2p.f90
3477    
3478  # F -> WHIRL  # F -> WHIRL
3479  # note that the canonicalized version cuts off at col 72  ad_input_code_sf.pre.s2p.B: ad_input_code_sf.pre.s2p.f90
3480  # 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 \$@  
3481    
3482  # WHIRL -> XAIF  # WHIRL -> XAIF
3483  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
3484          ./whirl2xaif -s -n --debug 1 -o \$@ \$<          \${OPENADFORTTK}/bin/whirl2xaif -s -n --debug 1 -o \$@ \$<
3485    
3486  # XAIF -> XAIF'  # XAIF -> XAIF'
3487  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
3488          ./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
3489    
3490  # XAIF' -> WHIRL'  # XAIF' -> WHIRL'
3491  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
3492          ./xaif2whirl --debug 1 ad_input_code_sf.w2f.pre.B \$<          \${OPENADFORTTK}/bin/xaif2whirl --debug 1 ad_input_code_sf.pre.s2p.B \$<
3493    
3494  # WHIRL' -> F'  # WHIRL' -> F'
3495  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
3496          ./whirl2f -FLIST:ftn_file=\$@ -openad \$<          \${OPEN64ROOT}/whirl2f/whirl2f -FLIST:ftn_file=\$@ -openad \$<
3497    
3498  # insert template directives  # insert template directives
3499  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
3500          ../OAD_support/insertTemplateDir.bash \$< \$@          \${OADTOOLS}/insertTemplateDir.bash \$< \$@
3501    
3502  PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F  PPEXTRAS=\$(notdir \$(wildcard \${OADTOOLS}/ad_template.*.F)) ad_inline.F
3503  # postprocess F'  # postprocess F'
3504  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
3505          # 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 \$<
3506            # the target is a placeholder to trigger a single execution of the rule
3507          touch \$@          touch \$@
3508          # this step also creates the file postProcess.make but we cannot  # put this so make knows about the postprocessing output
3509          # 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 --infoUnitFile w2f__types.f90 --outputFormat=fixed -m r -i ../OAD_support/ad_inline.f --width 4 \$<  
3510    
3511  # setup some links  # link the XAIF schema files
3512  %.xsd:  %.xsd:
3513          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3514    
 mfef90:  
         \$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 .  
   
3515  # link the support files:  # link the support files:
3516  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES) \$(PPEXTRAS):
3517          \$(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 \$@  
3518    
3519  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
3520    
3521  # ============ end OpenAD specific section ==============  # ============ end OpenAD specific section ==============
3522    
# Line 3232  for i in $NOOPTFILES ; do Line 3552  for i in $NOOPTFILES ; do
3552  done  done
3553    
3554  echo "  Add rules for links"  echo "  Add rules for links"
3555  cat srclinks.tmp >> $MAKEFILE  cat $TMP.srclinks >> $MAKEFILE
3556  rm -f srclinks.tmp  rm -f $TMP.srclinks
3557    
3558  echo "  Adding makedepend marker"  echo "  Adding makedepend marker"
3559  printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE  printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE
# Line 3241  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 3561  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
3561  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
3562    
3563  # Create special header files  # Create special header files
3564  $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"
3565  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
3566      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
3567  else  else
# Line 3255  else Line 3575  else
3575      fi      fi
3576  fi  fi
3577  if test ! -f AD_CONFIG.h ; then  if test ! -f AD_CONFIG.h ; then
3578      $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
3579  fi  fi
3580    
3581  #  Write the "state" for future records  #  Write the "state" for future records

Legend:
Removed from v.1.230  
changed lines
  Added in v.1.272

  ViewVC Help
Powered by ViewVC 1.1.22