/[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.143 by edhill, Tue Feb 14 16:21:09 2006 UTC revision 1.250 by jmc, Fri Apr 5 21:10:55 2013 UTC
# Line 1  Line 1 
1  #! /usr/bin/env bash  #! /usr/bin/env bash
2  #  #
3  # $Header$  # $Header$
4    # $Name$
5  #  #
6  # Makefile generator for MITgcm UV codes  # Makefile generator for MITgcm UV codes
7  #   created  by cnh 03/98  #   created  by cnh 03/98
# Line 8  Line 9 
9  #   modified by aja 01/00  #   modified by aja 01/00
10  #   rewritten in bash by eh3 08/03  #   rewritten in bash by eh3 08/03
11    
12    #  Explain usage
13    usage()  {
14    cat <<EOF
15    
16    Usage: "$0" [OPTIONS]
17      where [OPTIONS] can be:
18    
19        -help | --help | -h | --h
20              Print this help message and exit.
21    
22        -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
23          -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
24              Use "NAME" as the adoptfile.  By default, the file at
25              "tools/adjoint_options/adjoint_default" will be used.
26    
27        -nooptfile | --nooptfile
28          -optfile NAME | --optfile NAME | -of NAME | --of NAME
29          -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
30              Use "NAME" as the optfile.  By default, an attempt will be
31              made to find an appropriate "standard" optfile in the
32              tools/build_options/ directory.
33    
34        -pdepend NAME | --pdepend NAME
35          -pdepend=NAME | --pdepend=NAME
36              Get package dependency information from "NAME".
37    
38        -pgroups NAME | --pgroups NAME
39          -pgroups=NAME | --pgroups=NAME
40              Get the package groups information from "NAME".
41    
42        -bash NAME
43              Explicitly specify the Bourne or BASH shell to use
44    
45        -make NAME | -m NAME
46          --make=NAME | -m=NAME
47              Use "NAME" for the MAKE program. The default is "make" but
48              many platforms, "gmake" is the preferred choice.
49    
50        -makefile NAME | -mf NAME
51          --makefile=NAME | -mf=NAME
52              Call the makefile "NAME".  The default is "Makefile".
53    
54        -makedepend NAME | -md NAME
55          --makedepend=NAME | -md=NAME
56              Use "NAME" for the MAKEDEPEND program.
57    
58        -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
59          -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
60              Specify the location of the MITgcm ROOTDIR as "NAME".
61              By default, genamke will try to find the location by
62              looking in parent directories (up to the 5th parent).
63    
64        -mods NAME | --mods NAME | -mo NAME | --mo NAME
65          -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME
66              Here, "NAME" specifies a list of directories that are
67              used for additional source code.  Files found in the
68              "mods list" are given preference over files of the same
69              name found elsewhere.
70    
71        -disable NAME | --disable NAME
72          -disable=NAME | --disable=NAME
73              Here "NAME" specifies a list of packages that we don't
74              want to use.  If this violates package dependencies,
75              genamke will exit with an error message.
76    
77        -enable NAME | --enable NAME
78          -enable=NAME | --enable=NAME
79              Here "NAME" specifies a list of packages that we wish
80              to specifically enable.  If this violates package
81              dependencies, genamke will exit with an error message.
82    
83        -standarddirs NAME | --standarddirs NAME
84          -standarddirs=NAME | --standarddirs=NAME
85              Here, "NAME" specifies a list of directories to be
86              used as the "standard" code.
87    
88        -fortran NAME | --fortran NAME | -fc NAME | --fc NAME
89          -fc=NAME | --fc=NAME
90              Use "NAME" as the fortran compiler.  By default, genmake
91              will search for a working compiler by trying a list of
92              "usual suspects" such as g77, f77, etc.
93    
94        -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
95              Use "NAME" as the C compiler.  By default, genmake
96              will search for a working compiler by trying a list of
97              "usual suspects" such as gcc, c89, cc, etc.
98    
99        -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4
100              Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW)
101              *only* works if CPP_EEOPTIONS.h allows this.
102    
103        -ignoretime | -ignore_time | --ignoretime | --ignore_time
104              Ignore all the "wall clock" routines entirely.  This will
105              not in any way hurt the model results -- it simply means
106              that the code that checks how long the model spends in
107              various routines will give junk values.
108    
109        -ts | --ts
110              Produce timing information per timestep
111        -papis | --papis
112              Produce summary MFlop/s (and IPC) with PAPI per timestep
113        -pcls | --pcls
114              Produce summary MFlop/s etc. with PCL per timestep
115        -foolad | --foolad
116              Fool the AD code generator
117        -papi | --papi
118              Performance analysis with PAPI
119        -pcl | --pcl
120              Performance analysis with PCL
121        -hpmt | --hpmt
122              Performance analysis with the HPM Toolkit
123    
124        -ieee | --ieee
125              use IEEE numerics.  Note that this option *only* works
126              if it is supported by the OPTFILE that is being used.
127        -devel | --devel
128              Add additional warning and debugging flags for development
129              (if supported by the OPTFILE); also switch to IEEE numerics.
130        -gsl | --gsl
131              Use GSL to control floating point rounding and precision
132    
133        -mpi | --mpi
134              Include MPI header files and link to MPI libraries
135        -mpi=PATH | --mpi=PATH
136              Include MPI header files and link to MPI libraries using MPI_ROOT
137              set to PATH. i.e. Include files from \$PATH/include, link to libraries
138              from \$PATH/lib and use binaries from \$PATH/bin.
139    
140        -omp | --omp
141              Activate OpenMP code + use Compiler option OMPFLAG
142        -omp=OMPFLAG | --omp=OMPFLAG
143              Activate OpenMP code + use Compiler option OMPFLAG
144    
145        -es | --es | -embed-source | --embed-source
146              Embed a tarball containing the full source code
147              (including the Makefile, etc.) used to build the
148              executable [off by default]
149    
150        -ds | --ds
151              Report genmake internal variables status (DUMPSTATE)
152              to file "genmake_state" (for debug purpose)
153    
154      While it is most often a single word, the "NAME" variables specified
155      above can in many cases be a space-delimited string such as:
156    
157        --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'
158        -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'
159        -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'
160    
161      which, depending upon your shell, may need to be single-quoted.
162    
163      For more detailed genmake documentation, please see:
164    
165        http://mitgcm.org/public/devel_HOWTO/
166    
167    EOF
168    
169        exit 1
170    }
171    
172  # Search for particular CPP #cmds associated with packages  # Search for particular CPP #cmds associated with packages
173  # usage: test_for_package_in_cpp_options CPP_file package_name  # usage: test_for_package_in_cpp_options CPP_file package_name
174  test_for_package_in_cpp_options() {  test_for_package_in_cpp_options() {
175      cpp_options=$1      cpp_options=$1
176      pkg=$2      pkg=$2
177      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg" || exit 99      test_for_string_in_file $cpp_options "^ *# *define *\<ALLOW_$pkg\>"
178      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg" || exit 99      test_for_string_in_file $cpp_options "^ *# *undef *\<ALLOW_$pkg\>"
179      test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg" || exit 99      test_for_string_in_file $cpp_options "^ *# *define *\<DISABLE_$pkg\>"
180      test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg" || exit 99      test_for_string_in_file $cpp_options "^ *# *undef *\<DISABLE_$pkg\>"
181  }  }
182    
183  # Search for particular CPP #cmds associated with MPI  # Search for particular CPP #cmds associated with MPI
184  # usage: test_for_mpi_in_cpp_eeoptions CPP_file  # usage: test_for_mpi_in_cpp_eeoptions CPP_file
185  test_for_mpi_in_cpp_eeoptions() {  test_for_mpi_in_cpp_eeoptions() {
186      cpp_options=$1      cpp_options=$1
187      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI" || exit 99      test_for_string_in_file $cpp_options "^ *# *define *\<ALLOW_USE_MPI\>"
188      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI" || exit 99      test_for_string_in_file $cpp_options "^ *# *undef *\<ALLOW_USE_MPI\>"
     test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI" || exit 99  
     test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI" || exit 99  
189  }  }
190    
191  # Search for particular string in a file. Return 1 if detected, 0 if not  # Search for particular string in a file. Return 1 if detected, 0 if not
# Line 34  test_for_mpi_in_cpp_eeoptions() { Line 193  test_for_mpi_in_cpp_eeoptions() {
193  test_for_string_in_file() {  test_for_string_in_file() {
194      file=$1      file=$1
195      strng=$2      strng=$2
196      grep -i "$strng" $file > /dev/null 2>&1      grep "$strng" $file > /dev/null 2>&1
197      RETVAL=$?      RETVAL=$?
198      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
199          printf "Error: In $file there is an illegal line: "          printf "Error: In $file there is an illegal line: "
200          grep -i "$strng" $file          grep -i "$strng" $file
201          return 1          exit 99
202      fi      fi
203      return 0      return 0
204  }  }
# Line 48  test_for_string_in_file() { Line 207  test_for_string_in_file() {
207  # the package list.  # the package list.
208  expand_pkg_groups() {  expand_pkg_groups() {
209      new_packages=      new_packages=
     PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"  
210      if test -r $PKG_GROUPS ; then      if test -r $PKG_GROUPS ; then
211          cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp          cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp
212          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp
# Line 59  expand_pkg_groups() { Line 217  expand_pkg_groups() {
217              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
218                  matched=1                  matched=1
219                  replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`                  replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
220                  echo "    replacing \"$i\" with: $replace"                  echo "    replacing \"$i\" with:$replace"
221                  new_packages="$new_packages $replace"                  new_packages="$new_packages $replace"
222              else              else
223                  new_packages="$new_packages $i"                  new_packages="$new_packages $i"
# Line 102  EOF Line 260  EOF
260              check_for_broken_Ff              check_for_broken_Ff
261          else          else
262              cat <<EOF 2>&1              cat <<EOF 2>&1
263  ERROR: Your file system cannot distinguish between *.F and *.f files  ERROR: Your file system cannot distinguish between *.F and *.f files
264    (fails the "cp" test) and this program cannot find a suitable    (fails the "cp" test) and this program cannot find a suitable
265    replacement extension.  Please try a different build environment or    replacement extension.  Please try a different build environment or
266    contact the <MITgcm-support@mitgcm.org> list for help.    contact the <MITgcm-support@mitgcm.org> list for help.
267    
268  EOF  EOF
# Line 129  EOF Line 287  EOF
287  .F.$tfs:  .F.$tfs:
288          $LN \$< \$@          $LN \$< \$@
289  EOF  EOF
290      $MAKE "genmake_hello."$tfs > /dev/null 2>&1      $MAKE -f $MAKEFILE "genmake_hello."$tfs > /dev/null 2>&1
291      RETVAL=$?      RETVAL=$?
292      if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then      if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then
293          if test "x$FS" = x ; then          if test "x$FS" = x ; then
# Line 137  EOF Line 295  EOF
295              FS90='fr9'              FS90='fr9'
296              check_for_broken_Ff              check_for_broken_Ff
297          else          else
298              cat <<EOF 2>&1              echo "ERROR: test: '$MAKE -f $MAKEFILE genmake_hello.$tfs' Failed"
299  ERROR: Your file system cannot distinguish between *.F and *.f files              echo "       see simple makefile: '$MAKEFILE' (left here)"
300    (fails the "make/ln" test) and this program cannot find a suitable              echo "  Please check (1) your '$MAKE' command, (2) your '$LN' command"
301    replacement extension.  Please try a different build environment or              echo "           and (3) the allowed sufix '.F' and '.$tfs' in makefile"
302    contact the <MITgcm-support@mitgcm.org> list for help.              echo "  or contact the <MITgcm-support@mitgcm.org> list for help."
303                echo ""
 EOF  
304              exit -1              exit -1
305              return              return
306          fi          fi
# Line 157  EOF Line 314  EOF
314      return      return
315  }  }
316    
   
317  look_for_makedepend()  {  look_for_makedepend()  {
318    
319      #  The "original" makedepend is part of the Imake system that is      #  The "original" makedepend is part of the Imake system that is
# Line 168  look_for_makedepend()  { Line 324  look_for_makedepend()  {
324      #      #
325      #    1) a makedepend implementation shipped with the cyrus-imapd      #    1) a makedepend implementation shipped with the cyrus-imapd
326      #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/      #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
327      #      #    2) a local tools/xmakedepend shell script
     #    2) a known-buggy xmakedpend shell script  
328      #      #
329      #  So the choices are, in order:      #  So the choices are, in order:
     #  
330      #    1) use the user-specified program      #    1) use the user-specified program
331      #    2) use a system-wide default      #    2) use the local xmakedepend script (get all dependencies, but slower)
332      #    3) locally build and use the cyrus implementation      #    3) use a system-wide default
333      #    4) fall back to the buggy local xmakedpend script      #    4) locally build and use the cyrus makedepend
334        #             (faster, but can miss some dependencies)
335      #      #
336        echo >> $LOGFILE
337        echo "running: look_for_makedepend()" >> $LOGFILE
338        if test "x${MAKEDEPEND}" != x ; then
339            echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
340            RETVAL=$?
341            if test x"$RETVAL" = x0 ; then
342                build_cyrus_makedepend
343                RETVAL=$?
344                if test "x$RETVAL" != x0 ; then
345                    echo "WARNING: unable to build cyrus-makedepend. Try other 'makedepend'"
346                    MAKEDEPEND=
347                fi
348            else
349                echo "${MAKEDEPEND}" | grep 'tools.xmakedepend' > /dev/null 2>&1
350                RETVAL=$?
351                if test "x$RETVAL" = x0 ; then
352                    MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
353                fi
354                echo " -->     MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
355            fi
356        fi
357      if test "x${MAKEDEPEND}" = x ; then      if test "x${MAKEDEPEND}" = x ; then
         which makedepend > /dev/null 2>&1  
         RV0=$?  
358          test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"          test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"
359          #  echo 'MAKEFILE="'$MAKEFILE'"'          #  echo 'MAKEFILE="'$MAKEFILE'"'
360          cat <<EOF >> $MAKEFILE          cat <<EOF >> $MAKEFILE
361  #   THIS IS A TEST MAKEFILE GENERATED BY "genmake2"  #   THIS IS A TEST MAKEFILE GENERATED BY "genmake2"
362  #  #
363  #   Some "makedepend" implementations will die if they cannot  #   Some "makedepend" implementations will die if they cannot
364  #   find a Makefile -- so this file is here to gives them an  #   find a Makefile -- so this file is here to gives them an
365  #   empty one to find and parse.  #   empty one to find and parse.
366  EOF  EOF
367          cat <<EOF >> genmake_tc.f          cat <<EOF >> genmake_tc.f
# Line 196  EOF Line 370  EOF
370        stop        stop
371        end        end
372  EOF  EOF
373          makedepend genmake_tc.f > /dev/null 2>&1          $ROOTDIR/tools/xmakedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1
374          RV1=$?          RV1=$?
375            which makedepend > /dev/null 2>&1
376            RV2=$?
377            if test "x${RV2}" = x0 ; then
378                makedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1
379                RV3=$? ; loc_msg='not working.'
380            else RV3=$RV2 ; loc_msg='not found.'
381            fi
382          test -f $MAKEFILE  &&  rm -f $MAKEFILE          test -f $MAKEFILE  &&  rm -f $MAKEFILE
383          test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE          test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
384          if test "x${RV0}${RV1}" = x00 ; then          echo "  check makedepend (local: $RV1, system: $RV2, $RV3)"
385            if test "x${RV1}" = x0 ; then
386                MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
387                echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
388            elif test "x${RV3}" = x0 ; then
389                echo "    local tools/xmakedepend not working. Use system-default makedepend"
390              MAKEDEPEND=makedepend              MAKEDEPEND=makedepend
391                echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
392          else          else
393              echo "    a system-default makedepend was not found."              echo "    local tools/xmakedepend not working; system-default makedepend $loc_msg"
394                            echo -n "    Try to build cyrus-makedepend ..."
395              #  Try to build the cyrus implementation              #  Try to build the cyrus implementation
396              build_cyrus_makedepend              build_cyrus_makedepend
397              RETVAL=$?              RETVAL=$?
398              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" = x0 ; then
399                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'                  echo "  Works"
400                else
401                    echo "  Fails" ; echo "" >> $LOGFILE
402                    echo "ERROR: no working makedepend found ; look_for_makedepend FAILED" | tee -a $LOGFILE
403                    echo ""
404                    exit -1
405                    return
406              fi              fi
             rm -f ./genmake_cy_md  
         fi  
     else  
         #  echo "MAKEDEPEND=${MAKEDEPEND}"  
         echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1  
         RETVAL=$?  
         if test x"$RETVAL" = x0 ; then  
             build_cyrus_makedepend  
407          fi          fi
408      fi      fi
409  }  }
410    
   
411  build_cyrus_makedepend()  {  build_cyrus_makedepend()  {
412        echo >> $LOGFILE
413        echo "running: build_cyrus_makedepend()" >> $LOGFILE
414      rm -f ./genmake_cy_md      rm -f ./genmake_cy_md
415      (      (
416          cd $ROOTDIR/tools/cyrus-imapd-makedepend  \          cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
417              &&  ./configure > /dev/null 2>&1  \              &&  ./configure > /dev/null 2>&1  \
418              &&  make > /dev/null 2>&1              &&  $MAKE > /dev/null 2>&1
419          if test -x ./makedepend.exe ; then          if test -x ./makedepend.exe ; then
420              $LN ./makedepend.exe ./makedepend              $LN ./makedepend.exe ./makedepend
421          fi          fi
# Line 241  build_cyrus_makedepend()  { Line 427  build_cyrus_makedepend()  {
427      rm -f ./genmake_cy_md      rm -f ./genmake_cy_md
428      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
429          MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'          MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
430            echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
431          return 0          return 0
432      else      else
433          echo "WARNING: unable to build cyrus-imapd-makedepend"          echo "WARNING: fail to build cyrus-imapd-makedepend" >> $LOGFILE
434          return 1          return 1
435      fi      fi
436  }  }
437    
   
438  build_embed_encode()  build_embed_encode()
439  {  {
440      printf "  building the embed-encode utility...  "      printf "  building the embed-encode utility...  "
441      if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then      if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then
442          if test ! -d "$ROOTDIR/tools/embed_encode" ; then          if test ! -d "$ROOTDIR/tools/embed_encode" ; then
443              echo              echo
444              echo "    Error: can't locate \"$ROOTDIR/tools/embed_encode\""              echo "    Error: can't locate \"$ROOTDIR/tools/embed_encode\""
445              echo              echo
446              EMBED_SRC=f              EMBED_SRC=f
447              return 1              return 1
448          fi          fi
449          clist="cc gcc c89 $CC"          clist="cc gcc c89 $CC"
450          for ic in $clist ; do          for ic in $clist ; do
451              comm="$ic -o encode_files encode_files.c"              comm="$ic -o encode_files encode_files.c"
452              ( cd $ROOTDIR/tools/embed_encode && $comm ) > /dev/null 2>&1              ( cd $ROOTDIR/tools/embed_encode && $comm ) > /dev/null 2>&1
453              RETVAL=$?              RETVAL=$?
454              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
455                  echo "OK"                  echo "OK"
                 DEFINES="$DEFINES -DHAVE_EMBED_SRC"  
456                  return 0                  return 0
457              fi              fi
458          done          done
# Line 279  build_embed_encode() Line 464  build_embed_encode()
464          return 1          return 1
465      fi      fi
466      echo "OK"      echo "OK"
     DEFINES="$DEFINES -DHAVE_EMBED_SRC"  
467  }  }
468    
469    #  look for possible C compilers
470  # Guess possible config options for this host  look_for_C_compilers() {
471  find_possible_configs()  {      echo >> $LOGFILE
472        echo "running: look_for_C_compilers()" >> $LOGFILE
473      tmp1=`uname`"_"`uname -m`      rm -f ./genmake_hello.c  ./genmake_hello
474      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`      cat >> genmake_hello.c << EOF
     tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`  
     tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`  
     tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`  
     tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`  
     PLATFORM=$tmp3  
     echo $PLATFORM | grep cygwin > /dev/null 2>&1  &&  PLATFORM=cygwin_ia32  
     OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`  
     echo "  The platform appears to be:  $PLATFORM"  
       
     echo "test" > test  
     ln -s ./test link  
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         LN="ln -s"  
     else  
         echo "Error: \"ln -s\" does not appear to work on this system!"  
         echo "  For help, please contact <MITgcm-support@mitgcm.org>."  
         exit 1  
     fi  
     rm -f test link  
   
     if test "x$CPP" = x ; then  
         CPP="cpp -traditional -P"  
     fi  
   
     look_for_makedepend  
   
     #================================================================  
     #  look for possible C compilers  
     tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc"  
     p_CC=  
     for c in $tmp ; do  
         rm -f ./genmake_hello.c  ./genmake_hello  
         cat >> genmake_hello.c << EOF  
475  #include <stdio.h>  #include <stdio.h>
476  int main(int argc, char **argv) {  int main(int argc, char **argv) {
477    printf("Hello!\n");    printf("Hello!\n");
478    return 0;    return 0;
479  }  }
480  EOF  EOF
481          $c -o genmake_hello genmake_hello.c > /dev/null 2>&1      tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc icc"
482        p_CC=
483        for c in $tmp ; do
484            COMM="$c $CFLAGS -o genmake_hello genmake_hello.c"
485            echo $COMM >> $LOGFILE
486            $COMM >> $LOGFILE 2>&1
487          RETVAL=$?          RETVAL=$?
488          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
489                echo " $c test successful" >> $LOGFILE
490              p_CC="$p_CC $c"              p_CC="$p_CC $c"
491          fi          fi
492      done      done
# Line 346  Error: No C compilers were found in your Line 502  Error: No C compilers were found in your
502  EOF  EOF
503          exit 1          exit 1
504      else      else
505          echo "  The possible C compilers found in your path are:"          echo "  The possible C compilers found in your path are: $p_CC" | tee -a $LOGFILE
         echo "   "$p_CC  
506          if test "x$CC" = x ; then          if test "x$CC" = x ; then
507              CC=`echo $p_CC | $AWK '{print $1}'`              CC=`echo $p_CC | $AWK '{print $1}'`
508              echo "  Setting C compiler to: "$CC              echo "  Setting C compiler to: "$CC
509          fi          fi
510      fi      fi
511        echo " --> set CC='$CC'" >> $LOGFILE
512    }
513    
514    # Guess possible config options for this host
515    find_possible_optfile()  {
516    
517        echo >> $LOGFILE
518        echo "running: find_possible_optfile()" >> $LOGFILE
519        tmp1=`uname`"_"`uname -m`
520        tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
521        tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
522        tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
523        tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
524        tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
525        PLATFORM=$tmp3
526        echo $PLATFORM | grep cygwin > /dev/null 2>&1  &&  PLATFORM=cygwin_ia32
527        OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
528        echo "  The platform appears to be:  $PLATFORM" | tee -a $LOGFILE
529    
530      #================================================================      #================================================================
531      #  look for possible FORTRAN compilers      #  look for possible FORTRAN compilers
532      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 gfortran"      echo "  look for possible FORTRAN compilers" >> $LOGFILE
533        tmp="$MITGCM_FC $FC efc gfortran g77 f77 pgf77 pgf95 ifc ifort f90 f95 mpif77 mpf77 mpxlf95 g95"
534      p_FC=      p_FC=
535      for c in $tmp ; do      rm -f ./genmake_hello.f
536          rm -f ./hello.f ./hello      cat >> genmake_hello.f <<EOF
         cat >> hello.f <<EOF  
537        program hello        program hello
538        do i=1,3        do i=1,3
539          print *, 'hello world : ', i          print *, 'hello world : ', i
540        enddo        enddo
541        end        end
542  EOF  EOF
543          $c -o hello hello.f > /dev/null 2>&1      for f in $tmp ; do
544            COMM="$f -o genmake_hello genmake_hello.f"
545            echo $COMM >> $LOGFILE
546            $COMM >> $LOGFILE 2>&1
547          RETVAL=$?          RETVAL=$?
548          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
549              p_FC="$p_FC $c"              echo " $f test successful" >> $LOGFILE
550                p_FC="$p_FC $f"
551          fi          fi
552      done      done
553      rm -f ./hello.f ./hello      rm -f ./genmake_hello.f ./genmake_hello
554      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
555          cat 1>&2 <<EOF          cat 1>&2 <<EOF
556    
# Line 386  Error: No Fortran compilers were found i Line 563  Error: No Fortran compilers were found i
563  EOF  EOF
564          exit 1          exit 1
565      else      else
566          echo "  The possible FORTRAN compilers found in your path are:"          echo "  The possible FORTRAN compilers found in your path are: $p_FC" | tee -a $LOGFILE
         echo "   "$p_FC  
567      fi      fi
568    
569      #  Use the first of the compilers found in the current PATH      #  Use the first of the compilers found in the current PATH
# Line 396  EOF Line 572  EOF
572          for i in $p_FC ; do          for i in $p_FC ; do
573              OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i              OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
574              if test -r $OPTFILE ; then              if test -r $OPTFILE ; then
575                  echo "  Setting OPTFILE to: "$OPTFILE                  echo "  Setting OPTFILE to: "$OPTFILE | tee -a $LOGFILE
576                  break                  break
577              fi              fi
578          done          done
# Line 405  EOF Line 581  EOF
581      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
582          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
583          if test ! -r $OPTFILE ; then          if test ! -r $OPTFILE ; then
584               echo "  I looked for the file "$OPTFILE" but did not find it"               echo "  I looked for the file "$OPTFILE" but did not find it"
585          fi          fi
586      fi      fi
587  #    echo "  The options file:  $p_OF"  
 #    echo "    appears to match so we'll use it."  
 #   for i in $p_FC ; do  
 #p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i  
 #if test -r $p_OF ; then  
 #    OPTFILE=$p_OF  
 #    echo "  The options file:  $p_OF"  
 #    echo "    appears to match so we'll use it."  
 #    break  
 #fi  
 #   done  
588      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
589          cat 1>&2 <<EOF          cat 1>&2 <<EOF
590    
# Line 434  Error: No options file was found in:  $R Line 600  Error: No options file was found in:  $R
600  EOF  EOF
601          exit 1          exit 1
602      fi      fi
       
 #     # look for possible MPI libraries  
 #     mpi_libs=  
 #     mpi_fort=`which mpif77 2>/dev/null`  
 #     RETVAL=$?  
 #     if test "x${RETVAL}" = x0 ; then  
 #       cat >>test.f <<EOF  
 #       PROGRAM HELLO  
 #       DO 10, I=1,10  
 #       PRINT *,'Hello World'  
 #    10 CONTINUE  
 #       STOP  
 #       END  
 # EOF  
 #       eval "$mpi_fort -showme test.f > out"  
 #       RETVAL=$?  
 #       if test "x${RETVAL}" = x0 ; then  
 #           a=`cat out`  
 #           for i in $a ; do  
 #               case $i in  
 #                   -*)  
 #                       mpi_libs="$mpi_libs $i" ;;  
 #               esac  
 #           done  
 #           echo "The MPI libs appear to be:"  
 #           echo "  "$mpi_libs  
 #       fi  
 #       rm -f test.f out  
 #     fi  
   
603  }  }
604    
605  #  Parse the package dependency information  #  Parse the package dependency information
# Line 472  get_pdepend_list()  { Line 608  get_pdepend_list()  {
608      #  strip the comments and then convert the dependency file into      #  strip the comments and then convert the dependency file into
609      #  two arrays: PNAME, DNAME      #  two arrays: PNAME, DNAME
610      cat $1 | sed -e 's/#.*$//g' \      cat $1 | sed -e 's/#.*$//g' \
611          | $AWK 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \          | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
612          > ./.pd_tmp          > ./.pd_tmp
613        RETVAL=$?
614        if test ! "x${RETVAL}" = x0 ; then
615          echo "Error: unable to parse package dependencies -- please check PKG_DEPEND=\"$1\""
616          exit 1
617        fi
618      . ./.pd_tmp      . ./.pd_tmp
619      rm -f ./.pd_tmp      rm -f ./.pd_tmp
   
     printf "PNAME = "${}  
 }  
   
   
 #  Explain usage  
 usage()  {  
 cat <<EOF  
   
 Usage: "$0" [OPTIONS]  
   where [OPTIONS] can be:  
   
     -help | --help | -h | --h  
           Print this help message and exit.  
   
     -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME  
       -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME  
           Use "NAME" as the adoptfile.  By default, the file at  
           "tools/adjoint_options/adjoint_default" will be used.  
   
     -nooptfile | --nooptfile  
       -optfile NAME | --optfile NAME | -of NAME | --of NAME  
       -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME  
           Use "NAME" as the optfile.  By default, an attempt will be  
           made to find an appropriate "standard" optfile in the  
           tools/build_options/ directory.  
   
     -pdepend NAME | --pdepend NAME  
       -pdepend=NAME | --pdepend=NAME  
           Get package dependency information from "NAME".  
   
     -pdefault NAME | --pdefault NAME  
       -pdefault=NAME | --pdefault=NAME  
           Get the default package list from "NAME".  
   
     -make NAME | -m NAME  
       --make=NAME | -m=NAME  
           Use "NAME" for the MAKE program. The default is "make" but  
           many platforms, "gmake" is the preferred choice.  
   
     -makefile NAME | -mf NAME  
       --makefile=NAME | -mf=NAME  
           Call the makefile "NAME".  The default is "Makefile".  
   
     -makedepend NAME | -md NAME  
       --makedepend=NAME | -md=NAME  
           Use "NAME" for the MAKEDEPEND program.  
   
     -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME  
       -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME  
           Specify the location of the MITgcm ROOTDIR as "NAME".  
           By default, genamke will try to find the location by  
           looking in parent directories (up to the 5th parent).  
   
     -mods NAME | --mods NAME | -mo NAME | --mo NAME  
       -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME  
           Here, "NAME" specifies a list of directories that are  
           used for additional source code.  Files found in the  
           "mods list" are given preference over files of the same  
           name found elsewhere.  
   
     -disable NAME | --disable NAME  
       -disable=NAME | --disable=NAME  
           Here "NAME" specifies a list of packages that we don't  
           want to use.  If this violates package dependencies,  
           genamke will exit with an error message.  
   
     -enable NAME | --enable NAME  
       -enable=NAME | --enable=NAME  
           Here "NAME" specifies a list of packages that we wish  
           to specifically enable.  If this violates package  
           dependencies, genamke will exit with an error message.  
   
     -standarddirs NAME | --standarddirs NAME  
       -standarddirs=NAME | --standarddirs=NAME  
           Here, "NAME" specifies a list of directories to be  
           used as the "standard" code.  
   
     -fortran NAME | --fortran NAME | -fc NAME | --fc NAME  
       -fc=NAME | --fc=NAME  
           Use "NAME" as the fortran compiler.  By default, genmake  
           will search for a working compiler by trying a list of  
           "usual suspects" such as g77, f77, etc.  
   
     -cc NAME | --cc NAME | -cc=NAME | --cc=NAME  
           Use "NAME" as the C compiler.  By default, genmake  
           will search for a working compiler by trying a list of  
           "usual suspects" such as gcc, c89, cc, etc.  
   
     -[no]ieee | --[no]ieee  
           Do or don't use IEEE numerics.  Note that this option  
           *only* works if it is supported by the OPTFILE that  
           is being used.  
   
     -ignoretime | -ignore_time | --ignoretime | --ignore_time  
           Ignore all the "wall clock" routines entirely.  This will  
           not in any way hurt the model results -- it simply means  
           that the code that checks how long the model spends in  
           various routines will give junk values.  
   
     -ts | --ts  
           Produce timing information per timestep  
     -papis | --papis  
           Produce summary MFlop/s with PAPI per timestep  
     -foolad | --foolad  
           Fool the AD code generator  
     -papi | --papi  
           Performance analysis with PAPI  
     -hpmt | --hpmt  
           Performance analysis with the HPM Toolkit  
   
     -gsl | --gsl  
           Use GSL to control floating point rounding and precision  
   
     -mpi | --mpi  
           Include MPI header files and link to MPI libraries  
     -mpi=PATH | --mpi=PATH  
           Include MPI header files and link to MPI libraries using MPI_ROOT  
           set to PATH. i.e. Include files from \$PATH/include, link to libraries  
           from \$PATH/lib and use binaries from \$PATH/bin.  
   
     -es | --es | -embed-source | --embed-source  
           Embed a tarball containing the full source code  
           (including the Makefile, etc.) used to build the  
           executable [off by default]  
   
     -bash NAME  
           Explicitly specify the Bourne or BASH shell to use  
   
   While it is most often a single word, the "NAME" variables specified  
   above can in many cases be a space-delimited string such as:  
   
     --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'  
     -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'  
     -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'  
   
   which, depending upon your shell, may need to be single-quoted.  
   
   For more detailed genmake documentation, please see:  
   
     http://mitgcm.org/devel_HOWTO/  
   
 EOF  
   
     exit 1  
620  }  }
621    
622  #  Build a CPP macro to automate calling C routines from FORTRAN  #  Build a CPP macro to automate calling C routines from FORTRAN
# Line 628  get_fortran_c_namemangling()  { Line 624  get_fortran_c_namemangling()  {
624    
625      #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""      #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
626      if test ! "x$FC_NAMEMANGLE" = x ; then      if test ! "x$FC_NAMEMANGLE" = x ; then
627          return 0          return 0
628      fi      fi
629        echo " running: get_fortran_c_namemangling()" >> $LOGFILE
630    
631      default_nm="#define FC_NAMEMANGLE(X) X ## _"      default_nm="#define FC_NAMEMANGLE(X) X ## _"
632        
633      cat > genmake_test.c <<EOF      cat > genmake_test.c <<EOF
634  void tcall( char * string ) { tsub( string ); }  void tcall( char * string ) { tsub( string ); }
635  EOF  EOF
636      $MAKE genmake_test.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_test.c"
637        echo ' '$COMM >> $LOGFILE
638        $COMM >> $LOGFILE 2>&1
639      RETVAL=$?      RETVAL=$?
640      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
641          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
642          cat <<EOF>> genmake_errors          cat <<EOF>> $LOGFILE
643    
644  WARNING: C test compile fails   WARNING: C test compile fails
645  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
646  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
647  EOF  EOF
648          return 1          return 1
649      fi      fi
# Line 652  EOF Line 651  EOF
651      RETVAL=$?      RETVAL=$?
652      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
653          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
654          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
655    
656  WARNING: The "nm" command failed.   WARNING: The "nm" command failed.
657  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
658  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
659  EOF  EOF
660          return 1          return 1
661      fi      fi
# Line 666  EOF Line 665  EOF
665        call tsub( string )        call tsub( string )
666        end        end
667  EOF  EOF
668      $FC $FFLAGS -c genmake_tcomp.$FS >> genmake_warnings 2>&1      COMM="$FC $FFLAGS -c genmake_tcomp.$FS"
669        echo ' '$COMM >> $LOGFILE
670        $COMM >> $LOGFILE 2>&1
671      RETVAL=$?      RETVAL=$?
672      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
673          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
674          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
675    
676  WARNING: FORTRAN test compile fails -- please see "genmake_errors"   WARNING: FORTRAN test compile fails -- please see '$LOGFILE'
677  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
678  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
679  EOF  EOF
680          return 1          return 1
681      fi      fi
# Line 682  EOF Line 683  EOF
683      RETVAL=$?      RETVAL=$?
684      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
685          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
686          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
687    
688  WARNING: The "nm" command failed.   WARNING: The "nm" command failed.
689  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
690  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
691  EOF  EOF
692          return 1          return 1
693      fi      fi
# Line 712  EOF Line 713  EOF
713    
714      #  cleanup the testing files      #  cleanup the testing files
715      rm -f genmake_tcomp.* genmake_test.*      rm -f genmake_tcomp.* genmake_test.*
 }  
716    
717        echo " --> set FC_NAMEMANGLE='$FC_NAMEMANGLE'" >> $LOGFILE
718    }
719    
720  check_HAVE_CLOC()  {  check_HAVE_CLOC()  {
721        echo >> $LOGFILE
722        echo "running: check_HAVE_CLOC()" >> $LOGFILE
723      get_fortran_c_namemangling      get_fortran_c_namemangling
724      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
725  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 732  void FC_NAMEMANGLE(cloc) ( double *curti Line 736  void FC_NAMEMANGLE(cloc) ( double *curti
736   *curtim = *curtim/1.E6;   *curtim = *curtim/1.E6;
737  }  }
738  EOF  EOF
739      make genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
740        echo $COMM >> $LOGFILE
741        $COMM >> $LOGFILE 2>&1
742      RET_C=$?      RET_C=$?
743      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
744        program hello        program hello
# Line 742  EOF Line 748  EOF
748        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
749        end        end
750  EOF  EOF
751      $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
752        echo $COMM >> $LOGFILE
753        $COMM >> $LOGFILE 2>&1
754      RET_F=$?      RET_F=$?
755      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> $LOGFILE 2>&1
756      RETVAL=$?      RETVAL=$?
757      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
758          HAVE_CLOC=t          HAVE_CLOC=t
         DEFINES="$DEFINES -DHAVE_CLOC"  
759      fi      fi
760      rm -f genmake_tc*      rm -f genmake_tc*
761        echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE
762  }  }
763    
   
764  check_HAVE_SIGREG()  {  check_HAVE_SIGREG()  {
765        if test ! "x$HAVE_SIGREG" = x ; then
766            return
767        fi
768        echo >> $LOGFILE
769        echo "running: check_HAVE_SIGREG()" >> $LOGFILE
770      get_fortran_c_namemangling      get_fortran_c_namemangling
771      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
772  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 786  void FC_NAMEMANGLE(sigreg) (int * aip) Line 798  void FC_NAMEMANGLE(sigreg) (int * aip)
798      return;      return;
799  }  }
800  EOF  EOF
801      make genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
802        echo $COMM >> $LOGFILE
803        $COMM >> $LOGFILE 2>&1
804      RET_C=$?      RET_C=$?
805      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
806        program hello        program hello
# Line 796  EOF Line 810  EOF
810        call sigreg(anint)        call sigreg(anint)
811        end        end
812  EOF  EOF
813      echo >> genmake_warnings      cat genmake_tc_2.$FS >> $LOGFILE
     echo "running: check_HAVE_SIGREG()" >> genmake_warnings  
     cat genmake_tc_2.$FS >> genmake_warnings  
814      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
815      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
816      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
817      RETVAL=$?      RETVAL=$?
818      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
819          HAVE_SIGREG=t          HAVE_SIGREG=t
         DEFINES="$DEFINES -DHAVE_SIGREG"  
820      fi      fi
821      rm -f genmake_tc*      rm -f genmake_tc*
822        echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE
823  }  }
824    
   
825  check_HAVE_SETRLSTK()  {  check_HAVE_SETRLSTK()  {
826        if test ! "x$HAVE_SETRLSTK" = x ; then
827            return
828        fi
829        echo >> $LOGFILE
830        echo "running: check_HAVE_SETRLSTK()" >> $LOGFILE
831      get_fortran_c_namemangling      get_fortran_c_namemangling
832      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
833  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 827  void FC_NAMEMANGLE(setrlstk) () Line 843  void FC_NAMEMANGLE(setrlstk) ()
843      return;      return;
844  }  }
845  EOF  EOF
846      make genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
847        echo $COMM >> $LOGFILE
848        $COMM >> $LOGFILE 2>&1
849      RET_C=$?      RET_C=$?
850      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
851        program hello        program hello
# Line 835  EOF Line 853  EOF
853        call setrlstk()        call setrlstk()
854        end        end
855  EOF  EOF
856      echo >> genmake_warnings      cat genmake_tc_2.$FS >> $LOGFILE
     echo "running: check_HAVE_SETRLSTK()" >> genmake_warnings  
     cat genmake_tc_2.$FS >> genmake_warnings  
857      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
858      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
859      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
860      RETVAL=$?      RETVAL=$?
861      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
862          HAVE_SETRLSTK=t          HAVE_SETRLSTK=t
         DEFINES="$DEFINES -DHAVE_SETRLSTK"  
863      fi      fi
864      rm -f genmake_tc*      rm -f genmake_tc*
865        echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE
866  }  }
867    
   
868  check_HAVE_STAT()  {  check_HAVE_STAT()  {
869        echo >> $LOGFILE
870        echo "running: check_HAVE_STAT()" >> $LOGFILE
871      get_fortran_c_namemangling      get_fortran_c_namemangling
872      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
873  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 871  void FC_NAMEMANGLE(tfsize) ( int *nbyte Line 888  void FC_NAMEMANGLE(tfsize) ( int *nbyte
888          *nbyte = -1;          *nbyte = -1;
889  }  }
890  EOF  EOF
891      make genmake_tc_1.o >> genmake_tc.log 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
892        echo $COMM >> $LOGFILE
893        $COMM >> genmake_tc.log 2>&1
894      RET_C=$?      RET_C=$?
895      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
896        program hello        program hello
# Line 880  EOF Line 899  EOF
899        print *," HELLO WORLD", nbyte        print *," HELLO WORLD", nbyte
900        end        end
901  EOF  EOF
902      echo >> genmake_warnings      cat genmake_tc_2.$FS >> $LOGFILE
     echo "running: check_HAVE_STAT()" >> genmake_warnings  
     cat genmake_tc_2.$FS >> genmake_warnings  
903      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
904      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
905      $COMM >> genmake_tc.log 2>&1      $COMM >> genmake_tc.log 2>&1
906      RETVAL=$?      RETVAL=$?
907      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
908          HAVE_STAT=t          HAVE_STAT=t
         DEFINES="$DEFINES -DHAVE_STAT"  
909      fi      fi
910      rm -f genmake_tc*      rm -f genmake_tc*
911        echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE
912  }  }
913    
   
914  check_netcdf_libs()  {  check_netcdf_libs()  {
915      if test ! "x$SKIP_NETCDF_CHECK" = x ; then      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
916          return          return
917      fi      fi
918      echo >> genmake_warnings      echo >> $LOGFILE
919      echo "running: check_netcdf_libs()" >> genmake_warnings      echo "running: check_netcdf_libs()" >> $LOGFILE
920      cat <<EOF > genmake_tnc.F      cat <<EOF > genmake_tnc.F
921        program fgennc        program fgennc
922  #include "netcdf.inc"  #include "netcdf.inc"
923  EOF  EOF
924      if test ! "x$MPI" = x ; then     #if test ! "x$MPI" = x ; then
925          echo '#include "mpif.h"' >> genmake_tnc.F     #    echo '#include "mpif.h"' >> genmake_tnc.F
926      fi     #fi
927      cat <<EOF >> genmake_tnc.F      cat <<EOF >> genmake_tnc.F
928        integer iret, ncid, xid        integer iret, ncid, xid
929        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
# Line 918  EOF Line 934  EOF
934        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
935        end        end
936  EOF  EOF
937      echo "===  genmake_tnc.F  ===" > genmake_tnc.log      echo "===  genmake_tnc.F  >>>" > genmake_tnc.log
938      cat genmake_tnc.F >> genmake_tnc.log      cat genmake_tnc.F >> genmake_tnc.log
939      echo "===  genmake_tnc.F  ===" >> genmake_tnc.log      echo "<<<  genmake_tnc.F  ===" >> genmake_tnc.log
940      RET_CPP=f      RET_CPP=f
941      COMM="$CPP $DEFINES $INCLUDES genmake_tnc.F"      COMM="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES"
942      echo "$COMM" >> genmake_tnc.log      echo "$COMM" >> genmake_tnc.log
943      $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t      eval $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t
944      if test "x$RET_CPP" = xf ; then      if test "x$RET_CPP" = xf ; then
945          echo "  WARNING: CPP failed to pre-process the netcdf test." \          echo "  WARNING: CPP failed to pre-process the netcdf test." \
946              >> genmake_tnc.log              >> genmake_tnc.log
# Line 932  EOF Line 948  EOF
948              >> genmake_tnc.log              >> genmake_tnc.log
949      fi      fi
950      echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log      echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log
951      echo "  &&  $LINK -o genmake_tnc.o $LIBS" >> genmake_tnc.log      echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc.o $LIBS" >> genmake_tnc.log
952      $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \      $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
953          &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1          &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
954      RET_COMPILE=$?      RET_COMPILE=$?
955      cat genmake_tnc.log >> genmake_warnings      cat genmake_tnc.log >> $LOGFILE
956    
957      #EH3  Remove test program execution for machines that either disallow      #EH3  Remove test program execution for machines that either disallow
958      #EH3  execution or cannot support it (eg. cross-compilers)      #EH3  execution or cannot support it (eg. cross-compilers)
# Line 947  EOF Line 963  EOF
963    
964      if test "x$RET_COMPILE" = x0 ; then      if test "x$RET_COMPILE" = x0 ; then
965          HAVE_NETCDF=t          HAVE_NETCDF=t
966            echo "check_netcdf: successful" >> $LOGFILE
967      else      else
968          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
969          echo "try again with added '-lnetcdf'" > genmake_tnc.log          echo "==> try again with added '-lnetcdf'" > genmake_tnc.log
970          echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log          echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
971          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
972          echo " &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log          echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
973          $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \          cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null  \
974              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
975              &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1              &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
976          RET_COMPILE=$?          RET_COMPILE=$?
977          cat genmake_tnc.log >> genmake_warnings          echo >> $LOGFILE
978            cat genmake_tnc.log >> $LOGFILE
979          if test "x$RET_COMPILE" = x0 ; then          if test "x$RET_COMPILE" = x0 ; then
980              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
981              HAVE_NETCDF=t              HAVE_NETCDF=t
982                echo "check_netcdf: successful" >> $LOGFILE
983            else
984            # try again with "-lnetcdff" added to the libs
985                echo "==> try again with added '-lnetcdff -lnetcdf'" > genmake_tnc.log
986                echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
987                echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
988                echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
989                cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null  \
990                    &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
991                    &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdff -lnetcdf >> genmake_tnc.log 2>&1
992                RET_COMPILE=$?
993                echo >> $LOGFILE
994                cat genmake_tnc.log >> $LOGFILE
995                if test "x$RET_COMPILE" = x0 ; then
996                    LIBS="$LIBS -lnetcdff -lnetcdf"
997                    HAVE_NETCDF=t
998                    echo "check_netcdf: successful" >> $LOGFILE
999                fi
1000          fi          fi
1001      fi      fi
1002      rm -f genmake_tnc*      rm -f genmake_tnc*
1003        echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE
1004  }  }
1005    
1006    check_lapack_libs()  {
1007        if test ! "x$SKIP_LAPACK_CHECK" = x ; then
1008            return
1009        fi
1010        echo >> $LOGFILE
1011        echo "running: check_lapack_libs()" >> $LOGFILE
1012        cat <<EOF > genmake_tla.F
1013          program fgenla
1014          integer info
1015          integer ipiv( 2 )
1016          double precision ab( 4, 2 ), b( 2 )
1017          data ab / 0., 0., 1., 2., 0., 2., 1., 0. /
1018          data b / 1., 1. /
1019          call dgbsv( 2, 1, 1, 1, ab, 4, ipiv, b, 2, info )
1020          IF (info .NE. 0) write(*,*) 'Error:', info
1021          write(*,*) b
1022          end
1023    EOF
1024        echo "===  genmake_tla.F  >>>" > genmake_tla.log
1025        cat genmake_tla.F >> genmake_tla.log
1026        echo "<<<  genmake_tla.F  ===" >> genmake_tla.log
1027        RET_CPP=f
1028        COMM="cat genmake_tla.F | $CPP $DEFINES $INCLUDES"
1029        echo "$COMM" >> genmake_tla.log
1030        eval $COMM > genmake_tla.$FS 2>/dev/null  &&  RET_CPP=t
1031        if test "x$RET_CPP" = xf ; then
1032            echo "  WARNING: CPP failed to pre-process the lapack test." \
1033                >> genmake_tla.log
1034            echo "    Please check that \$INCLUDES is properly set." \
1035                >> genmake_tla.log
1036        fi
1037        echo "$FC $FFLAGS $FOPTIM -c genmake_tla.$FS  \ " >> genmake_tla.log
1038        echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tla.o $LIBS" >> genmake_tla.log
1039        $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1040            &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS >> genmake_tla.log 2>&1
1041        RET_COMPILE=$?
1042        cat genmake_tla.log >> $LOGFILE
1043    
1044        # test program execution not always possible (see check_netcdf_libs)
1045        #
1046        #test -x ./genmake_tla  &&  ./genmake_tla >> genmake_tla.log 2>&1
1047        #RETVAL=$?
1048        #if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
1049    
1050        if test "x$RET_COMPILE" = x0 ; then
1051            HAVE_LAPACK=t
1052            echo "check_lapack: successful" >> $LOGFILE
1053        else
1054            # try again with "-llapack" added to the libs
1055            echo "==> try again with added '-llapack'" > genmake_tla.log
1056            echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1057            echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1058            echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack" >> genmake_tla.log
1059            cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1060                &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1061                &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack >> genmake_tla.log 2>&1
1062            RET_COMPILE=$?
1063            echo >> $LOGFILE
1064            cat genmake_tla.log >> $LOGFILE
1065            if test "x$RET_COMPILE" = x0 ; then
1066                LIBS="$LIBS -llapack"
1067                HAVE_LAPACK=t
1068                echo "check_lapack: successful" >> $LOGFILE
1069            else
1070            # try again with "-lf77blas -lcblas" added to the libs
1071                echo "==> try again with added '-llapack -lf77blas -lcblas'" > genmake_tla.log
1072                echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1073                echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1074                echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas" >> genmake_tla.log
1075                cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1076                    &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1077                    &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas >> genmake_tla.log 2>&1
1078                RET_COMPILE=$?
1079                echo >> $LOGFILE
1080                cat genmake_tla.log >> $LOGFILE
1081                if test "x$RET_COMPILE" = x0 ; then
1082                    LIBS="$LIBS -llapack -lf77blas -lcblas"
1083                    HAVE_LAPACK=t
1084                    echo "check_lapack: successful" >> $LOGFILE
1085                else
1086                # try again with "-latlas" added to the libs
1087                    echo "==> try again with added '-llapack -lf77blas -lcblas -latlas'" > genmake_tla.log
1088                    echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1089                    echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1090                    echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas" >> genmake_tla.log
1091                    cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1092                        &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1093                        &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas >> genmake_tla.log 2>&1
1094                    RET_COMPILE=$?
1095                    echo >> $LOGFILE
1096                    cat genmake_tla.log >> $LOGFILE
1097                    if test "x$RET_COMPILE" = x0 ; then
1098                        LIBS="$LIBS -llapack -lf77blas -lcblas -latlas"
1099                        HAVE_LAPACK=t
1100                        echo "check_lapack: successful" >> $LOGFILE
1101                    fi
1102                fi
1103            fi
1104        fi
1105        rm -f genmake_tla*
1106        echo " --> set HAVE_LAPACK='$HAVE_LAPACK'" >> $LOGFILE
1107    }
1108    
1109    check_HAVE_FLUSH()  {
1110        if test ! "x$SKIP_CHECK_FLUSH" = x ; then
1111            return
1112        fi
1113        echo >> $LOGFILE
1114        echo "running: check_HAVE_FLUSH()" >> $LOGFILE
1115        cat <<EOF > genmake_tflsh.$FS
1116          program fgenflsh
1117          integer iounit
1118          character*9 fname
1119          iounit = 26
1120          fname = 'tmp.tflsh'
1121          open(iounit,FILE=fname,STATUS='unknown')
1122          write(iounit,*) 'genmake_tflsh: hello'
1123          call flush(iounit)
1124          close(iounit)
1125          end
1126    EOF
1127        echo "===  genmake_tflsh.$FS  >>>" > genmake_tflsh.log
1128        cat genmake_tflsh.$FS >> genmake_tflsh.log
1129        echo "<<<  genmake_tflsh.$FS  ===" >> genmake_tflsh.log
1130    
1131        echo "$FC $FFLAGS $FOPTIM -c genmake_tflsh.$FS  \ " >> genmake_tflsh.log
1132        echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tflsh.o $LIBS" >> genmake_tflsh.log
1133        $FC $FFLAGS $FOPTIM -c genmake_tflsh.$FS >> genmake_tflsh.log 2>&1  \
1134            &&  $LINK $FFLAGS $FOPTIM -o genmake_tflsh genmake_tflsh.o $LIBS >> genmake_tflsh.log 2>&1
1135        RET_COMPILE=$?
1136    
1137        if test "x$RET_COMPILE" = x0 ; then
1138            HAVE_FLUSH=t
1139            #cat genmake_tflsh.log >> $LOGFILE
1140            echo "  check_HAVE_FLUSH: successful" >> $LOGFILE
1141        else
1142            HAVE_FLUSH=f
1143            cat genmake_tflsh.log >> $LOGFILE
1144        fi
1145        rm -f genmake_tflsh*
1146        echo " --> set HAVE_FLUSH='$HAVE_FLUSH'" >> $LOGFILE
1147    }
1148    
1149  ###############################################################################  ###############################################################################
1150  #   Sequential part of script starts here  #   Sequential part of script starts here
# Line 989  ENABLE= Line 1167  ENABLE=
1167  DISABLE=  DISABLE=
1168  # MAKEFILE=  # MAKEFILE=
1169  # MAKEDEPEND=  # MAKEDEPEND=
1170  PDEPEND=  PKG_DEPEND=
1171  DUMPSTATE=t  PKG_GROUPS=
1172  PDEFAULT=  DUMPSTATE=f
1173  OPTFILE=  OPTFILE=
1174  INCLUDES="-I. $INCLUDES"  INCLUDES="-I. $INCLUDES"
1175  FFLAGS=  FFLAGS=
1176  FOPTIM=  FOPTIM=
1177    FEXTRAFLAGS=
1178    USE_EXTENDED_SRC=
1179    EXTENDED_SRC_FLAG=
1180    GET_FC_VERSION=
1181  CFLAGS=  CFLAGS=
1182  KFLAGS1=  KFLAGS1=
1183  KFLAGS2=  KFLAGS2=
# Line 1006  NOOPTFILES= Line 1188  NOOPTFILES=
1188  NOOPTFLAGS=  NOOPTFLAGS=
1189  MPI=  MPI=
1190  MPIPATH=  MPIPATH=
1191    OMP=
1192    OMPFLAG=
1193    USE_R4=
1194  TS=  TS=
1195  PAPIS=  PAPIS=
1196    PCLS=
1197  FOOLAD=  FOOLAD=
1198  PAPI=  PAPI=
1199    PCL=
1200  HPMT=  HPMT=
1201  GSL=  GSL=
1202    DEVEL=
1203  HAVE_TEST_L=  HAVE_TEST_L=
1204    
1205    # comment this line out to enable lapack test
1206    SKIP_LAPACK_CHECK=t
1207    
1208  # DEFINES checked by test compilation or command-line  # DEFINES checked by test compilation or command-line
1209  HAVE_SYSTEM=  HAVE_SYSTEM=
1210  HAVE_FDATE=  HAVE_FDATE=
1211  FC_NAMEMANGLE=  FC_NAMEMANGLE=
1212  HAVE_CLOC=  HAVE_CLOC=
1213  HAVE_SETRLSTK=  # HAVE_SETRLSTK=
1214  HAVE_STAT=  HAVE_STAT=
1215  HAVE_NETCDF=  HAVE_NETCDF=
1216  HAVE_ETIME=  HAVE_ETIME=
1217  IGNORE_TIME=  IGNORE_TIME=
1218    HAVE_LAPACK=
1219    HAVE_FLUSH=
1220    
1221  MODS=  MODS=
1222  TOOLSDIR=  TOOLSDIR=
# Line 1031  SOURCEDIRS= Line 1224  SOURCEDIRS=
1224  INCLUDEDIRS=  INCLUDEDIRS=
1225  STANDARDDIRS="USE_THE_DEFAULT"  STANDARDDIRS="USE_THE_DEFAULT"
1226    
1227    #- local config file
1228    gm_local="genmake_local"
1229    
1230  G2ARGS=  G2ARGS=
1231  BASH=  BASH=
1232  PWD=`pwd`  PWD=`pwd`
# Line 1046  MACHINE=`uname -a` Line 1242  MACHINE=`uname -a`
1242  EXECUTABLE=  EXECUTABLE=
1243  EXEHOOK=  EXEHOOK=
1244  EXEDIR=  EXEDIR=
 PACKAGES_CONF=  
1245  IEEE=  IEEE=
1246  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
1247      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
# Line 1067  FTL_TAF_FLAGS= Line 1262  FTL_TAF_FLAGS=
1262  SVD_TAMC_FLAGS=  SVD_TAMC_FLAGS=
1263  TAMC_EXTRA=  TAMC_EXTRA=
1264    
   
1265  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1266  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="ROOTDIR STANDARDDIRS MODS PKG_DEPEND PKG_GROUPS DISABLE ENABLE"
1267  gm_s2="FC CPP IEEE TS PAPIS PAPI HPMT GSL MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="PLATFORM OPTFILE MAKE MAKEFILE MAKEDEPEND FC CC MPI OMP USE_R4"
1268    gm_s3="FEXTRAFLAGS IEEE DEVEL GSL TS PAPIS PCLS PAPI PCL HPMT DUMPSTATE"
1269    
1270  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1271  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "  gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM"
1272  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
1273  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"  gm_s6="PWD TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"
1274  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s7="THISHOST THISUSER THISDATE THISVER MACHINE FC_NAMEMANGLE"
1275  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"  gm_s8="HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME HAVE_LAPACK HAVE_FLUSH"
1276    
1277  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1278  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
1279  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"
1280  gm_s12="TAF_EXTRA TAMC_EXTRA"  gm_s12="TAF_EXTRA TAMC_EXTRA"
1281    
1282  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7"  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8"
1283  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
1284    
1285  cat <<EOF  cat <<EOF
1286    
1287  GENMAKE :  GENMAKE :
1288    
1289  A program for GENerating MAKEfiles for the MITgcm project.  For a  A program for GENerating MAKEfiles for the MITgcm project.
1290  quick list of options, use "genmake -h" or for more detail see:     For a quick list of options, use "genmake2 -h"
1291    or for more detail see the Developer's HOWTO manual at:
1292    http://mitgcm.org/devel_HOWTO/     http://mitgcm.org/public/docs.html
1293    
1294  EOF  EOF
1295    
1296    LOGFILE="genmake.log"
1297    #- clean-up previous genmake logfiles:
1298    rm -f genmake_state genmake_*optfile $LOGFILE
1299    
1300  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
 gm_local="genmake_local"  
 for i in . $MODS ; do  
     if test -r $i/$gm_local ; then  
         . $i/$gm_local  
         break  
     fi  
 done  
 printf "  getting local config information:  "  
 if test -f $gm_local ; then  
     echo "using $gm_local"  
     . $gm_local  
     # echo "DISABLE=$DISABLE"  
     # echo "ENABLE=$ENABLE"  
 else  
     echo "none found"  
 fi  
1301    
1302  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
 #OPTIONS=  
 #n=0  
 #for i ; do  
 #   echo "$i  $n"  
 #   setvar="OPTIONS[$n]='$i'"  
 #   #  echo "  $setvar"  
 #   eval "$setvar"  
 #   n=$(( $n + 1 ))  
 #done  
1303  #parse_options  #parse_options
1304  ac_prev=  ac_prev=
1305  for ac_option in "$@" ; do  for ac_option in "$@" ; do
# Line 1138  for ac_option in "$@" ; do Line 1312  for ac_option in "$@" ; do
1312          ac_prev=          ac_prev=
1313          continue          continue
1314      fi      fi
1315        
1316      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
1317        
1318      case $ac_option in      case $ac_option in
1319            
1320          -help | --help | -h | --h)          -help | --help | -h | --h)
1321              usage ;;              usage ;;
1322            
1323          -nooptfile | --nooptfile)          -nooptfile | --nooptfile)
1324              OPTFILE="NONE" ;;              OPTFILE="NONE" ;;
1325          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
1326              ac_prev=OPTFILE ;;              ac_prev=OPTFILE ;;
1327          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
1328              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
1329            
1330          -adoptfile | --adoptfile | -adof | --adof)          -adoptfile | --adoptfile | -adof | --adof)
1331              ac_prev=AD_OPTFILE ;;              ac_prev=AD_OPTFILE ;;
1332          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
1333              AD_OPTFILE=$ac_optarg ;;              AD_OPTFILE=$ac_optarg ;;
1334            
1335          -pdepend | --pdepend)          -pdepend | --pdepend)
1336              ac_prev=PDEPEND ;;              ac_prev=PKG_DEPEND ;;
1337          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
1338              PDEPEND=$ac_optarg ;;              PKG_DEPEND=$ac_optarg ;;
1339            
1340          -pdefault | --pdefault)          -pgroups | --pgroups)
1341              ac_prev=PDEFAULT ;;              ac_prev=PKG_GROUPS ;;
1342          -pdefault=* | --pdefault=*)          -pgroups=* | --pgroups=*)
1343              PDEFAULT=$ac_optarg ;;              PKG_GROUPS=$ac_optarg ;;
1344            
1345          -make | --make | -m | --m)          -make | --make | -m | --m)
1346              ac_prev=MAKE ;;              ac_prev=MAKE ;;
1347          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
1348              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
1349            
1350          -bash | --bash)          -bash | --bash)
1351              ac_prev=BASH ;;              ac_prev=BASH ;;
1352          -bash=* | --bash=*)          -bash=* | --bash=*)
1353              BASH=$ac_optarg ;;              BASH=$ac_optarg ;;
1354            
1355          -makedepend | --makedepend | -md | --md)          -makedepend | --makedepend | -md | --md)
1356              ac_prev=MAKEDEPEND ;;              ac_prev=MAKEDEPEND ;;
1357          -makedepend=* | --makedepend=* | -md=* | --md=*)          -makedepend=* | --makedepend=* | -md=* | --md=*)
1358              MAKEDEPEND=$ac_optarg ;;              MAKEDEPEND=$ac_optarg ;;
1359            
1360          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -mf | --mf)
1361              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
1362          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -mf=* | --mf=*)
1363              MAKEFILE=$ac_optarg ;;              MAKEFILE=$ac_optarg ;;
1364            
1365          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)
1366              echo "ERROR: The platform option has been removed.  Please specify"              echo "ERROR: The platform option has been removed.  Please specify"
1367              echo "  the build options using the \"optfile\" mechanism."              echo "  the build options using the \"optfile\" mechanism."
1368              echo              echo
1369              usage              usage
1370              ;;              ;;
1371            
1372          -rootdir | --rootdir | -rd | --rd)          -rootdir | --rootdir | -rd | --rd)
1373              ac_prev=ROOTDIR ;;              ac_prev=ROOTDIR ;;
1374          -rootdir=* | --rootdir=* | -rd=* | --rd=*)          -rootdir=* | --rootdir=* | -rd=* | --rd=*)
1375              ROOTDIR=$ac_optarg ;;              ROOTDIR=$ac_optarg ;;
1376            
1377          -mods | --mods | -mo | --mo)          -mods | --mods | -mo | --mo)
1378              ac_prev=MODS ;;              ac_prev=MODS ;;
1379          -mods=* | --mods=* | -mo=* | --mo=*)          -mods=* | --mods=* | -mo=* | --mo=*)
1380              MODS=$ac_optarg ;;              MODS=$ac_optarg ;;
1381            
1382          -disable | --disable)          -disable | --disable)
1383              ac_prev=DISABLE ;;              ac_prev=DISABLE ;;
1384          -disable=* | --disable=*)          -disable=* | --disable=*)
1385              DISABLE=$ac_optarg ;;              DISABLE=$ac_optarg ;;
1386            
1387          -enable | --enable)          -enable | --enable)
1388              ac_prev=ENABLE ;;              ac_prev=ENABLE ;;
1389          -enable=* | --enable=*)          -enable=* | --enable=*)
1390              ENABLE=$ac_optarg ;;              ENABLE=$ac_optarg ;;
1391            
1392          -standarddirs | --standarddirs)          -standarddirs | --standarddirs)
1393              ac_prev=STANDARDDIRS ;;              ac_prev=STANDARDDIRS ;;
1394          -standarddirs=* | --standarddirs=*)          -standarddirs=* | --standarddirs=*)
# Line 1224  for ac_option in "$@" ; do Line 1398  for ac_option in "$@" ; do
1398  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1399  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1400  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1401            
1402          -cc | --cc)          -cc | --cc)
1403              ac_prev=CC ;;              ac_prev=CC ;;
1404          -cc=* | --cc=*)          -cc=* | --cc=*)
1405              CC=$ac_optarg ;;              CC=$ac_optarg ;;
1406            
1407          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1408              ac_prev=FC ;;              ac_prev=FC ;;
1409          -fc=* | --fc=*)          -fc=* | --fc=*)
1410              FC=$ac_optarg ;;              FC=$ac_optarg ;;
1411            
1412          -fs | --fs)          -fs | --fs)
1413              ac_prev=FS ;;              ac_prev=FS ;;
1414          -fs=* | --fs=*)          -fs=* | --fs=*)
1415              FS=$ac_optarg ;;              FS=$ac_optarg ;;
1416            
1417          -fs90 | --fs90)          -fs90 | --fs90)
1418              ac_prev=FS90 ;;              ac_prev=FS90 ;;
1419          -fs90=* | --fs90=*)          -fs90=* | --fs90=*)
1420              FS90=$ac_optarg ;;              FS90=$ac_optarg ;;
1421            
1422            -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )
1423                USE_R4=true ;;
1424    
1425          -ieee | --ieee)          -ieee | --ieee)
1426              IEEE=true ;;              IEEE=true ;;
1427          -noieee | --noieee)          -noieee | --noieee)
1428              IEEE= ;;              echo "Warning: ignore option '$ac_option' (default is already without '-ieee')" ;;
1429            -devel | --devel)
1430                IEEE=true ; DEVEL=true ;;
1431            -gsl | --gsl)
1432                GSL=true ;;
1433    
1434          -ts | --ts)          -ts | --ts)
1435              TS=true ;;              TS=true ;;
1436          -papis | --papis)          -papis | --papis)
1437              PAPIS=true ;;              PAPIS=true ;;
1438            -pcls | --pcls)
1439                PCLS=true ;;
1440          -foolad | --foolad)          -foolad | --foolad)
1441              FOOLAD=true ;;              FOOLAD=true ;;
1442          -papi | --papi)          -papi | --papi)
1443              PAPI=true ;;              PAPI=true ;;
1444            -pcl | --pcl)
1445                PCL=true ;;
1446          -hpmt | --hpmt)          -hpmt | --hpmt)
1447              HPMT=true ;;              HPMT=true ;;
1448    
         -gsl | --gsl)  
             GSL=true ;;  
   
1449          -mpi | --mpi)          -mpi | --mpi)
1450              MPI=true ;;              MPI=true ;;
1451          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
1452              MPIPATH=$ac_optarg              MPIPATH=$ac_optarg
1453              MPI=true ;;              MPI=true ;;
1454            
1455  #       -jam | --jam)          -omp | --omp)
1456  #           JAM=1 ;;              OMP=true ;;
1457  #       -nojam | --nojam)          -omp=* | --omp=*)
1458  #           JAM=0 ;;              OMPFLAG=$ac_optarg
1459                        OMP=true ;;
1460    
1461          -ds | --ds)          -ds | --ds)
1462              DUMPSTATE=t ;;              DUMPSTATE=t ;;
1463            
1464            -extra_flag | --extra_flag)
1465                ac_prev=FEXTRAFLAGS ;;
1466            -extra_flag=* | --extra_flag=*)
1467                FEXTRAFLAGS=$ac_optarg ;;
1468    
1469          -taf_extra | --taf_extra)          -taf_extra | --taf_extra)
1470              ac_prev=TAF_EXTRA ;;              ac_prev=TAF_EXTRA ;;
1471          -taf_extra=* | --taf_extra=*)          -taf_extra=* | --taf_extra=*)
# Line 1287  for ac_option in "$@" ; do Line 1475  for ac_option in "$@" ; do
1475              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1476          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1477              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1478            
1479          -ignoretime | -ignore_time | --ignoretime | --ignore_time)          -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1480              IGNORE_TIME="-DIGNORE_TIME" ;;              IGNORE_TIME="-DIGNORE_TIME" ;;
1481    
# Line 1298  for ac_option in "$@" ; do Line 1486  for ac_option in "$@" ; do
1486              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
1487              usage              usage
1488              ;;              ;;
1489            
1490          *)          *)
1491              echo "Error: unrecognized argument: "$ac_option              echo "Error: unrecognized argument: "$ac_option
1492              usage              usage
1493              ;;              ;;
1494            
1495      esac      esac
1496        
1497  done  done
1498    
1499    printf "  getting local config information:  "
1500    if test -f $gm_local ; then
1501        echo "using $gm_local"
1502        . $gm_local
1503    else
1504        echo "none found"
1505    fi
1506    
1507  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1508      echo      echo
1509      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
1510      echo "  file.  This file format is no longer supported.  Please see:"      echo "  file.  This file format is no longer supported.  For directions on"
1511      echo      echo "  how to setup and use the new \"genmake2\" script, please see:"
1512      echo "    http://mitgcm.org/devel_HOWTO/"      echo "    http://mitgcm.org/public/devel_HOWTO/"
1513        echo "  and send an email to MITgcm-support@mitgcm.org if you need help."
1514        echo "WARNING: ignore \"./.genmakerc\" and continue."
1515      echo      echo
     echo "  for directions on how to setup and use the new \"genmake2\" input"  
     echo "  files and send an email to MITgcm-support@mitgcm.org if you want help."  
     echo  
1516  fi  fi
1517    
1518  #  Find the MITgcm ${ROOTDIR}  #  Find the MITgcm ${ROOTDIR}
1519  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1520      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1521      if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesupp -a -d ../pkg ; then
1522          ROOTDIR=".."          ROOTDIR=".."
1523      else      else
1524          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
1525              if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then              if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
1526                  ROOTDIR=$d                  ROOTDIR=$d
1527                  printf "Warning:  ROOTDIR was not specified but there appears to be"                  printf "Warning: ROOTDIR was not specified ;"
1528                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."                  echo " try using a local copy of MITgcm found at \"$ROOTDIR\""
1529                  break                  break
1530              fi              fi
1531          done          done
# Line 1349  if test ! -d ${ROOTDIR} ; then Line 1543  if test ! -d ${ROOTDIR} ; then
1543  fi  fi
1544    
1545  #  Find the MITgcm ${THISVER}  #  Find the MITgcm ${THISVER}
1546  if test -f "${ROOTDIR}/doc/tag-index" ; then  version_file="${ROOTDIR}/doc/tag-index"
1547      THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`  if test -f $version_file ; then
1548        THISVER=`$AWK '/^checkpoint/{print $1; exit}' $version_file`
1549    #-  remove ./BUILD_INFO.h file if older than version_file
1550        if test -f ./BUILD_INFO.h -a ./BUILD_INFO.h -ot $version_file ; then
1551            echo "  remove ./BUILD_INFO.h (older than ${version_file})"
1552            rm -f ./BUILD_INFO.h
1553        fi
1554  fi  fi
1555    
1556  if test "x$MAKEFILE" = x ; then  if test "x$MAKEFILE" = x ; then
1557      MAKEFILE="Makefile"      MAKEFILE="Makefile"
1558  fi  fi
1559    
1560  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:"
1561  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1562      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
1563          echo "Warning: no OPTFILE specified so we'll look for possible settings"          echo "Warning: no OPTFILE specified so we'll look for possible settings"
1564          printf "\n===  Searching for possible settings for OPTFILE  ===\n"          printf "\n===  Searching for possible settings for OPTFILE  ===\n"
1565          find_possible_configs          find_possible_optfile
1566      else      else
1567          OPTFILE=$MITGCM_OF          OPTFILE=$MITGCM_OF
1568      fi      fi
# Line 1377  if test "x$OPTFILE" != xNONE ; then Line 1577  if test "x$OPTFILE" != xNONE ; then
1577              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1578              exit 1              exit 1
1579          fi          fi
1580          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" = xt ; then
1581              cp -f $OPTFILE "genmake_optfile"              cp -f $OPTFILE "genmake_optfile"
1582          fi          fi
1583      else      else
# Line 1386  if test "x$OPTFILE" != xNONE ; then Line 1586  if test "x$OPTFILE" != xNONE ; then
1586      fi      fi
1587  fi  fi
1588    
1589  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:"
1590  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1591      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" = x ; then
1592          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
# Line 1404  if test "x${AD_OPTFILE}" != xNONE ; then Line 1604  if test "x${AD_OPTFILE}" != xNONE ; then
1604              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1605              exit 1              exit 1
1606          fi          fi
1607          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" = xt ; then
1608              cp -f $AD_OPTFILE "genmake_ad_optfile"              cp -f $AD_OPTFILE "genmake_ad_optfile"
1609          fi          fi
1610      else      else
# Line 1432  Error: no Fortran compiler: please speci Line 1632  Error: no Fortran compiler: please speci
1632  EOF  EOF
1633      exit 1      exit 1
1634  fi  fi
1635    if test "x$GET_FC_VERSION" != x ; then
1636      echo "Get compiler version using: $FC $GET_FC_VERSION" >> $LOGFILE
1637      ff=`echo $FC | sed 's/ .*//'` ; xx=`echo $ff | sed 's/^./& /' | sed 's/ .*//'`
1638      if test $xx != '/' ; then which $ff >> $LOGFILE ; fi
1639      $FC $GET_FC_VERSION > genmake_fc_vers1 2> genmake_fc_vers2
1640      if test -s genmake_fc_vers1 ; then
1641        cat genmake_fc_vers1 >> $LOGFILE
1642      else
1643        cat genmake_fc_vers2 >> $LOGFILE
1644      fi
1645      echo "<-- compiler version ----" >> $LOGFILE
1646      rm -f genmake_fc_vers1 genmake_fc_vers2
1647    fi
1648    
1649  if test "x$CC" = x ; then  if test "x$CC" = x ; then
1650      CC=cc      look_for_C_compilers
 #     cat <<EOF 1>&2  
 # Error: no C compiler: please specify using one of the following:  
 #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"  
 #   2) the "-cc=XXX" command-line option  
 #   3) the "./genmake_local" file  
 # EOF  
 #     exit 1  
1651  fi  fi
1652    
1653  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1654      LINK=$FC      LINK=$FC
1655  fi  fi
# Line 1449  if test "x$MAKE" = x ; then Line 1657  if test "x$MAKE" = x ; then
1657      MAKE="make"      MAKE="make"
1658  fi  fi
1659  if test "x$CPP" = x ; then  if test "x$CPP" = x ; then
1660      CPP=cpp      CPP="cpp -traditional -P"
1661  fi  fi
1662  #EH3 === UGLY ===  #EH3 === UGLY ===
1663  #  The following is an ugly little hack to check for $CPP in /lib/ and  #  The following is an ugly little hack to check for $CPP in /lib/ and
# Line 1476  EOF Line 1684  EOF
1684  else  else
1685      rm -f test_cpp      rm -f test_cpp
1686  fi  fi
1687    
1688  look_for_makedepend  look_for_makedepend
1689    
1690    #  Check that soft-link command is set and usable
1691  if test "x$LN" = x ; then  if test "x$LN" = x ; then
1692      LN="ln -s"      LN="ln -s"
1693  fi  fi
# Line 1486  RETVAL=$? Line 1697  RETVAL=$?
1697  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
1698      cat <<EOF 1>&2      cat <<EOF 1>&2
1699    
1700  Error: The command "ln -s" failed -- please specify a working soft-link  Error: The command "$LN" failed -- please specify a working soft-link
1701    command in the optfile.    command in the optfile.
1702    
1703  EOF  EOF
# Line 1504  check_for_broken_Ff Line 1715  check_for_broken_Ff
1715    
1716  if test ! "x$MPI" = x ; then  if test ! "x$MPI" = x ; then
1717        echo "  Turning on MPI cpp macros"        echo "  Turning on MPI cpp macros"
1718        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI"
1719    #- To compile code older than checkpoint63s (2012/09/05), un-comment the following line:
1720    #     DEFINES="$DEFINES -DALWAYS_USE_MPI"
1721    fi
1722    if test ! "x$OMP" = x ; then
1723          echo "  Add OMPFLAG and turn on OpenMP cpp macros"
1724          FFLAGS="$FFLAGS $OMPFLAG"
1725          F90FLAGS="$F90FLAGS $OMPFLAG"
1726          DEFINES="$DEFINES -DUSE_OMP_THREADING"
1727    fi
1728    
1729    if test ! "x$USE_R4" = x ; then
1730          echo "  Turning on LET_RS_BE_REAL4 cpp flag"
1731          DEFINES="$DEFINES -DLET_RS_BE_REAL4"
1732  fi  fi
1733    
1734  if test ! "x$TS" = x ; then  if test ! "x$TS" = x ; then
1735        echo "  Turning on timing per timestep"        echo "  Turning on timing per timestep"
1736        if test ! "x$FOOLAD" = x ; then        if test ! "x$FOOLAD" = x ; then
1737              DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"
1738        else        else
1739              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1740        fi        fi
1741          PACKAGES="$PACKAGES showflops"
1742  fi  fi
1743  if test ! "x$PAPIS" = x ; then  if test ! "x$PAPIS" = x ; then
1744        echo "  Turning on PAPI flop summary per timestep"        echo "  Turning on PAPI flop summary per timestep"
# Line 1525  if test ! "x$PAPIS" = x ; then Line 1750  if test ! "x$PAPIS" = x ; then
1750        fi        fi
1751        INCLUDES="$INCLUDES $PAPIINC"        INCLUDES="$INCLUDES $PAPIINC"
1752        LIBS="$LIBS $PAPILIB"        LIBS="$LIBS $PAPILIB"
1753          PACKAGES="$PACKAGES showflops"
1754    fi
1755    if test ! "x$PCLS" = x ; then
1756          echo "  Turning on PCL counter summary per timestep"
1757          echo "  Please make sure PCLINC, PCLLIB are defined"
1758          if test ! "x$FOOLAD" = x ; then
1759                DEFINES="$DEFINES -DUSE_PCL_FLOPS_SFP"
1760          else
1761                DEFINES="$DEFINES -DUSE_PCL_FLOPS"
1762          fi
1763          INCLUDES="$INCLUDES $PCLINC"
1764          LIBS="$LIBS $PCLLIB"
1765          PACKAGES="$PACKAGES showflops"
1766  fi  fi
1767  if test ! "x$PAPI" = x ; then  if test ! "x$PAPI" = x ; then
1768        if test ! "x$PAPIS" = x ; then        if test ! "x$PAPIS" = x ; then
# Line 1532  if test ! "x$PAPI" = x ; then Line 1770  if test ! "x$PAPI" = x ; then
1770            echo "  Sticking with PAPI flop summary per timestep!"            echo "  Sticking with PAPI flop summary per timestep!"
1771        else        else
1772            echo "  Turning on performance analysis with PAPI"            echo "  Turning on performance analysis with PAPI"
1773            echo "  Please make sure PAPIINC, PAPILIB are defined"            echo "  Please make sure PAPIINC, PAPILIB are defined"
1774            DEFINES="$DEFINES -DUSE_PAPI"            DEFINES="$DEFINES -DUSE_PAPI"
1775            INCLUDES="$INCLUDES $PAPIINC"            INCLUDES="$INCLUDES $PAPIINC"
1776            LIBS="$LIBS $PAPILIB"            LIBS="$LIBS $PAPILIB"
1777        fi        fi
1778  fi  fi
1779    if test ! "x$PCL" = x ; then
1780          if test ! "x$PCLS" = x ; then
1781              echo "  PCL performance analysis and flop summary per timestep cannot co-exist!"
1782              echo "  Sticking with PCL flop summary per timestep!"
1783          else
1784              echo "  Turning on performance analysis with PCL"
1785              echo "  Please make sure PCLINC, PCLLIB are defined"
1786              DEFINES="$DEFINES -DUSE_PCL"
1787              INCLUDES="$INCLUDES $PCLINC"
1788              LIBS="$LIBS $PCLLIB"
1789          fi
1790    fi
1791  if test ! "x$HPMT" = x ; then  if test ! "x$HPMT" = x ; then
1792        if test ! "x$PAPI" = x ; then        if test ! "x$PAPI" = x ; then
1793            echo "  PAPI and the HPM Toolkit cannot co-exist!"            echo "  PAPI and the HPM Toolkit cannot co-exist!"
1794            echo "  Sticking with PAPI!"            echo "  Sticking with PAPI!"
1795        else        else
1796            if test ! "x$PCL" = x ; then
1797              echo "  PCL and the HPM Toolkit cannot co-exist!"
1798              echo "  Sticking with PCL!"
1799            else
1800            echo "  Turning on performance analysis with the HPM Toolkit"            echo "  Turning on performance analysis with the HPM Toolkit"
1801            echo "  Please make sure HPMTINC, HPMTLIB are defined"            echo "  Please make sure HPMTINC, HPMTLIB are defined"
1802            DEFINES="$DEFINES -DUSE_LIBHPM"            DEFINES="$DEFINES -DUSE_LIBHPM"
1803            INCLUDES="$INCLUDES $HPMTINC"            INCLUDES="$INCLUDES $HPMTINC"
1804            LIBS="$LIBS $HPMTLIB"            LIBS="$LIBS $HPMTLIB"
1805            fi
1806        fi        fi
1807  fi  fi
1808  if test ! "x$GSL" = x ; then  if test ! "x$GSL" = x ; then
# Line 1557  if test ! "x$GSL" = x ; then Line 1812  if test ! "x$GSL" = x ; then
1812        INCLUDES="$INCLUDES $GSLINC"        INCLUDES="$INCLUDES $GSLINC"
1813        LIBS="$LIBS $GSLLIB"        LIBS="$LIBS $GSLLIB"
1814  fi  fi
1815    #- if USE_EXTENDED_SRC is set, add EXTENDED_SRC_FLAG to FFLAGS :
1816    if test ! "x$USE_EXTENDED_SRC" = x ; then
1817          FFLAGS="$FFLAGS $EXTENDED_SRC_FLAG"
1818          F90FIXEDFORMAT="$F90FIXEDFORMAT $EXTENDED_SRC_FLAG"
1819    fi
1820    
1821  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1822  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
# Line 1623  rm -f genmake_tcomp* Line 1883  rm -f genmake_tcomp*
1883  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1884  check_HAVE_CLOC  check_HAVE_CLOC
1885  if test "x$HAVE_CLOC" != x ; then  if test "x$HAVE_CLOC" != x ; then
1886        DEFINES="$DEFINES -DHAVE_CLOC"
1887      echo "yes"      echo "yes"
1888  else  else
1889      echo "no"      echo "no"
# Line 1636  rm -f genmake_t* Line 1897  rm -f genmake_t*
1897    
1898  printf "  Can we unlimit the stack size using $FC...  "  printf "  Can we unlimit the stack size using $FC...  "
1899  check_HAVE_SETRLSTK  check_HAVE_SETRLSTK
1900  if test "x$HAVE_SETRLSTK" != x ; then  if test "x$HAVE_SETRLSTK" = xt ; then
1901        DEFINES="$DEFINES -DHAVE_SETRLSTK"
1902      echo "yes"      echo "yes"
1903  else  else
1904      echo "no"      echo "no"
# Line 1645  rm -f genmake_t* Line 1907  rm -f genmake_t*
1907    
1908  printf "  Can we register a signal handler using $FC...  "  printf "  Can we register a signal handler using $FC...  "
1909  check_HAVE_SIGREG  check_HAVE_SIGREG
1910  if test "x$HAVE_SIGREG" != x ; then  if test "x$HAVE_SIGREG" = xt ; then
1911        DEFINES="$DEFINES -DHAVE_SIGREG"
1912      echo "yes"      echo "yes"
1913  else  else
1914      echo "no"      echo "no"
# Line 1655  rm -f genmake_t* Line 1918  rm -f genmake_t*
1918  printf "  Can we use stat() through C calls...  "  printf "  Can we use stat() through C calls...  "
1919  check_HAVE_STAT  check_HAVE_STAT
1920  if test "x$HAVE_STAT" != x ; then  if test "x$HAVE_STAT" != x ; then
1921        DEFINES="$DEFINES -DHAVE_STAT"
1922      echo "yes"      echo "yes"
1923  else  else
1924      echo "no"      echo "no"
# Line 1664  rm -f genmake_t* Line 1928  rm -f genmake_t*
1928  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1929  check_netcdf_libs  check_netcdf_libs
1930  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
1931        DEFINES="$DEFINES -DHAVE_NETCDF"
1932        echo "yes"
1933    else
1934        echo "no"
1935    fi
1936    
1937    printf "  Can we create LAPACK-enabled binaries...  "
1938    check_lapack_libs
1939    if test "x$HAVE_LAPACK" != x ; then
1940        DEFINES="$DEFINES -DHAVE_LAPACK"
1941        echo "yes"
1942    else
1943        echo "no"
1944    fi
1945    
1946    printf "  Can we call FLUSH intrinsic subroutine...  "
1947    check_HAVE_FLUSH
1948    if test "x$HAVE_FLUSH" = xt ; then
1949        DEFINES="$DEFINES -DHAVE_FLUSH"
1950      echo "yes"      echo "yes"
1951  else  else
1952      echo "no"      echo "no"
1953  fi  fi
 DEFINES="$DEFINES $IGNORE_TIME"  
1954    
1955    DEFINES="$DEFINES $IGNORE_TIME"
1956  if test "x$EMBED_SRC" = xt ; then  if test "x$EMBED_SRC" = xt ; then
1957      build_embed_encode      build_embed_encode
1958  fi  fi
1959  if test "x$EMBED_SRC" = xt ; then  if test "x$EMBED_SRC" = xt ; then
1960      ENABLE="$ENABLE embed_files"      ENABLE="$ENABLE embed_files"
1961    #   DEFINES="$DEFINES -DHAVE_EMBED_SRC"
1962  fi  fi
1963    
   
1964  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1965  printf "  Adding MODS directories:  "  printf "  Adding MODS directories: "
1966  for d in $MODS ; do  for d in $MODS ; do
1967      if test ! -d $d ; then      if test ! -d $d ; then
1968          echo          echo
1969          echo "Error: MODS directory \"$d\" not found!"          echo "Error: MODS directory \"$d\" not found!"
1970          exit 1          exit 1
1971      else      else
1972          printf " $d"          printf "$d "
1973          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1974          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
1975      fi      fi
1976  done  done
1977  echo  echo
1978    
1979  if test "x${PLATFORM}" = x ; then  #if test "x${PLATFORM}" = x ; then
1980      PLATFORM=$p_PLATFORM  #    PLATFORM=$p_PLATFORM
1981  fi  #fi
1982    
1983  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1984      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
# Line 1735  ERROR: neither of the two default script Line 2018  ERROR: neither of the two default script
2018      ${TOOLSDIR}/set64bitConst.sh      ${TOOLSDIR}/set64bitConst.sh
2019      ${TOOLSDIR}/set64bitConst.csh      ${TOOLSDIR}/set64bitConst.csh
2020    
2021    are working so please check paths or specify (with \$S64) a    are working so please check paths or specify (with \$S64) a
2022    working version of this script.    working version of this script.
2023    
2024  EOF  EOF
# Line 1747  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSD Line 2030  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSD
2030    
2031  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
2032    
2033    #  Set Standard Code Directories:
2034    if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
2035        STANDARDDIRS="eesupp model"
2036    fi
2037    #  if model in Standard-Code-Dir, add eesupp (needed to compile model)
2038    echo " $STANDARDDIRS " | grep ' model ' > /dev/null 2>&1
2039    ckM=$?
2040    echo " $STANDARDDIRS " | grep ' eesupp ' > /dev/null 2>&1
2041    ckE=$?
2042    if test $ckM = 0 -a $ckE = 1 ; then
2043        STANDARDDIRS="$STANDARDDIRS eesupp"
2044    fi
2045    
2046  #  We have a special set of source files in eesupp/src which are  #  We have a special set of source files in eesupp/src which are
2047  #  generated from some template source files. We'll make them first so  #  generated from some template source files. We'll make them first so
2048  #  they appear as regular source code  #  they appear as regular source code
2049  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
2050      echo "  Making source files in eesupp from templates"      echo "  Making source files in eesupp from templates"
2051      ( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1      ( cd $ROOTDIR"/eesupp/src/" && $MAKE clean_old && $MAKE \
2052        ) > make_eesupp.errors 2>&1
2053      RETVAL=$?      RETVAL=$?
2054      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
2055          rm -f make_eesupp.errors          rm -f make_eesupp.errors
# Line 1763  if test -r $ROOTDIR"/eesupp/src/Makefile Line 2060  if test -r $ROOTDIR"/eesupp/src/Makefile
2060      fi      fi
2061  fi  fi
2062    
2063  #same for exch2  #same for pkg/exch2 and pkg/regrid
2064  if test -r $ROOTDIR"/pkg/exch2/Makefile" ; then  for pdir in exch2 regrid ; do
2065      echo "  Making source files in exch2 from  templates"      if test -r $ROOTDIR"/pkg/${pdir}/Makefile" ; then
2066      ( cd $ROOTDIR"/pkg/exch2/" && $MAKE ) > make_exch2.errors 2>&1          echo "  Making source files in pkg/${pdir} from templates"
2067      RETVAL=$?          ( cd $ROOTDIR"/pkg/"${pdir} && $MAKE clean_old && $MAKE \
2068      if test "x${RETVAL}" = x0 ; then          ) > make_${pdir}.errors 2>&1
2069          rm -f make_exch2.errors          RETVAL=$?
2070      else          if test "x${RETVAL}" = x0 ; then
2071          echo "Error: problem encountered while building source files in exch2:"              rm -f make_${pdir}.errors
2072          cat make_exch2.errors 1>&2          else
2073          exit 1              echo "Error: problem encountered while building source files in pkg/${pdir}:"
2074                cat make_${pdir}.errors 1>&2
2075                exit 1
2076            fi
2077      fi      fi
2078  fi  done
2079    
2080  printf "\n===  Determining package settings  ===\n"  printf "\n===  Determining package settings  ===\n"
2081  if  test "x${PDEPEND}" = x ; then  if  test "x${PKG_DEPEND}" = x ; then
2082      tmp=$ROOTDIR"/pkg/pkg_depend"      tmp=$ROOTDIR"/pkg/pkg_depend"
2083      if test -r $tmp ; then      if test -r $tmp ; then PKG_DEPEND=$tmp ; fi
2084          PDEPEND=$tmp  fi
2085      else  if  test "x${PKG_DEPEND}" = x ; then
2086          echo "Warning:  No package dependency information was specified."          echo "Warning:  No package dependency information was specified."
2087          echo "  Please check that ROOTDIR/pkg/pkg_depend exists."          echo "  Please check that ROOTDIR/pkg/pkg_depend exists."
     fi  
2088  else  else
2089      if test ! -r ${PDEPEND} ; then      if test ! -r ${PKG_DEPEND} ; then
2090          echo "Error:  can't read package dependency info from PDEPEND=\"$PDEPEND\""          echo "Error:  can't read package dependency info from PKG_DEPEND=\"$PKG_DEPEND\""
2091          exit 1          exit 1
2092      fi      fi
2093        echo "  getting package dependency info from  $PKG_DEPEND"
2094    #  Strip the comments and then convert the dependency file into arrays: PNAME, DNAME
2095        get_pdepend_list $PKG_DEPEND
2096  fi  fi
2097  echo "  getting package dependency info from  $PDEPEND"  
2098  #  Strip the comments and then convert the dependency file into  # A default package groups file "$ROOTDIR/pkg/pkg_groups" is provided
2099  #  two arrays: PNAME, DNAME  #  to define the "default_pkg_list" and package groups (for convenience, one
2100  cat $PDEPEND | sed -e 's/#.*$//g' \  #  can specify a group of packages using names like "ocean" and "atmosphere").
2101      | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \  if test "x${PKG_GROUPS}" = x ; then
2102      > ./.pd_tmp      tmp=$ROOTDIR"/pkg/pkg_groups"
2103  RETVAL=$?      if test -r $tmp ; then PKG_GROUPS=$tmp ; fi
2104  if test ! "x${RETVAL}" = x0 ; then  fi
2105      echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""  if test "x${PKG_GROUPS}" = x ; then
2106      exit 1          echo "Warning:  No package groups information was specified."
2107            echo "  Please check that ROOTDIR/pkg/pkg_groups exists."
2108    else
2109        if test ! -r ${PKG_GROUPS} ; then
2110            echo "Error:  can't read package groups info from PKG_GROUPS=\"$PKG_GROUPS\""
2111            exit 1
2112        fi
2113        echo "  getting package groups info from      $PKG_GROUPS"
2114  fi  fi
 . ./.pd_tmp  
 rm -f ./.pd_tmp  
2115    
2116  #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"  #  Search for packages to compile.
2117  #  file should eventually be added so that, for convenience, one can  echo "  checking list of packages to compile:"
2118  #  specify groups of packages using names like "ocean" and "atmosphere".  PKG_LIST=
2119  echo "  checking default package list:  "  if test "x${PKG_LIST}" = x ; then
 if test "x${PDEFAULT}" = x ; then  
2120      for i in "." $MODS ; do      for i in "." $MODS ; do
2121          if test -r $i"/packages.conf" ; then          if test -r $i"/packages.conf" ; then
2122                  PDEFAULT=$i"/packages.conf"                  PKG_LIST=$i"/packages.conf"
2123                  break                  break
2124          fi          fi
2125      done      done
2126  fi  fi
2127  if test "x${PDEFAULT}" = x ; then  if test "x${PKG_LIST}" = x ; then
2128      PDEFAULT="$ROOTDIR/pkg/pkg_default"      pkg_list='default_pkg_list'
2129  fi      if test "x${PKG_GROUPS}" = x ; then
2130  if test "x${PDEFAULT}" = xNONE ; then          echo "Error:  need package groups info to expand pkg_list=\"$pkg_list\""
2131      echo "    default packages file disabled"          exit 1
2132        fi
2133  else  else
2134      if test ! -r $PDEFAULT ; then      if test ! -r $PKG_LIST ; then
2135          echo "Warning:  can't read default packages from PDEFAULT=\"$PDEFAULT\""          echo "Error:  can't read package list from PKG_LIST=\"$PKG_LIST\""
2136            exit 1
2137      else      else
2138          echo "    using PDEFAULT=\"$PDEFAULT\""          echo "    using PKG_LIST=\"$PKG_LIST\""
2139          #  Strip the comments and add all the names          #  Strip the comments and add all the names
2140          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`          pkg_list=`cat $PKG_LIST | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
2141          RETVAL=$?          RETVAL=$?
2142          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
2143              printf "Error: can't parse default package list "              printf "Error: can't parse package list "
2144              echo "-- please check PDEFAULT=\"$PDEFAULT\""              echo "-- please check PKG_LIST=\"$PKG_LIST\""
2145              exit 1              exit 1
2146          fi          fi
         for i in $def ; do  
             PACKAGES="$PACKAGES $i"  
         done  
         echo "    before group expansion packages are: $PACKAGES"  
         RET=1  
         while test $RET = 1 ; do expand_pkg_groups; RET=$?; done  
         echo "    after group expansion packages are:  $PACKAGES"  
2147      fi      fi
2148  fi  fi
2149    for i in $pkg_list ; do
2150        PACKAGES="$PACKAGES $i"
2151    done
2152    echo     "    before group expansion packages are:$PACKAGES"
2153    if test "x${PKG_GROUPS}" != x ; then
2154        RET=1
2155        while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
2156        echo "    after group expansion packages are: $PACKAGES"
2157    fi
2158    
2159  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
2160    echo "" > ./.tmp_pack
2161  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2162      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
2163  done  done
# Line 1874  PACKAGES="$PACKAGES $ENABLE" Line 2185  PACKAGES="$PACKAGES $ENABLE"
2185  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2186      j=`echo $i | sed 's/[-+]//'`      j=`echo $i | sed 's/[-+]//'`
2187      if test ! -d "$ROOTDIR/pkg/$j" ; then      if test ! -d "$ROOTDIR/pkg/$j" ; then
2188          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
2189          exit 1          exit 1
2190      fi      fi
2191      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
2192  done  done
# Line 1884  for i in `grep -v "-" ./.tmp_pack | sort Line 2195  for i in `grep -v "-" ./.tmp_pack | sort
2195      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
2196  done  done
2197  rm -f ./.tmp_pack  rm -f ./.tmp_pack
2198  echo "    packages are:  $PACKAGES"  echo "    packages are: $PACKAGES"
2199    
2200  #  Check availability of NetCDF and then either build the MNC template  #  Check for package MNC: if NetCDF is available, then build the MNC
2201  #  files or delete mnc from the list of available packages.  #  template files ; otherwise, delete mnc from the list of packages.
2202  echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1  echo " $PACKAGES " | grep ' mnc ' > /dev/null 2>&1
2203  RETVAL=$?  mnc_in=$?
2204  if test "x$RETVAL" = x0 ; then  if test "x$HAVE_NETCDF" != xt ; then
2205      if test "x$HAVE_NETCDF" != xt ; then      if test "x$mnc_in" = x0 ; then
2206          cat <<EOF          cat <<EOF
   
2207  *********************************************************************  *********************************************************************
2208  WARNING: the "mnc" package was enabled but tests failed to compile  WARNING: the "mnc" package was enabled but tests failed to compile
2209    NetCDF applications.  Please check that:    NetCDF applications.  Please check that:
2210    
2211    1) NetCDF is correctly installed for this compiler and    1) NetCDF is correctly installed for this compiler and
2212    2) the LIBS variable (within the "optfile") specifies the correct    2) the LIBS variable (within the "optfile") specifies the correct
2213         NetCDF library to link against.         NetCDF library to link against.
2214    
2215    Due to this failure, the "mnc" package is now DISABLED.    Due to this failure, the "mnc" package is now DISABLED.
2216  *********************************************************************  *********************************************************************
   
2217  EOF  EOF
2218          PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`          PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
2219          DISABLE="$DISABLE mnc"          DISABLE="$DISABLE mnc"
2220      else      else
2221          ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1      #  this prevent to add mnc (due to pdepend rules) if not available
2222          RETVAL=$?          DISABLE="$DISABLE mnc"
2223          if test "x${RETVAL}" = x0 ; then      fi
2224              rm -f make_mnc.errors  else
2225          else      # we have NetCDF, we try to build MNC template files
2226              echo "Error: problem encountered while building source files in pkg/mnc:"      ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
2227              cat make_mnc.errors 1>&2      RETVAL=$?
2228        if test "x${RETVAL}" = x0 ; then
2229            rm -f make_mnc.errors
2230        else
2231            echo "Error: problem encountered while building source files in pkg/mnc:"
2232            cat make_mnc.errors 1>&2
2233            if test "x$mnc_in" = x0 ; then
2234              exit 1              exit 1
2235            else
2236                DISABLE="$DISABLE mnc"
2237          fi          fi
2238      fi      fi
2239  fi  fi
2240    
2241  echo "  applying package dependency rules"  #  Check for package PROFILES: if NetCDF is not available,
2242  ck=  #  then delete profiles from the list of available packages.
2243  while test "x$ck" != xtt ; do  if test "x$HAVE_NETCDF" != xt ; then
2244        echo " $PACKAGES " | grep ' profiles ' > /dev/null 2>&1
2245        RETVAL=$?
2246        if test "x$RETVAL" = x0 ; then
2247            cat <<EOF
2248    *********************************************************************
2249    WARNING: the "profiles" package was enabled but tests failed to
2250      compile NetCDF applications.  Please check that:
2251    
2252      1) NetCDF is correctly installed for this compiler and
2253      2) the LIBS variable (within the "optfile") specifies the correct
2254           NetCDF library to link against.
2255    
2256      Due to this failure, the "profiles" package is now DISABLED.
2257    *********************************************************************
2258    EOF
2259            PACKAGES=`echo $PACKAGES | sed -e 's/profiles//g'`
2260            DISABLE="$DISABLE profiles"
2261        else
2262        #  this prevent to add profiles (due to pdepend rules) if not available
2263            DISABLE="$DISABLE profiles"
2264        fi
2265    fi
2266    
2267    #  Check for package RADTRANS: if LAPACK is not available,
2268    #  then issue a warning that the direct radtrans solver is not available.
2269    if test "x$HAVE_LAPACK" != xt ; then
2270        echo " $PACKAGES " | grep ' radtrans ' > /dev/null 2>&1
2271        RETVAL=$?
2272        if test "x$RETVAL" = x0 ; then
2273            cat <<EOF
2274    *********************************************************************
2275    WARNING: the "radtrans" package was enabled but tests failed to
2276      compile LAPACK applications.  This means that the direct radtrans
2277      solver is not available and compilation will fail if it is enabled.
2278      If you want to use the direct solver, please check that:
2279    
2280      1) LAPACK is correctly installed for this compiler and
2281      2) the LIBS variable (within the "optfile") specifies the correct
2282         LAPACK library to link against.
2283    *********************************************************************
2284    EOF
2285        fi
2286    fi
2287    
2288    if  test "x${PKG_DEPEND}" != x ; then
2289      echo "  applying package dependency rules"
2290      ck=
2291      while test "x$ck" != xtt ; do
2292      i=0      i=0
2293      # rtot=${#PNAME[@]}      # rtot=${#PNAME[@]}
2294      rtot=$nname      rtot=$nname
2295      while test $i -lt $rtot ; do      while test $i -le $rtot ; do
2296    
2297          #  Is $pname in the current $PACKAGES list?          #  Is $pname in the current $PACKAGES list?
2298          #  pname=${PNAME[$i]}          #  pname=${PNAME[$i]}
# Line 1939  while test "x$ck" != xtt ; do Line 2304  while test "x$ck" != xtt ; do
2304                  pin="t"                  pin="t"
2305              fi              fi
2306          done          done
2307            #  or in the current $STANDARDDIRS list?
2308            for p in $STANDARDDIRS ; do
2309                if test "x$p" = "x$pname" ; then pin="t" ; fi
2310            done
2311    
2312          #  Is the DNAME entry a (+) or (-) rule ?          #  Is the DNAME entry a (+) or (-) rule ?
2313          tmp="dname=\"\$DNAME_$i\""          tmp="dname=\"\$DNAME_$i\""
# Line 1961  while test "x$ck" != xtt ; do Line 2330  while test "x$ck" != xtt ; do
2330    
2331          #  Do we need to add $dname according to the dependency rules?          #  Do we need to add $dname according to the dependency rules?
2332          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
2333                #echo "   " $pname ": need to add :" $dname
2334              in_dis="f"              in_dis="f"
2335              for dis in $DISABLE ; do              for dis in $DISABLE ; do
2336                  if test "x$dis" = "x$dname" ; then                  if test "x$dis" = "x$dname" ; then
# Line 1981  while test "x$ck" != xtt ; do Line 2351  while test "x$ck" != xtt ; do
2351          #  Do we need to get rid of $dname according to the dependency rules?          #  Do we need to get rid of $dname according to the dependency rules?
2352          if test "x$pin" = xt -a "x$plus" = "x-" -a "x$din" = xt; then          if test "x$pin" = xt -a "x$plus" = "x-" -a "x$din" = xt; then
2353              echo "Error: can't satisfy package dependencies:"              echo "Error: can't satisfy package dependencies:"
2354              echo "  \"$pname\" was requested but is disallowed by"              echo "  \"$pname\" was requested but is disallowed by"
2355              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
2356              exit 1              exit 1
2357          fi          fi
2358          i=`echo "$i + 1" | bc -l`          i=`echo "$i + 1" | bc -l`
2359          #i=$(( $i + 1 ))          #i=$(( $i + 1 ))
2360      done      done
2361      ck=$ck"t"      ck=$ck"t"
2362  done    done
2363  echo "    packages are:  $PACKAGES"    echo "    packages are: $PACKAGES"
2364    fi
2365  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2366      adr="$ROOTDIR/pkg/$i"      adr="$ROOTDIR/pkg/$i"
2367      if test -d $adr ; then      if test -d $adr ; then
# Line 2007  done Line 2378  done
2378    
2379  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
2380  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
2381  #  The following UGLY HACK sets multiple "#undef"s and it needs to go  #  The following UGLY HACK sets multiple "#undef"s and it needs to go
2382  #  away.  On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h  #  away.  On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h
2383  #  file would eventually be split up so that all package-related #define  #  file would eventually be split up so that all package-related #define
2384  #  statements could be separated and handled only by genmake.  #  statements could be separated and handled only by genmake.
2385  names=`ls -1 "$ROOTDIR/pkg"`  names=`ls -1 "$ROOTDIR/pkg"`
# Line 2025  for n in $names ; do Line 2396  for n in $names ; do
2396          done          done
2397          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
2398              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
2399              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
2400          fi          fi
2401      fi      fi
2402  done  done
# Line 2036  for i in $PACKAGES ; do Line 2407  for i in $PACKAGES ; do
2407  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
2408    
2409  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
2410      case $i in      case $i in
2411          aim_v23)          aim_v23)
2412              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
2413              echo "Warning: ALLOW_AIM is set to enable aim_v23."              echo "Warning: ALLOW_AIM is set to enable aim_v23."
2414              ;;              ;;
2415      esac      esac
# Line 2046  for i in $PACKAGES ; do Line 2417  for i in $PACKAGES ; do
2417    
2418  done  done
2419    
2420  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS='$STANDARDDIRS'"
2421  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
 if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then  
     STANDARDDIRS="eesupp model"  
 fi  
2422  if test "x$STANDARDDIRS" != x ; then  if test "x$STANDARDDIRS" != x ; then
2423      for d in $STANDARDDIRS ; do      for d in $STANDARDDIRS ; do
2424          adr="$ROOTDIR/$d/src"          adr="$ROOTDIR/$d/src"
# Line 2083  for i in $spaths ; do Line 2451  for i in $spaths ; do
2451      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
2452          echo "    found CPP_OPTIONS=\"$try\""          echo "    found CPP_OPTIONS=\"$try\""
2453          CPP_OPTIONS="$try"          CPP_OPTIONS="$try"
2454          # 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
2455          for n in $names ; do          for n in $names ; do
2456              test_for_package_in_cpp_options $CPP_OPTIONS $n              test_for_package_in_cpp_options $CPP_OPTIONS $n
2457          done          done
2458      fi      fi
2459      try="$i/CPP_EEOPTIONS.h"      try="$i/CPP_EEOPTIONS.h"
2460      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
2461          echo "    found CPP_EEOPTIONS=\"$try\""          echo "    found CPP_EEOPTIONS=\"$try\""
2462          # 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
2463  #**** not yet enabled ****  #**** not yet enabled ****
2464  #        test_for_mpi_in_cpp_eeoptions $try  #        test_for_mpi_in_cpp_eeoptions $try
2465  #**** not yet enabled ****  #**** not yet enabled ****
# Line 2105  fi Line 2473  fi
2473    
2474  #  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
2475  #  compiler.  #  compiler.
2476  if test -f ./ad_files ; then  if test -f ./adSrcFiles.tmp ; then
2477      rm -f ./ad_files      rm -f ./adSrcFiles.tmp
2478  fi  fi
2479  echo "  Creating the list of files for the adjoint compiler."  echo "  Creating the list of files for the adjoint compiler."
2480    touch adSrcFiles.tmp
2481  for i in $SOURCEDIRS ; do  for i in $SOURCEDIRS ; do
2482      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2483      for j in $list_files ; do      for j in $list_files ; do
2484          cat $i/$j >> ad_files          cat $i/$j >> adSrcFiles.tmp
2485      done      done
2486  done  done
2487  if test ! "x"$FS = "x.f" ; then  if test ! "x"$FS = "x.f" ; then
2488      cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f      cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f
2489      mv -f ad_files_f ad_files      mv -f adSrcFiles.tmp_f adSrcFiles.tmp
2490  fi  fi
2491    
2492  echo  echo
# Line 2141  if test ! "x$DIVA" = x ; then Line 2510  if test ! "x$DIVA" = x ; then
2510          fi          fi
2511          MPIINCLUDEDIR='$MPIHOME/include'          MPIINCLUDEDIR='$MPIHOME/include'
2512      fi      fi
2513        
2514      if test -r $MPIINCLUDEDIR/mpif.h ; then      if test -r $MPIINCLUDEDIR/mpif.h ; then
2515          for i in $MPI_HEADER_FILES; do          for i in $MPI_HEADER_FILES; do
2516              cp -p $MPIINCLUDEDIR/$i ./mpi_headers              cp -p $MPIINCLUDEDIR/$i ./mpi_headers
# Line 2150  if test ! "x$DIVA" = x ; then Line 2519  if test ! "x$DIVA" = x ; then
2519          perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h          perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h
2520      else      else
2521          echo " We cannot create a copy of mpif.h!"          echo " We cannot create a copy of mpif.h!"
2522          exit -1  #       exit -1
2523      fi      fi
2524  fi  fi
2525    
# Line 2175  if test ! -r ".links.tmp/foo" ; then Line 2544  if test ! -r ".links.tmp/foo" ; then
2544      exit 1      exit 1
2545  fi  fi
2546  rm -f .links.tmp/foo  rm -f .links.tmp/foo
2547    
2548    if test "x$OPENAD" != x ; then
2549        OAD_DONT_COMPILE="/dev/null"
2550        OAD_DONT_TRANSFORM="/dev/null"
2551        OAD_KEEP_ORIGINAL="/dev/null"
2552        OAD_CB2M_FILES="/dev/null"
2553        OADTOOLS="$TOOLSDIR/OAD_support"
2554        test -f "oadtempflile"  &&  \rm -f "oadtempflile"
2555    cat >> "oadtempflile" <<EOF
2556    $OADTOOLS
2557    EOF
2558        echo "  looking for dontCompile file:  "
2559        for i in "." $MODS ; do
2560            if test -r $i"/dontCompile" ; then
2561                OAD_DONT_COMPILE=$i"/dontCompile"
2562                echo "     found $OAD_DONT_COMPILE"
2563                break
2564            fi
2565        done
2566        echo "  looking for dontTransform file:  "
2567        for i in "." $MODS ; do
2568            if test -r $i"/dontTransform" ; then
2569                OAD_DONT_TRANSFORM=$i"/dontTransform"
2570                echo "     found $OAD_DONT_TRANSFORM"
2571                break
2572            fi
2573        done
2574        echo "  looking for keepOriginal file:  "
2575        for i in "." $MODS ; do
2576            if test -r $i"/keepOriginal" ; then
2577                OAD_KEEP_ORIGINAL=$i"/keepOriginal"
2578                echo "     found $OAD_KEEP_ORIGINAL"
2579                break
2580            fi
2581        done
2582        echo "  looking for cb2mFiles:  "
2583        for i in "." $MODS ; do
2584            if test -r $i"/cb2mFiles" ; then
2585                OAD_CB2M_FILES=$i"/cb2mFiles"
2586                echo "     found $OAD_CB2M_FILES"
2587                break
2588            fi
2589        done
2590        echo "   OpenAD exceptions:  "
2591    fi
2592    
2593  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
2594  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
2595  printf 'SRCFILES = '    > srclist.inc  printf 'F77_SRC_FILES = ' > F77srclist.tmp
2596  printf 'CSRCFILES = '   > csrclist.inc  printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp
2597  printf 'F90SRCFILES = ' > f90srclist.inc  printf 'C_SRC_FILES = '   > csrclist.tmp
2598  printf 'HEADERFILES = ' > hlist.inc  printf 'F90_SRC_FILES = ' > F90srclist.tmp
2599  printf 'AD_FLOW_FILES = ' > ad_flow_files.inc  printf 'H_SRC_FILES = '   > hsrclist.tmp
2600    printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp
2601  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2602  for d in $alldirs ; do  for d in $alldirs ; do
2603      deplist=      deplist=
2604      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
2605      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
2606        if test "x$OPENAD" != x ; then
2607            sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2608        fi
2609      for sf in $sfiles ; do      for sf in $sfiles ; do
2610          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
2611              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2612                  ignore_f=f                  ignore_f=f
2613                  case $d/$sf in                  case $d/$sf in
2614                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
2615                          ignore_f=t                          ignore_f=t
2616                          ;;                          ;;
2617                    ./AD_CONFIG.h)                    ./AD_CONFIG.h)
2618                          ignore_f=t                          ignore_f=t
2619                          ;;                          ;;
2620                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
2621                          ignore_f=t                          ignore_f=t
2622                          ;;                          ;;
2623                    ./BUILD_INFO.h)                    ./BUILD_INFO.h)
2624                          ignore_f=t                          ignore_f=t
2625                          ;;                          ;;
2626                    ./EMBEDDED_FILES.h)                    ./EMBEDDED_FILES.h)
2627                          ignore_f=t                          ignore_f=t
2628                          ;;                          ;;
2629                    *)                    *)
2630                          #  For the local directory *ONLY*,                          #  For the local directory *ONLY*,
2631                          #  ignore all soft-links                          #  ignore all soft-links
2632                          if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then                          if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
# Line 2217  for d in $alldirs ; do Line 2636  for d in $alldirs ; do
2636                              deplist="$deplist $sf"                              deplist="$deplist $sf"
2637                          fi                          fi
2638                          ;;                          ;;
2639                  esac                  esac
2640                  if test "x$ignore_f" = xf ; then                  if test "x$ignore_f" = xf ; then
2641                      extn=`echo $sf | $AWK -F. '{print $NF}'`                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2642                      case $extn in                      case $extn in
2643                          F)                        F)
2644                              echo    " \\"  >> srclist.inc                          echo    " \\"  >> F77srclist.tmp
2645                              printf " $sf" >> srclist.inc                          printf " $sf" >> F77srclist.tmp
2646                              ;;                          if test "x$OPENAD" != x ; then
2647                          F90)                              basename=${sf%%.F}
2648                              echo    " \\"  >> f90srclist.inc                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`
2649                              printf " $sf" >> f90srclist.inc                              if test -z "$isAD" ; then
2650                              ;;                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`
2651                          c)                                  if test -z "$toBeIgnored" ; then
2652                              echo    " \\"  >> csrclist.inc                                      echo    " \\"  >> nonADF77srclist.tmp
2653                              printf " $sf" >> csrclist.inc                                      printf " $sf" >> nonADF77srclist.tmp
2654                              ;;                                  else
2655                          h)                                      echo "    not to be compiled   :  $sf"
2656                              echo    " \\"  >> hlist.inc                                  fi
2657                              printf " $sf" >> hlist.inc                              else # file is initially listed as an AD file we want to exclude it
2658                              ;;                                   # or we want to retain the untransformed version
2659                          flow)                                  notToBeTransformed=`egrep ^$basename'[      ]*' ${OAD_DONT_TRANSFORM}`
2660                              echo    " \\"  >> ad_flow_files.inc                                  untransformedVersionToBeKept=`egrep ^$basename'[      ]*' ${OAD_KEEP_ORIGINAL}`
2661                              printf " $sf" >> ad_flow_files.inc                                  if test -n "$notToBeTransformed"; then
2662                              ;;                                      echo "    not to be transformed:  $sf"
2663                      esac                                  fi
2664                  fi                                  if test -n "$untransformedVersionToBeKept" ; then
2665                                        echo "    original to be kept  :  $sf"
2666                                    fi
2667                                    if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2668                                        echo    " \\"  >> nonADF77srclist.tmp
2669                                        printf " $sf" >> nonADF77srclist.tmp
2670                                    fi
2671                                fi
2672                            fi
2673                            ;;
2674                        F90)
2675                            echo    " \\"  >> F90srclist.tmp
2676                            printf " $sf" >> F90srclist.tmp
2677                            ;;
2678                        c)
2679                            echo    " \\"  >> csrclist.tmp
2680                            printf " $sf" >> csrclist.tmp
2681                            ;;
2682                        h)
2683                            echo    " \\"  >> hsrclist.tmp
2684                            printf " $sf" >> hsrclist.tmp
2685                            ;;
2686                        flow)
2687                            echo    " \\"  >> ad_flow_files.tmp
2688                            printf " $sf" >> ad_flow_files.tmp
2689                            ;;
2690                       esac
2691                    fi
2692              fi              fi
2693          fi          fi
2694      done      done
2695      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2696          if test "$d" != "." ; then
2697          echo "" >> srclinks.tmp          echo "" >> srclinks.tmp
2698          echo "#  These files are linked from $d" >> srclinks.tmp          echo "#  These files are linked from $d" >> srclinks.tmp
2699          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> srclinks.tmp
2700          printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp  # We need to make sure that the link isn't already there.
2701    # This may happen when make thinks that a header file has to be "remade"
2702    # because a module it depends on has changed.  In this case we do nothing.
2703            printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp
2704          fi
2705      fi      fi
2706  done  done
2707  rm -rf .links.tmp  rm -rf .links.tmp
2708  echo "" >> srclist.inc  echo "" >> F77srclist.tmp
2709  echo "" >> csrclist.inc  echo "" >> nonADF77srclist.tmp
2710  echo "" >> f90srclist.inc  echo "" >> csrclist.tmp
2711  echo "" >> hlist.inc  echo "" >> F90srclist.tmp
2712  echo "" >> ad_flow_files.inc  echo "" >> hsrclist.tmp
2713    echo "" >> ad_flow_files.tmp
2714    
2715    CMDLINE=$0
2716    for xx in "$@" ; do nw=`echo $xx | wc -w`
2717        if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
2718                            else CMDLINE="$CMDLINE '$xx'" ; fi
2719    done
2720    
2721  if test -f $MAKEFILE ; then  if test -f $MAKEFILE ; then
2722      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.old"
2723  fi  fi
2724  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
2725  echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE  echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE
# Line 2269  echo "#    $MACHINE" >> $MAKEFILE Line 2727  echo "#    $MACHINE" >> $MAKEFILE
2727  echo "# This makefile was generated automatically on" >> $MAKEFILE  echo "# This makefile was generated automatically on" >> $MAKEFILE
2728  echo "#    $THISDATE" >> $MAKEFILE  echo "#    $THISDATE" >> $MAKEFILE
2729  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2730  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $CMDLINE"  >> $MAKEFILE
2731  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2732  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2733    
# Line 2280  EXE_SVD=$EXECUTABLE"_svd" Line 2738  EXE_SVD=$EXECUTABLE"_svd"
2738  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2739  #  #
2740  # OPTFILE="$OPTFILE"  # OPTFILE="$OPTFILE"
2741  #  #
2742  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
2743  # SOURCEDIRS   : Directories containing the source (.F) files  # SOURCEDIRS   : Directories containing the source (.F) files
2744  # INCLUDEDIRS  : Directories containing the header-source (.h) files  # INCLUDEDIRS  : Directories containing the header-source (.h) files
# Line 2291  cat >>$MAKEFILE <<EOF Line 2749  cat >>$MAKEFILE <<EOF
2749  # INCLUDES     : Directories searched for header files  # INCLUDES     : Directories searched for header files
2750  # DEFINES      : Macro definitions for CPP  # DEFINES      : Macro definitions for CPP
2751  # MAKEDEPEND   : Dependency generator  # MAKEDEPEND   : Dependency generator
 # KPP          : Special preprocessor command (specific to platform)  
 # KFLAGS       : Flags for KPP  
2752  # FC           : Fortran compiler command  # FC           : Fortran compiler command
2753  # FFLAGS       : Configuration/debugging options for FC  # FFLAGS       : Configuration/debugging options for FC
2754  # FOPTIM       : Optimization options for FC  # FOPTIM       : Optimization options for FC
# Line 2300  cat >>$MAKEFILE <<EOF Line 2756  cat >>$MAKEFILE <<EOF
2756  # LIBS         : Library flags /or/ additional optimization/debugging flags  # LIBS         : Library flags /or/ additional optimization/debugging flags
2757    
2758  ROOTDIR     = ${ROOTDIR}  ROOTDIR     = ${ROOTDIR}
2759  BUILDDIR    = ${BUILDDIR}    BUILDDIR    = ${BUILDDIR}
2760  SOURCEDIRS  = ${SOURCEDIRS}  SOURCEDIRS  = ${SOURCEDIRS}
2761  INCLUDEDIRS = ${INCLUDEDIRS}  INCLUDEDIRS = ${INCLUDEDIRS}
2762  EXEDIR      = ${EXEDIR}  EXEDIR      = ${EXEDIR}
2763  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
2764  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIR}
2765    OADTOOLS    = ${OADTOOLS}
2766    
2767  #eh3  new defines for the adjoint work  #eh3  new defines for the adjoint work
2768  AUTODIFF    = ${ROOTDIR}/pkg/autodiff  AUTODIFF    = ${ROOTDIR}/pkg/autodiff
# Line 2326  else Line 2783  else
2783      echo "EMBEDDED_FILES = " >>$MAKEFILE      echo "EMBEDDED_FILES = " >>$MAKEFILE
2784  fi  fi
2785    
2786  #  Note: figure out some way to add Hyades JAM libraries here  # extract default cpp search path so we can pass it to makedepend
2787    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}'`
2788    
2789  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2790  # Unix ln (link)  # Unix ln (link)
2791  LN = ${LN}  LN = ${LN}
 # C preprocessor  
 CPP = cat \$< | ${S64} | ${CPP}  
2792  # Dependency generator  # Dependency generator
2793  MAKEDEPEND = ${MAKEDEPEND}  MAKEDEPEND = ${MAKEDEPEND}
2794  # Special preprocessor (KAP on DECs, FPP on Crays)  # Special preprocessor (KAP on DECs, FPP on Crays)
# Line 2349  LINK = ${LINK} ${LDADD} Line 2806  LINK = ${LINK} ${LDADD}
2806  DEFINES = ${DEFINES}  DEFINES = ${DEFINES}
2807  # Includes for CPP  # Includes for CPP
2808  INCLUDES = ${INCLUDES}  INCLUDES = ${INCLUDES}
2809    # default CPP includes for makedepend
2810    CPPINCLUDES = ${CPPINCLUDES}
2811  # Flags for KPP  # Flags for KPP
2812  KFLAGS1 = ${KFLAGS1}  KFLAGS1 = ${KFLAGS1}
2813  KFLAGS2 = ${KFLAGS2}  KFLAGS2 = ${KFLAGS2}
2814  # Optim./debug for FC  # Optim./debug for FC
2815  FFLAGS = ${FFLAGS}  FFLAGS = ${FFLAGS} ${FEXTRAFLAGS}
2816  FOPTIM = ${FOPTIM}  FOPTIM = ${FOPTIM}
2817  # Optim./debug for FC  # Optim./debug for FC
2818  F90FLAGS = ${F90FLAGS}  F90FLAGS = ${F90FLAGS}
2819  F90OPTIM = ${F90OPTIM}  F90OPTIM = ${F90OPTIM}
2820    F90FIXEDFORMAT = ${F90FIXEDFORMAT}
2821  # Flags for CC  # Flags for CC
2822  CFLAGS = ${CFLAGS}  CFLAGS = ${CFLAGS}
2823  # Files that should not be optimized  # Files that should not be optimized
# Line 2365  NOOPTFILES = ${NOOPTFILES} Line 2825  NOOPTFILES = ${NOOPTFILES}
2825  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2826  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2827  LIBS = ${LIBS}  LIBS = ${LIBS}
2828  # Name of the Mekfile  # Name of the makefile
2829  MAKEFILE=${MAKEFILE}  MAKEFILE = ${MAKEFILE}
2830    # Name of the make program
2831    MAKE = ${MAKE}
2832    
2833  EOF  EOF
2834    
2835  cat srclist.inc       >> $MAKEFILE  cat F77srclist.tmp      >> $MAKEFILE
2836  cat csrclist.inc      >> $MAKEFILE  cat nonADF77srclist.tmp >> $MAKEFILE
2837  cat f90srclist.inc    >> $MAKEFILE  cat csrclist.tmp        >> $MAKEFILE
2838  cat hlist.inc         >> $MAKEFILE  cat F90srclist.tmp      >> $MAKEFILE
2839  cat ad_flow_files.inc >> $MAKEFILE  cat hsrclist.tmp        >> $MAKEFILE
2840    cat ad_flow_files.tmp   >> $MAKEFILE
2841    
2842    rm -f F77srclist.tmp nonADF77srclist.tmp csrclist.tmp F90srclist.tmp hsrclist.tmp ad_flow_files.tmp
2843    
2844  echo >> $MAKEFILE  echo >> $MAKEFILE
2845  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE  
2846  echo 'F90FILES =  $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE  # add definitions for preprocessed sources
2847  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  # and note that not all systems allow case sensitive extensions
2848    # hence the $FS and $FS90 here.
2849    # for fixed format f90 files we use ff90 or FF90 resp
2850    # but these are not expected to be the original source files
2851    
2852    echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE
2853    echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE
2854    echo 'OBJFILES= $(F77_SRC_FILES:.F=.o) $(C_SRC_FILES:.c=.o) $(F90_SRC_FILES:.F90=.o)' >> $MAKEFILE
2855    echo 'FLOWFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE
2856  echo >> $MAKEFILE  echo >> $MAKEFILE
2857  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
2858  echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE  echo '.SUFFIXES: .o .'$FS' .p .F .c .f'$FS90' .'$FS90' .FF90 .F90 .flowdir .flow' >> $MAKEFILE
 rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc  
 rm -f ad_flow_files.inc  
2859    
2860  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2861    
2862  all: \$(EXECUTABLE)  all: fwd_exe_target
2863  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES) \$(EMBEDDED_FILES)  fwd_exe_target:
2864            @echo Update AD_CONFIG.h and make \$(EXECUTABLE)
2865            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Forward version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
2866            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2867            @-rm -f ad_config.template
2868            \$(MAKE) -f \$(MAKEFILE) \$(EXECUTABLE)
2869    
2870    \$(EXECUTABLE): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(EMBEDDED_FILES)
2871          @echo Creating \$@ ...          @echo Creating \$@ ...
2872          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2873    
2874  depend:  depend:
2875          @make links          @\$(MAKE) -f \$(MAKEFILE) links
2876          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(CPPINCLUDES) \$(F77_SRC_FILES)
2877          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2878          -rm -f makedepend.out          -rm -f makedepend.out
2879    
# Line 2401  lib: libmitgcmuv.a Line 2881  lib: libmitgcmuv.a
2881    
2882  libmitgcmuv.a: \$(OBJFILES)  libmitgcmuv.a: \$(OBJFILES)
2883          ar rcv libmitgcmuv.a \$(OBJFILES)          ar rcv libmitgcmuv.a \$(OBJFILES)
2884            ar d   libmitgcmuv.a main.o
2885    
2886  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  obj: \$(OBJFILES)
2887    
2888  small_f: \$(F77FILES) \$(F90FILES)  links: \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(SPECIAL_FILES)
2889    
2890    small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
2891    
2892  output.txt: \$(EXECUTABLE)  output.txt: \$(EXECUTABLE)
2893          @printf 'running ... '          @printf 'running ... '
2894          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
2895    
2896    # remove most of the files that "make" generates
2897  clean:  clean:
2898          -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2899            -rm -rf *.o
2900            -rm -rf *.$FS *.flowdir
2901            -rm -rf *.f$FS90 \$(AD_CLEAN) ad_input*
2902    
2903    # remove most of the files that "make" and "make depend" generate
2904  Clean:  Clean:
2905          @make clean          @\$(MAKE) -f \$(MAKEFILE) clean
2906          @make cleanlinks          @\$(MAKE) -f \$(MAKEFILE) cleanlinks
2907          -rm -f \$(SPECIAL_FILES)          -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old
2908          -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak          -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log taf_ftl.log
2909            -rm -f genmake_warnings genmake_errors make.log
2910    
2911    # remove also the executable, files that "genmake2" generates (except Makefile)
2912    #         and output from a run (plus log files from testreport)
2913  CLEAN:  CLEAN:
2914          @make Clean          @\$(MAKE) -f \$(MAKEFILE) Clean
2915            -rm -f \$(EXECUTABLE) \$(EXE_AD) \$(EXE_FTL) *.bak
2916            -rm -f $LOGFILE genmake_state genmake_*optfile
2917            -rm -f SIZE.h.mpi genmake.tr_log make.tr_log
2918          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2919          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2920          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2921          -rm -f \$(EXECUTABLE) output.txt STD*          -rm -f *.txt STD* *diagnostics.log datetime
2922            -rm -f *_MIT_CE_000.opt0000 costfunction*0000
2923            -rm -rf mnc_test_*
2924    
 #eh3 Makefile: makefile  
2925  makefile:  makefile:
2926          $THIS_SCRIPT $G2ARGS          $THIS_SCRIPT $G2ARGS
2927  cleanlinks:  cleanlinks:
2928          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2929    
2930  # Special targets (SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are created by make
2931  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2932          @echo Creating \$@ ...          @echo Creating \$@ ...
2933          @$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) > \$@
2934  AD_CONFIG.h:  AD_CONFIG.h:
2935          @echo Creating \$@ ...          @echo Creating \$@ ...
2936          @$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 > \$@
2937  FC_NAMEMANGLE.h:  FC_NAMEMANGLE.h:
2938          @echo Creating \$@ ...          @echo Creating \$@ ...
2939          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
# Line 2455  if test "x$EMBED_SRC" = xt ; then Line 2952  if test "x$EMBED_SRC" = xt ; then
2952    
2953  decode_files.o : EMBEDDED_FILES.h  decode_files.o : EMBEDDED_FILES.h
2954    
2955  ##  \$(F77FILES)  ##  \$(F77_PP_SRC_FILES)
2956  all_fF.tar.gz : \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(F77FILES) Makefile  all_fF.tar.gz : \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2957          @echo Creating \$@ ...          @echo Creating \$@ ...
2958          -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(F77FILES) Makefile          -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2959          -rm -f all_fF.tar.gz          -rm -f all_fF.tar.gz
2960          -gzip all_fF.tar          -gzip all_fF.tar
2961    
# Line 2476  cat >>$MAKEFILE <<EOF Line 2973  cat >>$MAKEFILE <<EOF
2973  ## This nullifies any default implicit rules concerning these two file types:  ## This nullifies any default implicit rules concerning these two file types:
2974  ## %.o : %.F  ## %.o : %.F
2975    
2976    # C preprocessing and replacing the _d in constants:
2977    CPPCMD = cat \$< | ${CPP} \$(DEFINES) \$(INCLUDES) | ${S64}
2978    
2979  .F.$FS:  .F.$FS:
2980          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD)  > \$@
2981  .$FS.o:  .$FS.o:
2982          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2983    .F.o:
2984            \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2985  .F90.$FS90:  .F90.$FS90:
2986          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD)  > \$@
2987    .FF90.f$FS90:
2988            \$(CPPCMD)  > \$@
2989  .$FS90.o:  .$FS90.o:
2990          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2991    .f$FS90.o:
2992            cp \$< \$(basename  \$<).f90
2993            \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$(F90FIXEDFORMAT) \$(basename  \$<).f90
2994  .c.o:  .c.o:
2995          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
2996    .flow.flowdir:
2997            \$(CPPCMD) > \$@
2998    
2999  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
3000  .F.p:  .F.p:
3001          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPPCMD) > \$@
3002  .p.$FS:  .p.$FS:
3003          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
3004    
3005    EOF
3006    
3007  #=========================================  #=========================================
3008  #===  Automatic Differentiation Rules  ===  #===  Automatic Differentiation Rules  ===
3009    #===  for TAMC/TAF  ======================
3010    
3011    if test "x$OPENAD" = x ; then
3012    
3013    cat >>$MAKEFILE <<EOF
3014    
3015  TAMC           = ${TAMC}  TAMC           = ${TAMC}
3016  TAF            = ${TAF}  TAF            = ${TAF}
# Line 2509  ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF Line 3025  ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF
3025  ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"  ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
3026  for i in $ad_vars ; do  for i in $ad_vars ; do
3027      name=$i      name=$i
3028      t1="t2=\$"`echo $i`      t1="t2=\$"`echo "$i"`
3029      eval $t1      eval $t1
3030      printf "%-20s = " $name >> $MAKEFILE      printf "%-20s = " $name >> $MAKEFILE
3031      echo $t2 >> $MAKEFILE      echo "$t2" | sed -e 's| \+| |g' >> $MAKEFILE
3032  done  done
3033    
3034  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
3035  echo >> $MAKEFILE  echo >> $MAKEFILE
3036  printf "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
3037  AD_FILES=`cat ad_files`  AD_FILES=`cat adSrcFiles.tmp`
3038  for i in $AD_FILES ; do  for i in $AD_FILES ; do
3039      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
3040      printf " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
3041  done  done
3042  echo >> $MAKEFILE  echo >> $MAKEFILE
3043  rm -f ad_files  rm -f adSrcFiles.tmp
3044    
3045  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3046    
3047  # ... AD ...  # ... AD ...
3048  adall: ad_taf  adall: ad_exe_target
3049  adtaf: ad_taf_output.$FS  adtaf: ad_taf_output.$FS
3050  adtamc: ad_tamc_output.$FS  adtamc: ad_tamc_output.$FS
3051    
3052  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)  ad_exe_target:
3053          @$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)
3054            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3055            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3056            @-rm -f ad_config.template
3057            \$(MAKE) -f \$(MAKEFILE) \$(EXE_AD)
3058    
3059    ad_input_code.$FS: \$(AD_FILES) \$(AD_FLOW_FILES)
3060            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3061          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
3062          -rm -f ad_config.template          @-rm -f ad_config.template
3063          @make \$(F77FILES)          @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3064          @make \$(AD_FLOW_FILES)          @\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)
3065          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS          cat \$(FLOWFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS
3066    
3067  ad_taf_output.$FS: ad_input_code.$FS  ad_taf_output.$FS: ad_input_code.$FS
3068          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3069            ls -l ad_input_code_ad.$FS
3070          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
3071    
3072  adtafonly:  adtafonly:
3073          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3074            ls -l ad_input_code_ad.$FS
3075          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
3076    
3077  ad_taf: ad_taf_output.o \$(OBJFILES)  \$(EXE_AD): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) ad_taf_output.o \$(OBJFILES) \$(EMBEDDED_FILES)
3078          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
3079    
3080  ad_tamc_output.$FS: ad_input_code.$FS  ad_tamc_output.$FS: ad_input_code.$FS
3081          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
3082          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
3083    
3084  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
3085          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
3086    
3087  adonlyfwd:  adonlyfwd:
3088          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
3089    
3090  adtrick:  adtrick:
3091          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
3092    
3093    adobj: ad_taf_output.o \$(OBJFILES)
3094    
3095  # ... FTL ...  # ... FTL ...
3096  ftlall: ftl_taf  ftlall: ftl_exe_target
3097  ftltaf: ftl_taf_output.$FS  ftltaf: ftl_taf_output.$FS
3098  ftltamc: ftl_tamc_output.$FS  ftltamc: ftl_tamc_output.$FS
3099    
3100  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)  ftl_exe_target:
3101          @$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)
3102          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
3103          -rm -f ftl_config.template          @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3104          @make \$(F77FILES)          @-rm -f ad_config.template
3105          @make \$(AD_FLOW_FILES)          \$(MAKE) -f \$(MAKEFILE) \$(EXE_FTL)
3106          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS  
3107    ftl_input_code.$FS: \$(AD_FILES)
3108            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3109            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3110            @-rm -f ad_config.template
3111            @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3112            @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3113            cat \$(AD_FLOW_FILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ftl_input_code.$FS
3114    
3115  ftl_taf_output.$FS: ftl_input_code.$FS  ftl_taf_output.$FS: ftl_input_code.$FS
3116          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3117            ls -l ftl_input_code_ftl.$FS
3118          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
3119    
3120  ftltafonly:  ftltafonly:
3121          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3122            ls -l ftl_input_code_ftl.$FS
3123          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
3124    
3125  ftl_taf: ftl_taf_output.o \$(OBJFILES)  \$(EXE_FTL): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) ftl_taf_output.o \$(OBJFILES) \$(EMBEDDED_FILES)
3126          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
3127    
3128  ftl_tamc_output.$FS: ftl_input_code.$FS  ftl_tamc_output.$FS: ftl_input_code.$FS
3129          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
3130          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
3131    
3132  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
3133          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
   
3134    
3135  # ... SVD ...  # ... SVD ...
3136  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
# Line 2617  svd_touch: Line 3152  svd_touch:
3152          touch ad_taf_output.$FS ftl_taf_output.$FS          touch ad_taf_output.$FS ftl_taf_output.$FS
3153          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
3154          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
3155          @$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
3156          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
3157          -rm -f ftl_config.template          @-rm -f ad_config.template
3158    
3159  #=========================================  EOF
3160    
3161    fi
3162    
3163    #===  for OpenAD  ========================
3164    
3165    if test "x$OPENAD" != x ; then
3166    
3167    # ============ begin OpenAD specific section ==============
3168    
3169    cat >>$MAKEFILE <<EOF
3170    
3171    # all the source files linked from the various locations:
3172    ALL_LINKED_FILES= \
3173    \$(F77_SRC_FILES) \
3174    \$(C_SRC_FILES) \
3175    \$(H_SRC_FILES) \
3176    \$(F90_SRC_FILES) \
3177    \$(SPECIAL_FILES)
3178    
3179    ifndef OPENADROOT
3180      \$(error "Error:  environment variable OPENADROOT not defined!")
3181    endif
3182    
3183    ifndef XAIFSCHEMAROOT
3184      \$(error "Error:  environment variable XAIFSCHEMAROOT not defined!")
3185    endif
3186    
3187    ifndef XAIFBOOSTERROOT
3188      \$(error "Error:  environment variable XAIFBOOSTERROOT not defined!")
3189    endif
3190    
3191    EOF
3192    
3193    echo "  Add the source list for common block to module conversion "
3194    echo >> $MAKEFILE
3195    printf "CB2M_F90_SRC_NAMES = " >> $MAKEFILE
3196    for i in `cat ${OAD_CB2M_FILES}` ; do
3197      echo    " \\" >> $MAKEFILE
3198      printf " $i" >> $MAKEFILE
3199    done
3200    echo >> $MAKEFILE
3201    
3202    echo "  Add the source list for AD code generation"
3203    echo >> $MAKEFILE
3204    printf "AD_FILES = " >> $MAKEFILE
3205    for i in `cat ${OAD_CB2M_FILES}` ; do
3206      echo    " \\" >> $MAKEFILE
3207      printf " ${i}_mod.f$FS90" >> $MAKEFILE
3208    done
3209    AD_FILES=`cat adSrcFiles.tmp`
3210    for i in $AD_FILES ; do
3211      basename=${i%%.f}
3212      toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`
3213      if test -z "$toBeIgnored" ; then
3214        echo    " \\" >> $MAKEFILE
3215        printf " $i" >> $MAKEFILE
3216      fi
3217    done
3218    echo >> $MAKEFILE
3219    rm -f adSrcFiles.tmp
3220    
3221    cat >>$MAKEFILE <<EOF
3222    
3223    adAll: \$(EXE_AD)
3224    .PHONY: adAll
3225    
3226    CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))
3227    
3228    .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90)
3229    
3230    .PHONY: adDepend
3231    adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90)
3232            \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
3233            \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
3234            -rm -f makedepend.out
3235    
3236    OPENAD_SUPPORT_F90_SRC_FILES = \
3237    w2f__types.F90 \
3238    OAD_active.F90 \
3239    OAD_cp.F90 \
3240    OAD_rev.F90 \
3241    OAD_tape.F90 \
3242    revolve.F90
3243    
3244    OPENAD_SUPPORT_C_SRC_FILES = \
3245    iaddr.c \
3246    timeRatio.c
3247    
3248    f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)
3249            cat \$^ > \$@
3250    
3251    f95_test.f90: all_mods.xb.x2w.w2f.pp.f$FS90 \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
3252            cat \$^ > \$@
3253    
3254    f95_test.out: f95_test_mods.f90 f95_test.f90
3255            f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1
3256            f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1
3257    
3258    CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)
3259    
3260    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)
3261    
3262    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)
3263    
3264    \$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.tag \$(AD_OBJ_FILES_S2)
3265            \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)
3266    
3267    # create sources files modules from header files containing common blocks
3268    %_mod.FF90 : %.h \${OADTOOLS}/cb2mGetModules.csh \${OADTOOLS}/cb2mGetModules.awk
3269            \${OADTOOLS}/cb2mGetModules.csh $< \${OADTOOLS}/cb2mGetModules.awk
3270    
3271    # create new header files with USE statements for the new modules made above
3272    %_mod.h : %.h \${OADTOOLS}/cb2mGetHeaders.csh \${OADTOOLS}/cb2mGetHeaders.awk
3273            \${OADTOOLS}/cb2mGetHeaders.csh $< \${OADTOOLS}/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
3274    
3275    # change the include directives of everybody to refer to  the new header files with the USE statements
3276    %_cb2m.FF90 : %.F \${OADTOOLS}/cb2mUseModules.bash
3277            \${OADTOOLS}/cb2mUseModules.bash $< ${MPI}
3278    
3279    # makefile debug rule
3280    small_f: \$(CB2M_F90_PP_SRC_FILES)
3281    .PHONY: small_f
3282    
3283    ad_output.txt: \$(EXE_AD)
3284            @printf 'linking data files ... '
3285            \$(LN) -f ../input_ad/data* ../input_ad/eedata .
3286            \$(LN) -f ../../global_ocean.90x40x15/input/*.bin .
3287            @printf 'running ... '
3288            @./\$(EXE_AD) > \$@
3289    
3290    ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3291            cat \$^ > \$@
3292    
3293    # canonicalizer
3294    ad_input_code_sf.pre.f90 : \$(CB2M_AD_FILES)
3295            \${OPENADFORTTK_BASE}/tools/SourceProcessing/preProcess.py --timing --r8 -H -S  -o \$@ \$^
3296    
3297    # replace stop statements (to avoid the implied unstructured control flow)  with print statements
3298    ad_input_code_sf.pre.s2p.f90 : ad_input_code_sf.pre.f90
3299            cat \$< | sed -f \${OADTOOLS}/stop2print.sed > ad_input_code_sf.pre.s2p.f90
3300    
3301    # F -> WHIRL
3302    ad_input_code_sf.pre.s2p.B: ad_input_code_sf.pre.s2p.f90
3303            \${OPEN64ROOT}/crayf90/sgi/mfef90 -r8 -z -F ad_input_code_sf.pre.s2p.f90
3304    
3305    # WHIRL -> XAIF
3306    ad_input_code_sf.pre.s2p.xaif : ad_input_code_sf.pre.s2p.B
3307            \${OPENADFORTTK}/bin/whirl2xaif -s -n --debug 1 -o \$@ \$<
3308    
3309    # XAIF -> XAIF'
3310    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
3311            \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r
3312    
3313    # XAIF' -> WHIRL'
3314    ad_input_code_sf.pre.s2p.xb.x2w.B : ad_input_code_sf.pre.s2p.xb.xaif
3315            \${OPENADFORTTK}/bin/xaif2whirl --debug 1 ad_input_code_sf.pre.s2p.B \$<
3316    
3317    # WHIRL' -> F'
3318    ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.B
3319            \${OPEN64ROOT}/whirl2f/whirl2f -FLIST:ftn_file=\$@ -openad \$<
3320    
3321    # insert template directives
3322    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
3323            \${OADTOOLS}/insertTemplateDir.bash \$< \$@
3324    
3325    PPEXTRAS=\$(wildcard \${OADTOOLS}/ad_template.*.F) \${OADTOOLS}/ad_inline.F
3326    # postprocess F'
3327    postProcess.tag: ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90 \$(PPEXTRAS:.F=.f) | w2f__types.f90
3328            \${OPENADFORTTK_BASE}/tools/SourceProcessing/postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed --separateOutput --pathSuffix "" --filenameSuffix "_oad" -m r -i \${OADTOOLS}/ad_inline.f \$<
3329            # the target is a placeholder to trigger a single execution of the rule
3330            touch \$@
3331    # put this so make knows about the postprocessing output
3332    OAD_intrinsics_oad.f \$(CB2M_AD_FILES:.f$FS90=_oad.f): postProcess.tag
3333    
3334    # link the XAIF schema files
3335    %.xsd:
3336            \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3337    
3338    # link the support files:
3339    \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):
3340            \$(LN) \${OADTOOLS}/\$@ .
3341    
3342    AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag \$(PPEXTRAS:.F=.f)
3343    
3344    # ============ end OpenAD specific section ==============
3345    
3346  EOF  EOF
3347    
3348    fi
3349    
3350    #=========================================
3351    
3352  if test "x$EXEHOOK" != x ; then  if test "x$EXEHOOK" != x ; then
3353      printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE      printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
3354  fi  fi
# Line 2660  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 3384  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
3384  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
3385    
3386  # Create special header files  # Create special header files
3387  $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"
3388  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
3389      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
3390  else  else
# Line 2674  else Line 3398  else
3398      fi      fi
3399  fi  fi
3400  if test ! -f AD_CONFIG.h ; then  if test ! -f AD_CONFIG.h ; then
3401      $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
3402  fi  fi
3403    
   
3404  #  Write the "state" for future records  #  Write the "state" for future records
3405  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" = xt ; then
3406      printf "" > genmake_state      printf "" > genmake_state
3407      for i in $gm_state ; do      for i in $gm_state ; do
3408          t1="t2=\$$i"          t1="t2=\$$i"
3409          eval $t1          eval $t1
3410          echo "$i='$t2'" >> genmake_state          echo "$i='$t2'" | sed -e 's/  */ /g' >> genmake_state
3411      done      done
3412  fi  fi

Legend:
Removed from v.1.143  
changed lines
  Added in v.1.250

  ViewVC Help
Powered by ViewVC 1.1.22