/[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.190 by utke, Wed Apr 22 18:35:00 2009 UTC revision 1.236 by jmc, Fri Aug 24 23:07:27 2012 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() {
# Line 56  test_for_string_in_file() { Line 217  test_for_string_in_file() {
217  # the package list.  # the package list.
218  expand_pkg_groups() {  expand_pkg_groups() {
219      new_packages=      new_packages=
     PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"  
220      if test -r $PKG_GROUPS ; then      if test -r $PKG_GROUPS ; then
221          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
222          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp
# Line 67  expand_pkg_groups() { Line 227  expand_pkg_groups() {
227              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
228                  matched=1                  matched=1
229                  replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`                  replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
230                  echo "    replacing \"$i\" with: $replace"                  echo "    replacing \"$i\" with:$replace"
231                  new_packages="$new_packages $replace"                  new_packages="$new_packages $replace"
232              else              else
233                  new_packages="$new_packages $i"                  new_packages="$new_packages $i"
# Line 110  EOF Line 270  EOF
270              check_for_broken_Ff              check_for_broken_Ff
271          else          else
272              cat <<EOF 2>&1              cat <<EOF 2>&1
273  ERROR: Your file system cannot distinguish between *.F and *.f files  ERROR: Your file system cannot distinguish between *.F and *.f files
274    (fails the "cp" test) and this program cannot find a suitable    (fails the "cp" test) and this program cannot find a suitable
275    replacement extension.  Please try a different build environment or    replacement extension.  Please try a different build environment or
276    contact the <MITgcm-support@mitgcm.org> list for help.    contact the <MITgcm-support@mitgcm.org> list for help.
277    
278  EOF  EOF
# Line 137  EOF Line 297  EOF
297  .F.$tfs:  .F.$tfs:
298          $LN \$< \$@          $LN \$< \$@
299  EOF  EOF
300      $MAKE "genmake_hello."$tfs > /dev/null 2>&1      $MAKE -f $MAKEFILE "genmake_hello."$tfs > /dev/null 2>&1
301      RETVAL=$?      RETVAL=$?
302      if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then      if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then
303          if test "x$FS" = x ; then          if test "x$FS" = x ; then
# Line 145  EOF Line 305  EOF
305              FS90='fr9'              FS90='fr9'
306              check_for_broken_Ff              check_for_broken_Ff
307          else          else
308              cat <<EOF 2>&1              echo "ERROR: test: '$MAKE -f $MAKEFILE genmake_hello.$tfs' Failed"
309  ERROR: Your file system cannot distinguish between *.F and *.f files              echo "       see simple makefile: '$MAKEFILE' (left here)"
310    (fails the "make/ln" test) and this program cannot find a suitable              echo "  Please check (1) your '$MAKE' command, (2) your '$LN' command"
311    replacement extension.  Please try a different build environment or              echo "           and (3) the allowed sufix '.F' and '.$tfs' in makefile"
312    contact the <MITgcm-support@mitgcm.org> list for help.              echo "  or contact the <MITgcm-support@mitgcm.org> list for help."
313                echo ""
 EOF  
314              exit -1              exit -1
315              return              return
316          fi          fi
# Line 165  EOF Line 324  EOF
324      return      return
325  }  }
326    
   
327  look_for_makedepend()  {  look_for_makedepend()  {
328    
329      #  The "original" makedepend is part of the Imake system that is      #  The "original" makedepend is part of the Imake system that is
# Line 186  look_for_makedepend()  { Line 344  look_for_makedepend()  {
344      #    3) locally build and use the cyrus implementation      #    3) locally build and use the cyrus implementation
345      #    4) fall back to the buggy local xmakedpend script      #    4) fall back to the buggy local xmakedpend script
346      #      #
347        echo >> $LOGFILE
348        echo "running: look_for_makedepend()" >> $LOGFILE
349        if test "x${MAKEDEPEND}" != x ; then
350            echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
351            RETVAL=$?
352            if test x"$RETVAL" = x0 ; then
353                build_cyrus_makedepend
354                RETVAL=$?
355                if test "x$RETVAL" != x0 ; then
356                    echo "WARNING: unable to build cyrus-makedepend. Try 'makedepend'"
357                    MAKEDEPEND=
358                fi
359            else
360                echo "${MAKEDEPEND}" | grep 'tools.xmakedepend' > /dev/null 2>&1
361                RETVAL=$?
362                if test "x$RETVAL" = x0 ; then
363                    MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
364                fi
365                echo " -->     MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
366            fi
367        fi
368      if test "x${MAKEDEPEND}" = x ; then      if test "x${MAKEDEPEND}" = x ; then
369          which makedepend > /dev/null 2>&1          which makedepend > /dev/null 2>&1
370          RV0=$?          RV0=$?
# Line 194  look_for_makedepend()  { Line 373  look_for_makedepend()  {
373          cat <<EOF >> $MAKEFILE          cat <<EOF >> $MAKEFILE
374  #   THIS IS A TEST MAKEFILE GENERATED BY "genmake2"  #   THIS IS A TEST MAKEFILE GENERATED BY "genmake2"
375  #  #
376  #   Some "makedepend" implementations will die if they cannot  #   Some "makedepend" implementations will die if they cannot
377  #   find a Makefile -- so this file is here to gives them an  #   find a Makefile -- so this file is here to gives them an
378  #   empty one to find and parse.  #   empty one to find and parse.
379  EOF  EOF
380          cat <<EOF >> genmake_tc.f          cat <<EOF >> genmake_tc.f
# Line 204  EOF Line 383  EOF
383        stop        stop
384        end        end
385  EOF  EOF
386          makedepend genmake_tc.f > /dev/null 2>&1          makedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1
387          RV1=$?          RV1=$?
388          test -f $MAKEFILE  &&  rm -f $MAKEFILE          test -f $MAKEFILE  &&  rm -f $MAKEFILE
389          test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE          test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
390          if test "x${RV0}${RV1}" = x00 ; then          if test "x${RV0}${RV1}" = x00 ; then
391              MAKEDEPEND=makedepend              MAKEDEPEND=makedepend
392                echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
393          else          else
394              echo "    a system-default makedepend was not found."              echo "    system-default makedepend not found. Try to build cyrus-makedepend"
               
395              #  Try to build the cyrus implementation              #  Try to build the cyrus implementation
396              build_cyrus_makedepend              build_cyrus_makedepend
397              RETVAL=$?              RETVAL=$?
398              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
399                    echo "WARNING: unable to build cyrus-makedepend. Use local xmakedepend"
400                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
401                    echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
402              fi              fi
             rm -f ./genmake_cy_md  
         fi  
     else  
         #  echo "MAKEDEPEND=${MAKEDEPEND}"  
         echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1  
         RETVAL=$?  
         if test x"$RETVAL" = x0 ; then  
             build_cyrus_makedepend  
403          fi          fi
404      fi      fi
405  }  }
406    
   
407  build_cyrus_makedepend()  {  build_cyrus_makedepend()  {
408        echo >> $LOGFILE
409        echo "running: build_cyrus_makedepend()" >> $LOGFILE
410      rm -f ./genmake_cy_md      rm -f ./genmake_cy_md
411      (      (
412          cd $ROOTDIR/tools/cyrus-imapd-makedepend  \          cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
# Line 249  build_cyrus_makedepend()  { Line 423  build_cyrus_makedepend()  {
423      rm -f ./genmake_cy_md      rm -f ./genmake_cy_md
424      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
425          MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'          MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
426            echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
427          return 0          return 0
428      else      else
429          echo "WARNING: unable to build cyrus-imapd-makedepend"          echo "WARNING: fail to build cyrus-imapd-makedepend" >> $LOGFILE
430          return 1          return 1
431      fi      fi
432  }  }
433    
   
434  build_embed_encode()  build_embed_encode()
435  {  {
436      printf "  building the embed-encode utility...  "      printf "  building the embed-encode utility...  "
# Line 269  build_embed_encode() Line 443  build_embed_encode()
443              return 1              return 1
444          fi          fi
445          clist="cc gcc c89 $CC"          clist="cc gcc c89 $CC"
446          for ic in $clist ; do          for ic in $clist ; do
447              comm="$ic -o encode_files encode_files.c"              comm="$ic -o encode_files encode_files.c"
448              ( cd $ROOTDIR/tools/embed_encode && $comm ) > /dev/null 2>&1              ( cd $ROOTDIR/tools/embed_encode && $comm ) > /dev/null 2>&1
449              RETVAL=$?              RETVAL=$?
450              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
451                  echo "OK"                  echo "OK"
                 DEFINES="$DEFINES -DHAVE_EMBED_SRC"  
452                  return 0                  return 0
453              fi              fi
454          done          done
# Line 287  build_embed_encode() Line 460  build_embed_encode()
460          return 1          return 1
461      fi      fi
462      echo "OK"      echo "OK"
     DEFINES="$DEFINES -DHAVE_EMBED_SRC"  
463  }  }
464    
465    #  look for possible C compilers
466  # Guess possible config options for this host  look_for_C_compilers() {
467  find_possible_configs()  {      echo >> $LOGFILE
468        echo "running: look_for_C_compilers()" >> $LOGFILE
469      tmp1=`uname`"_"`uname -m`      rm -f ./genmake_hello.c  ./genmake_hello
470      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 icc"  
     p_CC=  
     for c in $tmp ; do  
         rm -f ./genmake_hello.c  ./genmake_hello  
         cat >> genmake_hello.c << EOF  
471  #include <stdio.h>  #include <stdio.h>
472  int main(int argc, char **argv) {  int main(int argc, char **argv) {
473    printf("Hello!\n");    printf("Hello!\n");
474    return 0;    return 0;
475  }  }
476  EOF  EOF
477          $c -o genmake_hello genmake_hello.c > /dev/null 2>&1      tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc icc"
478        p_CC=
479        for c in $tmp ; do
480            COMM="$c $CFLAGS -o genmake_hello genmake_hello.c"
481            echo $COMM >> $LOGFILE
482            $COMM >> $LOGFILE 2>&1
483          RETVAL=$?          RETVAL=$?
484          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
485                echo " $c test successful" >> $LOGFILE
486              p_CC="$p_CC $c"              p_CC="$p_CC $c"
487          fi          fi
488      done      done
# Line 354  Error: No C compilers were found in your Line 498  Error: No C compilers were found in your
498  EOF  EOF
499          exit 1          exit 1
500      else      else
501          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  
502          if test "x$CC" = x ; then          if test "x$CC" = x ; then
503              CC=`echo $p_CC | $AWK '{print $1}'`              CC=`echo $p_CC | $AWK '{print $1}'`
504              echo "  Setting C compiler to: "$CC              echo "  Setting C compiler to: "$CC
505          fi          fi
506      fi      fi
507        echo " --> set CC='$CC'" >> $LOGFILE
508    }
509    
510    # Guess possible config options for this host
511    find_possible_optfile()  {
512    
513        echo >> $LOGFILE
514        echo "running: find_possible_optfile()" >> $LOGFILE
515        tmp1=`uname`"_"`uname -m`
516        tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
517        tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
518        tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
519        tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
520        tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
521        PLATFORM=$tmp3
522        echo $PLATFORM | grep cygwin > /dev/null 2>&1  &&  PLATFORM=cygwin_ia32
523        OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
524        echo "  The platform appears to be:  $PLATFORM" | tee -a $LOGFILE
525    
526      #================================================================      #================================================================
527      #  look for possible FORTRAN compilers      #  look for possible FORTRAN compilers
528      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc ifort f90 f95 mpif77 mpf77 mpxlf95 gfortran g95"      echo "  look for possible FORTRAN compilers" >> $LOGFILE
529        tmp="$MITGCM_FC $FC efc gfortran g77 f77 pgf77 pgf95 ifc ifort f90 f95 mpif77 mpf77 mpxlf95 g95"
530      p_FC=      p_FC=
531      for c in $tmp ; do      rm -f ./genmake_hello.f
532          rm -f ./hello.f ./hello      cat >> genmake_hello.f <<EOF
         cat >> hello.f <<EOF  
533        program hello        program hello
534        do i=1,3        do i=1,3
535          print *, 'hello world : ', i          print *, 'hello world : ', i
536        enddo        enddo
537        end        end
538  EOF  EOF
539          $c -o hello hello.f > /dev/null 2>&1      for f in $tmp ; do
540            COMM="$f -o genmake_hello genmake_hello.f"
541            echo $COMM >> $LOGFILE
542            $COMM >> $LOGFILE 2>&1
543          RETVAL=$?          RETVAL=$?
544          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
545              p_FC="$p_FC $c"              echo " $f test successful" >> $LOGFILE
546                p_FC="$p_FC $f"
547          fi          fi
548      done      done
549      rm -f ./hello.f ./hello      rm -f ./genmake_hello.f ./genmake_hello
550      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
551          cat 1>&2 <<EOF          cat 1>&2 <<EOF
552    
# Line 394  Error: No Fortran compilers were found i Line 559  Error: No Fortran compilers were found i
559  EOF  EOF
560          exit 1          exit 1
561      else      else
562          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  
563      fi      fi
564    
565      #  Use the first of the compilers found in the current PATH      #  Use the first of the compilers found in the current PATH
# Line 404  EOF Line 568  EOF
568          for i in $p_FC ; do          for i in $p_FC ; do
569              OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i              OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
570              if test -r $OPTFILE ; then              if test -r $OPTFILE ; then
571                  echo "  Setting OPTFILE to: "$OPTFILE                  echo "  Setting OPTFILE to: "$OPTFILE | tee -a $LOGFILE
572                  break                  break
573              fi              fi
574          done          done
575      fi      fi
   
     if test "x$OPTFILE" = x ; then  
         OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC  
         if test ! -r $OPTFILE ; then  
              echo "  I looked for the file "$OPTFILE" but did not find it"  
         fi  
     fi  
 #    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  
     if test "x$OPTFILE" = x ; then  
         cat 1>&2 <<EOF  
   
 Error: No options file was found in:  $ROOTDIR/tools/build_options/  
   that matches this platform ("$PLATFORM") and the compilers found in  
   your path.  Please specify an "optfile" using:  
   
     1) the command line (eg. "-optfile=path/to/OPTFILE"), or  
     2) the MITGCM_OF environment variable.  
   
   If you need help, please contact the developers at <MITgcm-support@mitgcm.org>.  
   
 EOF  
         exit 1  
     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  
   
 }  
   
 #  Parse the package dependency information  
 get_pdepend_list()  {  
   
     #  strip the comments and then convert the dependency file into  
     #  two arrays: PNAME, DNAME  
     cat $1 | sed -e 's/#.*$//g' \  
         | $AWK 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \  
         > ./.pd_tmp  
     . ./.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 (and IPC) with PAPI per timestep  
     -pcls | --pcls  
           Produce summary MFlop/s etc. with PCL per timestep  
     -foolad | --foolad  
           Fool the AD code generator  
     -papi | --papi  
           Performance analysis with PAPI  
     -pcl | --pcl  
           Performance analysis with PCL  
     -hpmt | --hpmt  
           Performance analysis with the HPM Toolkit  
   
     -gsl | --gsl  
           Use GSL to control floating point rounding and precision  
     -devel | --devel  
           Add additional warning and debugging flags for development  
   
     -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.  
   
     -omp | --omp  
           Activate OpenMP code + use Compiler option OMPFLAG  
     -omp=OMPFLAG | --omp=OMPFLAG  
           Activate OpenMP code + use Compiler option OMPFLAG  
576    
577      -es | --es | -embed-source | --embed-source      if test "x$OPTFILE" = x ; then
578            Embed a tarball containing the full source code          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
579            (including the Makefile, etc.) used to build the          if test ! -r $OPTFILE ; then
580            executable [off by default]               echo "  I looked for the file "$OPTFILE" but did not find it"
581            fi
582        fi
583    
584      -bash NAME      if test "x$OPTFILE" = x ; then
585            Explicitly specify the Bourne or BASH shell to use          cat 1>&2 <<EOF
586    
587    While it is most often a single word, the "NAME" variables specified  Error: No options file was found in:  $ROOTDIR/tools/build_options/
588    above can in many cases be a space-delimited string such as:    that matches this platform ("$PLATFORM") and the compilers found in
589      your path.  Please specify an "optfile" using:
590    
591      --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'      1) the command line (eg. "-optfile=path/to/OPTFILE"), or
592      -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'      2) the MITGCM_OF environment variable.
     -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'  
593    
594    which, depending upon your shell, may need to be single-quoted.    If you need help, please contact the developers at <MITgcm-support@mitgcm.org>.
595    
596    For more detailed genmake documentation, please see:  EOF
597            exit 1
598        fi
599    
600      http://mitgcm.org/devel_HOWTO/  #     # look for possible MPI libraries
601    #     mpi_libs=
602    #     mpi_fort=`which mpif77 2>/dev/null`
603    #     RETVAL=$?
604    #     if test "x${RETVAL}" = x0 ; then
605    #       cat >>test.f <<EOF
606    #       PROGRAM HELLO
607    #       DO 10, I=1,10
608    #       PRINT *,'Hello World'
609    #    10 CONTINUE
610    #       STOP
611    #       END
612    # EOF
613    #       eval "$mpi_fort -showme test.f > out"
614    #       RETVAL=$?
615    #       if test "x${RETVAL}" = x0 ; then
616    #           a=`cat out`
617    #           for i in $a ; do
618    #               case $i in
619    #                   -*)
620    #                       mpi_libs="$mpi_libs $i" ;;
621    #               esac
622    #           done
623    #           echo "The MPI libs appear to be:"
624    #           echo "  "$mpi_libs
625    #       fi
626    #       rm -f test.f out
627    #     fi
628    }
629    
630  EOF  #  Parse the package dependency information
631    get_pdepend_list()  {
632    
633      exit 1      #  strip the comments and then convert the dependency file into
634        #  two arrays: PNAME, DNAME
635        cat $1 | sed -e 's/#.*$//g' \
636            | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
637            > ./.pd_tmp
638        RETVAL=$?
639        if test ! "x${RETVAL}" = x0 ; then
640          echo "Error: unable to parse package dependencies -- please check PKG_DEPEND=\"$1\""
641          exit 1
642        fi
643        . ./.pd_tmp
644        rm -f ./.pd_tmp
645  }  }
646    
647  #  Build a CPP macro to automate calling C routines from FORTRAN  #  Build a CPP macro to automate calling C routines from FORTRAN
# Line 647  get_fortran_c_namemangling()  { Line 649  get_fortran_c_namemangling()  {
649    
650      #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""      #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
651      if test ! "x$FC_NAMEMANGLE" = x ; then      if test ! "x$FC_NAMEMANGLE" = x ; then
652          return 0          return 0
653      fi      fi
654        echo " running: get_fortran_c_namemangling()" >> $LOGFILE
655    
656      default_nm="#define FC_NAMEMANGLE(X) X ## _"      default_nm="#define FC_NAMEMANGLE(X) X ## _"
657        
658      cat > genmake_test.c <<EOF      cat > genmake_test.c <<EOF
659  void tcall( char * string ) { tsub( string ); }  void tcall( char * string ) { tsub( string ); }
660  EOF  EOF
661      $MAKE genmake_test.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_test.c"
662        echo ' '$COMM >> $LOGFILE
663        $COMM >> $LOGFILE 2>&1
664      RETVAL=$?      RETVAL=$?
665      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
666          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
667          cat <<EOF>> genmake_errors          cat <<EOF>> $LOGFILE
668    
669  WARNING: C test compile fails   WARNING: C test compile fails
670  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
671  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
672  EOF  EOF
673          return 1          return 1
674      fi      fi
# Line 671  EOF Line 676  EOF
676      RETVAL=$?      RETVAL=$?
677      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
678          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
679          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
680    
681  WARNING: The "nm" command failed.   WARNING: The "nm" command failed.
682  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
683  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
684  EOF  EOF
685          return 1          return 1
686      fi      fi
# Line 685  EOF Line 690  EOF
690        call tsub( string )        call tsub( string )
691        end        end
692  EOF  EOF
693      $FC $FFLAGS -c genmake_tcomp.$FS >> genmake_warnings 2>&1      COMM="$FC $FFLAGS -c genmake_tcomp.$FS"
694        echo ' '$COMM >> $LOGFILE
695        $COMM >> $LOGFILE 2>&1
696      RETVAL=$?      RETVAL=$?
697      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
698          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
699          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
700    
701  WARNING: FORTRAN test compile fails -- please see "genmake_errors"   WARNING: FORTRAN test compile fails -- please see '$LOGFILE'
702  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
703  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
704  EOF  EOF
705          return 1          return 1
706      fi      fi
# Line 701  EOF Line 708  EOF
708      RETVAL=$?      RETVAL=$?
709      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
710          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
711          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
712    
713  WARNING: The "nm" command failed.   WARNING: The "nm" command failed.
714  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
715  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
716  EOF  EOF
717          return 1          return 1
718      fi      fi
# Line 731  EOF Line 738  EOF
738    
739      #  cleanup the testing files      #  cleanup the testing files
740      rm -f genmake_tcomp.* genmake_test.*      rm -f genmake_tcomp.* genmake_test.*
 }  
741    
742        echo " --> set FC_NAMEMANGLE='$FC_NAMEMANGLE'" >> $LOGFILE
743    }
744    
745  check_HAVE_CLOC()  {  check_HAVE_CLOC()  {
746        echo >> $LOGFILE
747        echo "running: check_HAVE_CLOC()" >> $LOGFILE
748      get_fortran_c_namemangling      get_fortran_c_namemangling
749      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
750  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 752  void FC_NAMEMANGLE(cloc) ( double *curti Line 762  void FC_NAMEMANGLE(cloc) ( double *curti
762  }  }
763  EOF  EOF
764      COMM="$CC $CFLAGS -c genmake_tc_1.c"      COMM="$CC $CFLAGS -c genmake_tc_1.c"
765      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
766      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
767      RET_C=$?      RET_C=$?
768      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
769        program hello        program hello
# Line 764  EOF Line 774  EOF
774        end        end
775  EOF  EOF
776      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"
777      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
778      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
779      RET_F=$?      RET_F=$?
780      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> $LOGFILE 2>&1
781      RETVAL=$?      RETVAL=$?
782      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
783          HAVE_CLOC=t          HAVE_CLOC=t
         DEFINES="$DEFINES -DHAVE_CLOC"  
784      fi      fi
785      rm -f genmake_tc*      rm -f genmake_tc*
786        echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE
787  }  }
788    
   
789  check_HAVE_SIGREG()  {  check_HAVE_SIGREG()  {
790      if test ! "x$HAVE_SIGREG" = x ; then      if test ! "x$HAVE_SIGREG" = x ; then
791          return          return
792      fi      fi
793        echo >> $LOGFILE
794        echo "running: check_HAVE_SIGREG()" >> $LOGFILE
795      get_fortran_c_namemangling      get_fortran_c_namemangling
796      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
797  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 813  void FC_NAMEMANGLE(sigreg) (int * aip) Line 824  void FC_NAMEMANGLE(sigreg) (int * aip)
824  }  }
825  EOF  EOF
826      COMM="$CC $CFLAGS -c genmake_tc_1.c"      COMM="$CC $CFLAGS -c genmake_tc_1.c"
827      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
828      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
829      RET_C=$?      RET_C=$?
830      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
831        program hello        program hello
# Line 824  EOF Line 835  EOF
835        call sigreg(anint)        call sigreg(anint)
836        end        end
837  EOF  EOF
838      echo >> genmake_warnings      cat genmake_tc_2.$FS >> $LOGFILE
     echo "running: check_HAVE_SIGREG()" >> genmake_warnings  
     cat genmake_tc_2.$FS >> genmake_warnings  
839      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"
840      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
841      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
842      RETVAL=$?      RETVAL=$?
843      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
844          HAVE_SIGREG=t          HAVE_SIGREG=t
         DEFINES="$DEFINES -DHAVE_SIGREG"  
845      fi      fi
846      rm -f genmake_tc*      rm -f genmake_tc*
847        echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE
848  }  }
849    
   
850  check_HAVE_SETRLSTK()  {  check_HAVE_SETRLSTK()  {
     if test "x$HAVE_SETRLSTK" = xt ; then  
         DEFINES="$DEFINES -DHAVE_SETRLSTK"  
         return  
     fi    
851      if test ! "x$HAVE_SETRLSTK" = x ; then      if test ! "x$HAVE_SETRLSTK" = x ; then
852          return          return
853      fi      fi
854        echo >> $LOGFILE
855        echo "running: check_HAVE_SETRLSTK()" >> $LOGFILE
856      get_fortran_c_namemangling      get_fortran_c_namemangling
857      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
858  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 863  void FC_NAMEMANGLE(setrlstk) () Line 869  void FC_NAMEMANGLE(setrlstk) ()
869  }  }
870  EOF  EOF
871      COMM="$CC $CFLAGS -c genmake_tc_1.c"      COMM="$CC $CFLAGS -c genmake_tc_1.c"
872      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
873      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
874      RET_C=$?      RET_C=$?
875      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
876        program hello        program hello
# Line 872  EOF Line 878  EOF
878        call setrlstk()        call setrlstk()
879        end        end
880  EOF  EOF
881      echo >> genmake_warnings      cat genmake_tc_2.$FS >> $LOGFILE
     echo "running: check_HAVE_SETRLSTK()" >> genmake_warnings  
     cat genmake_tc_2.$FS >> genmake_warnings  
882      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"
883      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
884      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
885      RETVAL=$?      RETVAL=$?
886      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
887          HAVE_SETRLSTK=t          HAVE_SETRLSTK=t
         DEFINES="$DEFINES -DHAVE_SETRLSTK"  
888      fi      fi
889      rm -f genmake_tc*      rm -f genmake_tc*
890        echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE
891  }  }
892    
   
893  check_HAVE_STAT()  {  check_HAVE_STAT()  {
894        echo >> $LOGFILE
895        echo "running: check_HAVE_STAT()" >> $LOGFILE
896      get_fortran_c_namemangling      get_fortran_c_namemangling
897      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
898  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 909  void FC_NAMEMANGLE(tfsize) ( int *nbyte Line 914  void FC_NAMEMANGLE(tfsize) ( int *nbyte
914  }  }
915  EOF  EOF
916      COMM="$CC $CFLAGS -c genmake_tc_1.c"      COMM="$CC $CFLAGS -c genmake_tc_1.c"
917      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
918      $COMM >> genmake_tc.log 2>&1      $COMM >> genmake_tc.log 2>&1
919      RET_C=$?      RET_C=$?
920      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
# Line 919  EOF Line 924  EOF
924        print *," HELLO WORLD", nbyte        print *," HELLO WORLD", nbyte
925        end        end
926  EOF  EOF
927      echo >> genmake_warnings      cat genmake_tc_2.$FS >> $LOGFILE
     echo "running: check_HAVE_STAT()" >> genmake_warnings  
     cat genmake_tc_2.$FS >> genmake_warnings  
928      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"
929      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
930      $COMM >> genmake_tc.log 2>&1      $COMM >> genmake_tc.log 2>&1
931      RETVAL=$?      RETVAL=$?
932      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
933          HAVE_STAT=t          HAVE_STAT=t
         DEFINES="$DEFINES -DHAVE_STAT"  
934      fi      fi
935      rm -f genmake_tc*      rm -f genmake_tc*
936        echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE
937  }  }
938    
   
939  check_netcdf_libs()  {  check_netcdf_libs()  {
940      if test ! "x$SKIP_NETCDF_CHECK" = x ; then      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
941          return          return
942      fi      fi
943      echo >> genmake_warnings      echo >> $LOGFILE
944      echo "running: check_netcdf_libs()" >> genmake_warnings      echo "running: check_netcdf_libs()" >> $LOGFILE
945      cat <<EOF > genmake_tnc.F      cat <<EOF > genmake_tnc.F
946        program fgennc        program fgennc
947  #include "netcdf.inc"  #include "netcdf.inc"
# Line 957  EOF Line 959  EOF
959        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
960        end        end
961  EOF  EOF
962      echo "===  genmake_tnc.F  ===" > genmake_tnc.log      echo "===  genmake_tnc.F  >>>" > genmake_tnc.log
963      cat genmake_tnc.F >> genmake_tnc.log      cat genmake_tnc.F >> genmake_tnc.log
964      echo "===  genmake_tnc.F  ===" >> genmake_tnc.log      echo "<<<  genmake_tnc.F  ===" >> genmake_tnc.log
965      RET_CPP=f      RET_CPP=f
966      COMM="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES"      COMM="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES"
967      echo "$COMM" >> genmake_tnc.log      echo "$COMM" >> genmake_tnc.log
# Line 975  EOF Line 977  EOF
977      $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \      $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
978          &&  $LINK $FFLAGS $FOPTIM -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
979      RET_COMPILE=$?      RET_COMPILE=$?
980      cat genmake_tnc.log >> genmake_warnings      cat genmake_tnc.log >> $LOGFILE
981    
982      #EH3  Remove test program execution for machines that either disallow      #EH3  Remove test program execution for machines that either disallow
983      #EH3  execution or cannot support it (eg. cross-compilers)      #EH3  execution or cannot support it (eg. cross-compilers)
# Line 986  EOF Line 988  EOF
988    
989      if test "x$RET_COMPILE" = x0 ; then      if test "x$RET_COMPILE" = x0 ; then
990          HAVE_NETCDF=t          HAVE_NETCDF=t
991            echo "check_netcdf: successful" >> $LOGFILE
992      else      else
993          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
994          echo "try again with added '-lnetcdf'" > genmake_tnc.log          echo "==> try again with added '-lnetcdf'" > genmake_tnc.log
995          echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log          echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
996          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
997          echo " &&  $LINK $FFLAGS $FOPTIM -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
# Line 996  EOF Line 999  EOF
999              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
1000              &&  $LINK $FFLAGS $FOPTIM -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
1001          RET_COMPILE=$?          RET_COMPILE=$?
1002          cat genmake_tnc.log >> genmake_warnings          echo >> $LOGFILE
1003            cat genmake_tnc.log >> $LOGFILE
1004          if test "x$RET_COMPILE" = x0 ; then          if test "x$RET_COMPILE" = x0 ; then
1005              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
1006              HAVE_NETCDF=t              HAVE_NETCDF=t
1007                echo "check_netcdf: successful" >> $LOGFILE
1008          else          else
1009          # try again with "-lnetcdff" added to the libs          # try again with "-lnetcdff" added to the libs
1010              echo "try again with added '-lnetcdff -lnetcdf'" > genmake_tnc.log              echo "==> try again with added '-lnetcdff -lnetcdf'" > genmake_tnc.log
1011              echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log              echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
1012              echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log              echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
1013              echo " &&  $LINK $FFLAGS $FOPTIM -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
# Line 1010  EOF Line 1015  EOF
1015                  &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \                  &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
1016                  &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdff -lnetcdf >> genmake_tnc.log 2>&1                  &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdff -lnetcdf >> genmake_tnc.log 2>&1
1017              RET_COMPILE=$?              RET_COMPILE=$?
1018              cat genmake_tnc.log >> genmake_warnings              echo >> $LOGFILE
1019                cat genmake_tnc.log >> $LOGFILE
1020              if test "x$RET_COMPILE" = x0 ; then              if test "x$RET_COMPILE" = x0 ; then
1021                  LIBS="$LIBS -lnetcdff -lnetcdf"                  LIBS="$LIBS -lnetcdff -lnetcdf"
1022                  HAVE_NETCDF=t                  HAVE_NETCDF=t
1023                    echo "check_netcdf: successful" >> $LOGFILE
1024              fi              fi
1025          fi          fi
1026      fi      fi
1027      rm -f genmake_tnc*      rm -f genmake_tnc*
1028        echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE
1029  }  }
1030    
1031    check_lapack_libs()  {
1032        if test ! "x$SKIP_LAPACK_CHECK" = x ; then
1033            return
1034        fi
1035        echo >> $LOGFILE
1036        echo "running: check_lapack_libs()" >> $LOGFILE
1037        cat <<EOF > genmake_tla.F
1038          program fgenla
1039          integer info
1040          integer ipiv( 2 )
1041          double precision ab( 4, 2 ), b( 2 )
1042          data ab / 0., 0., 1., 2., 0., 2., 1., 0. /
1043          data b / 1., 1. /
1044          call dgbsv( 2, 1, 1, 1, ab, 4, ipiv, b, 2, info )
1045          IF (info .NE. 0) write(*,*) 'Error:', info
1046          write(*,*) b
1047          end
1048    EOF
1049        echo "===  genmake_tla.F  >>>" > genmake_tla.log
1050        cat genmake_tla.F >> genmake_tla.log
1051        echo "<<<  genmake_tla.F  ===" >> genmake_tla.log
1052        RET_CPP=f
1053        COMM="cat genmake_tla.F | $CPP $DEFINES $INCLUDES"
1054        echo "$COMM" >> genmake_tla.log
1055        eval $COMM > genmake_tla.$FS 2>/dev/null  &&  RET_CPP=t
1056        if test "x$RET_CPP" = xf ; then
1057            echo "  WARNING: CPP failed to pre-process the lapack test." \
1058                >> genmake_tla.log
1059            echo "    Please check that \$INCLUDES is properly set." \
1060                >> genmake_tla.log
1061        fi
1062        echo "$FC $FFLAGS $FOPTIM -c genmake_tla.$FS  \ " >> genmake_tla.log
1063        echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tla.o $LIBS" >> genmake_tla.log
1064        $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1065            &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS >> genmake_tla.log 2>&1
1066        RET_COMPILE=$?
1067        cat genmake_tla.log >> $LOGFILE
1068    
1069        # test program execution not always possible (see check_netcdf_libs)
1070        #
1071        #test -x ./genmake_tla  &&  ./genmake_tla >> genmake_tla.log 2>&1
1072        #RETVAL=$?
1073        #if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
1074    
1075        if test "x$RET_COMPILE" = x0 ; then
1076            HAVE_LAPACK=t
1077            echo "check_lapack: successful" >> $LOGFILE
1078        else
1079            # try again with "-llapack" added to the libs
1080            echo "==> try again with added '-llapack'" > genmake_tla.log
1081            echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1082            echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1083            echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack" >> genmake_tla.log
1084            cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1085                &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1086                &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack >> genmake_tla.log 2>&1
1087            RET_COMPILE=$?
1088            echo >> $LOGFILE
1089            cat genmake_tla.log >> $LOGFILE
1090            if test "x$RET_COMPILE" = x0 ; then
1091                LIBS="$LIBS -llapack"
1092                HAVE_LAPACK=t
1093                echo "check_lapack: successful" >> $LOGFILE
1094            else
1095            # try again with "-lf77blas -lcblas" added to the libs
1096                echo "==> try again with added '-llapack -lf77blas -lcblas'" > genmake_tla.log
1097                echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1098                echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1099                echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas" >> genmake_tla.log
1100                cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1101                    &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1102                    &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas >> genmake_tla.log 2>&1
1103                RET_COMPILE=$?
1104                echo >> $LOGFILE
1105                cat genmake_tla.log >> $LOGFILE
1106                if test "x$RET_COMPILE" = x0 ; then
1107                    LIBS="$LIBS -llapack -lf77blas -lcblas"
1108                    HAVE_LAPACK=t
1109                    echo "check_lapack: successful" >> $LOGFILE
1110                else
1111                # try again with "-latlas" added to the libs
1112                    echo "==> try again with added '-llapack -lf77blas -lcblas -latlas'" > genmake_tla.log
1113                    echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1114                    echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1115                    echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas" >> genmake_tla.log
1116                    cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1117                        &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1118                        &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas >> genmake_tla.log 2>&1
1119                    RET_COMPILE=$?
1120                    echo >> $LOGFILE
1121                    cat genmake_tla.log >> $LOGFILE
1122                    if test "x$RET_COMPILE" = x0 ; then
1123                        LIBS="$LIBS -llapack -lf77blas -lcblas -latlas"
1124                        HAVE_LAPACK=t
1125                        echo "check_lapack: successful" >> $LOGFILE
1126                    fi
1127                fi
1128            fi
1129        fi
1130        rm -f genmake_tla*
1131        echo " --> set HAVE_LAPACK='$HAVE_LAPACK'" >> $LOGFILE
1132    }
1133    
1134    
1135  ###############################################################################  ###############################################################################
# Line 1043  ENABLE= Line 1153  ENABLE=
1153  DISABLE=  DISABLE=
1154  # MAKEFILE=  # MAKEFILE=
1155  # MAKEDEPEND=  # MAKEDEPEND=
1156  PDEPEND=  PKG_DEPEND=
1157  DUMPSTATE=t  PKG_GROUPS=
1158  PDEFAULT=  DUMPSTATE=f
1159  OPTFILE=  OPTFILE=
1160  INCLUDES="-I. $INCLUDES"  INCLUDES="-I. $INCLUDES"
1161  FFLAGS=  FFLAGS=
# Line 1053  FOPTIM= Line 1163  FOPTIM=
1163  FEXTRAFLAGS=  FEXTRAFLAGS=
1164  USE_EXTENDED_SRC=  USE_EXTENDED_SRC=
1165  EXTENDED_SRC_FLAG=  EXTENDED_SRC_FLAG=
1166    GET_FC_VERSION=
1167  CFLAGS=  CFLAGS=
1168  KFLAGS1=  KFLAGS1=
1169  KFLAGS2=  KFLAGS2=
# Line 1065  MPI= Line 1176  MPI=
1176  MPIPATH=  MPIPATH=
1177  OMP=  OMP=
1178  OMPFLAG=  OMPFLAG=
1179    USE_R4=
1180  TS=  TS=
1181  PAPIS=  PAPIS=
1182  PCLS=  PCLS=
# Line 1086  HAVE_STAT= Line 1198  HAVE_STAT=
1198  HAVE_NETCDF=  HAVE_NETCDF=
1199  HAVE_ETIME=  HAVE_ETIME=
1200  IGNORE_TIME=  IGNORE_TIME=
1201    HAVE_LAPACK=
1202    
1203  MODS=  MODS=
1204  TOOLSDIR=  TOOLSDIR=
# Line 1108  MACHINE=`uname -a` Line 1221  MACHINE=`uname -a`
1221  EXECUTABLE=  EXECUTABLE=
1222  EXEHOOK=  EXEHOOK=
1223  EXEDIR=  EXEDIR=
 PACKAGES_CONF=  
1224  IEEE=  IEEE=
1225  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
1226      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
# Line 1129  FTL_TAF_FLAGS= Line 1241  FTL_TAF_FLAGS=
1241  SVD_TAMC_FLAGS=  SVD_TAMC_FLAGS=
1242  TAMC_EXTRA=  TAMC_EXTRA=
1243    
   
1244  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1245  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PKG_DEPEND PKG_GROUPS DISABLE ENABLE MAKEFILE MAKEDEPEND PLATFORM"
1246  gm_s2="FC CPP IEEE TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI OMP DUMPSTATE STANDARDDIRS"  gm_s2="FC CC MPI OMP USE_R4 TS PAPIS PCLS PAPI PCL HPMT IEEE DEVEL GSL FEXTRAFLAGS"
1247    gm_s3="ROOTDIR STANDARDDIRS MODS DUMPSTATE"
1248    
1249  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1250  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM FEXTRAFLAGS"  gm_s4="LN S64 LINK MAKE PACKAGES INCLUDES FFLAGS FOPTIM"
1251  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
1252  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"  gm_s6="TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"
1253  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s7="PWD THISHOST THISUSER THISDATE THISVER MACHINE"
1254  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"  gm_s8="FC_NAMEMANGLE HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME HAVE_LAPACK"
1255    
1256  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1257  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"
1258  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"
1259  gm_s12="TAF_EXTRA TAMC_EXTRA"  gm_s12="TAF_EXTRA TAMC_EXTRA"
1260    
1261  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"
1262  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
1263    
1264  cat <<EOF  cat <<EOF
1265    
1266  GENMAKE :  GENMAKE :
1267    
1268  A program for GENerating MAKEfiles for the MITgcm project.  For a  A program for GENerating MAKEfiles for the MITgcm project.
1269  quick list of options, use "genmake -h" or for more detail see:     For a quick list of options, use "genmake2 -h"
1270    or for more detail see the Developer's HOWTO manual at:
1271    http://mitgcm.org/devel_HOWTO/     http://mitgcm.org/public/docs.html
1272    
1273  EOF  EOF
1274    
1275    LOGFILE="genmake.log"
1276    #- clean-up previous genmake logfiles:
1277    rm -f genmake_state genmake_*optfile $LOGFILE
1278    
1279  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
1280  gm_local="genmake_local"  gm_local="genmake_local"
1281  printf "  getting local config information:  "  printf "  getting local config information:  "
# Line 1173  else Line 1289  else
1289  fi  fi
1290    
1291  #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  
1292  #parse_options  #parse_options
1293  ac_prev=  ac_prev=
1294  for ac_option in "$@" ; do  for ac_option in "$@" ; do
# Line 1194  for ac_option in "$@" ; do Line 1301  for ac_option in "$@" ; do
1301          ac_prev=          ac_prev=
1302          continue          continue
1303      fi      fi
1304        
1305      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
1306        
1307      case $ac_option in      case $ac_option in
1308            
1309          -help | --help | -h | --h)          -help | --help | -h | --h)
1310              usage ;;              usage ;;
1311            
1312          -nooptfile | --nooptfile)          -nooptfile | --nooptfile)
1313              OPTFILE="NONE" ;;              OPTFILE="NONE" ;;
1314          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
1315              ac_prev=OPTFILE ;;              ac_prev=OPTFILE ;;
1316          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
1317              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
1318            
1319          -adoptfile | --adoptfile | -adof | --adof)          -adoptfile | --adoptfile | -adof | --adof)
1320              ac_prev=AD_OPTFILE ;;              ac_prev=AD_OPTFILE ;;
1321          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
1322              AD_OPTFILE=$ac_optarg ;;              AD_OPTFILE=$ac_optarg ;;
1323            
1324          -pdepend | --pdepend)          -pdepend | --pdepend)
1325              ac_prev=PDEPEND ;;              ac_prev=PKG_DEPEND ;;
1326          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
1327              PDEPEND=$ac_optarg ;;              PKG_DEPEND=$ac_optarg ;;
1328            
1329          -pdefault | --pdefault)          -pgroups | --pgroups)
1330              ac_prev=PDEFAULT ;;              ac_prev=PKG_GROUPS ;;
1331          -pdefault=* | --pdefault=*)          -pgroups=* | --pgroups=*)
1332              PDEFAULT=$ac_optarg ;;              PKG_GROUPS=$ac_optarg ;;
1333            
1334          -make | --make | -m | --m)          -make | --make | -m | --m)
1335              ac_prev=MAKE ;;              ac_prev=MAKE ;;
1336          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
1337              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
1338            
1339          -bash | --bash)          -bash | --bash)
1340              ac_prev=BASH ;;              ac_prev=BASH ;;
1341          -bash=* | --bash=*)          -bash=* | --bash=*)
1342              BASH=$ac_optarg ;;              BASH=$ac_optarg ;;
1343            
1344          -makedepend | --makedepend | -md | --md)          -makedepend | --makedepend | -md | --md)
1345              ac_prev=MAKEDEPEND ;;              ac_prev=MAKEDEPEND ;;
1346          -makedepend=* | --makedepend=* | -md=* | --md=*)          -makedepend=* | --makedepend=* | -md=* | --md=*)
1347              MAKEDEPEND=$ac_optarg ;;              MAKEDEPEND=$ac_optarg ;;
1348            
1349          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -ma | --ma)
1350              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
1351          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -ma=* | --ma=*)
1352              MAKEFILE=$ac_optarg ;;              MAKEFILE=$ac_optarg ;;
1353            
1354          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)
1355              echo "ERROR: The platform option has been removed.  Please specify"              echo "ERROR: The platform option has been removed.  Please specify"
1356              echo "  the build options using the \"optfile\" mechanism."              echo "  the build options using the \"optfile\" mechanism."
1357              echo              echo
1358              usage              usage
1359              ;;              ;;
1360            
1361          -rootdir | --rootdir | -rd | --rd)          -rootdir | --rootdir | -rd | --rd)
1362              ac_prev=ROOTDIR ;;              ac_prev=ROOTDIR ;;
1363          -rootdir=* | --rootdir=* | -rd=* | --rd=*)          -rootdir=* | --rootdir=* | -rd=* | --rd=*)
1364              ROOTDIR=$ac_optarg ;;              ROOTDIR=$ac_optarg ;;
1365            
1366          -mods | --mods | -mo | --mo)          -mods | --mods | -mo | --mo)
1367              ac_prev=MODS ;;              ac_prev=MODS ;;
1368          -mods=* | --mods=* | -mo=* | --mo=*)          -mods=* | --mods=* | -mo=* | --mo=*)
1369              MODS=$ac_optarg ;;              MODS=$ac_optarg ;;
1370            
1371          -disable | --disable)          -disable | --disable)
1372              ac_prev=DISABLE ;;              ac_prev=DISABLE ;;
1373          -disable=* | --disable=*)          -disable=* | --disable=*)
1374              DISABLE=$ac_optarg ;;              DISABLE=$ac_optarg ;;
1375            
1376          -enable | --enable)          -enable | --enable)
1377              ac_prev=ENABLE ;;              ac_prev=ENABLE ;;
1378          -enable=* | --enable=*)          -enable=* | --enable=*)
1379              ENABLE=$ac_optarg ;;              ENABLE=$ac_optarg ;;
1380            
1381          -standarddirs | --standarddirs)          -standarddirs | --standarddirs)
1382              ac_prev=STANDARDDIRS ;;              ac_prev=STANDARDDIRS ;;
1383          -standarddirs=* | --standarddirs=*)          -standarddirs=* | --standarddirs=*)
# Line 1280  for ac_option in "$@" ; do Line 1387  for ac_option in "$@" ; do
1387  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1388  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1389  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1390            
1391          -cc | --cc)          -cc | --cc)
1392              ac_prev=CC ;;              ac_prev=CC ;;
1393          -cc=* | --cc=*)          -cc=* | --cc=*)
1394              CC=$ac_optarg ;;              CC=$ac_optarg ;;
1395            
1396          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1397              ac_prev=FC ;;              ac_prev=FC ;;
1398          -fc=* | --fc=*)          -fc=* | --fc=*)
1399              FC=$ac_optarg ;;              FC=$ac_optarg ;;
1400            
1401          -fs | --fs)          -fs | --fs)
1402              ac_prev=FS ;;              ac_prev=FS ;;
1403          -fs=* | --fs=*)          -fs=* | --fs=*)
1404              FS=$ac_optarg ;;              FS=$ac_optarg ;;
1405            
1406          -fs90 | --fs90)          -fs90 | --fs90)
1407              ac_prev=FS90 ;;              ac_prev=FS90 ;;
1408          -fs90=* | --fs90=*)          -fs90=* | --fs90=*)
1409              FS90=$ac_optarg ;;              FS90=$ac_optarg ;;
1410            
1411            -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )
1412                USE_R4=true ;;
1413    
1414          -ieee | --ieee)          -ieee | --ieee)
1415              IEEE=true ;;              IEEE=true ;;
1416          -noieee | --noieee)          -noieee | --noieee)
1417              IEEE= ;;              echo "Warning: ignore option '$ac_option' (default is already without '-ieee')" ;;
1418            -devel | --devel)
1419                IEEE=true ; DEVEL=true ;;
1420            -gsl | --gsl)
1421                GSL=true ;;
1422    
1423          -ts | --ts)          -ts | --ts)
1424              TS=true ;;              TS=true ;;
# Line 1321  for ac_option in "$@" ; do Line 1435  for ac_option in "$@" ; do
1435          -hpmt | --hpmt)          -hpmt | --hpmt)
1436              HPMT=true ;;              HPMT=true ;;
1437    
         -gsl | --gsl)  
             GSL=true ;;  
   
         -devel | --devel)  
             DEVEL=true ;;  
   
1438          -mpi | --mpi)          -mpi | --mpi)
1439              MPI=true ;;              MPI=true ;;
1440          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
1441              MPIPATH=$ac_optarg              MPIPATH=$ac_optarg
1442              MPI=true ;;              MPI=true ;;
1443            
1444          -omp | --omp)          -omp | --omp)
1445              OMP=true ;;              OMP=true ;;
1446          -omp=* | --omp=*)          -omp=* | --omp=*)
1447              OMPFLAG=$ac_optarg              OMPFLAG=$ac_optarg
1448              OMP=true ;;              OMP=true ;;
1449            
1450          -ds | --ds)          -ds | --ds)
1451              DUMPSTATE=t ;;              DUMPSTATE=t ;;
1452            
1453            -extra_flag | --extra_flag)
1454                ac_prev=FEXTRAFLAGS ;;
1455            -extra_flag=* | --extra_flag=*)
1456                FEXTRAFLAGS=$ac_optarg ;;
1457    
1458          -taf_extra | --taf_extra)          -taf_extra | --taf_extra)
1459              ac_prev=TAF_EXTRA ;;              ac_prev=TAF_EXTRA ;;
1460          -taf_extra=* | --taf_extra=*)          -taf_extra=* | --taf_extra=*)
# Line 1351  for ac_option in "$@" ; do Line 1464  for ac_option in "$@" ; do
1464              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1465          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1466              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1467            
1468          -ignoretime | -ignore_time | --ignoretime | --ignore_time)          -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1469              IGNORE_TIME="-DIGNORE_TIME" ;;              IGNORE_TIME="-DIGNORE_TIME" ;;
1470    
# Line 1362  for ac_option in "$@" ; do Line 1475  for ac_option in "$@" ; do
1475              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
1476              usage              usage
1477              ;;              ;;
1478            
1479          *)          *)
1480              echo "Error: unrecognized argument: "$ac_option              echo "Error: unrecognized argument: "$ac_option
1481              usage              usage
1482              ;;              ;;
1483            
1484      esac      esac
       
 done  
1485    
1486    done
1487    
1488  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1489      echo      echo
1490      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
1491      echo "  file.  This file format is no longer supported.  For directions on"      echo "  file.  This file format is no longer supported.  For directions on"
1492      echo "  how to setup and use the new \"genmake2\" script, please see:"      echo "  how to setup and use the new \"genmake2\" script, please see:"
1493      echo "    http://mitgcm.org/devel_HOWTO/"      echo "    http://mitgcm.org/public/devel_HOWTO/"
1494      echo "  and send an email to MITgcm-support@mitgcm.org if you need help."      echo "  and send an email to MITgcm-support@mitgcm.org if you need help."
1495      echo "WARNING: ignore \"./.genmakerc\" and continue."      echo "WARNING: ignore \"./.genmakerc\" and continue."
1496      echo      echo
1497  fi  fi
1498    
1499  #  Find the MITgcm ${ROOTDIR}  #  Find the MITgcm ${ROOTDIR}
# Line 1393  if test "x${ROOTDIR}" = x ; then Line 1505  if test "x${ROOTDIR}" = x ; then
1505          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
1506              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
1507                  ROOTDIR=$d                  ROOTDIR=$d
1508                  printf "Warning:  ROOTDIR was not specified but there appears to be"                  printf "Warning: ROOTDIR was not specified ;"
1509                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."                  echo " try using a local copy of MITgcm found at \"$ROOTDIR\""
1510                  break                  break
1511              fi              fi
1512          done          done
# Line 1414  fi Line 1526  fi
1526  #  Find the MITgcm ${THISVER}  #  Find the MITgcm ${THISVER}
1527  version_file="${ROOTDIR}/doc/tag-index"  version_file="${ROOTDIR}/doc/tag-index"
1528  if test -f $version_file ; then  if test -f $version_file ; then
1529      THISVER=`grep '^checkpoint' $version_file | head -1`      THISVER=`$AWK '/^checkpoint/{print $1; exit}' $version_file`
1530  #-  remove ./BUILD_INFO.h file if older than version_file  #-  remove ./BUILD_INFO.h file if older than version_file
1531      if test -f ./BUILD_INFO.h -a ./BUILD_INFO.h -ot $version_file ; then      if test -f ./BUILD_INFO.h -a ./BUILD_INFO.h -ot $version_file ; then
1532          echo "  remove ./BUILD_INFO.h (older than ${version_file})"          echo "  remove ./BUILD_INFO.h (older than ${version_file})"
# Line 1426  if test "x$MAKEFILE" = x ; then Line 1538  if test "x$MAKEFILE" = x ; then
1538      MAKEFILE="Makefile"      MAKEFILE="Makefile"
1539  fi  fi
1540    
1541  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:"
1542  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1543      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
1544          echo "Warning: no OPTFILE specified so we'll look for possible settings"          echo "Warning: no OPTFILE specified so we'll look for possible settings"
1545          printf "\n===  Searching for possible settings for OPTFILE  ===\n"          printf "\n===  Searching for possible settings for OPTFILE  ===\n"
1546          find_possible_configs          find_possible_optfile
1547      else      else
1548          OPTFILE=$MITGCM_OF          OPTFILE=$MITGCM_OF
1549      fi      fi
# Line 1446  if test "x$OPTFILE" != xNONE ; then Line 1558  if test "x$OPTFILE" != xNONE ; then
1558              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1559              exit 1              exit 1
1560          fi          fi
1561          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" = xt ; then
1562              cp -f $OPTFILE "genmake_optfile"              cp -f $OPTFILE "genmake_optfile"
1563          fi          fi
1564      else      else
# Line 1455  if test "x$OPTFILE" != xNONE ; then Line 1567  if test "x$OPTFILE" != xNONE ; then
1567      fi      fi
1568  fi  fi
1569    
1570  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:"
1571  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1572      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" = x ; then
1573          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
# Line 1473  if test "x${AD_OPTFILE}" != xNONE ; then Line 1585  if test "x${AD_OPTFILE}" != xNONE ; then
1585              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1586              exit 1              exit 1
1587          fi          fi
1588          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" = xt ; then
1589              cp -f $AD_OPTFILE "genmake_ad_optfile"              cp -f $AD_OPTFILE "genmake_ad_optfile"
1590          fi          fi
1591      else      else
# Line 1501  Error: no Fortran compiler: please speci Line 1613  Error: no Fortran compiler: please speci
1613  EOF  EOF
1614      exit 1      exit 1
1615  fi  fi
1616    if test "x$GET_FC_VERSION" != x ; then
1617      echo "Get compiler version using: $FC $GET_FC_VERSION" >> $LOGFILE
1618      ff=`echo $FC | sed 's/ .*//'` ; xx=`echo $ff | sed 's/^./& /' | sed 's/ .*//'`
1619      if test $xx != '/' ; then which $ff >> $LOGFILE ; fi
1620      $FC $GET_FC_VERSION > genmake_fc_vers1 2> genmake_fc_vers2
1621      if test -s genmake_fc_vers1 ; then
1622        cat genmake_fc_vers1 >> $LOGFILE
1623      else
1624        cat genmake_fc_vers2 >> $LOGFILE
1625      fi
1626      echo "<-- compiler version ----" >> $LOGFILE
1627      rm -f genmake_fc_vers1 genmake_fc_vers2
1628    fi
1629    
1630  if test "x$CC" = x ; then  if test "x$CC" = x ; then
1631      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  
1632  fi  fi
1633    
1634  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1635      LINK=$FC      LINK=$FC
1636  fi  fi
# Line 1518  if test "x$MAKE" = x ; then Line 1638  if test "x$MAKE" = x ; then
1638      MAKE="make"      MAKE="make"
1639  fi  fi
1640  if test "x$CPP" = x ; then  if test "x$CPP" = x ; then
1641      CPP=cpp      CPP="cpp -traditional -P"
1642  fi  fi
1643  #EH3 === UGLY ===  #EH3 === UGLY ===
1644  #  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 1545  EOF Line 1665  EOF
1665  else  else
1666      rm -f test_cpp      rm -f test_cpp
1667  fi  fi
1668    
1669  look_for_makedepend  look_for_makedepend
1670    
1671    #  Check that soft-link command is set and usable
1672  if test "x$LN" = x ; then  if test "x$LN" = x ; then
1673      LN="ln -s"      LN="ln -s"
1674  fi  fi
# Line 1555  RETVAL=$? Line 1678  RETVAL=$?
1678  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
1679      cat <<EOF 1>&2      cat <<EOF 1>&2
1680    
1681  Error: The command "ln -s" failed -- please specify a working soft-link  Error: The command "$LN" failed -- please specify a working soft-link
1682    command in the optfile.    command in the optfile.
1683    
1684  EOF  EOF
# Line 1582  if test ! "x$OMP" = x ; then Line 1705  if test ! "x$OMP" = x ; then
1705        DEFINES="$DEFINES -DUSE_OMP_THREADING"        DEFINES="$DEFINES -DUSE_OMP_THREADING"
1706  fi  fi
1707    
1708    if test ! "x$USE_R4" = x ; then
1709          echo "  Turning on LET_RS_BE_REAL4 cpp flag"
1710          DEFINES="$DEFINES -DLET_RS_BE_REAL4"
1711    fi
1712    
1713  if test ! "x$TS" = x ; then  if test ! "x$TS" = x ; then
1714        echo "  Turning on timing per timestep"        echo "  Turning on timing per timestep"
1715        if test ! "x$FOOLAD" = x ; then        if test ! "x$FOOLAD" = x ; then
1716              DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"
1717        else        else
1718              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1719        fi        fi
# Line 1621  if test ! "x$PAPI" = x ; then Line 1749  if test ! "x$PAPI" = x ; then
1749            echo "  Sticking with PAPI flop summary per timestep!"            echo "  Sticking with PAPI flop summary per timestep!"
1750        else        else
1751            echo "  Turning on performance analysis with PAPI"            echo "  Turning on performance analysis with PAPI"
1752            echo "  Please make sure PAPIINC, PAPILIB are defined"            echo "  Please make sure PAPIINC, PAPILIB are defined"
1753            DEFINES="$DEFINES -DUSE_PAPI"            DEFINES="$DEFINES -DUSE_PAPI"
1754            INCLUDES="$INCLUDES $PAPIINC"            INCLUDES="$INCLUDES $PAPIINC"
1755            LIBS="$LIBS $PAPILIB"            LIBS="$LIBS $PAPILIB"
# Line 1633  if test ! "x$PCL" = x ; then Line 1761  if test ! "x$PCL" = x ; then
1761            echo "  Sticking with PCL flop summary per timestep!"            echo "  Sticking with PCL flop summary per timestep!"
1762        else        else
1763            echo "  Turning on performance analysis with PCL"            echo "  Turning on performance analysis with PCL"
1764            echo "  Please make sure PCLINC, PCLLIB are defined"            echo "  Please make sure PCLINC, PCLLIB are defined"
1765            DEFINES="$DEFINES -DUSE_PCL"            DEFINES="$DEFINES -DUSE_PCL"
1766            INCLUDES="$INCLUDES $PCLINC"            INCLUDES="$INCLUDES $PCLINC"
1767            LIBS="$LIBS $PCLLIB"            LIBS="$LIBS $PCLLIB"
# Line 1648  if test ! "x$HPMT" = x ; then Line 1776  if test ! "x$HPMT" = x ; then
1776            echo "  Sticking with PCL!"            echo "  Sticking with PCL!"
1777        else        else
1778            echo "  Turning on performance analysis with the HPM Toolkit"            echo "  Turning on performance analysis with the HPM Toolkit"
1779            echo "  Please make sure HPMTINC, HPMTLIB are defined"            echo "  Please make sure HPMTINC, HPMTLIB are defined"
1780            DEFINES="$DEFINES -DUSE_LIBHPM"            DEFINES="$DEFINES -DUSE_LIBHPM"
1781            INCLUDES="$INCLUDES $HPMTINC"            INCLUDES="$INCLUDES $HPMTINC"
1782            LIBS="$LIBS $HPMTLIB"            LIBS="$LIBS $HPMTLIB"
1783        fi        fi
1784        fi        fi
# Line 1733  rm -f genmake_tcomp* Line 1861  rm -f genmake_tcomp*
1861  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1862  check_HAVE_CLOC  check_HAVE_CLOC
1863  if test "x$HAVE_CLOC" != x ; then  if test "x$HAVE_CLOC" != x ; then
1864        DEFINES="$DEFINES -DHAVE_CLOC"
1865      echo "yes"      echo "yes"
1866  else  else
1867      echo "no"      echo "no"
# Line 1747  rm -f genmake_t* Line 1876  rm -f genmake_t*
1876  printf "  Can we unlimit the stack size using $FC...  "  printf "  Can we unlimit the stack size using $FC...  "
1877  check_HAVE_SETRLSTK  check_HAVE_SETRLSTK
1878  if test "x$HAVE_SETRLSTK" = xt ; then  if test "x$HAVE_SETRLSTK" = xt ; then
1879        DEFINES="$DEFINES -DHAVE_SETRLSTK"
1880      echo "yes"      echo "yes"
1881  else  else
1882      echo "no"      echo "no"
# Line 1756  rm -f genmake_t* Line 1886  rm -f genmake_t*
1886  printf "  Can we register a signal handler using $FC...  "  printf "  Can we register a signal handler using $FC...  "
1887  check_HAVE_SIGREG  check_HAVE_SIGREG
1888  if test "x$HAVE_SIGREG" = xt ; then  if test "x$HAVE_SIGREG" = xt ; then
1889        DEFINES="$DEFINES -DHAVE_SIGREG"
1890      echo "yes"      echo "yes"
1891  else  else
1892      echo "no"      echo "no"
# Line 1765  rm -f genmake_t* Line 1896  rm -f genmake_t*
1896  printf "  Can we use stat() through C calls...  "  printf "  Can we use stat() through C calls...  "
1897  check_HAVE_STAT  check_HAVE_STAT
1898  if test "x$HAVE_STAT" != x ; then  if test "x$HAVE_STAT" != x ; then
1899        DEFINES="$DEFINES -DHAVE_STAT"
1900      echo "yes"      echo "yes"
1901  else  else
1902      echo "no"      echo "no"
# Line 1774  rm -f genmake_t* Line 1906  rm -f genmake_t*
1906  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1907  check_netcdf_libs  check_netcdf_libs
1908  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
1909        DEFINES="$DEFINES -DHAVE_NETCDF"
1910        echo "yes"
1911    else
1912        echo "no"
1913    fi
1914    
1915    printf "  Can we create LAPACK-enabled binaries...  "
1916    check_lapack_libs
1917    if test "x$HAVE_LAPACK" != x ; then
1918        DEFINES="$DEFINES -DHAVE_LAPACK"
1919      echo "yes"      echo "yes"
1920  else  else
1921      echo "no"      echo "no"
# Line 1785  if test "x$EMBED_SRC" = xt ; then Line 1927  if test "x$EMBED_SRC" = xt ; then
1927  fi  fi
1928  if test "x$EMBED_SRC" = xt ; then  if test "x$EMBED_SRC" = xt ; then
1929      ENABLE="$ENABLE embed_files"      ENABLE="$ENABLE embed_files"
1930    #   DEFINES="$DEFINES -DHAVE_EMBED_SRC"
1931  fi  fi
1932    
   
1933  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1934  printf "  Adding MODS directories: "  printf "  Adding MODS directories: "
 MPI_LNKF=  
1935  for d in $MODS ; do  for d in $MODS ; do
1936      if test ! -d $d ; then      if test ! -d $d ; then
1937          echo          echo
# Line 1800  for d in $MODS ; do Line 1941  for d in $MODS ; do
1941          printf "$d "          printf "$d "
1942          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1943          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
         #-------------------------------------------------------  
         # Put special links so that MPI specific files are used  
         MPI_FILES=`(cd $d ; find . -name "*_mpi" -print)`  
         for i in $MPI_FILES ; do  
           ii=`echo $i | sed 's:^\./::'`  
           name=`echo $ii | sed 's:_mpi::' `  
           if test "x$MPI" = x ; then  
           # NO: We undo an _mpi symbolically linked file  
             if test -L $name ; then  
               cmp $name "$d/$ii" > /dev/null 2>&1  
               RETVAL=$?  
               if test "x$RETVAL" = x0 ; then  
                 printf "Un-linking $name ; "  
                 rm -f $name  
               fi  
             fi  
           else  
           # YES: We symbolically link this file (with conditions if already there)  
             if test -L $name ; then  
               cmp $d/$ii $name > /dev/null 2>&1  
               RETVAL=$?  
               yy=0 ;  
               for xx in $MPI_LNKF ; do if test $xx = $name ; then yy=1 ; fi ; done  
               if test "x$RETVAL" != x0 -a $yy = 0 ; then  
               # remove sym-link if different and has not just been linked  
                 printf "Un-link + "  
                 rm -f $name  
               fi  
               if test "x$RETVAL" = x0 ; then  
               # if identical, keep sym-link and keep record of it  
                 MPI_LNKF="$MPI_LNKF $name"  
               fi  
             fi  
             if ! test -f $name ; then  
               # make sym-link and keep record of it  
                 printf "Linking $ii to $name ; "  
                 ln -sf $d/$ii $name  
                 MPI_LNKF="$MPI_LNKF $name"  
             fi  
           fi  
         done  
         #-------------------------------------------------------  
1944      fi      fi
1945  done  done
1946  echo  echo
 #echo "MPI_LNKF='$MPI_LNKF'"  
1947    
1948  if test "x${PLATFORM}" = x ; then  #if test "x${PLATFORM}" = x ; then
1949      PLATFORM=$p_PLATFORM  #    PLATFORM=$p_PLATFORM
1950  fi  #fi
1951    
1952  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1953      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
# Line 1889  ERROR: neither of the two default script Line 1987  ERROR: neither of the two default script
1987      ${TOOLSDIR}/set64bitConst.sh      ${TOOLSDIR}/set64bitConst.sh
1988      ${TOOLSDIR}/set64bitConst.csh      ${TOOLSDIR}/set64bitConst.csh
1989    
1990    are working so please check paths or specify (with \$S64) a    are working so please check paths or specify (with \$S64) a
1991    working version of this script.    working version of this script.
1992    
1993  EOF  EOF
# Line 1901  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSD Line 1999  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSD
1999    
2000  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
2001    
2002    #  Set Standard Code Directories:
2003    if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
2004        STANDARDDIRS="eesupp model"
2005    fi
2006    #  if model in Standard-Code-Dir, add eesupp (needed to compile model)
2007    echo " $STANDARDDIRS " | grep ' model ' > /dev/null 2>&1
2008    ckM=$?
2009    echo " $STANDARDDIRS " | grep ' eesupp ' > /dev/null 2>&1
2010    ckE=$?
2011    if test $ckM = 0 -a $ckE = 1 ; then
2012        STANDARDDIRS="$STANDARDDIRS eesupp"
2013    fi
2014    
2015  #  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
2016  #  generated from some template source files. We'll make them first so  #  generated from some template source files. We'll make them first so
2017  #  they appear as regular source code  #  they appear as regular source code
2018  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
2019      echo "  Making source files in eesupp from templates"      echo "  Making source files in eesupp from templates"
2020      ( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1      ( cd $ROOTDIR"/eesupp/src/" && $MAKE clean_old && $MAKE \
2021        ) > make_eesupp.errors 2>&1
2022      RETVAL=$?      RETVAL=$?
2023      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
2024          rm -f make_eesupp.errors          rm -f make_eesupp.errors
# Line 1921  fi Line 2033  fi
2033  for pdir in exch2 regrid ; do  for pdir in exch2 regrid ; do
2034      if test -r $ROOTDIR"/pkg/${pdir}/Makefile" ; then      if test -r $ROOTDIR"/pkg/${pdir}/Makefile" ; then
2035          echo "  Making source files in pkg/${pdir} from templates"          echo "  Making source files in pkg/${pdir} from templates"
2036          ( cd $ROOTDIR"/pkg/"${pdir} && $MAKE ) > make_${pdir}.errors 2>&1          ( cd $ROOTDIR"/pkg/"${pdir} && $MAKE clean_old && $MAKE \
2037            ) > make_${pdir}.errors 2>&1
2038          RETVAL=$?          RETVAL=$?
2039          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
2040              rm -f make_${pdir}.errors              rm -f make_${pdir}.errors
# Line 1934  for pdir in exch2 regrid ; do Line 2047  for pdir in exch2 regrid ; do
2047  done  done
2048    
2049  printf "\n===  Determining package settings  ===\n"  printf "\n===  Determining package settings  ===\n"
2050  if  test "x${PDEPEND}" = x ; then  if  test "x${PKG_DEPEND}" = x ; then
2051      tmp=$ROOTDIR"/pkg/pkg_depend"      tmp=$ROOTDIR"/pkg/pkg_depend"
2052      if test -r $tmp ; then      if test -r $tmp ; then PKG_DEPEND=$tmp ; fi
2053          PDEPEND=$tmp  fi
2054      else  if  test "x${PKG_DEPEND}" = x ; then
2055          echo "Warning:  No package dependency information was specified."          echo "Warning:  No package dependency information was specified."
2056          echo "  Please check that ROOTDIR/pkg/pkg_depend exists."          echo "  Please check that ROOTDIR/pkg/pkg_depend exists."
     fi  
2057  else  else
2058      if test ! -r ${PDEPEND} ; then      if test ! -r ${PKG_DEPEND} ; then
2059          echo "Error:  can't read package dependency info from PDEPEND=\"$PDEPEND\""          echo "Error:  can't read package dependency info from PKG_DEPEND=\"$PKG_DEPEND\""
2060          exit 1          exit 1
2061      fi      fi
2062        echo "  getting package dependency info from  $PKG_DEPEND"
2063    #  Strip the comments and then convert the dependency file into arrays: PNAME, DNAME
2064        get_pdepend_list $PKG_DEPEND
2065  fi  fi
2066  echo "  getting package dependency info from  $PDEPEND"  
2067  #  Strip the comments and then convert the dependency file into  # A default package groups file "$ROOTDIR/pkg/pkg_groups" is provided
2068  #  two arrays: PNAME, DNAME  #  to define the "default_pkg_list" and package groups (for convenience, one
2069  cat $PDEPEND | sed -e 's/#.*$//g' \  #  can specify a group of packages using names like "ocean" and "atmosphere").
2070      | $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
2071      > ./.pd_tmp      tmp=$ROOTDIR"/pkg/pkg_groups"
2072  RETVAL=$?      if test -r $tmp ; then PKG_GROUPS=$tmp ; fi
2073  if test ! "x${RETVAL}" = x0 ; then  fi
2074      echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""  if test "x${PKG_GROUPS}" = x ; then
2075      exit 1          echo "Warning:  No package groups information was specified."
2076            echo "  Please check that ROOTDIR/pkg/pkg_groups exists."
2077    else
2078        if test ! -r ${PKG_GROUPS} ; then
2079            echo "Error:  can't read package groups info from PKG_GROUPS=\"$PKG_GROUPS\""
2080            exit 1
2081        fi
2082        echo "  getting package groups info from      $PKG_GROUPS"
2083  fi  fi
 . ./.pd_tmp  
 rm -f ./.pd_tmp  
2084    
2085  #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"  #  Search for packages to compile.
2086  #  file should eventually be added so that, for convenience, one can  echo "  checking list of packages to compile:"
2087  #  specify groups of packages using names like "ocean" and "atmosphere".  PKG_LIST=
2088  echo "  checking default package list:  "  if test "x${PKG_LIST}" = x ; then
 if test "x${PDEFAULT}" = x ; then  
2089      for i in "." $MODS ; do      for i in "." $MODS ; do
2090          if test -r $i"/packages.conf" ; then          if test -r $i"/packages.conf" ; then
2091                  PDEFAULT=$i"/packages.conf"                  PKG_LIST=$i"/packages.conf"
2092                  break                  break
2093          fi          fi
2094      done      done
2095  fi  fi
2096  if test "x${PDEFAULT}" = x ; then  if test "x${PKG_LIST}" = x ; then
2097      PDEFAULT="$ROOTDIR/pkg/pkg_default"      pkg_list='default_pkg_list'
2098  fi      if test "x${PKG_GROUPS}" = x ; then
2099  if test "x${PDEFAULT}" = xNONE ; then          echo "Error:  need package groups info to expand pkg_list=\"$pkg_list\""
2100      echo "    default packages file disabled"          exit 1
2101        fi
2102  else  else
2103      if test ! -r $PDEFAULT ; then      if test ! -r $PKG_LIST ; then
2104          echo "Warning:  can't read default packages from PDEFAULT=\"$PDEFAULT\""          echo "Error:  can't read package list from PKG_LIST=\"$PKG_LIST\""
2105            exit 1
2106      else      else
2107          echo "    using PDEFAULT=\"$PDEFAULT\""          echo "    using PKG_LIST=\"$PKG_LIST\""
2108          #  Strip the comments and add all the names          #  Strip the comments and add all the names
2109          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}'`
2110          RETVAL=$?          RETVAL=$?
2111          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
2112              printf "Error: can't parse default package list "              printf "Error: can't parse package list "
2113              echo "-- please check PDEFAULT=\"$PDEFAULT\""              echo "-- please check PKG_LIST=\"$PKG_LIST\""
2114              exit 1              exit 1
2115          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"  
2116      fi      fi
2117  fi  fi
2118    for i in $pkg_list ; do
2119        PACKAGES="$PACKAGES $i"
2120    done
2121    echo     "    before group expansion packages are:$PACKAGES"
2122    if test "x${PKG_GROUPS}" != x ; then
2123        RET=1
2124        while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
2125        echo "    after group expansion packages are: $PACKAGES"
2126    fi
2127    
2128  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
2129    echo "" > ./.tmp_pack
2130  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2131      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
2132  done  done
# Line 2030  PACKAGES="$PACKAGES $ENABLE" Line 2154  PACKAGES="$PACKAGES $ENABLE"
2154  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2155      j=`echo $i | sed 's/[-+]//'`      j=`echo $i | sed 's/[-+]//'`
2156      if test ! -d "$ROOTDIR/pkg/$j" ; then      if test ! -d "$ROOTDIR/pkg/$j" ; then
2157          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
2158          exit 1          exit 1
2159      fi      fi
2160      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
2161  done  done
# Line 2040  for i in `grep -v "-" ./.tmp_pack | sort Line 2164  for i in `grep -v "-" ./.tmp_pack | sort
2164      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
2165  done  done
2166  rm -f ./.tmp_pack  rm -f ./.tmp_pack
2167  echo "    packages are:  $PACKAGES"  echo "    packages are: $PACKAGES"
2168    
2169  #  Check for package MNC: if NetCDF is available, then build the MNC  #  Check for package MNC: if NetCDF is available, then build the MNC
2170  #  template files ; otherwise, delete mnc from the list of packages.  #  template files ; otherwise, delete mnc from the list of packages.
2171  echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1  echo " $PACKAGES " | grep ' mnc ' > /dev/null 2>&1
2172  RETVAL=$?  mnc_in=$?
2173  if test "x$RETVAL" = x0 ; then  if test "x$HAVE_NETCDF" != xt ; then
2174      if test "x$HAVE_NETCDF" != xt ; then      if test "x$mnc_in" = x0 ; then
2175          cat <<EOF          cat <<EOF
   
2176  *********************************************************************  *********************************************************************
2177  WARNING: the "mnc" package was enabled but tests failed to compile  WARNING: the "mnc" package was enabled but tests failed to compile
2178    NetCDF applications.  Please check that:    NetCDF applications.  Please check that:
2179    
2180    1) NetCDF is correctly installed for this compiler and    1) NetCDF is correctly installed for this compiler and
2181    2) the LIBS variable (within the "optfile") specifies the correct    2) the LIBS variable (within the "optfile") specifies the correct
2182         NetCDF library to link against.         NetCDF library to link against.
2183    
2184    Due to this failure, the "mnc" package is now DISABLED.    Due to this failure, the "mnc" package is now DISABLED.
2185  *********************************************************************  *********************************************************************
   
2186  EOF  EOF
2187          PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`          PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
2188          DISABLE="$DISABLE mnc"          DISABLE="$DISABLE mnc"
2189      else      else
2190          ( 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
2191          RETVAL=$?          DISABLE="$DISABLE mnc"
2192          if test "x${RETVAL}" = x0 ; then      fi
2193              rm -f make_mnc.errors  else
2194        # we have NetCDF, we try to build MNC template files
2195        ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
2196        RETVAL=$?
2197        if test "x${RETVAL}" = x0 ; then
2198            rm -f make_mnc.errors
2199        else
2200            echo "Error: problem encountered while building source files in pkg/mnc:"
2201            cat make_mnc.errors 1>&2
2202            if test "x$mnc_in" = x0 ; then
2203                exit 1
2204          else          else
2205              echo "Error: problem encountered while building source files in pkg/mnc:"              DISABLE="$DISABLE mnc"
             cat make_mnc.errors 1>&2  
             exit 1  
2206          fi          fi
2207      fi      fi
2208  fi  fi
2209    
2210  #  Check for package PROFILES: if NetCDF is not available,  #  Check for package PROFILES: if NetCDF is not available,
2211  #  then delete profiles from the list of available packages.  #  then delete profiles from the list of available packages.
2212  echo $PACKAGES | grep ' profiles ' > /dev/null 2>&1  if test "x$HAVE_NETCDF" != xt ; then
2213  RETVAL=$?      echo " $PACKAGES " | grep ' profiles ' > /dev/null 2>&1
2214  if test "x$RETVAL" = x0 ; then      RETVAL=$?
2215      if test "x$HAVE_NETCDF" != xt ; then      if test "x$RETVAL" = x0 ; then
2216          cat <<EOF          cat <<EOF
   
2217  *********************************************************************  *********************************************************************
2218  WARNING: the "profiles" package was enabled but tests failed to  WARNING: the "profiles" package was enabled but tests failed to
2219    compile NetCDF applications.  Please check that:    compile NetCDF applications.  Please check that:
2220    
2221    1) NetCDF is correctly installed for this compiler and    1) NetCDF is correctly installed for this compiler and
2222    2) the LIBS variable (within the "optfile") specifies the correct    2) the LIBS variable (within the "optfile") specifies the correct
2223         NetCDF library to link against.         NetCDF library to link against.
2224    
2225    Due to this failure, the "profiles" package is now DISABLED.    Due to this failure, the "profiles" package is now DISABLED.
2226  *********************************************************************  *********************************************************************
   
2227  EOF  EOF
2228          PACKAGES=`echo $PACKAGES | sed -e 's/profiles//g'`          PACKAGES=`echo $PACKAGES | sed -e 's/profiles//g'`
2229          DISABLE="$DISABLE profiles"          DISABLE="$DISABLE profiles"
2230        else
2231        #  this prevent to add profiles (due to pdepend rules) if not available
2232            DISABLE="$DISABLE profiles"
2233        fi
2234    fi
2235    
2236    #  Check for package RADTRANS: if LAPACK is not available,
2237    #  then issue a warning that the direct radtrans solver is not available.
2238    if test "x$HAVE_LAPACK" != xt ; then
2239        echo " $PACKAGES " | grep ' radtrans ' > /dev/null 2>&1
2240        RETVAL=$?
2241        if test "x$RETVAL" = x0 ; then
2242            cat <<EOF
2243    *********************************************************************
2244    WARNING: the "radtrans" package was enabled but tests failed to
2245      compile LAPACK applications.  This means that the direct radtrans
2246      solver is not available and compilation will fail if it is enabled.
2247      If you want to use the direct solver, please check that:
2248    
2249      1) LAPACK is correctly installed for this compiler and
2250      2) the LIBS variable (within the "optfile") specifies the correct
2251         LAPACK library to link against.
2252    *********************************************************************
2253    EOF
2254      fi      fi
2255  fi  fi
2256    
2257  echo "  applying package dependency rules"  if  test "x${PKG_DEPEND}" != x ; then
2258  ck=    echo "  applying package dependency rules"
2259  while test "x$ck" != xtt ; do    ck=
2260      while test "x$ck" != xtt ; do
2261      i=0      i=0
2262      # rtot=${#PNAME[@]}      # rtot=${#PNAME[@]}
2263      rtot=$nname      rtot=$nname
# Line 2120  while test "x$ck" != xtt ; do Line 2273  while test "x$ck" != xtt ; do
2273                  pin="t"                  pin="t"
2274              fi              fi
2275          done          done
2276            #  or in the current $STANDARDDIRS list?
2277            for p in $STANDARDDIRS ; do
2278                if test "x$p" = "x$pname" ; then pin="t" ; fi
2279            done
2280    
2281          #  Is the DNAME entry a (+) or (-) rule ?          #  Is the DNAME entry a (+) or (-) rule ?
2282          tmp="dname=\"\$DNAME_$i\""          tmp="dname=\"\$DNAME_$i\""
# Line 2142  while test "x$ck" != xtt ; do Line 2299  while test "x$ck" != xtt ; do
2299    
2300          #  Do we need to add $dname according to the dependency rules?          #  Do we need to add $dname according to the dependency rules?
2301          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
2302              #echo "   " $pname ": need to add :" $dname              #echo "   " $pname ": need to add :" $dname
2303              in_dis="f"              in_dis="f"
2304              for dis in $DISABLE ; do              for dis in $DISABLE ; do
2305                  if test "x$dis" = "x$dname" ; then                  if test "x$dis" = "x$dname" ; then
# Line 2163  while test "x$ck" != xtt ; do Line 2320  while test "x$ck" != xtt ; do
2320          #  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?
2321          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
2322              echo "Error: can't satisfy package dependencies:"              echo "Error: can't satisfy package dependencies:"
2323              echo "  \"$pname\" was requested but is disallowed by"              echo "  \"$pname\" was requested but is disallowed by"
2324              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
2325              exit 1              exit 1
2326          fi          fi
2327          i=`echo "$i + 1" | bc -l`          i=`echo "$i + 1" | bc -l`
2328          #i=$(( $i + 1 ))          #i=$(( $i + 1 ))
2329      done      done
2330      ck=$ck"t"      ck=$ck"t"
2331  done    done
2332  echo "    packages are:  $PACKAGES"    echo "    packages are: $PACKAGES"
2333    fi
2334  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2335      adr="$ROOTDIR/pkg/$i"      adr="$ROOTDIR/pkg/$i"
2336      if test -d $adr ; then      if test -d $adr ; then
# Line 2189  done Line 2347  done
2347    
2348  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
2349  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
2350  #  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
2351  #  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
2352  #  file would eventually be split up so that all package-related #define  #  file would eventually be split up so that all package-related #define
2353  #  statements could be separated and handled only by genmake.  #  statements could be separated and handled only by genmake.
2354  names=`ls -1 "$ROOTDIR/pkg"`  names=`ls -1 "$ROOTDIR/pkg"`
# Line 2207  for n in $names ; do Line 2365  for n in $names ; do
2365          done          done
2366          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
2367              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
2368              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
2369          fi          fi
2370      fi      fi
2371  done  done
# Line 2218  for i in $PACKAGES ; do Line 2376  for i in $PACKAGES ; do
2376  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
2377    
2378  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
2379      case $i in      case $i in
2380          aim_v23)          aim_v23)
2381              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
2382              echo "Warning: ALLOW_AIM is set to enable aim_v23."              echo "Warning: ALLOW_AIM is set to enable aim_v23."
2383              ;;              ;;
2384      esac      esac
# Line 2228  for i in $PACKAGES ; do Line 2386  for i in $PACKAGES ; do
2386    
2387  done  done
2388    
2389  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS='$STANDARDDIRS'"
2390  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
 if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then  
     STANDARDDIRS="eesupp model"  
 fi  
2391  if test "x$STANDARDDIRS" != x ; then  if test "x$STANDARDDIRS" != x ; then
2392      for d in $STANDARDDIRS ; do      for d in $STANDARDDIRS ; do
2393          adr="$ROOTDIR/$d/src"          adr="$ROOTDIR/$d/src"
# Line 2265  for i in $spaths ; do Line 2420  for i in $spaths ; do
2420      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
2421          echo "    found CPP_OPTIONS=\"$try\""          echo "    found CPP_OPTIONS=\"$try\""
2422          CPP_OPTIONS="$try"          CPP_OPTIONS="$try"
2423          # 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
2424          for n in $names ; do          for n in $names ; do
2425              test_for_package_in_cpp_options $CPP_OPTIONS $n              test_for_package_in_cpp_options $CPP_OPTIONS $n
2426          done          done
2427      fi      fi
2428      try="$i/CPP_EEOPTIONS.h"      try="$i/CPP_EEOPTIONS.h"
2429      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
2430          echo "    found CPP_EEOPTIONS=\"$try\""          echo "    found CPP_EEOPTIONS=\"$try\""
2431          # 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
2432  #**** not yet enabled ****  #**** not yet enabled ****
2433  #        test_for_mpi_in_cpp_eeoptions $try  #        test_for_mpi_in_cpp_eeoptions $try
2434  #**** not yet enabled ****  #**** not yet enabled ****
# Line 2291  if test -f ./adSrcFiles.tmp ; then Line 2446  if test -f ./adSrcFiles.tmp ; then
2446      rm -f ./adSrcFiles.tmp      rm -f ./adSrcFiles.tmp
2447  fi  fi
2448  echo "  Creating the list of files for the adjoint compiler."  echo "  Creating the list of files for the adjoint compiler."
2449    touch adSrcFiles.tmp
2450  for i in $SOURCEDIRS ; do  for i in $SOURCEDIRS ; do
2451      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2452      for j in $list_files ; do      for j in $list_files ; do
# Line 2323  if test ! "x$DIVA" = x ; then Line 2479  if test ! "x$DIVA" = x ; then
2479          fi          fi
2480          MPIINCLUDEDIR='$MPIHOME/include'          MPIINCLUDEDIR='$MPIHOME/include'
2481      fi      fi
2482        
2483      if test -r $MPIINCLUDEDIR/mpif.h ; then      if test -r $MPIINCLUDEDIR/mpif.h ; then
2484          for i in $MPI_HEADER_FILES; do          for i in $MPI_HEADER_FILES; do
2485              cp -p $MPIINCLUDEDIR/$i ./mpi_headers              cp -p $MPIINCLUDEDIR/$i ./mpi_headers
# Line 2358  if test ! -r ".links.tmp/foo" ; then Line 2514  if test ! -r ".links.tmp/foo" ; then
2514  fi  fi
2515  rm -f .links.tmp/foo  rm -f .links.tmp/foo
2516    
2517  if test "x$OPENAD" != x ; then  if test "x$OPENAD" != x ; then
2518      OAD_DONT_COMPILE="/dev/null"      OAD_DONT_COMPILE="/dev/null"
2519      OAD_DONT_TRANSFORM="/dev/null"      OAD_DONT_TRANSFORM="/dev/null"
2520      OAD_KEEP_ORIGINAL="/dev/null"      OAD_KEEP_ORIGINAL="/dev/null"
# Line 2411  for d in $alldirs ; do Line 2567  for d in $alldirs ; do
2567      deplist=      deplist=
2568      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
2569      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
2570      if test "x$OPENAD" != x ; then      if test "x$OPENAD" != x ; then
2571          sfiles=`( echo $sfiles | grep -v _cb2m\. )`          sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2572      fi      fi
2573      for sf in $sfiles ; do      for sf in $sfiles ; do
2574          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
2575              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2576                  ignore_f=f                  ignore_f=f
2577                  case $d/$sf in                  case $d/$sf in
2578                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
2579                          ignore_f=t                          ignore_f=t
2580                          ;;                          ;;
2581                    ./AD_CONFIG.h)                    ./AD_CONFIG.h)
2582                          ignore_f=t                          ignore_f=t
2583                          ;;                          ;;
2584                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
2585                          ignore_f=t                          ignore_f=t
2586                          ;;                          ;;
2587                    ./BUILD_INFO.h)                    ./BUILD_INFO.h)
2588                          ignore_f=t                          ignore_f=t
2589                          ;;                          ;;
2590                    ./EMBEDDED_FILES.h)                    ./EMBEDDED_FILES.h)
2591                          ignore_f=t                          ignore_f=t
2592                          ;;                          ;;
2593                    *)                    *)
2594                          #  For the local directory *ONLY*,                          #  For the local directory *ONLY*,
2595                          #  ignore all soft-links                          #  ignore all soft-links
2596                          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 2444  for d in $alldirs ; do Line 2600  for d in $alldirs ; do
2600                              deplist="$deplist $sf"                              deplist="$deplist $sf"
2601                          fi                          fi
2602                          ;;                          ;;
2603                  esac                  esac
2604                  if test "x$ignore_f" = xf ; then                  if test "x$ignore_f" = xf ; then
2605                      extn=`echo $sf | $AWK -F. '{print $NF}'`                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2606                      case $extn in                      case $extn in
2607                        F)                        F)
2608                          echo    " \\"  >> F77srclist.tmp                          echo    " \\"  >> F77srclist.tmp
2609                          printf " $sf" >> F77srclist.tmp                          printf " $sf" >> F77srclist.tmp
2610                          if test "x$OPENAD" != x ; then                          if test "x$OPENAD" != x ; then
2611                              basename=${sf%%.F}                              basename=${sf%%.F}
2612                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`
2613                              if test -z "$isAD" ; then                              if test -z "$isAD" ; then
2614                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`
2615                                  if test -z "$toBeIgnored" ; then                                  if test -z "$toBeIgnored" ; then
2616                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> nonADF77srclist.tmp
2617                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> nonADF77srclist.tmp
2618                                  else                                  else
2619                                      echo "    not to be compiled   :  $sf"                                      echo "    not to be compiled   :  $sf"
2620                                  fi                                  fi
2621                              else # file is initially listed as an AD file we want to exclude it                              else # file is initially listed as an AD file we want to exclude it
2622                                   # or we want to retain the untransformed version                                   # or we want to retain the untransformed version
2623                                  notToBeTransformed=`egrep ^$basename'[      ]*' ${OAD_DONT_TRANSFORM}`                                  notToBeTransformed=`egrep ^$basename'[      ]*' ${OAD_DONT_TRANSFORM}`
2624                                  untransformedVersionToBeKept=`egrep ^$basename'[      ]*' ${OAD_KEEP_ORIGINAL}`                                  untransformedVersionToBeKept=`egrep ^$basename'[      ]*' ${OAD_KEEP_ORIGINAL}`
2625                                  if test -n "$notToBeTransformed"; then                                  if test -n "$notToBeTransformed"; then
2626                                      echo "    not to be transformed:  $sf"                                      echo "    not to be transformed:  $sf"
2627                                  fi                                  fi
2628                                  if test -n "$untransformedVersionToBeKept" ; then                                  if test -n "$untransformedVersionToBeKept" ; then
2629                                      echo "    original to be kept  :  $sf"                                      echo "    original to be kept  :  $sf"
2630                                  fi                                      fi
2631                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2632                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> nonADF77srclist.tmp
2633                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> nonADF77srclist.tmp
# Line 2491  for d in $alldirs ; do Line 2647  for d in $alldirs ; do
2647                          echo    " \\"  >> hsrclist.tmp                          echo    " \\"  >> hsrclist.tmp
2648                          printf " $sf" >> hsrclist.tmp                          printf " $sf" >> hsrclist.tmp
2649                          ;;                          ;;
2650                      flow)                      flow)
2651                          echo    " \\"  >> ad_flow_files.tmp                          echo    " \\"  >> ad_flow_files.tmp
2652                          printf " $sf" >> ad_flow_files.tmp                          printf " $sf" >> ad_flow_files.tmp
2653                          ;;                          ;;
# Line 2502  for d in $alldirs ; do Line 2658  for d in $alldirs ; do
2658      done      done
2659      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2660        if test "$d" != "." ; then        if test "$d" != "." ; then
2661          echo "" >> srclinks.tmp          echo "" >> srclinks.tmp
2662          echo "#  These files are linked from $d" >> srclinks.tmp          echo "#  These files are linked from $d" >> srclinks.tmp
2663          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> srclinks.tmp
2664  # We need to make sure that the link isn't already there.  # We need to make sure that the link isn't already there.
# Line 2520  echo "" >> F90srclist.tmp Line 2676  echo "" >> F90srclist.tmp
2676  echo "" >> hsrclist.tmp  echo "" >> hsrclist.tmp
2677  echo "" >> ad_flow_files.tmp  echo "" >> ad_flow_files.tmp
2678    
2679    CMDLINE=$0
2680    for xx in "$@" ; do nw=`echo $xx | wc -w`
2681        if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
2682                            else CMDLINE="$CMDLINE '$xx'" ; fi
2683    done
2684    
2685  if test -f $MAKEFILE ; then  if test -f $MAKEFILE ; then
2686      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.old"
2687  fi  fi
2688  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
2689  echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE  echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE
# Line 2529  echo "#    $MACHINE" >> $MAKEFILE Line 2691  echo "#    $MACHINE" >> $MAKEFILE
2691  echo "# This makefile was generated automatically on" >> $MAKEFILE  echo "# This makefile was generated automatically on" >> $MAKEFILE
2692  echo "#    $THISDATE" >> $MAKEFILE  echo "#    $THISDATE" >> $MAKEFILE
2693  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2694  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $CMDLINE"  >> $MAKEFILE
2695  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2696  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2697    
# Line 2540  EXE_SVD=$EXECUTABLE"_svd" Line 2702  EXE_SVD=$EXECUTABLE"_svd"
2702  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2703  #  #
2704  # OPTFILE="$OPTFILE"  # OPTFILE="$OPTFILE"
2705  #  #
2706  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
2707  # SOURCEDIRS   : Directories containing the source (.F) files  # SOURCEDIRS   : Directories containing the source (.F) files
2708  # INCLUDEDIRS  : Directories containing the header-source (.h) files  # INCLUDEDIRS  : Directories containing the header-source (.h) files
# Line 2560  cat >>$MAKEFILE <<EOF Line 2722  cat >>$MAKEFILE <<EOF
2722  # LIBS         : Library flags /or/ additional optimization/debugging flags  # LIBS         : Library flags /or/ additional optimization/debugging flags
2723    
2724  ROOTDIR     = ${ROOTDIR}  ROOTDIR     = ${ROOTDIR}
2725  BUILDDIR    = ${BUILDDIR}    BUILDDIR    = ${BUILDDIR}
2726  SOURCEDIRS  = ${SOURCEDIRS}  SOURCEDIRS  = ${SOURCEDIRS}
2727  INCLUDEDIRS = ${INCLUDEDIRS}  INCLUDEDIRS = ${INCLUDEDIRS}
2728  EXEDIR      = ${EXEDIR}  EXEDIR      = ${EXEDIR}
# Line 2625  NOOPTFILES = ${NOOPTFILES} Line 2787  NOOPTFILES = ${NOOPTFILES}
2787  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2788  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2789  LIBS = ${LIBS}  LIBS = ${LIBS}
2790  # Name of the Mekfile  # Name of the makefile
2791  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2792    
2793  EOF  EOF
# Line 2641  rm -f F77srclist.tmp nonADF77srclist.tmp Line 2803  rm -f F77srclist.tmp nonADF77srclist.tmp
2803    
2804  echo >> $MAKEFILE  echo >> $MAKEFILE
2805    
2806  # add definitions for preprocessed sources  # add definitions for preprocessed sources
2807  # and note that not all systems allow case sensitive extensions  # and note that not all systems allow case sensitive extensions
2808  # hence the $FS and $FS90 here.  # hence the $FS and $FS90 here.
2809  # for fixed format f90 files we use ff90 or FF90 resp  # for fixed format f90 files we use ff90 or FF90 resp
2810  # but these are not expected to be the original source files  # but these are not expected to be the original source files
2811    
2812  echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE  echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE
2813  echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE  echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE
2814  echo 'OBJFILES= $(F77_SRC_FILES:.F=.o) $(C_SRC_FILES:.c=.o) $(F90_SRC_FILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES= $(F77_SRC_FILES:.F=.o) $(C_SRC_FILES:.c=.o) $(F90_SRC_FILES:.F90=.o)' >> $MAKEFILE
2815  echo 'FLOFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE  echo 'FLOWFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE
2816  echo >> $MAKEFILE  echo >> $MAKEFILE
2817  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
2818  echo '.SUFFIXES: .o .'$FS' .p .F .c .f'$FS90' .'$FS90' .FF90 .F90 .flowdir .flow' >> $MAKEFILE  echo '.SUFFIXES: .o .'$FS' .p .F .c .f'$FS90' .'$FS90' .FF90 .F90 .flowdir .flow' >> $MAKEFILE
# Line 2661  all: \$(EXECUTABLE) Line 2823  all: \$(EXECUTABLE)
2823  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(EMBEDDED_FILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(EMBEDDED_FILES)
2824          @echo Creating \$@ ...          @echo Creating \$@ ...
2825          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2826    
2827  depend:  depend:
2828          @make links          @make -f \$(MAKEFILE) links
2829          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)          \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
2830          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2831          -rm -f makedepend.out          -rm -f makedepend.out
2832    
# Line 2673  libmitgcmuv.a: \$(OBJFILES) Line 2836  libmitgcmuv.a: \$(OBJFILES)
2836          ar rcv libmitgcmuv.a \$(OBJFILES)          ar rcv libmitgcmuv.a \$(OBJFILES)
2837          ar d   libmitgcmuv.a main.o          ar d   libmitgcmuv.a main.o
2838    
2839    obj: \$(OBJFILES)
2840    
2841  links: \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(SPECIAL_FILES)  links: \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(SPECIAL_FILES)
2842    
2843  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
# Line 2681  output.txt: \$(EXECUTABLE) Line 2846  output.txt: \$(EXECUTABLE)
2846          @printf 'running ... '          @printf 'running ... '
2847          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
2848    
2849    # remove most of the files that "make" generates
2850  clean:  clean:
2851          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2852          -rm -rf *.o          -rm -rf *.o
2853          -rm -rf *.$FS *.flowdir          -rm -rf *.$FS *.flowdir
2854          -rm -rf *.f$FS90 *_mod.h *_mod.F90 *.FF90 *.mod-whirl ad_input*          -rm -rf *.f$FS90 \$(AD_CLEAN) ad_input*
2855          -rm -rf temp.sed  
2856    # remove most of the files that "make" and "make depend" generate
2857  Clean:  Clean:
2858          @make clean          @make -f \$(MAKEFILE) clean
2859          @make cleanlinks          @make -f \$(MAKEFILE) cleanlinks
2860          -rm -f \$(SPECIAL_FILES)          -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old
2861          -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log f90mkdepend.log *.bak          -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log taf_ftl.log
2862          -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log          -rm -f genmake_warnings genmake_errors make.log
2863    
2864    # remove also the executable, files that "genmake2" generates (except Makefile)
2865    #         and output from a run (plus log files from testreport)
2866  CLEAN:  CLEAN:
2867          @make Clean          @make -f \$(MAKEFILE) Clean
2868            -rm -f \$(EXECUTABLE) \$(EXE_AD) \$(EXE_FTL) *.bak
2869            -rm -f $LOGFILE genmake_state genmake_*optfile
2870            -rm -f SIZE.h.mpi genmake.tr_log make.tr_log
2871          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2872          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2873          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2874          -rm -f \$(EXECUTABLE) \$(EXE_AD) *.txt STD* *diagnostics.log datetime          -rm -f *.txt STD* *diagnostics.log datetime
2875          -rm -f *_MIT_CE_000.opt0000 costfunction*0000          -rm -f *_MIT_CE_000.opt0000 costfunction*0000
2876          -rm -rf mnc_test_*          -rm -rf mnc_test_*
2877    
 #eh3 Makefile: makefile  
2878  makefile:  makefile:
2879          $THIS_SCRIPT $G2ARGS          $THIS_SCRIPT $G2ARGS
2880  cleanlinks:  cleanlinks:
# Line 2714  ${PACKAGES_DOT_H}: Line 2886  ${PACKAGES_DOT_H}:
2886          @$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 "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@
2887  AD_CONFIG.h:  AD_CONFIG.h:
2888          @echo Creating \$@ ...          @echo Creating \$@ ...
2889          @$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 "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > \$@
2890  FC_NAMEMANGLE.h:  FC_NAMEMANGLE.h:
2891          @echo Creating \$@ ...          @echo Creating \$@ ...
2892          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
# Line 2733  if test "x$EMBED_SRC" = xt ; then Line 2905  if test "x$EMBED_SRC" = xt ; then
2905    
2906  decode_files.o : EMBEDDED_FILES.h  decode_files.o : EMBEDDED_FILES.h
2907    
2908  ##  \$(F77_PP_SRC_FILES)  ##  \$(F77_PP_SRC_FILES)
2909  all_fF.tar.gz : \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile  all_fF.tar.gz : \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2910          @echo Creating \$@ ...          @echo Creating \$@ ...
2911          -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) 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
# Line 2758  cat >>$MAKEFILE <<EOF Line 2930  cat >>$MAKEFILE <<EOF
2930          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2931  .$FS.o:  .$FS.o:
2932          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2933    .F.o:
2934            \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2935  .F90.$FS90:  .F90.$FS90:
2936          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2937  .FF90.f$FS90:  .FF90.f$FS90:
# Line 2784  EOF Line 2958  EOF
2958  #===  Automatic Differentiation Rules  ===  #===  Automatic Differentiation Rules  ===
2959  #===  for TAMC/TAF  ======================  #===  for TAMC/TAF  ======================
2960    
2961  if test "x$OPENAD" = x ; then  if test "x$OPENAD" = x ; then
2962    
2963  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2964    
# Line 2826  adtaf: ad_taf_output.$FS Line 3000  adtaf: ad_taf_output.$FS
3000  adtamc: ad_tamc_output.$FS  adtamc: ad_tamc_output.$FS
3001    
3002  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES)  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES)
3003          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3004          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
3005          -rm -f ad_config.template          -rm -f ad_config.template
3006          @make \$(F77_PP_SRC_FILES)          @make -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3007          @make \$(FLOFILES)          @make -f \$(MAKEFILE) \$(FLOWFILES)
3008          cat \$(FLOFILES) \$(AD_FILES) > ad_input_code.$FS          cat \$(FLOWFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS
3009    
3010  ad_taf_output.$FS: ad_input_code.$FS  ad_taf_output.$FS: ad_input_code.$FS
3011          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
# Line 2844  adtafonly: Line 3018  adtafonly:
3018          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
3019    
3020  \${EXE_AD}: ad_taf_output.o \$(OBJFILES)  \${EXE_AD}: ad_taf_output.o \$(OBJFILES)
3021          \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
3022    
3023  ad_tamc_output.$FS: ad_input_code.$FS  ad_tamc_output.$FS: ad_input_code.$FS
3024          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
3025          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
3026    
3027  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
3028          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
3029    
3030  adonlyfwd:  adonlyfwd:
3031          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
3032    
3033  adtrick:  adtrick:
3034          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
3035    
3036    adobj: ad_taf_output.o \$(OBJFILES)
3037    
3038  # ... FTL ...  # ... FTL ...
3039  ftlall: ftl_taf  ftlall: \$(EXE_FTL)
3040  ftltaf: ftl_taf_output.$FS  ftltaf: ftl_taf_output.$FS
3041  ftltamc: ftl_tamc_output.$FS  ftltamc: ftl_tamc_output.$FS
3042    
3043  ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)  ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)
3044          @$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 "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ftl_config.template
3045          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
3046          -rm -f ftl_config.template          -rm -f ftl_config.template
3047          @make \$(F77_PP_SRC_FILES)          @make -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3048          @make \$(AD_FLOW_FILES)          @make -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3049          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS          cat \$(AD_FLOW_FILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ftl_input_code.$FS
3050    
3051  ftl_taf_output.$FS: ftl_input_code.$FS  ftl_taf_output.$FS: ftl_input_code.$FS
3052          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
# Line 2882  ftltafonly: Line 3058  ftltafonly:
3058          ls -l ftl_input_code_ftl.$FS          ls -l ftl_input_code_ftl.$FS
3059          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
3060    
3061  ftl_taf: ftl_taf_output.o \$(OBJFILES)  \${EXE_FTL}: ftl_taf_output.o \$(OBJFILES)
3062          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
3063    
3064  ftl_tamc_output.$FS: ftl_input_code.$FS  ftl_tamc_output.$FS: ftl_input_code.$FS
3065          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
3066          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
3067    
3068  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
3069          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
   
3070    
3071  # ... SVD ...  # ... SVD ...
3072  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
# Line 2913  svd_touch: Line 3088  svd_touch:
3088          touch ad_taf_output.$FS ftl_taf_output.$FS          touch ad_taf_output.$FS ftl_taf_output.$FS
3089          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
3090          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
3091          @$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 "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ftl_config.template
3092          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
3093          -rm -f ftl_config.template          -rm -f ftl_config.template
3094    
3095  EOF  EOF
3096    
3097  fi  fi
3098    
3099  #===  for OpenAD  ========================  #===  for OpenAD  ========================
3100    
3101  if test "x$OPENAD" != x ; then  if test "x$OPENAD" != x ; then
3102    
3103  # ============ begin OpenAD specific section ==============  # ============ begin OpenAD specific section ==============
3104    
3105  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3106    
3107  # all the source files linked from the various locations:  # all the source files linked from the various locations:
3108  ALL_LINKED_FILES= \  ALL_LINKED_FILES= \
3109  \$(F77_SRC_FILES) \  \$(F77_SRC_FILES) \
3110  \$(C_SRC_FILES) \  \$(C_SRC_FILES) \
# Line 2981  rm -f adSrcFiles.tmp Line 3156  rm -f adSrcFiles.tmp
3156    
3157  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3158    
3159  adAll: \$(EXE_AD)  adAll: \$(EXE_AD)
3160  .PHONY: adAll  .PHONY: adAll
3161    
3162  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))
# Line 2990  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod. Line 3165  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.
3165    
3166  .PHONY: adDepend  .PHONY: adDepend
3167  adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90)  adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90)
3168          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)          \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
3169          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
3170          -rm -f makedepend.out          -rm -f makedepend.out
3171    
# Line 2999  w2f__types.F90 \ Line 3174  w2f__types.F90 \
3174  OAD_active.F90 \  OAD_active.F90 \
3175  OAD_cp.F90 \  OAD_cp.F90 \
3176  OAD_rev.F90 \  OAD_rev.F90 \
3177  OAD_tape.F90          OAD_tape.F90
3178    
3179  OPENAD_SUPPORT_C_SRC_FILES = \  OPENAD_SUPPORT_C_SRC_FILES = \
3180  iaddr.c \  iaddr.c \
# Line 3008  timeRatio.c Line 3183  timeRatio.c
3183  f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)  f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)
3184          cat \$^ > \$@          cat \$^ > \$@
3185    
3186  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  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
3187          cat \$^ > \$@          cat \$^ > \$@
3188    
3189  f95_test.out: f95_test_mods.f90 f95_test.f90  f95_test.out: f95_test_mods.f90 f95_test.f90
3190          f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1          f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1
3191          f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1          f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1
3192    
3193  AD_OBJ_FILES=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) all_mods.xb.x2w.w2f.pp.o  ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.o \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o)  CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)
3194    
3195    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)
3196    
3197  \$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(AD_OBJ_FILES)  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)
         @echo Creating \$@ ...  
         \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES) \$(LIBS)  
3198    
3199  # makefile debug rule  \$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.tag \$(AD_OBJ_FILES_S2)
3200  openad: ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)
 .PHONY: openad  
3201    
3202  # create the module files  # create sources files modules from header files containing common blocks
3203  %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk  %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk
3204          ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk          ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk
3205    
3206  # create the header files  # create new header files with USE statements for the new modules made above
3207  %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk  %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk
3208          ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)          ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
3209    
3210  # change everybody else to use the new module files:  # change the include directives of everybody to refer to  the new header files with the USE statements
3211  %_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash  %_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash
3212          ../OAD_support/cb2mUseModules.bash $< ${MPI}          ../OAD_support/cb2mUseModules.bash $< ${MPI}
3213    
# Line 3048  ad_output.txt: \$(EXE_AD) Line 3222  ad_output.txt: \$(EXE_AD)
3222          @printf 'running ... '          @printf 'running ... '
3223          @./\$(EXE_AD) > \$@          @./\$(EXE_AD) > \$@
3224    
3225  CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
 ad_input_code.f$FS90: ../OAD_support/maxMinDefs.f \$(CB2M_AD_FILES)  
3226          cat \$^ > \$@          cat \$^ > \$@
3227    
 # strip all comments and blanks to reduce  
 # the file size in order to reduce perl's memory requirements  
 ad_input_code_sf.f$FS90 : ad_input_code.f$FS90  
         cat \$^ | sed -f ../OAD_support/strip.sed | sed -f ../OAD_support/stop2print.sed > \$@  
   
 # mfef90 preprocessing  
 # expand statement functions  
 # expose mfef90 specific substring handling  
 # add the w2f__types module  
 ad_input_code_sf.w2f.f$FS90: ad_input_code_sf.f$FS90 mfef90 whirl2f whirl2f_be w2f__types.f90  
         ./mfef90 -r8 -z -F -N132 \$<  
         mv \$<.B \$(basename \$<).B  
         ./whirl2f -openad \$(basename \$<).B  
         cat w2f__types.f90 \$(basename \$<).w2f.f > \$@  
   
3228  # canonicalizer  # canonicalizer
3229  ad_input_code_sf.w2f.pre.f$FS90: ad_input_code_sf.w2f.f$FS90 preProcess.py  ad_input_code_sf.pre.f90 : \$(CB2M_AD_FILES)
3230          ./preProcess.py -H -S \$< -o \$@          \${OPENADFORTTK_BASE}/tools/SourceProcessing/preProcess.py --timing --r8 -H -S  -o \$@ \$^
3231    
3232    # replace stop statements (to avoid the implied unstructured control flow)  with print statements
3233    ad_input_code_sf.pre.s2p.f90 : ad_input_code_sf.pre.f90
3234            cat \$< | sed -f ../OAD_support/stop2print.sed > ad_input_code_sf.pre.s2p.f90
3235    
3236  # F -> WHIRL  # F -> WHIRL
3237  # note that the canonicalized version cuts off at col 72  ad_input_code_sf.pre.s2p.B: ad_input_code_sf.pre.s2p.f90
3238  # doing this also for string constants which is ok as long          \${OPEN64ROOT}/crayf90/sgi/mfef90 -r8 -z -F ad_input_code_sf.pre.s2p.f90
 # as we are in fixed mode and cut of exactly there.  
 # Otherwise mfef90 patches in spaces to fill up to 72 (or 132)  
 # characters respectively.  
 ad_input_code_sf.w2f.pre.B: ad_input_code_sf.w2f.pre.f$FS90 mfef90  
         ./mfef90 -r8 -z -F \$<  
         mv \$<.B \$@  
3239    
3240  # WHIRL -> XAIF  # WHIRL -> XAIF
3241  ad_input_code_sf.w2f.pre.xaif : ad_input_code_sf.w2f.pre.B whirl2xaif  ad_input_code_sf.pre.s2p.xaif : ad_input_code_sf.pre.s2p.B
3242          ./whirl2xaif -s -n --debug 1 -o \$@ \$<          \${OPENADFORTTK}/bin/whirl2xaif -s -n --debug 1 -o \$@ \$<
3243    
3244  # XAIF -> XAIF'  # XAIF -> XAIF'
3245  ad_input_code_sf.w2f.pre.xb.xaif : ad_input_code_sf.w2f.pre.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd oadDriver  ad_input_code_sf.pre.s2p.xb.xaif : ad_input_code_sf.pre.s2p.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd
3246          ./oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r          \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r
3247    
3248  # XAIF' -> WHIRL'  # XAIF' -> WHIRL'
3249  ad_input_code_sf.w2f.pre.xb.x2w.B : ad_input_code_sf.w2f.pre.xb.xaif xaif2whirl  ad_input_code_sf.pre.s2p.xb.x2w.B : ad_input_code_sf.pre.s2p.xb.xaif
3250          ./xaif2whirl --debug 1 --structured ad_input_code_sf.w2f.pre.B \$<          \${OPENADFORTTK}/bin/xaif2whirl --debug 1 ad_input_code_sf.pre.s2p.B \$<
3251    
3252  # WHIRL' -> F'  # WHIRL' -> F'
3253  ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.B whirl2f whirl2f_be  ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.B
3254          ./whirl2f -FLIST:ftn_file=\$@ -openad \$<          \${OPEN64ROOT}/whirl2f/whirl2f -FLIST:ftn_file=\$@ -openad \$<
3255    
3256  # insert template directives  # insert template directives
3257  ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90 ../OAD_support/insertTemplateDir.bash  ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 ../OAD_support/insertTemplateDir.bash
3258          ../OAD_support/insertTemplateDir.bash \$< \$@          ../OAD_support/insertTemplateDir.bash \$< \$@
3259    
3260  PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F  PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F
3261  # postprocess F'  # postprocess F'
3262  ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 postProcess.py \$(PPEXTRAS:.F=.f)  postProcess.tag: ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90 \$(PPEXTRAS:.F=.f) | w2f__types.f90
3263          ./postProcess.py -m r -i ../OAD_support/ad_inline.f -o \$@ \$<          \${OPENADFORTTK_BASE}/tools/SourceProcessing/postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed --separateOutput --pathSuffix "" --filenameSuffix "_oad" -m r -i ../OAD_support/ad_inline.f \$<
3264            # the target is a placeholder to trigger a single execution of the rule
3265            touch \$@
3266    # put this so make knows about the postprocessing output
3267    OAD_intrinsics_oad.f \$(CB2M_AD_FILES:.f$FS90=_oad.f): postProcess.tag
3268    
3269  # extract all transformed modules  # link the XAIF schema files
 all_mods.xb.x2w.w2f.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90  
         cat \$< | sed -n '/MODULE /,/END MODULE/p' > \$@  
   
 # remove the transformed globals module from the  
 # transformed ad_input_code file  
 # and remove for now the duplicate variables  
 # and fix 2 data statements  
 ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90  
         cat \$< | sed '/MODULE /,/END MODULE/d' | sed '/^      INTEGER(w2f__i4) DOLOOP_UB/d' > \$@  
   
 # setup some links  
3270  %.xsd:  %.xsd:
3271          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3272    
 mfef90:  
         \$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 .  
   
3273  # link the support files:  # link the support files:
3274  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):
3275          \$(LN) ../OAD_support/\$@ .          \$(LN) ../OAD_support/\$@ .
3276    
3277  whirl2xaif xaif2whirl:  AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag \$(PPEXTRAS:.F=.f)
         \$(LN) \${OPENADFORTTK}/bin/\$@ .  
   
 preProcess.py postProcess.py:  
         \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ .  
   
 whirl2f whirl2f_be:  
         \$(LN) \${OPEN64ROOT}/whirl2f/\$@ .  
   
 oadDriver:  
         \$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver \$@  
3278    
3279  # ============ end OpenAD specific section ==============  # ============ end OpenAD specific section ==============
3280    
# Line 3183  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 3319  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
3319  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
3320    
3321  # Create special header files  # Create special header files
3322  $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 "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" $DISABLED_PACKAGES " " "Enabled packages:" $ENABLED_PACKAGES > $PACKAGES_DOT_H".tmp"
3323  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
3324      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
3325  else  else
# Line 3197  else Line 3333  else
3333      fi      fi
3334  fi  fi
3335  if test ! -f AD_CONFIG.h ; then  if test ! -f AD_CONFIG.h ; then
3336      $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 "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > AD_CONFIG.h
3337  fi  fi
3338    
   
3339  #  Write the "state" for future records  #  Write the "state" for future records
3340  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" = xt ; then
3341      printf "" > genmake_state      printf "" > genmake_state
3342      for i in $gm_state ; do      for i in $gm_state ; do
3343          t1="t2=\$$i"          t1="t2=\$$i"
3344          eval $t1          eval $t1
3345          echo "$i='$t2'" >> genmake_state          echo "$i='$t2'" | sed -e 's/  */ /g' >> genmake_state
3346      done      done
3347  fi  fi

Legend:
Removed from v.1.190  
changed lines
  Added in v.1.236

  ViewVC Help
Powered by ViewVC 1.1.22