/[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.197 by utke, Tue Sep 22 04:36:30 2009 UTC revision 1.218 by jmc, Sun Dec 26 01:04:45 2010 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        -[no]ieee | --[no]ieee
100              Do or don't use IEEE numerics.  Note that this option
101              *only* works if it is supported by the OPTFILE that
102              is being used.
103    
104        -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4
105              Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW)
106              *only* works if CPP_EEOPTIONS.h allows this.
107    
108        -ignoretime | -ignore_time | --ignoretime | --ignore_time
109              Ignore all the "wall clock" routines entirely.  This will
110              not in any way hurt the model results -- it simply means
111              that the code that checks how long the model spends in
112              various routines will give junk values.
113    
114        -ts | --ts
115              Produce timing information per timestep
116        -papis | --papis
117              Produce summary MFlop/s (and IPC) with PAPI per timestep
118        -pcls | --pcls
119              Produce summary MFlop/s etc. with PCL per timestep
120        -foolad | --foolad
121              Fool the AD code generator
122        -papi | --papi
123              Performance analysis with PAPI
124        -pcl | --pcl
125              Performance analysis with PCL
126        -hpmt | --hpmt
127              Performance analysis with the HPM Toolkit
128    
129        -gsl | --gsl
130              Use GSL to control floating point rounding and precision
131        -devel | --devel
132              Add additional warning and debugging flags for development
133    
134        -mpi | --mpi
135              Include MPI header files and link to MPI libraries
136        -mpi=PATH | --mpi=PATH
137              Include MPI header files and link to MPI libraries using MPI_ROOT
138              set to PATH. i.e. Include files from \$PATH/include, link to libraries
139              from \$PATH/lib and use binaries from \$PATH/bin.
140    
141        -omp | --omp
142              Activate OpenMP code + use Compiler option OMPFLAG
143        -omp=OMPFLAG | --omp=OMPFLAG
144              Activate OpenMP code + use Compiler option OMPFLAG
145    
146        -es | --es | -embed-source | --embed-source
147              Embed a tarball containing the full source code
148              (including the Makefile, etc.) used to build the
149              executable [off by default]
150    
151        -ds | --ds
152              Report genmake internal variables status (DUMPSTATE)
153              to file "genmake_state" (for debug purpose)
154    
155      While it is most often a single word, the "NAME" variables specified
156      above can in many cases be a space-delimited string such as:
157    
158        --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'
159        -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'
160        -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'
161    
162      which, depending upon your shell, may need to be single-quoted.
163    
164      For more detailed genmake documentation, please see:
165    
166        http://mitgcm.org/public/devel_HOWTO/
167    
168    EOF
169    
170        exit 1
171    }
172    
173  # Search for particular CPP #cmds associated with packages  # Search for particular CPP #cmds associated with packages
174  # usage: test_for_package_in_cpp_options CPP_file package_name  # usage: test_for_package_in_cpp_options CPP_file package_name
175  test_for_package_in_cpp_options() {  test_for_package_in_cpp_options() {
# Line 56  test_for_string_in_file() { Line 218  test_for_string_in_file() {
218  # the package list.  # the package list.
219  expand_pkg_groups() {  expand_pkg_groups() {
220      new_packages=      new_packages=
     PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"  
221      if test -r $PKG_GROUPS ; then      if test -r $PKG_GROUPS ; then
222          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
223          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 228  expand_pkg_groups() {
228              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
229                  matched=1                  matched=1
230                  replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`                  replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
231                  echo "    replacing \"$i\" with: $replace"                  echo "    replacing \"$i\" with:$replace"
232                  new_packages="$new_packages $replace"                  new_packages="$new_packages $replace"
233              else              else
234                  new_packages="$new_packages $i"                  new_packages="$new_packages $i"
# Line 110  EOF Line 271  EOF
271              check_for_broken_Ff              check_for_broken_Ff
272          else          else
273              cat <<EOF 2>&1              cat <<EOF 2>&1
274  ERROR: Your file system cannot distinguish between *.F and *.f files  ERROR: Your file system cannot distinguish between *.F and *.f files
275    (fails the "cp" test) and this program cannot find a suitable    (fails the "cp" test) and this program cannot find a suitable
276    replacement extension.  Please try a different build environment or    replacement extension.  Please try a different build environment or
277    contact the <MITgcm-support@mitgcm.org> list for help.    contact the <MITgcm-support@mitgcm.org> list for help.
278    
279  EOF  EOF
# Line 146  EOF Line 307  EOF
307              check_for_broken_Ff              check_for_broken_Ff
308          else          else
309              cat <<EOF 2>&1              cat <<EOF 2>&1
310  ERROR: Your file system cannot distinguish between *.F and *.f files  ERROR: Your file system cannot distinguish between *.F and *.f files
311    (fails the "make/ln" test) and this program cannot find a suitable    (fails the "make/ln" test) and this program cannot find a suitable
312    replacement extension.  Please try a different build environment or    replacement extension.  Please try a different build environment or
313    contact the <MITgcm-support@mitgcm.org> list for help.    contact the <MITgcm-support@mitgcm.org> list for help.
314    
315  EOF  EOF
# Line 165  EOF Line 326  EOF
326      return      return
327  }  }
328    
   
329  look_for_makedepend()  {  look_for_makedepend()  {
330    
331      #  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 346  look_for_makedepend()  {
346      #    3) locally build and use the cyrus implementation      #    3) locally build and use the cyrus implementation
347      #    4) fall back to the buggy local xmakedpend script      #    4) fall back to the buggy local xmakedpend script
348      #      #
349        echo >> $LOGFILE
350        echo "running: look_for_makedepend()" >> $LOGFILE
351        if test "x${MAKEDEPEND}" != x ; then
352            echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
353            RETVAL=$?
354            if test x"$RETVAL" = x0 ; then
355                build_cyrus_makedepend
356                RETVAL=$?
357                if test "x$RETVAL" != x0 ; then
358                    echo "WARNING: unable to build cyrus-makedepend. Try 'makedepend'"
359                    MAKEDEPEND=
360                fi
361            else
362                echo " -->     MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
363            fi
364        fi
365      if test "x${MAKEDEPEND}" = x ; then      if test "x${MAKEDEPEND}" = x ; then
366          which makedepend > /dev/null 2>&1          which makedepend > /dev/null 2>&1
367          RV0=$?          RV0=$?
# Line 194  look_for_makedepend()  { Line 370  look_for_makedepend()  {
370          cat <<EOF >> $MAKEFILE          cat <<EOF >> $MAKEFILE
371  #   THIS IS A TEST MAKEFILE GENERATED BY "genmake2"  #   THIS IS A TEST MAKEFILE GENERATED BY "genmake2"
372  #  #
373  #   Some "makedepend" implementations will die if they cannot  #   Some "makedepend" implementations will die if they cannot
374  #   find a Makefile -- so this file is here to gives them an  #   find a Makefile -- so this file is here to gives them an
375  #   empty one to find and parse.  #   empty one to find and parse.
376  EOF  EOF
377          cat <<EOF >> genmake_tc.f          cat <<EOF >> genmake_tc.f
# Line 210  EOF Line 386  EOF
386          test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE          test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
387          if test "x${RV0}${RV1}" = x00 ; then          if test "x${RV0}${RV1}" = x00 ; then
388              MAKEDEPEND=makedepend              MAKEDEPEND=makedepend
389                echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
390          else          else
391              echo "    a system-default makedepend was not found."              echo "    system-default makedepend not found. Try to build cyrus-makedepend"
               
392              #  Try to build the cyrus implementation              #  Try to build the cyrus implementation
393              build_cyrus_makedepend              build_cyrus_makedepend
394              RETVAL=$?              RETVAL=$?
395              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
396                    echo "WARNING: unable to build cyrus-makedepend. Use local xmakedepend"
397                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
398                    echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
399              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  
400          fi          fi
401      fi      fi
402  }  }
403    
   
404  build_cyrus_makedepend()  {  build_cyrus_makedepend()  {
405        echo >> $LOGFILE
406        echo "running: build_cyrus_makedepend()" >> $LOGFILE
407      rm -f ./genmake_cy_md      rm -f ./genmake_cy_md
408      (      (
409          cd $ROOTDIR/tools/cyrus-imapd-makedepend  \          cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
# Line 249  build_cyrus_makedepend()  { Line 420  build_cyrus_makedepend()  {
420      rm -f ./genmake_cy_md      rm -f ./genmake_cy_md
421      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
422          MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'          MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
423            echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
424          return 0          return 0
425      else      else
426          echo "WARNING: unable to build cyrus-imapd-makedepend"          echo "WARNING: fail to build cyrus-imapd-makedepend" >> $LOGFILE
427          return 1          return 1
428      fi      fi
429  }  }
430    
   
431  build_embed_encode()  build_embed_encode()
432  {  {
433      printf "  building the embed-encode utility...  "      printf "  building the embed-encode utility...  "
# Line 269  build_embed_encode() Line 440  build_embed_encode()
440              return 1              return 1
441          fi          fi
442          clist="cc gcc c89 $CC"          clist="cc gcc c89 $CC"
443          for ic in $clist ; do          for ic in $clist ; do
444              comm="$ic -o encode_files encode_files.c"              comm="$ic -o encode_files encode_files.c"
445              ( cd $ROOTDIR/tools/embed_encode && $comm ) > /dev/null 2>&1              ( cd $ROOTDIR/tools/embed_encode && $comm ) > /dev/null 2>&1
446              RETVAL=$?              RETVAL=$?
# Line 290  build_embed_encode() Line 461  build_embed_encode()
461      DEFINES="$DEFINES -DHAVE_EMBED_SRC"      DEFINES="$DEFINES -DHAVE_EMBED_SRC"
462  }  }
463    
464    #  look for possible C compilers
465  # Guess possible config options for this host  look_for_C_compilers() {
466  find_possible_configs()  {      echo >> $LOGFILE
467        echo "running: look_for_C_compilers()" >> $LOGFILE
468      tmp1=`uname`"_"`uname -m`      rm -f ./genmake_hello.c  ./genmake_hello
469      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  
470  #include <stdio.h>  #include <stdio.h>
471  int main(int argc, char **argv) {  int main(int argc, char **argv) {
472    printf("Hello!\n");    printf("Hello!\n");
473    return 0;    return 0;
474  }  }
475  EOF  EOF
476          $c -o genmake_hello genmake_hello.c > /dev/null 2>&1      tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc icc"
477        p_CC=
478        for c in $tmp ; do
479            COMM="$c $CFLAGS -o genmake_hello genmake_hello.c"
480            echo $COMM >> $LOGFILE
481            $COMM >> $LOGFILE 2>&1
482          RETVAL=$?          RETVAL=$?
483          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
484                echo " $c test successful" >> $LOGFILE
485              p_CC="$p_CC $c"              p_CC="$p_CC $c"
486          fi          fi
487      done      done
# Line 354  Error: No C compilers were found in your Line 497  Error: No C compilers were found in your
497  EOF  EOF
498          exit 1          exit 1
499      else      else
500          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  
501          if test "x$CC" = x ; then          if test "x$CC" = x ; then
502              CC=`echo $p_CC | $AWK '{print $1}'`              CC=`echo $p_CC | $AWK '{print $1}'`
503              echo "  Setting C compiler to: "$CC              echo "  Setting C compiler to: "$CC
504          fi          fi
505      fi      fi
506        echo " --> set CC='$CC'" >> $LOGFILE
507    }
508    
509    # Guess possible config options for this host
510    find_possible_optfile()  {
511    
512        echo >> $LOGFILE
513        echo "running: find_possible_optfile()" >> $LOGFILE
514        tmp1=`uname`"_"`uname -m`
515        tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
516        tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
517        tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
518        tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
519        tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
520        PLATFORM=$tmp3
521        echo $PLATFORM | grep cygwin > /dev/null 2>&1  &&  PLATFORM=cygwin_ia32
522        OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
523        echo "  The platform appears to be:  $PLATFORM" | tee -a $LOGFILE
524    
525      #================================================================      #================================================================
526      #  look for possible FORTRAN compilers      #  look for possible FORTRAN compilers
527      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
528        tmp="$MITGCM_FC $FC efc gfortran g77 f77 pgf77 pgf95 ifc ifort f90 f95 mpif77 mpf77 mpxlf95 g95"
529      p_FC=      p_FC=
530      for c in $tmp ; do      rm -f ./genmake_hello.f
531          rm -f ./hello.f ./hello      cat >> genmake_hello.f <<EOF
         cat >> hello.f <<EOF  
532        program hello        program hello
533        do i=1,3        do i=1,3
534          print *, 'hello world : ', i          print *, 'hello world : ', i
535        enddo        enddo
536        end        end
537  EOF  EOF
538          $c -o hello hello.f > /dev/null 2>&1      for f in $tmp ; do
539            COMM="$f -o genmake_hello genmake_hello.f"
540            echo $COMM >> $LOGFILE
541            $COMM >> $LOGFILE 2>&1
542          RETVAL=$?          RETVAL=$?
543          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
544              p_FC="$p_FC $c"              echo " $f test successful" >> $LOGFILE
545                p_FC="$p_FC $f"
546          fi          fi
547      done      done
548      rm -f ./hello.f ./hello      rm -f ./genmake_hello.f ./genmake_hello
549      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
550          cat 1>&2 <<EOF          cat 1>&2 <<EOF
551    
# Line 394  Error: No Fortran compilers were found i Line 558  Error: No Fortran compilers were found i
558  EOF  EOF
559          exit 1          exit 1
560      else      else
561          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  
562      fi      fi
563    
564      #  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 567  EOF
567          for i in $p_FC ; do          for i in $p_FC ; do
568              OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i              OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
569              if test -r $OPTFILE ; then              if test -r $OPTFILE ; then
570                  echo "  Setting OPTFILE to: "$OPTFILE                  echo "  Setting OPTFILE to: "$OPTFILE | tee -a $LOGFILE
571                  break                  break
572              fi              fi
573          done          done
# Line 416  EOF Line 579  EOF
579               echo "  I looked for the file "$OPTFILE" but did not find it"               echo "  I looked for the file "$OPTFILE" but did not find it"
580          fi          fi
581      fi      fi
582  #    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  
583      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
584          cat 1>&2 <<EOF          cat 1>&2 <<EOF
585    
# Line 442  Error: No options file was found in:  $R Line 595  Error: No options file was found in:  $R
595  EOF  EOF
596          exit 1          exit 1
597      fi      fi
598        
599  #     # look for possible MPI libraries  #     # look for possible MPI libraries
600  #     mpi_libs=  #     mpi_libs=
601  #     mpi_fort=`which mpif77 2>/dev/null`  #     mpi_fort=`which mpif77 2>/dev/null`
# Line 461  EOF Line 614  EOF
614  #       if test "x${RETVAL}" = x0 ; then  #       if test "x${RETVAL}" = x0 ; then
615  #           a=`cat out`  #           a=`cat out`
616  #           for i in $a ; do  #           for i in $a ; do
617  #               case $i in  #               case $i in
618  #                   -*)  #                   -*)
619  #                       mpi_libs="$mpi_libs $i" ;;  #                       mpi_libs="$mpi_libs $i" ;;
620  #               esac  #               esac
# Line 471  EOF Line 624  EOF
624  #       fi  #       fi
625  #       rm -f test.f out  #       rm -f test.f out
626  #     fi  #     fi
   
627  }  }
628    
629  #  Parse the package dependency information  #  Parse the package dependency information
# Line 480  get_pdepend_list()  { Line 632  get_pdepend_list()  {
632      #  strip the comments and then convert the dependency file into      #  strip the comments and then convert the dependency file into
633      #  two arrays: PNAME, DNAME      #  two arrays: PNAME, DNAME
634      cat $1 | sed -e 's/#.*$//g' \      cat $1 | sed -e 's/#.*$//g' \
635          | $AWK 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \          | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
636          > ./.pd_tmp          > ./.pd_tmp
637        RETVAL=$?
638        if test ! "x${RETVAL}" = x0 ; then
639          echo "Error: unable to parse package dependencies -- please check PKG_DEPEND=\"$1\""
640          exit 1
641        fi
642      . ./.pd_tmp      . ./.pd_tmp
643      rm -f ./.pd_tmp      rm -f ./.pd_tmp
   
     printf "PNAME = "${}  
 }  
   
   
 #  Explain usage  
 usage()  {  
 cat <<EOF  
   
 Usage: "$0" [OPTIONS]  
   where [OPTIONS] can be:  
   
     -help | --help | -h | --h  
           Print this help message and exit.  
   
     -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME  
       -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME  
           Use "NAME" as the adoptfile.  By default, the file at  
           "tools/adjoint_options/adjoint_default" will be used.  
   
     -nooptfile | --nooptfile  
       -optfile NAME | --optfile NAME | -of NAME | --of NAME  
       -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME  
           Use "NAME" as the optfile.  By default, an attempt will be  
           made to find an appropriate "standard" optfile in the  
           tools/build_options/ directory.  
   
     -pdepend NAME | --pdepend NAME  
       -pdepend=NAME | --pdepend=NAME  
           Get package dependency information from "NAME".  
   
     -pdefault NAME | --pdefault NAME  
       -pdefault=NAME | --pdefault=NAME  
           Get the default package list from "NAME".  
   
     -make NAME | -m NAME  
       --make=NAME | -m=NAME  
           Use "NAME" for the MAKE program. The default is "make" but  
           many platforms, "gmake" is the preferred choice.  
   
     -makefile NAME | -mf NAME  
       --makefile=NAME | -mf=NAME  
           Call the makefile "NAME".  The default is "Makefile".  
   
     -makedepend NAME | -md NAME  
       --makedepend=NAME | -md=NAME  
           Use "NAME" for the MAKEDEPEND program.  
   
     -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME  
       -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME  
           Specify the location of the MITgcm ROOTDIR as "NAME".  
           By default, genamke will try to find the location by  
           looking in parent directories (up to the 5th parent).  
   
     -mods NAME | --mods NAME | -mo NAME | --mo NAME  
       -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME  
           Here, "NAME" specifies a list of directories that are  
           used for additional source code.  Files found in the  
           "mods list" are given preference over files of the same  
           name found elsewhere.  
   
     -disable NAME | --disable NAME  
       -disable=NAME | --disable=NAME  
           Here "NAME" specifies a list of packages that we don't  
           want to use.  If this violates package dependencies,  
           genamke will exit with an error message.  
   
     -enable NAME | --enable NAME  
       -enable=NAME | --enable=NAME  
           Here "NAME" specifies a list of packages that we wish  
           to specifically enable.  If this violates package  
           dependencies, genamke will exit with an error message.  
   
     -standarddirs NAME | --standarddirs NAME  
       -standarddirs=NAME | --standarddirs=NAME  
           Here, "NAME" specifies a list of directories to be  
           used as the "standard" code.  
   
     -fortran NAME | --fortran NAME | -fc NAME | --fc NAME  
       -fc=NAME | --fc=NAME  
           Use "NAME" as the fortran compiler.  By default, genmake  
           will search for a working compiler by trying a list of  
           "usual suspects" such as g77, f77, etc.  
   
     -cc NAME | --cc NAME | -cc=NAME | --cc=NAME  
           Use "NAME" as the C compiler.  By default, genmake  
           will search for a working compiler by trying a list of  
           "usual suspects" such as gcc, c89, cc, etc.  
   
     -[no]ieee | --[no]ieee  
           Do or don't use IEEE numerics.  Note that this option  
           *only* works if it is supported by the OPTFILE that  
           is being used.  
   
     -ignoretime | -ignore_time | --ignoretime | --ignore_time  
           Ignore all the "wall clock" routines entirely.  This will  
           not in any way hurt the model results -- it simply means  
           that the code that checks how long the model spends in  
           various routines will give junk values.  
   
     -ts | --ts  
           Produce timing information per timestep  
     -papis | --papis  
           Produce summary MFlop/s (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  
   
     -es | --es | -embed-source | --embed-source  
           Embed a tarball containing the full source code  
           (including the Makefile, etc.) used to build the  
           executable [off by default]  
   
     -bash NAME  
           Explicitly specify the Bourne or BASH shell to use  
   
   While it is most often a single word, the "NAME" variables specified  
   above can in many cases be a space-delimited string such as:  
   
     --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'  
     -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'  
     -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'  
   
   which, depending upon your shell, may need to be single-quoted.  
   
   For more detailed genmake documentation, please see:  
   
     http://mitgcm.org/devel_HOWTO/  
   
 EOF  
   
     exit 1  
644  }  }
645    
646  #  Build a CPP macro to automate calling C routines from FORTRAN  #  Build a CPP macro to automate calling C routines from FORTRAN
# Line 649  get_fortran_c_namemangling()  { Line 650  get_fortran_c_namemangling()  {
650      if test ! "x$FC_NAMEMANGLE" = x ; then      if test ! "x$FC_NAMEMANGLE" = x ; then
651          return 0          return 0
652      fi      fi
653        echo " running: get_fortran_c_namemangling()" >> $LOGFILE
654    
655      default_nm="#define FC_NAMEMANGLE(X) X ## _"      default_nm="#define FC_NAMEMANGLE(X) X ## _"
656        
657      cat > genmake_test.c <<EOF      cat > genmake_test.c <<EOF
658  void tcall( char * string ) { tsub( string ); }  void tcall( char * string ) { tsub( string ); }
659  EOF  EOF
660      $MAKE genmake_test.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_test.c"
661        echo ' '$COMM >> $LOGFILE
662        $COMM >> $LOGFILE 2>&1
663      RETVAL=$?      RETVAL=$?
664      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
665          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
666          cat <<EOF>> genmake_errors          cat <<EOF>> $LOGFILE
667    
668  WARNING: C test compile fails   WARNING: C test compile fails
669  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
670  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
671  EOF  EOF
672          return 1          return 1
673      fi      fi
# Line 671  EOF Line 675  EOF
675      RETVAL=$?      RETVAL=$?
676      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
677          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
678          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
679    
680  WARNING: The "nm" command failed.   WARNING: The "nm" command failed.
681  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
682  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
683  EOF  EOF
684          return 1          return 1
685      fi      fi
# Line 685  EOF Line 689  EOF
689        call tsub( string )        call tsub( string )
690        end        end
691  EOF  EOF
692      $FC $FFLAGS -c genmake_tcomp.$FS >> genmake_warnings 2>&1      COMM="$FC $FFLAGS -c genmake_tcomp.$FS"
693        echo ' '$COMM >> $LOGFILE
694        $COMM >> $LOGFILE 2>&1
695      RETVAL=$?      RETVAL=$?
696      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
697          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
698          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
699    
700  WARNING: FORTRAN test compile fails -- please see "genmake_errors"   WARNING: FORTRAN test compile fails -- please see '$LOGFILE'
701  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
702  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
703  EOF  EOF
704          return 1          return 1
705      fi      fi
# Line 701  EOF Line 707  EOF
707      RETVAL=$?      RETVAL=$?
708      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
709          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
710          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
711    
712  WARNING: The "nm" command failed.   WARNING: The "nm" command failed.
713  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
714  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
715  EOF  EOF
716          return 1          return 1
717      fi      fi
# Line 731  EOF Line 737  EOF
737    
738      #  cleanup the testing files      #  cleanup the testing files
739      rm -f genmake_tcomp.* genmake_test.*      rm -f genmake_tcomp.* genmake_test.*
 }  
740    
741        echo " --> set FC_NAMEMANGLE='$FC_NAMEMANGLE'" >> $LOGFILE
742    }
743    
744  check_HAVE_CLOC()  {  check_HAVE_CLOC()  {
745        echo >> $LOGFILE
746        echo "running: check_HAVE_CLOC()" >> $LOGFILE
747      get_fortran_c_namemangling      get_fortran_c_namemangling
748      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
749  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 752  void FC_NAMEMANGLE(cloc) ( double *curti Line 761  void FC_NAMEMANGLE(cloc) ( double *curti
761  }  }
762  EOF  EOF
763      COMM="$CC $CFLAGS -c genmake_tc_1.c"      COMM="$CC $CFLAGS -c genmake_tc_1.c"
764      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
765      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
766      RET_C=$?      RET_C=$?
767      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
768        program hello        program hello
# Line 764  EOF Line 773  EOF
773        end        end
774  EOF  EOF
775      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"
776      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
777      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
778      RET_F=$?      RET_F=$?
779      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> $LOGFILE 2>&1
780      RETVAL=$?      RETVAL=$?
781      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
782          HAVE_CLOC=t          HAVE_CLOC=t
783          DEFINES="$DEFINES -DHAVE_CLOC"          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
845          DEFINES="$DEFINES -DHAVE_SIGREG"          DEFINES="$DEFINES -DHAVE_SIGREG"
846      fi      fi
847      rm -f genmake_tc*      rm -f genmake_tc*
848        echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE
849  }  }
850    
   
851  check_HAVE_SETRLSTK()  {  check_HAVE_SETRLSTK()  {
852      if test "x$HAVE_SETRLSTK" = xt ; then      if test "x$HAVE_SETRLSTK" = xt ; then
853          DEFINES="$DEFINES -DHAVE_SETRLSTK"          DEFINES="$DEFINES -DHAVE_SETRLSTK"
# Line 847  check_HAVE_SETRLSTK()  { Line 856  check_HAVE_SETRLSTK()  {
856      if test ! "x$HAVE_SETRLSTK" = x ; then      if test ! "x$HAVE_SETRLSTK" = x ; then
857          return          return
858      fi      fi
859        echo >> $LOGFILE
860        echo "running: check_HAVE_SETRLSTK()" >> $LOGFILE
861      get_fortran_c_namemangling      get_fortran_c_namemangling
862      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
863  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 863  void FC_NAMEMANGLE(setrlstk) () Line 874  void FC_NAMEMANGLE(setrlstk) ()
874  }  }
875  EOF  EOF
876      COMM="$CC $CFLAGS -c genmake_tc_1.c"      COMM="$CC $CFLAGS -c genmake_tc_1.c"
877      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
878      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
879      RET_C=$?      RET_C=$?
880      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
881        program hello        program hello
# Line 872  EOF Line 883  EOF
883        call setrlstk()        call setrlstk()
884        end        end
885  EOF  EOF
886      echo >> genmake_warnings      cat genmake_tc_2.$FS >> $LOGFILE
     echo "running: check_HAVE_SETRLSTK()" >> genmake_warnings  
     cat genmake_tc_2.$FS >> genmake_warnings  
887      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"
888      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
889      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
890      RETVAL=$?      RETVAL=$?
891      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
892          HAVE_SETRLSTK=t          HAVE_SETRLSTK=t
893          DEFINES="$DEFINES -DHAVE_SETRLSTK"          DEFINES="$DEFINES -DHAVE_SETRLSTK"
894      fi      fi
895      rm -f genmake_tc*      rm -f genmake_tc*
896        echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE
897  }  }
898    
   
899  check_HAVE_STAT()  {  check_HAVE_STAT()  {
900        echo >> $LOGFILE
901        echo "running: check_HAVE_STAT()" >> $LOGFILE
902      get_fortran_c_namemangling      get_fortran_c_namemangling
903      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
904  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 909  void FC_NAMEMANGLE(tfsize) ( int *nbyte Line 920  void FC_NAMEMANGLE(tfsize) ( int *nbyte
920  }  }
921  EOF  EOF
922      COMM="$CC $CFLAGS -c genmake_tc_1.c"      COMM="$CC $CFLAGS -c genmake_tc_1.c"
923      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
924      $COMM >> genmake_tc.log 2>&1      $COMM >> genmake_tc.log 2>&1
925      RET_C=$?      RET_C=$?
926      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
# Line 919  EOF Line 930  EOF
930        print *," HELLO WORLD", nbyte        print *," HELLO WORLD", nbyte
931        end        end
932  EOF  EOF
933      echo >> genmake_warnings      cat genmake_tc_2.$FS >> $LOGFILE
     echo "running: check_HAVE_STAT()" >> genmake_warnings  
     cat genmake_tc_2.$FS >> genmake_warnings  
934      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"
935      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
936      $COMM >> genmake_tc.log 2>&1      $COMM >> genmake_tc.log 2>&1
937      RETVAL=$?      RETVAL=$?
938      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
# Line 931  EOF Line 940  EOF
940          DEFINES="$DEFINES -DHAVE_STAT"          DEFINES="$DEFINES -DHAVE_STAT"
941      fi      fi
942      rm -f genmake_tc*      rm -f genmake_tc*
943        echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE
944  }  }
945    
   
946  check_netcdf_libs()  {  check_netcdf_libs()  {
947      if test ! "x$SKIP_NETCDF_CHECK" = x ; then      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
948          return          return
949      fi      fi
950      echo >> genmake_warnings      echo >> $LOGFILE
951      echo "running: check_netcdf_libs()" >> genmake_warnings      echo "running: check_netcdf_libs()" >> $LOGFILE
952      cat <<EOF > genmake_tnc.F      cat <<EOF > genmake_tnc.F
953        program fgennc        program fgennc
954  #include "netcdf.inc"  #include "netcdf.inc"
# Line 957  EOF Line 966  EOF
966        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
967        end        end
968  EOF  EOF
969      echo "===  genmake_tnc.F  ===" > genmake_tnc.log      echo "===  genmake_tnc.F  >>>" > genmake_tnc.log
970      cat genmake_tnc.F >> genmake_tnc.log      cat genmake_tnc.F >> genmake_tnc.log
971      echo "===  genmake_tnc.F  ===" >> genmake_tnc.log      echo "<<<  genmake_tnc.F  ===" >> genmake_tnc.log
972      RET_CPP=f      RET_CPP=f
973      COMM="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES"      COMM="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES"
974      echo "$COMM" >> genmake_tnc.log      echo "$COMM" >> genmake_tnc.log
# Line 975  EOF Line 984  EOF
984      $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \      $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
985          &&  $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
986      RET_COMPILE=$?      RET_COMPILE=$?
987      cat genmake_tnc.log >> genmake_warnings      cat genmake_tnc.log >> $LOGFILE
988    
989      #EH3  Remove test program execution for machines that either disallow      #EH3  Remove test program execution for machines that either disallow
990      #EH3  execution or cannot support it (eg. cross-compilers)      #EH3  execution or cannot support it (eg. cross-compilers)
# Line 986  EOF Line 995  EOF
995    
996      if test "x$RET_COMPILE" = x0 ; then      if test "x$RET_COMPILE" = x0 ; then
997          HAVE_NETCDF=t          HAVE_NETCDF=t
998            echo "check_netcdf: successful" >> $LOGFILE
999      else      else
1000          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
1001          echo "try again with added '-lnetcdf'" > genmake_tnc.log          echo "==> try again with added '-lnetcdf'" > genmake_tnc.log
1002          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
1003          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
1004          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 1006  EOF
1006              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
1007              &&  $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
1008          RET_COMPILE=$?          RET_COMPILE=$?
1009          cat genmake_tnc.log >> genmake_warnings          echo >> $LOGFILE
1010            cat genmake_tnc.log >> $LOGFILE
1011          if test "x$RET_COMPILE" = x0 ; then          if test "x$RET_COMPILE" = x0 ; then
1012              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
1013              HAVE_NETCDF=t              HAVE_NETCDF=t
1014                echo "check_netcdf: successful" >> $LOGFILE
1015          else          else
1016          # try again with "-lnetcdff" added to the libs          # try again with "-lnetcdff" added to the libs
1017              echo "try again with added '-lnetcdff -lnetcdf'" > genmake_tnc.log              echo "==> try again with added '-lnetcdff -lnetcdf'" > genmake_tnc.log
1018              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
1019              echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log              echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
1020              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 1022  EOF
1022                  &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \                  &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
1023                  &&  $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
1024              RET_COMPILE=$?              RET_COMPILE=$?
1025              cat genmake_tnc.log >> genmake_warnings              echo >> $LOGFILE
1026                cat genmake_tnc.log >> $LOGFILE
1027              if test "x$RET_COMPILE" = x0 ; then              if test "x$RET_COMPILE" = x0 ; then
1028                  LIBS="$LIBS -lnetcdff -lnetcdf"                  LIBS="$LIBS -lnetcdff -lnetcdf"
1029                  HAVE_NETCDF=t                  HAVE_NETCDF=t
1030                    echo "check_netcdf: successful" >> $LOGFILE
1031              fi              fi
1032          fi          fi
1033      fi      fi
1034      rm -f genmake_tnc*      rm -f genmake_tnc*
1035        echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE
1036  }  }
1037    
1038    
   
1039  ###############################################################################  ###############################################################################
1040  #   Sequential part of script starts here  #   Sequential part of script starts here
1041  ###############################################################################  ###############################################################################
# Line 1043  ENABLE= Line 1057  ENABLE=
1057  DISABLE=  DISABLE=
1058  # MAKEFILE=  # MAKEFILE=
1059  # MAKEDEPEND=  # MAKEDEPEND=
1060  PDEPEND=  PKG_DEPEND=
1061  DUMPSTATE=t  PKG_GROUPS=
1062  PDEFAULT=  DUMPSTATE=f
1063  OPTFILE=  OPTFILE=
1064  INCLUDES="-I. $INCLUDES"  INCLUDES="-I. $INCLUDES"
1065  FFLAGS=  FFLAGS=
# Line 1053  FOPTIM= Line 1067  FOPTIM=
1067  FEXTRAFLAGS=  FEXTRAFLAGS=
1068  USE_EXTENDED_SRC=  USE_EXTENDED_SRC=
1069  EXTENDED_SRC_FLAG=  EXTENDED_SRC_FLAG=
1070    GET_FC_VERSION=
1071  CFLAGS=  CFLAGS=
1072  KFLAGS1=  KFLAGS1=
1073  KFLAGS2=  KFLAGS2=
# Line 1065  MPI= Line 1080  MPI=
1080  MPIPATH=  MPIPATH=
1081  OMP=  OMP=
1082  OMPFLAG=  OMPFLAG=
1083    USE_R4=
1084  TS=  TS=
1085  PAPIS=  PAPIS=
1086  PCLS=  PCLS=
# Line 1129  FTL_TAF_FLAGS= Line 1145  FTL_TAF_FLAGS=
1145  SVD_TAMC_FLAGS=  SVD_TAMC_FLAGS=
1146  TAMC_EXTRA=  TAMC_EXTRA=
1147    
   
1148  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1149  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PKG_DEPEND PKG_GROUPS MAKEFILE MAKEDEPEND PLATFORM ROOTDIR MODS DISABLE ENABLE"
1150  gm_s2="FC CPP IEEE TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI OMP DUMPSTATE STANDARDDIRS"  gm_s2="FC CC IEEE USE_R4 TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI OMP DUMPSTATE STANDARDDIRS"
1151    
1152  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1153  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM FEXTRAFLAGS"  gm_s3="LN S64 LINK MAKE PACKAGES INCLUDES FFLAGS FOPTIM FEXTRAFLAGS"
1154  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
1155  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD THISHOST THISUSER THISDATE THISVER MACHINE"
1156  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
1157  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"  gm_s7="FC_NAMEMANGLE HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME"
1158    
1159  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1160  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"
# Line 1153  cat <<EOF Line 1168  cat <<EOF
1168    
1169  GENMAKE :  GENMAKE :
1170    
1171  A program for GENerating MAKEfiles for the MITgcm project.  For a  A program for GENerating MAKEfiles for the MITgcm project.
1172  quick list of options, use "genmake -h" or for more detail see:     For a quick list of options, use "genmake2 -h"
1173    or for more detail see the Developer's HOWTO manual at:
1174    http://mitgcm.org/devel_HOWTO/     http://mitgcm.org/public/docs.html
1175    
1176  EOF  EOF
1177    
1178    LOGFILE="genmake.log"
1179    #- clean-up previous genmake logfiles:
1180    rm -f genmake_state genmake_*optfile $LOGFILE
1181    
1182  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
1183  gm_local="genmake_local"  gm_local="genmake_local"
1184  printf "  getting local config information:  "  printf "  getting local config information:  "
# Line 1185  for ac_option in "$@" ; do Line 1204  for ac_option in "$@" ; do
1204          ac_prev=          ac_prev=
1205          continue          continue
1206      fi      fi
1207        
1208      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
1209        
1210      case $ac_option in      case $ac_option in
1211                    
1212          -help | --help | -h | --h)          -help | --help | -h | --h)
# Line 1206  for ac_option in "$@" ; do Line 1225  for ac_option in "$@" ; do
1225              AD_OPTFILE=$ac_optarg ;;              AD_OPTFILE=$ac_optarg ;;
1226                    
1227          -pdepend | --pdepend)          -pdepend | --pdepend)
1228              ac_prev=PDEPEND ;;              ac_prev=PKG_DEPEND ;;
1229          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
1230              PDEPEND=$ac_optarg ;;              PKG_DEPEND=$ac_optarg ;;
1231                    
1232          -pdefault | --pdefault)          -pgroups | --pgroups)
1233              ac_prev=PDEFAULT ;;              ac_prev=PKG_GROUPS ;;
1234          -pdefault=* | --pdefault=*)          -pgroups=* | --pgroups=*)
1235              PDEFAULT=$ac_optarg ;;              PKG_GROUPS=$ac_optarg ;;
1236                    
1237          -make | --make | -m | --m)          -make | --make | -m | --m)
1238              ac_prev=MAKE ;;              ac_prev=MAKE ;;
# Line 1297  for ac_option in "$@" ; do Line 1316  for ac_option in "$@" ; do
1316          -noieee | --noieee)          -noieee | --noieee)
1317              IEEE= ;;              IEEE= ;;
1318    
1319            -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )
1320                USE_R4=true ;;
1321    
1322          -ts | --ts)          -ts | --ts)
1323              TS=true ;;              TS=true ;;
1324          -papis | --papis)          -papis | --papis)
# Line 1360  for ac_option in "$@" ; do Line 1382  for ac_option in "$@" ; do
1382              ;;              ;;
1383                    
1384      esac      esac
       
 done  
1385    
1386    done
1387    
1388  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1389      echo      echo
# Line 1372  if test -f ./.genmakerc ; then Line 1393  if test -f ./.genmakerc ; then
1393      echo "    http://mitgcm.org/devel_HOWTO/"      echo "    http://mitgcm.org/devel_HOWTO/"
1394      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."
1395      echo "WARNING: ignore \"./.genmakerc\" and continue."      echo "WARNING: ignore \"./.genmakerc\" and continue."
1396      echo      echo
1397  fi  fi
1398    
1399  #  Find the MITgcm ${ROOTDIR}  #  Find the MITgcm ${ROOTDIR}
# Line 1384  if test "x${ROOTDIR}" = x ; then Line 1405  if test "x${ROOTDIR}" = x ; then
1405          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
1406              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
1407                  ROOTDIR=$d                  ROOTDIR=$d
1408                  printf "Warning:  ROOTDIR was not specified but there appears to be"                  printf "Warning: ROOTDIR was not specified ;"
1409                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."                  echo " try using a local copy of MITgcm found at \"$ROOTDIR\""
1410                  break                  break
1411              fi              fi
1412          done          done
# Line 1405  fi Line 1426  fi
1426  #  Find the MITgcm ${THISVER}  #  Find the MITgcm ${THISVER}
1427  version_file="${ROOTDIR}/doc/tag-index"  version_file="${ROOTDIR}/doc/tag-index"
1428  if test -f $version_file ; then  if test -f $version_file ; then
1429      THISVER=`grep '^checkpoint' $version_file | head -1`      THISVER=`$AWK '/^checkpoint/{print $1; exit}' $version_file`
1430  #-  remove ./BUILD_INFO.h file if older than version_file  #-  remove ./BUILD_INFO.h file if older than version_file
1431      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
1432          echo "  remove ./BUILD_INFO.h (older than ${version_file})"          echo "  remove ./BUILD_INFO.h (older than ${version_file})"
# Line 1422  if test "x${OPTFILE}" = x ; then Line 1443  if test "x${OPTFILE}" = x ; then
1443      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
1444          echo "Warning: no OPTFILE specified so we'll look for possible settings"          echo "Warning: no OPTFILE specified so we'll look for possible settings"
1445          printf "\n===  Searching for possible settings for OPTFILE  ===\n"          printf "\n===  Searching for possible settings for OPTFILE  ===\n"
1446          find_possible_configs          find_possible_optfile
1447      else      else
1448          OPTFILE=$MITGCM_OF          OPTFILE=$MITGCM_OF
1449      fi      fi
# Line 1437  if test "x$OPTFILE" != xNONE ; then Line 1458  if test "x$OPTFILE" != xNONE ; then
1458              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1459              exit 1              exit 1
1460          fi          fi
1461          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" = xt ; then
1462              cp -f $OPTFILE "genmake_optfile"              cp -f $OPTFILE "genmake_optfile"
1463          fi          fi
1464      else      else
# Line 1464  if test "x${AD_OPTFILE}" != xNONE ; then Line 1485  if test "x${AD_OPTFILE}" != xNONE ; then
1485              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1486              exit 1              exit 1
1487          fi          fi
1488          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" = xt ; then
1489              cp -f $AD_OPTFILE "genmake_ad_optfile"              cp -f $AD_OPTFILE "genmake_ad_optfile"
1490          fi          fi
1491      else      else
# Line 1492  Error: no Fortran compiler: please speci Line 1513  Error: no Fortran compiler: please speci
1513  EOF  EOF
1514      exit 1      exit 1
1515  fi  fi
1516    if test "x$GET_FC_VERSION" != x ; then
1517      echo "Get compiler version using: $FC $GET_FC_VERSION" >> $LOGFILE
1518      $FC $GET_FC_VERSION >> $LOGFILE 2>&1
1519      echo "<-- compiler version ----" >> $LOGFILE
1520    fi
1521    
1522  if test "x$CC" = x ; then  if test "x$CC" = x ; then
1523      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  
1524  fi  fi
1525    
1526  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1527      LINK=$FC      LINK=$FC
1528  fi  fi
# Line 1509  if test "x$MAKE" = x ; then Line 1530  if test "x$MAKE" = x ; then
1530      MAKE="make"      MAKE="make"
1531  fi  fi
1532  if test "x$CPP" = x ; then  if test "x$CPP" = x ; then
1533      CPP=cpp      CPP="cpp -traditional -P"
1534  fi  fi
1535  #EH3 === UGLY ===  #EH3 === UGLY ===
1536  #  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 1536  EOF Line 1557  EOF
1557  else  else
1558      rm -f test_cpp      rm -f test_cpp
1559  fi  fi
1560    
1561  look_for_makedepend  look_for_makedepend
1562    
1563    #  Check that soft-link command is set and usable
1564  if test "x$LN" = x ; then  if test "x$LN" = x ; then
1565      LN="ln -s"      LN="ln -s"
1566  fi  fi
# Line 1546  RETVAL=$? Line 1570  RETVAL=$?
1570  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
1571      cat <<EOF 1>&2      cat <<EOF 1>&2
1572    
1573  Error: The command "ln -s" failed -- please specify a working soft-link  Error: The command "$LN" failed -- please specify a working soft-link
1574    command in the optfile.    command in the optfile.
1575    
1576  EOF  EOF
# Line 1573  if test ! "x$OMP" = x ; then Line 1597  if test ! "x$OMP" = x ; then
1597        DEFINES="$DEFINES -DUSE_OMP_THREADING"        DEFINES="$DEFINES -DUSE_OMP_THREADING"
1598  fi  fi
1599    
1600    if test ! "x$USE_R4" = x ; then
1601          echo "  Turning on LET_RS_BE_REAL4 cpp flag"
1602          DEFINES="$DEFINES -DLET_RS_BE_REAL4"
1603    fi
1604    
1605  if test ! "x$TS" = x ; then  if test ! "x$TS" = x ; then
1606        echo "  Turning on timing per timestep"        echo "  Turning on timing per timestep"
1607        if test ! "x$FOOLAD" = x ; then        if test ! "x$FOOLAD" = x ; then
# Line 1778  if test "x$EMBED_SRC" = xt ; then Line 1807  if test "x$EMBED_SRC" = xt ; then
1807      ENABLE="$ENABLE embed_files"      ENABLE="$ENABLE embed_files"
1808  fi  fi
1809    
   
1810  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1811  printf "  Adding MODS directories: "  printf "  Adding MODS directories: "
1812  for d in $MODS ; do  for d in $MODS ; do
# Line 1794  for d in $MODS ; do Line 1822  for d in $MODS ; do
1822  done  done
1823  echo  echo
1824    
1825  if test "x${PLATFORM}" = x ; then  #if test "x${PLATFORM}" = x ; then
1826      PLATFORM=$p_PLATFORM  #    PLATFORM=$p_PLATFORM
1827  fi  #fi
1828    
1829  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1830      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
# Line 1836  ERROR: neither of the two default script Line 1864  ERROR: neither of the two default script
1864      ${TOOLSDIR}/set64bitConst.sh      ${TOOLSDIR}/set64bitConst.sh
1865      ${TOOLSDIR}/set64bitConst.csh      ${TOOLSDIR}/set64bitConst.csh
1866    
1867    are working so please check paths or specify (with \$S64) a    are working so please check paths or specify (with \$S64) a
1868    working version of this script.    working version of this script.
1869    
1870  EOF  EOF
# Line 1848  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSD Line 1876  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSD
1876    
1877  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
1878    
1879    #  Set Standard Code Directories:
1880    if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
1881        STANDARDDIRS="eesupp model"
1882    fi
1883    #  if model in Standard-Code-Dir, add eesupp (needed to compile model)
1884    echo " $STANDARDDIRS " | grep ' model ' > /dev/null 2>&1
1885    ckM=$?
1886    echo " $STANDARDDIRS " | grep ' eesupp ' > /dev/null 2>&1
1887    ckE=$?
1888    if test $ckM = 0 -a $ckE = 1 ; then
1889        STANDARDDIRS="$STANDARDDIRS eesupp"
1890    fi
1891    
1892  #  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
1893  #  generated from some template source files. We'll make them first so  #  generated from some template source files. We'll make them first so
1894  #  they appear as regular source code  #  they appear as regular source code
1895  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
1896      echo "  Making source files in eesupp from templates"      echo "  Making source files in eesupp from templates"
1897      ( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1      ( cd $ROOTDIR"/eesupp/src/" && $MAKE clean_old && $MAKE \
1898        ) > make_eesupp.errors 2>&1
1899      RETVAL=$?      RETVAL=$?
1900      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
1901          rm -f make_eesupp.errors          rm -f make_eesupp.errors
# Line 1868  fi Line 1910  fi
1910  for pdir in exch2 regrid ; do  for pdir in exch2 regrid ; do
1911      if test -r $ROOTDIR"/pkg/${pdir}/Makefile" ; then      if test -r $ROOTDIR"/pkg/${pdir}/Makefile" ; then
1912          echo "  Making source files in pkg/${pdir} from templates"          echo "  Making source files in pkg/${pdir} from templates"
1913          ( cd $ROOTDIR"/pkg/"${pdir} && $MAKE ) > make_${pdir}.errors 2>&1          ( cd $ROOTDIR"/pkg/"${pdir} && $MAKE clean_old && $MAKE \
1914            ) > make_${pdir}.errors 2>&1
1915          RETVAL=$?          RETVAL=$?
1916          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
1917              rm -f make_${pdir}.errors              rm -f make_${pdir}.errors
# Line 1881  for pdir in exch2 regrid ; do Line 1924  for pdir in exch2 regrid ; do
1924  done  done
1925    
1926  printf "\n===  Determining package settings  ===\n"  printf "\n===  Determining package settings  ===\n"
1927  if  test "x${PDEPEND}" = x ; then  if  test "x${PKG_DEPEND}" = x ; then
1928      tmp=$ROOTDIR"/pkg/pkg_depend"      tmp=$ROOTDIR"/pkg/pkg_depend"
1929      if test -r $tmp ; then      if test -r $tmp ; then PKG_DEPEND=$tmp ; fi
1930          PDEPEND=$tmp  fi
1931      else  if  test "x${PKG_DEPEND}" = x ; then
1932          echo "Warning:  No package dependency information was specified."          echo "Warning:  No package dependency information was specified."
1933          echo "  Please check that ROOTDIR/pkg/pkg_depend exists."          echo "  Please check that ROOTDIR/pkg/pkg_depend exists."
     fi  
1934  else  else
1935      if test ! -r ${PDEPEND} ; then      if test ! -r ${PKG_DEPEND} ; then
1936          echo "Error:  can't read package dependency info from PDEPEND=\"$PDEPEND\""          echo "Error:  can't read package dependency info from PKG_DEPEND=\"$PKG_DEPEND\""
1937          exit 1          exit 1
1938      fi      fi
1939        echo "  getting package dependency info from  $PKG_DEPEND"
1940    #  Strip the comments and then convert the dependency file into arrays: PNAME, DNAME
1941        get_pdepend_list $PKG_DEPEND
1942  fi  fi
1943  echo "  getting package dependency info from  $PDEPEND"  
1944  #  Strip the comments and then convert the dependency file into  # A default package groups file "$ROOTDIR/pkg/pkg_groups" is provided
1945  #  two arrays: PNAME, DNAME  #  to define the "default_pkg_list" and package groups (for convenience, one
1946  cat $PDEPEND | sed -e 's/#.*$//g' \  #  can specify a group of packages using names like "ocean" and "atmosphere").
1947      | $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
1948      > ./.pd_tmp      tmp=$ROOTDIR"/pkg/pkg_groups"
1949  RETVAL=$?      if test -r $tmp ; then PKG_GROUPS=$tmp ; fi
1950  if test ! "x${RETVAL}" = x0 ; then  fi
1951      echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""  if test "x${PKG_GROUPS}" = x ; then
1952      exit 1          echo "Warning:  No package groups information was specified."
1953            echo "  Please check that ROOTDIR/pkg/pkg_groups exists."
1954    else
1955        if test ! -r ${PKG_GROUPS} ; then
1956            echo "Error:  can't read package groups info from PKG_GROUPS=\"$PKG_GROUPS\""
1957            exit 1
1958        fi
1959        echo "  getting package groups info from      $PKG_GROUPS"
1960  fi  fi
 . ./.pd_tmp  
 rm -f ./.pd_tmp  
1961    
1962  #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"  #  Search for packages to compile.
1963  #  file should eventually be added so that, for convenience, one can  echo "  checking list of packages to compile:"
1964  #  specify groups of packages using names like "ocean" and "atmosphere".  PKG_LIST=
1965  echo "  checking default package list:  "  if test "x${PKG_LIST}" = x ; then
 if test "x${PDEFAULT}" = x ; then  
1966      for i in "." $MODS ; do      for i in "." $MODS ; do
1967          if test -r $i"/packages.conf" ; then          if test -r $i"/packages.conf" ; then
1968                  PDEFAULT=$i"/packages.conf"                  PKG_LIST=$i"/packages.conf"
1969                  break                  break
1970          fi          fi
1971      done      done
1972  fi  fi
1973  if test "x${PDEFAULT}" = x ; then  if test "x${PKG_LIST}" = x ; then
1974      PDEFAULT="$ROOTDIR/pkg/pkg_default"      pkg_list='default_pkg_list'
1975  fi      if test "x${PKG_GROUPS}" = x ; then
1976  if test "x${PDEFAULT}" = xNONE ; then          echo "Error:  need package groups info to expand pkg_list=\"$pkg_list\""
1977      echo "    default packages file disabled"          exit 1
1978        fi
1979  else  else
1980      if test ! -r $PDEFAULT ; then      if test ! -r $PKG_LIST ; then
1981          echo "Warning:  can't read default packages from PDEFAULT=\"$PDEFAULT\""          echo "Error:  can't read package list from PKG_LIST=\"$PKG_LIST\""
1982            exit 1
1983      else      else
1984          echo "    using PDEFAULT=\"$PDEFAULT\""          echo "    using PKG_LIST=\"$PKG_LIST\""
1985          #  Strip the comments and add all the names          #  Strip the comments and add all the names
1986          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}'`
1987          RETVAL=$?          RETVAL=$?
1988          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
1989              printf "Error: can't parse default package list "              printf "Error: can't parse package list "
1990              echo "-- please check PDEFAULT=\"$PDEFAULT\""              echo "-- please check PKG_LIST=\"$PKG_LIST\""
1991              exit 1              exit 1
1992          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"  
1993      fi      fi
1994  fi  fi
1995    for i in $pkg_list ; do
1996        PACKAGES="$PACKAGES $i"
1997    done
1998    echo     "    before group expansion packages are:$PACKAGES"
1999    if test "x${PKG_GROUPS}" != x ; then
2000        RET=1
2001        while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
2002        echo "    after group expansion packages are: $PACKAGES"
2003    fi
2004    
2005  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
2006    echo "" > ./.tmp_pack
2007  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2008      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
2009  done  done
# Line 1977  PACKAGES="$PACKAGES $ENABLE" Line 2031  PACKAGES="$PACKAGES $ENABLE"
2031  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2032      j=`echo $i | sed 's/[-+]//'`      j=`echo $i | sed 's/[-+]//'`
2033      if test ! -d "$ROOTDIR/pkg/$j" ; then      if test ! -d "$ROOTDIR/pkg/$j" ; then
2034          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
2035          exit 1          exit 1
2036      fi      fi
2037      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
# Line 1987  for i in `grep -v "-" ./.tmp_pack | sort Line 2041  for i in `grep -v "-" ./.tmp_pack | sort
2041      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
2042  done  done
2043  rm -f ./.tmp_pack  rm -f ./.tmp_pack
2044  echo "    packages are:  $PACKAGES"  echo "    packages are: $PACKAGES"
2045    
2046  #  Check for package MNC: if NetCDF is available, then build the MNC  #  Check for package MNC: if NetCDF is available, then build the MNC
2047  #  template files ; otherwise, delete mnc from the list of packages.  #  template files ; otherwise, delete mnc from the list of packages.
2048  echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1  echo " $PACKAGES " | grep ' mnc ' > /dev/null 2>&1
2049  RETVAL=$?  mnc_in=$?
2050  if test "x$RETVAL" = x0 ; then  if test "x$HAVE_NETCDF" != xt ; then
2051      if test "x$HAVE_NETCDF" != xt ; then      if test "x$mnc_in" = x0 ; then
2052          cat <<EOF          cat <<EOF
   
2053  *********************************************************************  *********************************************************************
2054  WARNING: the "mnc" package was enabled but tests failed to compile  WARNING: the "mnc" package was enabled but tests failed to compile
2055    NetCDF applications.  Please check that:    NetCDF applications.  Please check that:
2056    
2057    1) NetCDF is correctly installed for this compiler and    1) NetCDF is correctly installed for this compiler and
2058    2) the LIBS variable (within the "optfile") specifies the correct    2) the LIBS variable (within the "optfile") specifies the correct
2059         NetCDF library to link against.         NetCDF library to link against.
2060    
2061    Due to this failure, the "mnc" package is now DISABLED.    Due to this failure, the "mnc" package is now DISABLED.
2062  *********************************************************************  *********************************************************************
   
2063  EOF  EOF
2064          PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`          PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
2065          DISABLE="$DISABLE mnc"          DISABLE="$DISABLE mnc"
2066      else      else
2067          ( 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
2068          RETVAL=$?          DISABLE="$DISABLE mnc"
2069          if test "x${RETVAL}" = x0 ; then      fi
2070              rm -f make_mnc.errors  else
2071        # we have NetCDF, we try to build MNC template files
2072        ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
2073        RETVAL=$?
2074        if test "x${RETVAL}" = x0 ; then
2075            rm -f make_mnc.errors
2076        else
2077            echo "Error: problem encountered while building source files in pkg/mnc:"
2078            cat make_mnc.errors 1>&2
2079            if test "x$mnc_in" = x0 ; then
2080                exit 1
2081          else          else
2082              echo "Error: problem encountered while building source files in pkg/mnc:"              DISABLE="$DISABLE mnc"
             cat make_mnc.errors 1>&2  
             exit 1  
2083          fi          fi
2084      fi      fi
2085  fi  fi
2086    
2087  #  Check for package PROFILES: if NetCDF is not available,  #  Check for package PROFILES: if NetCDF is not available,
2088  #  then delete profiles from the list of available packages.  #  then delete profiles from the list of available packages.
2089  echo $PACKAGES | grep ' profiles ' > /dev/null 2>&1  if test "x$HAVE_NETCDF" != xt ; then
2090  RETVAL=$?      echo " $PACKAGES " | grep ' profiles ' > /dev/null 2>&1
2091  if test "x$RETVAL" = x0 ; then      RETVAL=$?
2092      if test "x$HAVE_NETCDF" != xt ; then      if test "x$RETVAL" = x0 ; then
2093          cat <<EOF          cat <<EOF
   
2094  *********************************************************************  *********************************************************************
2095  WARNING: the "profiles" package was enabled but tests failed to  WARNING: the "profiles" package was enabled but tests failed to
2096    compile NetCDF applications.  Please check that:    compile NetCDF applications.  Please check that:
2097    
2098    1) NetCDF is correctly installed for this compiler and    1) NetCDF is correctly installed for this compiler and
2099    2) the LIBS variable (within the "optfile") specifies the correct    2) the LIBS variable (within the "optfile") specifies the correct
2100         NetCDF library to link against.         NetCDF library to link against.
2101    
2102    Due to this failure, the "profiles" package is now DISABLED.    Due to this failure, the "profiles" package is now DISABLED.
2103  *********************************************************************  *********************************************************************
   
2104  EOF  EOF
2105          PACKAGES=`echo $PACKAGES | sed -e 's/profiles//g'`          PACKAGES=`echo $PACKAGES | sed -e 's/profiles//g'`
2106          DISABLE="$DISABLE profiles"          DISABLE="$DISABLE profiles"
2107        else
2108        #  this prevent to add profiles (due to pdepend rules) if not available
2109            DISABLE="$DISABLE profiles"
2110      fi      fi
2111  fi  fi
2112    
2113  echo "  applying package dependency rules"  if  test "x${PKG_DEPEND}" != x ; then
2114  ck=    echo "  applying package dependency rules"
2115  while test "x$ck" != xtt ; do    ck=
2116      while test "x$ck" != xtt ; do
2117      i=0      i=0
2118      # rtot=${#PNAME[@]}      # rtot=${#PNAME[@]}
2119      rtot=$nname      rtot=$nname
# Line 2067  while test "x$ck" != xtt ; do Line 2129  while test "x$ck" != xtt ; do
2129                  pin="t"                  pin="t"
2130              fi              fi
2131          done          done
2132            #  or in the current $STANDARDDIRS list?
2133            for p in $STANDARDDIRS ; do
2134                if test "x$p" = "x$pname" ; then pin="t" ; fi
2135            done
2136    
2137          #  Is the DNAME entry a (+) or (-) rule ?          #  Is the DNAME entry a (+) or (-) rule ?
2138          tmp="dname=\"\$DNAME_$i\""          tmp="dname=\"\$DNAME_$i\""
# Line 2110  while test "x$ck" != xtt ; do Line 2176  while test "x$ck" != xtt ; do
2176          #  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?
2177          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
2178              echo "Error: can't satisfy package dependencies:"              echo "Error: can't satisfy package dependencies:"
2179              echo "  \"$pname\" was requested but is disallowed by"              echo "  \"$pname\" was requested but is disallowed by"
2180              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
2181              exit 1              exit 1
2182          fi          fi
# Line 2118  while test "x$ck" != xtt ; do Line 2184  while test "x$ck" != xtt ; do
2184          #i=$(( $i + 1 ))          #i=$(( $i + 1 ))
2185      done      done
2186      ck=$ck"t"      ck=$ck"t"
2187  done    done
2188  echo "    packages are:  $PACKAGES"    echo "    packages are: $PACKAGES"
2189    fi
2190  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2191      adr="$ROOTDIR/pkg/$i"      adr="$ROOTDIR/pkg/$i"
2192      if test -d $adr ; then      if test -d $adr ; then
# Line 2136  done Line 2203  done
2203    
2204  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
2205  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
2206  #  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
2207  #  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
2208  #  file would eventually be split up so that all package-related #define  #  file would eventually be split up so that all package-related #define
2209  #  statements could be separated and handled only by genmake.  #  statements could be separated and handled only by genmake.
2210  names=`ls -1 "$ROOTDIR/pkg"`  names=`ls -1 "$ROOTDIR/pkg"`
# Line 2165  for i in $PACKAGES ; do Line 2232  for i in $PACKAGES ; do
2232  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
2233    
2234  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
2235      case $i in      case $i in
2236          aim_v23)          aim_v23)
2237              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
2238              echo "Warning: ALLOW_AIM is set to enable aim_v23."              echo "Warning: ALLOW_AIM is set to enable aim_v23."
# Line 2175  for i in $PACKAGES ; do Line 2242  for i in $PACKAGES ; do
2242    
2243  done  done
2244    
2245  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS='$STANDARDDIRS'"
2246  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
 if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then  
     STANDARDDIRS="eesupp model"  
 fi  
2247  if test "x$STANDARDDIRS" != x ; then  if test "x$STANDARDDIRS" != x ; then
2248      for d in $STANDARDDIRS ; do      for d in $STANDARDDIRS ; do
2249          adr="$ROOTDIR/$d/src"          adr="$ROOTDIR/$d/src"
# Line 2238  if test -f ./adSrcFiles.tmp ; then Line 2302  if test -f ./adSrcFiles.tmp ; then
2302      rm -f ./adSrcFiles.tmp      rm -f ./adSrcFiles.tmp
2303  fi  fi
2304  echo "  Creating the list of files for the adjoint compiler."  echo "  Creating the list of files for the adjoint compiler."
2305    touch adSrcFiles.tmp
2306  for i in $SOURCEDIRS ; do  for i in $SOURCEDIRS ; do
2307      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2308      for j in $list_files ; do      for j in $list_files ; do
# Line 2270  if test ! "x$DIVA" = x ; then Line 2335  if test ! "x$DIVA" = x ; then
2335          fi          fi
2336          MPIINCLUDEDIR='$MPIHOME/include'          MPIINCLUDEDIR='$MPIHOME/include'
2337      fi      fi
2338        
2339      if test -r $MPIINCLUDEDIR/mpif.h ; then      if test -r $MPIINCLUDEDIR/mpif.h ; then
2340          for i in $MPI_HEADER_FILES; do          for i in $MPI_HEADER_FILES; do
2341              cp -p $MPIINCLUDEDIR/$i ./mpi_headers              cp -p $MPIINCLUDEDIR/$i ./mpi_headers
# Line 2305  if test ! -r ".links.tmp/foo" ; then Line 2370  if test ! -r ".links.tmp/foo" ; then
2370  fi  fi
2371  rm -f .links.tmp/foo  rm -f .links.tmp/foo
2372    
2373  if test "x$OPENAD" != x ; then  if test "x$OPENAD" != x ; then
2374      OAD_DONT_COMPILE="/dev/null"      OAD_DONT_COMPILE="/dev/null"
2375      OAD_DONT_TRANSFORM="/dev/null"      OAD_DONT_TRANSFORM="/dev/null"
2376      OAD_KEEP_ORIGINAL="/dev/null"      OAD_KEEP_ORIGINAL="/dev/null"
# Line 2358  for d in $alldirs ; do Line 2423  for d in $alldirs ; do
2423      deplist=      deplist=
2424      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
2425      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
2426      if test "x$OPENAD" != x ; then      if test "x$OPENAD" != x ; then
2427          sfiles=`( echo $sfiles | grep -v _cb2m\. )`          sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2428      fi      fi
2429      for sf in $sfiles ; do      for sf in $sfiles ; do
# Line 2398  for d in $alldirs ; do Line 2463  for d in $alldirs ; do
2463                        F)                        F)
2464                          echo    " \\"  >> F77srclist.tmp                          echo    " \\"  >> F77srclist.tmp
2465                          printf " $sf" >> F77srclist.tmp                          printf " $sf" >> F77srclist.tmp
2466                          if test "x$OPENAD" != x ; then                          if test "x$OPENAD" != x ; then
2467                              basename=${sf%%.F}                              basename=${sf%%.F}
2468                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`
2469                              if test -z "$isAD" ; then                              if test -z "$isAD" ; then
2470                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`
2471                                  if test -z "$toBeIgnored" ; then                                  if test -z "$toBeIgnored" ; then
2472                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> nonADF77srclist.tmp
2473                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> nonADF77srclist.tmp
2474                                  else                                  else
2475                                      echo "    not to be compiled   :  $sf"                                      echo "    not to be compiled   :  $sf"
2476                                  fi                                  fi
2477                              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
2478                                   # or we want to retain the untransformed version                                   # or we want to retain the untransformed version
2479                                  notToBeTransformed=`egrep ^$basename'[      ]*' ${OAD_DONT_TRANSFORM}`                                  notToBeTransformed=`egrep ^$basename'[      ]*' ${OAD_DONT_TRANSFORM}`
2480                                  untransformedVersionToBeKept=`egrep ^$basename'[      ]*' ${OAD_KEEP_ORIGINAL}`                                  untransformedVersionToBeKept=`egrep ^$basename'[      ]*' ${OAD_KEEP_ORIGINAL}`
2481                                  if test -n "$notToBeTransformed"; then                                  if test -n "$notToBeTransformed"; then
2482                                      echo "    not to be transformed:  $sf"                                      echo "    not to be transformed:  $sf"
2483                                  fi                                  fi
2484                                  if test -n "$untransformedVersionToBeKept" ; then                                  if test -n "$untransformedVersionToBeKept" ; then
2485                                      echo "    original to be kept  :  $sf"                                      echo "    original to be kept  :  $sf"
2486                                  fi                                      fi
2487                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2488                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> nonADF77srclist.tmp
2489                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> nonADF77srclist.tmp
# Line 2474  for xx in "$@" ; do nw=`echo $xx | wc -w Line 2539  for xx in "$@" ; do nw=`echo $xx | wc -w
2539  done  done
2540    
2541  if test -f $MAKEFILE ; then  if test -f $MAKEFILE ; then
2542      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.old"
2543  fi  fi
2544  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
2545  echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE  echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE
# Line 2493  EXE_SVD=$EXECUTABLE"_svd" Line 2558  EXE_SVD=$EXECUTABLE"_svd"
2558  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2559  #  #
2560  # OPTFILE="$OPTFILE"  # OPTFILE="$OPTFILE"
2561  #  #
2562  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
2563  # SOURCEDIRS   : Directories containing the source (.F) files  # SOURCEDIRS   : Directories containing the source (.F) files
2564  # INCLUDEDIRS  : Directories containing the header-source (.h) files  # INCLUDEDIRS  : Directories containing the header-source (.h) files
# Line 2513  cat >>$MAKEFILE <<EOF Line 2578  cat >>$MAKEFILE <<EOF
2578  # LIBS         : Library flags /or/ additional optimization/debugging flags  # LIBS         : Library flags /or/ additional optimization/debugging flags
2579    
2580  ROOTDIR     = ${ROOTDIR}  ROOTDIR     = ${ROOTDIR}
2581  BUILDDIR    = ${BUILDDIR}    BUILDDIR    = ${BUILDDIR}
2582  SOURCEDIRS  = ${SOURCEDIRS}  SOURCEDIRS  = ${SOURCEDIRS}
2583  INCLUDEDIRS = ${INCLUDEDIRS}  INCLUDEDIRS = ${INCLUDEDIRS}
2584  EXEDIR      = ${EXEDIR}  EXEDIR      = ${EXEDIR}
# Line 2594  rm -f F77srclist.tmp nonADF77srclist.tmp Line 2659  rm -f F77srclist.tmp nonADF77srclist.tmp
2659    
2660  echo >> $MAKEFILE  echo >> $MAKEFILE
2661    
2662  # add definitions for preprocessed sources  # add definitions for preprocessed sources
2663  # and note that not all systems allow case sensitive extensions  # and note that not all systems allow case sensitive extensions
2664  # hence the $FS and $FS90 here.  # hence the $FS and $FS90 here.
2665  # for fixed format f90 files we use ff90 or FF90 resp  # for fixed format f90 files we use ff90 or FF90 resp
2666  # but these are not expected to be the original source files  # but these are not expected to be the original source files
2667    
2668  echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE  echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE
# Line 2634  output.txt: \$(EXECUTABLE) Line 2699  output.txt: \$(EXECUTABLE)
2699          @printf 'running ... '          @printf 'running ... '
2700          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
2701    
2702    # remove most of the files that "make" generates
2703  clean:  clean:
2704          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2705          -rm -rf *.o          -rm -rf *.o
2706          -rm -rf *.$FS *.flowdir          -rm -rf *.$FS *.flowdir
2707          -rm -rf *.f$FS90 \$(AD_CLEAN) ad_input*          -rm -rf *.f$FS90 \$(AD_CLEAN) ad_input*
2708    
2709    # remove most of the files that "make" and "make depend" generate
2710  Clean:  Clean:
2711          @make clean          @make clean
2712          @make cleanlinks          @make cleanlinks
2713          -rm -f \$(SPECIAL_FILES)          -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old
         -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log f90mkdepend.log *.bak  
2714          -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log          -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log
2715            -rm -f genmake_warnings genmake_errors make.log
2716    
2717    # remove also the executable, files that "genmake2" generates (except Makefile)
2718    #         and output from a run (plus log files from testreport)
2719  CLEAN:  CLEAN:
2720          @make Clean          @make Clean
2721            -rm -f \$(EXECUTABLE) \$(EXE_AD) *.bak
2722            -rm -f $LOGFILE genmake_state genmake_*optfile genmake.tr_log make.tr_log
2723          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2724          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2725          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2726          -rm -f \$(EXECUTABLE) \$(EXE_AD) *.txt STD* *diagnostics.log datetime          -rm -f *.txt STD* *diagnostics.log datetime
2727          -rm -f *_MIT_CE_000.opt0000 costfunction*0000          -rm -f *_MIT_CE_000.opt0000 costfunction*0000
2728          -rm -rf mnc_test_*          -rm -rf mnc_test_*
2729    
 #eh3 Makefile: makefile  
2730  makefile:  makefile:
2731          $THIS_SCRIPT $G2ARGS          $THIS_SCRIPT $G2ARGS
2732  cleanlinks:  cleanlinks:
# Line 2685  if test "x$EMBED_SRC" = xt ; then Line 2757  if test "x$EMBED_SRC" = xt ; then
2757    
2758  decode_files.o : EMBEDDED_FILES.h  decode_files.o : EMBEDDED_FILES.h
2759    
2760  ##  \$(F77_PP_SRC_FILES)  ##  \$(F77_PP_SRC_FILES)
2761  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
2762          @echo Creating \$@ ...          @echo Creating \$@ ...
2763          -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 2710  cat >>$MAKEFILE <<EOF Line 2782  cat >>$MAKEFILE <<EOF
2782          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2783  .$FS.o:  .$FS.o:
2784          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2785    .F.o:
2786            \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2787  .F90.$FS90:  .F90.$FS90:
2788          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2789  .FF90.f$FS90:  .FF90.f$FS90:
# Line 2736  EOF Line 2810  EOF
2810  #===  Automatic Differentiation Rules  ===  #===  Automatic Differentiation Rules  ===
2811  #===  for TAMC/TAF  ======================  #===  for TAMC/TAF  ======================
2812    
2813  if test "x$OPENAD" = x ; then  if test "x$OPENAD" = x ; then
2814    
2815  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2816    
# Line 2783  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC Line 2857  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC
2857          -rm -f ad_config.template          -rm -f ad_config.template
2858          @make \$(F77_PP_SRC_FILES)          @make \$(F77_PP_SRC_FILES)
2859          @make \$(FLOFILES)          @make \$(FLOFILES)
2860          cat \$(FLOFILES) \$(AD_FILES) > ad_input_code.$FS          cat \$(FLOFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS
2861    
2862  ad_taf_output.$FS: ad_input_code.$FS  ad_taf_output.$FS: ad_input_code.$FS
2863          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
# Line 2796  adtafonly: Line 2870  adtafonly:
2870          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
2871    
2872  \${EXE_AD}: ad_taf_output.o \$(OBJFILES)  \${EXE_AD}: ad_taf_output.o \$(OBJFILES)
2873          \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2874    
2875  ad_tamc_output.$FS: ad_input_code.$FS  ad_tamc_output.$FS: ad_input_code.$FS
2876          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2877          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
2878    
2879  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2880          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2881    
2882  adonlyfwd:  adonlyfwd:
2883          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2884    
2885  adtrick:  adtrick:
2886          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2887    
# Line 2835  ftltafonly: Line 2909  ftltafonly:
2909          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
2910    
2911  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
2912          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2913    
2914  ftl_tamc_output.$FS: ftl_input_code.$FS  ftl_tamc_output.$FS: ftl_input_code.$FS
2915          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2916          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
2917    
2918  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2919          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
   
2920    
2921  # ... SVD ...  # ... SVD ...
2922  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
# Line 2871  svd_touch: Line 2944  svd_touch:
2944    
2945  EOF  EOF
2946    
2947  fi  fi
2948    
2949  #===  for OpenAD  ========================  #===  for OpenAD  ========================
2950    
2951  if test "x$OPENAD" != x ; then  if test "x$OPENAD" != x ; then
2952    
2953  # ============ begin OpenAD specific section ==============  # ============ begin OpenAD specific section ==============
2954    
2955  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2956    
2957  # all the source files linked from the various locations:  # all the source files linked from the various locations:
2958  ALL_LINKED_FILES= \  ALL_LINKED_FILES= \
2959  \$(F77_SRC_FILES) \  \$(F77_SRC_FILES) \
2960  \$(C_SRC_FILES) \  \$(C_SRC_FILES) \
# Line 2933  rm -f adSrcFiles.tmp Line 3006  rm -f adSrcFiles.tmp
3006    
3007  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3008    
3009  adAll: \$(EXE_AD)  adAll: \$(EXE_AD)
3010  .PHONY: adAll  .PHONY: adAll
3011    
3012  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 2951  w2f__types.F90 \ Line 3024  w2f__types.F90 \
3024  OAD_active.F90 \  OAD_active.F90 \
3025  OAD_cp.F90 \  OAD_cp.F90 \
3026  OAD_rev.F90 \  OAD_rev.F90 \
3027  OAD_tape.F90          OAD_tape.F90
3028    
3029  OPENAD_SUPPORT_C_SRC_FILES = \  OPENAD_SUPPORT_C_SRC_FILES = \
3030  iaddr.c \  iaddr.c \
# Line 2960  timeRatio.c Line 3033  timeRatio.c
3033  f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)  f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)
3034          cat \$^ > \$@          cat \$^ > \$@
3035    
3036  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
3037          cat \$^ > \$@          cat \$^ > \$@
3038    
3039  f95_test.out: f95_test_mods.f90 f95_test.f90  f95_test.out: f95_test_mods.f90 f95_test.f90
3040          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
3041          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
3042    
3043  # the file included below is created by the  # the file included below is created by the
3044  # postProcessor and its inclusion sets the  # postProcessor and its inclusion sets the
3045  # variable POSTPROCESSEDFILES  # variable POSTPROCESSEDFILES
3046  # used below. Because the file is made during  # used below. Because the file is made during
3047  # make it won't be read until the second (recursive)  # make it won't be read until the second (recursive)
3048  # invocation in the rule below  # invocation in the rule below
3049  -include postProcess.make  -include postProcess.make
3050    
# Line 2997  endif Line 3070  endif
3070  openad: ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90  openad: ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
3071  .PHONY: openad  .PHONY: openad
3072    
3073  # create the module files  # create the module files
3074  %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk  %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk
3075          ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk          ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk
3076    
3077  # create the header files  # create the header files
3078  %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk  %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk
3079          ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)          ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
3080    
3081  # change everybody else to use the new module files:  # change everybody else to use the new module files:
# Line 3024  CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS9 Line 3097  CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS9
3097  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3098          cat \$^ > \$@          cat \$^ > \$@
3099    
3100  # strip all comments and blanks to reduce  # strip all comments and blanks to reduce
3101  # the file size in order to reduce perl's memory requirements  # the file size in order to reduce perl's memory requirements
3102  ad_input_code_sf.f$FS90 : ad_input_code.f$FS90  ad_input_code_sf.f$FS90 : ad_input_code.f$FS90
3103          cat \$^ | sed -f ../OAD_support/strip.sed | sed -f ../OAD_support/stop2print.sed > \$@          cat \$^ | sed -f ../OAD_support/strip.sed | sed -f ../OAD_support/stop2print.sed > \$@
3104    
3105  # mfef90 preprocessing  # mfef90 preprocessing
3106  # expand statement functions  # expand statement functions
3107  # expose mfef90 specific substring handling  # expose mfef90 specific substring handling
3108  # add the w2f__types module  # add the w2f__types module
3109  ad_input_code_sf.w2f.f$FS90: ad_input_code_sf.f$FS90 mfef90 whirl2f whirl2f_be w2f__types.f90  ad_input_code_sf.w2f.f$FS90: ad_input_code_sf.f$FS90 mfef90 whirl2f whirl2f_be w2f__types.f90
3110          ./mfef90 -r8 -z -F -N132 \$<          ./mfef90 -r8 -z -F -N132 \$<
3111          mv \$<.B \$(basename \$<).B          mv \$<.B \$(basename \$<).B
3112          ./whirl2f -openad \$(basename \$<).B          ./whirl2f -openad \$(basename \$<).B
3113          cat w2f__types.f90 \$(basename \$<).w2f.f > \$@          cat w2f__types.f90 \$(basename \$<).w2f.f > \$@
3114    
3115  # canonicalizer  # canonicalizer
3116  ad_input_code_sf.w2f.pre.f$FS90: ad_input_code_sf.w2f.f$FS90 preProcess.py  ad_input_code_sf.w2f.pre.f$FS90: ad_input_code_sf.w2f.f$FS90 preProcess.py
3117          ./preProcess.py --timing -H -S \$< -o \$@          ./preProcess.py --timing --r8 -H -S \$< -o \$@
3118    
3119  # F -> WHIRL  # F -> WHIRL
3120  # note that the canonicalized version cuts off at col 72  # note that the canonicalized version cuts off at col 72
3121  # doing this also for string constants which is ok as long  # doing this also for string constants which is ok as long
3122  # as we are in fixed mode and cut of exactly there.  # as we are in fixed mode and cut of exactly there.
3123  # Otherwise mfef90 patches in spaces to fill up to 72 (or 132)  # Otherwise mfef90 patches in spaces to fill up to 72 (or 132)
3124  # characters respectively.  # characters respectively.
3125  ad_input_code_sf.w2f.pre.B: ad_input_code_sf.w2f.pre.f$FS90 mfef90  ad_input_code_sf.w2f.pre.B: ad_input_code_sf.w2f.pre.f$FS90 mfef90
3126          ./mfef90 -r8 -z -F \$<          ./mfef90 -r8 -z -F \$<
# Line 3067  ad_input_code_sf.w2f.pre.xb.x2w.B : ad_i Line 3140  ad_input_code_sf.w2f.pre.xb.x2w.B : ad_i
3140    
3141  # WHIRL' -> F'  # WHIRL' -> F'
3142  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.w2f.pre.xb.x2w.w2f.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.B whirl2f whirl2f_be
3143          ./whirl2f -FLIST:ftn_file=\$@ -openad \$<          ./whirl2f -FLIST:ftn_file=\$@ -openad \$<
3144    
3145  # insert template directives  # insert template directives
3146  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.w2f.pre.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90 ../OAD_support/insertTemplateDir.bash
# Line 3076  ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f Line 3149  ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f
3149  PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F  PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F
3150  # postprocess F'  # postprocess F'
3151  postProcess.tag: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 postProcess.py \$(PPEXTRAS:.F=.f)  postProcess.tag: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 postProcess.py \$(PPEXTRAS:.F=.f)
3152          # the target is a placeholder to signal execution of the rule          # the target is a placeholder to signal execution of the rule
3153          touch \$@          touch \$@
3154          # this step also creates the file postProcess.make but we cannot          # this step also creates the file postProcess.make but we cannot
3155          # name it as the target or else make will try to remake it for          # name it as the target or else make will try to remake it for
3156          # the include directive above for any rule, e.g. make clean          # the include directive above for any rule, e.g. make clean
3157          ./postProcess.py --progress --timing -m r -i ../OAD_support/ad_inline.f --width 4 \$<          ./postProcess.py --progress --timing --outputFormat=fixed -m r -i ../OAD_support/ad_inline.f --width 4 \$<
3158    
3159  # setup some links  # setup some links
3160  %.xsd:  %.xsd:
3161          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3162    
3163  mfef90:  mfef90:
3164          \$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 .          \$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 .
3165    
3166  # link the support files:  # link the support files:
3167  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):
3168          \$(LN) ../OAD_support/\$@ .          \$(LN) ../OAD_support/\$@ .
3169    
3170  whirl2xaif xaif2whirl:  whirl2xaif xaif2whirl:
3171          \$(LN) \${OPENADFORTTK}/bin/\$@ .          \$(LN) \${OPENADFORTTK}/bin/\$@ .
3172    
3173  preProcess.py postProcess.py:  preProcess.py postProcess.py:
3174          \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ .          \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ .
3175    
3176  whirl2f whirl2f_be:  whirl2f whirl2f_be:
# Line 3151  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 3224  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
3224  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
3225    
3226  # Create special header files  # Create special header files
3227  $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"
3228  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
3229      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
3230  else  else
# Line 3168  if test ! -f AD_CONFIG.h ; then Line 3241  if test ! -f AD_CONFIG.h ; then
3241      $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 -UALLOW_ECCO_OPTIMIZATION > AD_CONFIG.h
3242  fi  fi
3243    
   
3244  #  Write the "state" for future records  #  Write the "state" for future records
3245  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" = xt ; then
3246      printf "" > genmake_state      printf "" > genmake_state
3247      for i in $gm_state ; do      for i in $gm_state ; do
3248          t1="t2=\$$i"          t1="t2=\$$i"

Legend:
Removed from v.1.197  
changed lines
  Added in v.1.218

  ViewVC Help
Powered by ViewVC 1.1.22