/[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.83 by adcroft, Tue Jul 6 18:06:49 2004 UTC revision 1.236 by jmc, Fri Aug 24 23:07:27 2012 UTC
# Line 1  Line 1 
1  #! /usr/bin/env sh  #! /usr/bin/env bash
2  #  #
3  # $Header$  # $Header$
4    # $Name$
5  #  #
6  # Makefile generator for MITgcm UV codes  # Makefile generator for MITgcm UV codes
7  #   created  by cnh 03/98  #   created  by cnh 03/98
# Line 8  Line 9 
9  #   modified by aja 01/00  #   modified by aja 01/00
10  #   rewritten in bash by eh3 08/03  #   rewritten in bash by eh3 08/03
11    
12    #  Explain usage
13    usage()  {
14    cat <<EOF
15    
16    Usage: "$0" [OPTIONS]
17      where [OPTIONS] can be:
18    
19        -help | --help | -h | --h
20              Print this help message and exit.
21    
22        -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
23          -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
24              Use "NAME" as the adoptfile.  By default, the file at
25              "tools/adjoint_options/adjoint_default" will be used.
26    
27        -nooptfile | --nooptfile
28          -optfile NAME | --optfile NAME | -of NAME | --of NAME
29          -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
30              Use "NAME" as the optfile.  By default, an attempt will be
31              made to find an appropriate "standard" optfile in the
32              tools/build_options/ directory.
33    
34        -pdepend NAME | --pdepend NAME
35          -pdepend=NAME | --pdepend=NAME
36              Get package dependency information from "NAME".
37    
38        -pgroups NAME | --pgroups NAME
39          -pgroups=NAME | --pgroups=NAME
40              Get the package groups information from "NAME".
41    
42        -bash NAME
43              Explicitly specify the Bourne or BASH shell to use
44    
45        -make NAME | -m NAME
46          --make=NAME | -m=NAME
47              Use "NAME" for the MAKE program. The default is "make" but
48              many platforms, "gmake" is the preferred choice.
49    
50        -makefile NAME | -mf NAME
51          --makefile=NAME | -mf=NAME
52              Call the makefile "NAME".  The default is "Makefile".
53    
54        -makedepend NAME | -md NAME
55          --makedepend=NAME | -md=NAME
56              Use "NAME" for the MAKEDEPEND program.
57    
58        -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
59          -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
60              Specify the location of the MITgcm ROOTDIR as "NAME".
61              By default, genamke will try to find the location by
62              looking in parent directories (up to the 5th parent).
63    
64        -mods NAME | --mods NAME | -mo NAME | --mo NAME
65          -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME
66              Here, "NAME" specifies a list of directories that are
67              used for additional source code.  Files found in the
68              "mods list" are given preference over files of the same
69              name found elsewhere.
70    
71        -disable NAME | --disable NAME
72          -disable=NAME | --disable=NAME
73              Here "NAME" specifies a list of packages that we don't
74              want to use.  If this violates package dependencies,
75              genamke will exit with an error message.
76    
77        -enable NAME | --enable NAME
78          -enable=NAME | --enable=NAME
79              Here "NAME" specifies a list of packages that we wish
80              to specifically enable.  If this violates package
81              dependencies, genamke will exit with an error message.
82    
83        -standarddirs NAME | --standarddirs NAME
84          -standarddirs=NAME | --standarddirs=NAME
85              Here, "NAME" specifies a list of directories to be
86              used as the "standard" code.
87    
88        -fortran NAME | --fortran NAME | -fc NAME | --fc NAME
89          -fc=NAME | --fc=NAME
90              Use "NAME" as the fortran compiler.  By default, genmake
91              will search for a working compiler by trying a list of
92              "usual suspects" such as g77, f77, etc.
93    
94        -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
95              Use "NAME" as the C compiler.  By default, genmake
96              will search for a working compiler by trying a list of
97              "usual suspects" such as gcc, c89, cc, etc.
98    
99        -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4
100              Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW)
101              *only* works if CPP_EEOPTIONS.h allows this.
102    
103        -ignoretime | -ignore_time | --ignoretime | --ignore_time
104              Ignore all the "wall clock" routines entirely.  This will
105              not in any way hurt the model results -- it simply means
106              that the code that checks how long the model spends in
107              various routines will give junk values.
108    
109        -ts | --ts
110              Produce timing information per timestep
111        -papis | --papis
112              Produce summary MFlop/s (and IPC) with PAPI per timestep
113        -pcls | --pcls
114              Produce summary MFlop/s etc. with PCL per timestep
115        -foolad | --foolad
116              Fool the AD code generator
117        -papi | --papi
118              Performance analysis with PAPI
119        -pcl | --pcl
120              Performance analysis with PCL
121        -hpmt | --hpmt
122              Performance analysis with the HPM Toolkit
123    
124        -ieee | --ieee
125              use IEEE numerics.  Note that this option *only* works
126              if it is supported by the OPTFILE that is being used.
127        -devel | --devel
128              Add additional warning and debugging flags for development
129              (if supported by the OPTFILE); also switch to IEEE numerics.
130        -gsl | --gsl
131              Use GSL to control floating point rounding and precision
132    
133        -mpi | --mpi
134              Include MPI header files and link to MPI libraries
135        -mpi=PATH | --mpi=PATH
136              Include MPI header files and link to MPI libraries using MPI_ROOT
137              set to PATH. i.e. Include files from \$PATH/include, link to libraries
138              from \$PATH/lib and use binaries from \$PATH/bin.
139    
140        -omp | --omp
141              Activate OpenMP code + use Compiler option OMPFLAG
142        -omp=OMPFLAG | --omp=OMPFLAG
143              Activate OpenMP code + use Compiler option OMPFLAG
144    
145        -es | --es | -embed-source | --embed-source
146              Embed a tarball containing the full source code
147              (including the Makefile, etc.) used to build the
148              executable [off by default]
149    
150        -ds | --ds
151              Report genmake internal variables status (DUMPSTATE)
152              to file "genmake_state" (for debug purpose)
153    
154      While it is most often a single word, the "NAME" variables specified
155      above can in many cases be a space-delimited string such as:
156    
157        --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'
158        -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'
159        -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'
160    
161      which, depending upon your shell, may need to be single-quoted.
162    
163      For more detailed genmake documentation, please see:
164    
165        http://mitgcm.org/public/devel_HOWTO/
166    
167    EOF
168    
169        exit 1
170    }
171    
172  # Search for particular CPP #cmds associated with packages  # Search for particular CPP #cmds associated with packages
173  # usage: test_for_package_in_cpp_options CPP_file package_name  # usage: test_for_package_in_cpp_options CPP_file package_name
174  test_for_package_in_cpp_options() {  test_for_package_in_cpp_options() {
175      cpp_options=$1      cpp_options=$1
176      pkg=$2      pkg=$2
177      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg[ ]"
178      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg[ ]"
179      test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg[ ]"
180      test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg[ ]"
181        test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg$"
182        test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg$"
183        test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg$"
184        test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg$"
185  }  }
186    
187  # Search for particular CPP #cmds associated with MPI  # Search for particular CPP #cmds associated with MPI
188  # usage: test_for_mpi_in_cpp_eeoptions CPP_file  # usage: test_for_mpi_in_cpp_eeoptions CPP_file
189  test_for_mpi_in_cpp_eeoptions() {  test_for_mpi_in_cpp_eeoptions() {
190      cpp_options=$1      cpp_options=$1
191      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI[ ]"
192      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI[ ]"
193      test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI[ ]"
194      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI[ ]"
195        test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI$"
196        test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI$"
197        test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI$"
198        test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI$"
199  }  }
200    
201  # Search for particular string in a file. Return 1 if detected, 0 if not  # Search for particular string in a file. Return 1 if detected, 0 if not
# Line 39  test_for_string_in_file() { Line 208  test_for_string_in_file() {
208      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
209          printf "Error: In $file there is an illegal line: "          printf "Error: In $file there is an illegal line: "
210          grep -i "$strng" $file          grep -i "$strng" $file
211          return 1          exit 99
212      fi      fi
213      return 0      return 0
214  }  }
# Line 48  test_for_string_in_file() { Line 217  test_for_string_in_file() {
217  # the package list.  # the package list.
218  expand_pkg_groups() {  expand_pkg_groups() {
219      new_packages=      new_packages=
     PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"  
220      if test -r $PKG_GROUPS ; then      if test -r $PKG_GROUPS ; then
221          cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp          cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp
222          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp
# Line 59  expand_pkg_groups() { Line 227  expand_pkg_groups() {
227              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
228                  matched=1                  matched=1
229                  replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`                  replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
230                  echo "    replacing \"$i\" with: $replace"                  echo "    replacing \"$i\" with:$replace"
231                  new_packages="$new_packages $replace"                  new_packages="$new_packages $replace"
232              else              else
233                  new_packages="$new_packages $i"                  new_packages="$new_packages $i"
# Line 102  EOF Line 270  EOF
270              check_for_broken_Ff              check_for_broken_Ff
271          else          else
272              cat <<EOF 2>&1              cat <<EOF 2>&1
273  ERROR: Your file system cannot distinguish between *.F and *.f files  ERROR: Your file system cannot distinguish between *.F and *.f files
274    (fails the "cp" test) and this program cannot find a suitable    (fails the "cp" test) and this program cannot find a suitable
275    replacement extension.  Please try a different build environment or    replacement extension.  Please try a different build environment or
276    contact the <MITgcm-support@mitgcm.org> list for help.    contact the <MITgcm-support@mitgcm.org> list for help.
277    
278  EOF  EOF
# Line 122  EOF Line 290  EOF
290        stop        stop
291        end        end
292  EOF  EOF
293      test -e Makefile  &&  mv -f Makefile Makefile.bak      test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"
294      cat <<EOF >> Makefile      cat <<EOF >> $MAKEFILE
 %.$tfs : %.F  
295  .SUFFIXES:  .SUFFIXES:
296  genmake_hello.$tfs: genmake_hello.F  .SUFFIXES: .$tfs .F
297          $LN genmake_hello.F genmake_hello.$tfs  .F.$tfs:
298            $LN \$< \$@
299  EOF  EOF
300      $MAKE "genmake_hello."$tfs > /dev/null 2>&1      $MAKE -f $MAKEFILE "genmake_hello."$tfs > /dev/null 2>&1
301      RETVAL=$?      RETVAL=$?
302      if test "x$RETVAL" != x0 -o ! -e "genmake_hello."$tfs ; then      if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then
303          if test "x$FS" = x ; then          if test "x$FS" = x ; then
304              FS='for'              FS='for'
305              FS90='fr9'              FS90='fr9'
306              check_for_broken_Ff              check_for_broken_Ff
307          else          else
308              cat <<EOF 2>&1              echo "ERROR: test: '$MAKE -f $MAKEFILE genmake_hello.$tfs' Failed"
309  ERROR: Your file system cannot distinguish between *.F and *.f files              echo "       see simple makefile: '$MAKEFILE' (left here)"
310    (fails the "make/ln" test) and this program cannot find a suitable              echo "  Please check (1) your '$MAKE' command, (2) your '$LN' command"
311    replacement extension.  Please try a different build environment or              echo "           and (3) the allowed sufix '.F' and '.$tfs' in makefile"
312    contact the <MITgcm-support@mitgcm.org> list for help.              echo "  or contact the <MITgcm-support@mitgcm.org> list for help."
313                echo ""
 EOF  
314              exit -1              exit -1
315              return              return
316          fi          fi
317      fi      fi
318      rm -f genmake_hello.* Makefile      rm -f genmake_hello.* $MAKEFILE
319      test -e Makefile  &&  mv -f Makefile.bak Makefile      test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
320    
321      #  If we make it here, use the extensions      #  If we make it here, use the extensions
322      FS=$tfs      FS=$tfs
# Line 157  EOF Line 324  EOF
324      return      return
325  }  }
326    
327    look_for_makedepend()  {
 # Guess possible config options for this host  
 find_possible_configs()  {  
   
     tmp1=`uname`"_"`uname -m`  
     tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`  
     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  
328    
329      #  The "original" makedepend is part of the Imake system that is      #  The "original" makedepend is part of the Imake system that is
330      #  most often distributed with XFree86 or with an XFree86 source      #  most often distributed with XFree86 or with an XFree86 source
# Line 206  find_possible_configs()  { Line 344  find_possible_configs()  {
344      #    3) locally build and use the cyrus implementation      #    3) locally build and use the cyrus implementation
345      #    4) fall back to the buggy local xmakedpend script      #    4) fall back to the buggy local xmakedpend script
346      #      #
347        echo >> $LOGFILE
348        echo "running: look_for_makedepend()" >> $LOGFILE
349        if test "x${MAKEDEPEND}" != x ; then
350            echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
351            RETVAL=$?
352            if test x"$RETVAL" = x0 ; then
353                build_cyrus_makedepend
354                RETVAL=$?
355                if test "x$RETVAL" != x0 ; then
356                    echo "WARNING: unable to build cyrus-makedepend. Try 'makedepend'"
357                    MAKEDEPEND=
358                fi
359            else
360                echo "${MAKEDEPEND}" | grep 'tools.xmakedepend' > /dev/null 2>&1
361                RETVAL=$?
362                if test "x$RETVAL" = x0 ; then
363                    MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
364                fi
365                echo " -->     MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
366            fi
367        fi
368      if test "x${MAKEDEPEND}" = x ; then      if test "x${MAKEDEPEND}" = x ; then
369        which makedepend > /dev/null 2>&1          which makedepend > /dev/null 2>&1
370        RV0=$?          RV0=$?
371        cat <<EOF >> genmake_tc.f          test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"
372            #  echo 'MAKEFILE="'$MAKEFILE'"'
373            cat <<EOF >> $MAKEFILE
374    #   THIS IS A TEST MAKEFILE GENERATED BY "genmake2"
375    #
376    #   Some "makedepend" implementations will die if they cannot
377    #   find a Makefile -- so this file is here to gives them an
378    #   empty one to find and parse.
379    EOF
380            cat <<EOF >> genmake_tc.f
381        program test        program test
382        write(*,*) 'test'        write(*,*) 'test'
383        stop        stop
384        end        end
385  EOF  EOF
386        makedepend genmake_tc.f > /dev/null 2>&1          makedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1
387        RV1=$?          RV1=$?
388        if test ! "x${RV0}${RV1}" = x00 ; then          test -f $MAKEFILE  &&  rm -f $MAKEFILE
389           echo "    a system-default makedepend was not found."          test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
390            if test "x${RV0}${RV1}" = x00 ; then
391           #  Try to build the cyrus impl              MAKEDEPEND=makedepend
392           rm -f ./genmake_cy_md              echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
393           (          else
394               cd $ROOTDIR/tools/cyrus-imapd-makedepend  \              echo "    system-default makedepend not found. Try to build cyrus-makedepend"
395                   &&  ./configure > /dev/null 2>&1  \              #  Try to build the cyrus implementation
396                   &&  make > /dev/null 2>&1              build_cyrus_makedepend
397               if test -x ./makedepend.exe ; then              RETVAL=$?
398                   $LN ./makedepend.exe ./makedepend              if test "x$RETVAL" != x0 ; then
399               fi                  echo "WARNING: unable to build cyrus-makedepend. Use local xmakedepend"
400               ./makedepend ifparser.c > /dev/null 2>&1  \                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
401                   &&  echo "true"                  echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
402           ) > ./genmake_cy_md              fi
403           grep true ./genmake_cy_md > /dev/null 2>&1          fi
          RETVAL=$?  
          if test "x$RETVAL" = x0 ; then  
              MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'  
          else  
              MAKEDEPEND='$(TOOLSDIR)/xmakedepend'  
          fi  
          rm -f ./genmake_cy_md  
       fi  
404      fi      fi
405    }
406    
407      # look for possible fortran compilers  build_cyrus_makedepend()  {
408      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"      echo >> $LOGFILE
409      p_FC=      echo "running: build_cyrus_makedepend()" >> $LOGFILE
410        rm -f ./genmake_cy_md
411        (
412            cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
413                &&  ./configure > /dev/null 2>&1  \
414                &&  make > /dev/null 2>&1
415            if test -x ./makedepend.exe ; then
416                $LN ./makedepend.exe ./makedepend
417            fi
418            ./makedepend ifparser.c > /dev/null 2>&1  \
419                &&  echo "true"
420        ) > ./genmake_cy_md
421        grep true ./genmake_cy_md > /dev/null 2>&1
422        RETVAL=$?
423        rm -f ./genmake_cy_md
424        if test "x$RETVAL" = x0 ; then
425            MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
426            echo " --> set MAKEDEPEND=${MAKEDEPEND}" >> $LOGFILE
427            return 0
428        else
429            echo "WARNING: fail to build cyrus-imapd-makedepend" >> $LOGFILE
430            return 1
431        fi
432    }
433    
434    build_embed_encode()
435    {
436        printf "  building the embed-encode utility...  "
437        if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then
438            if test ! -d "$ROOTDIR/tools/embed_encode" ; then
439                echo
440                echo "    Error: can't locate \"$ROOTDIR/tools/embed_encode\""
441                echo
442                EMBED_SRC=f
443                return 1
444            fi
445            clist="cc gcc c89 $CC"
446            for ic in $clist ; do
447                comm="$ic -o encode_files encode_files.c"
448                ( cd $ROOTDIR/tools/embed_encode && $comm ) > /dev/null 2>&1
449                RETVAL=$?
450                if test "x$RETVAL" = x0 ; then
451                    echo "OK"
452                    return 0
453                fi
454            done
455            echo
456            echo "    Error: unable to build $ROOTDIR/embed_encode/encode_files"
457            echo "      so it has been disabled"
458            echo
459            EMBED_SRC=f
460            return 1
461        fi
462        echo "OK"
463    }
464    
465    #  look for possible C compilers
466    look_for_C_compilers() {
467        echo >> $LOGFILE
468        echo "running: look_for_C_compilers()" >> $LOGFILE
469        rm -f ./genmake_hello.c  ./genmake_hello
470        cat >> genmake_hello.c << EOF
471    #include <stdio.h>
472    int main(int argc, char **argv) {
473      printf("Hello!\n");
474      return 0;
475    }
476    EOF
477        tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc icc"
478        p_CC=
479      for c in $tmp ; do      for c in $tmp ; do
480          rm -f ./hello.f ./hello          COMM="$c $CFLAGS -o genmake_hello genmake_hello.c"
481          cat >> hello.f <<EOF          echo $COMM >> $LOGFILE
482            $COMM >> $LOGFILE 2>&1
483            RETVAL=$?
484            if test "x${RETVAL}" = x0 ; then
485                echo " $c test successful" >> $LOGFILE
486                p_CC="$p_CC $c"
487            fi
488        done
489        rm -f ./genmake_hello.c ./genmake_hello
490        if test "x${p_CC}" = x ; then
491            cat 1>&2 <<EOF
492    
493    Error: No C compilers were found in your path.  Please specify one using:
494    
495        1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
496        2) the CC or MITGCM_CC environment variables.
497    
498    EOF
499            exit 1
500        else
501            echo "  The possible C compilers found in your path are: $p_CC" | tee -a $LOGFILE
502            if test "x$CC" = x ; then
503                CC=`echo $p_CC | $AWK '{print $1}'`
504                echo "  Setting C compiler to: "$CC
505            fi
506        fi
507        echo " --> set CC='$CC'" >> $LOGFILE
508    }
509    
510    # Guess possible config options for this host
511    find_possible_optfile()  {
512    
513        echo >> $LOGFILE
514        echo "running: find_possible_optfile()" >> $LOGFILE
515        tmp1=`uname`"_"`uname -m`
516        tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
517        tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
518        tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
519        tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
520        tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
521        PLATFORM=$tmp3
522        echo $PLATFORM | grep cygwin > /dev/null 2>&1  &&  PLATFORM=cygwin_ia32
523        OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
524        echo "  The platform appears to be:  $PLATFORM" | tee -a $LOGFILE
525    
526        #================================================================
527        #  look for possible FORTRAN compilers
528        echo "  look for possible FORTRAN compilers" >> $LOGFILE
529        tmp="$MITGCM_FC $FC efc gfortran g77 f77 pgf77 pgf95 ifc ifort f90 f95 mpif77 mpf77 mpxlf95 g95"
530        p_FC=
531        rm -f ./genmake_hello.f
532        cat >> genmake_hello.f <<EOF
533        program hello        program hello
534        do i=1,3        do i=1,3
535          print *, 'hello world : ', i          print *, 'hello world : ', i
536        enddo        enddo
537        end        end
538  EOF  EOF
539          $c -o hello hello.f > /dev/null 2>&1      for f in $tmp ; do
540            COMM="$f -o genmake_hello genmake_hello.f"
541            echo $COMM >> $LOGFILE
542            $COMM >> $LOGFILE 2>&1
543          RETVAL=$?          RETVAL=$?
544          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
545              p_FC="$p_FC $c"              echo " $f test successful" >> $LOGFILE
546                p_FC="$p_FC $f"
547          fi          fi
548      done      done
549      rm -f ./hello.f ./hello      rm -f ./genmake_hello.f ./genmake_hello
550      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
551          cat 1>&2 <<EOF          cat 1>&2 <<EOF
552    
# Line 269  Error: No Fortran compilers were found i Line 554  Error: No Fortran compilers were found i
554    
555      1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),      1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
556      2) a command-line option (eg. "-fc NAME"), or      2) a command-line option (eg. "-fc NAME"), or
557      3) the MITGCM_FC environment variable.      3) the FC or MITGCM_FC environment variables.
558    
559  EOF  EOF
560          exit 1          exit 1
561      else      else
562          echo "  The possible FORTRAN compilers found in your path are:"          echo "  The possible FORTRAN compilers found in your path are: $p_FC" | tee -a $LOGFILE
563          echo "   "$p_FC      fi
564          if test "x$FC" = x ; then  
565              FC=`echo $p_FC | $AWK '{print $1}'`      #  Use the first of the compilers found in the current PATH
566              echo "  Setting FORTRAN compiler to: "$FC      #  that has a correctly-named optfile
567          fi      if test "x$OPTFILE" = x  -a  "x$FC" = x ; then
568            for i in $p_FC ; do
569                OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
570                if test -r $OPTFILE ; then
571                    echo "  Setting OPTFILE to: "$OPTFILE | tee -a $LOGFILE
572                    break
573                fi
574            done
575      fi      fi
576    
577      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
578          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
579          if test ! -r $OPTFILE ; then          if test ! -r $OPTFILE ; then
580               echo "  I looked for the file "$OPTFILE" but did not find it"               echo "  I looked for the file "$OPTFILE" but did not find it"
581          fi          fi
582      fi      fi
583  #    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  
584      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
585          cat 1>&2 <<EOF          cat 1>&2 <<EOF
586    
# Line 314  Error: No options file was found in:  $R Line 596  Error: No options file was found in:  $R
596  EOF  EOF
597          exit 1          exit 1
598      fi      fi
599        
600  #     # look for possible MPI libraries  #     # look for possible MPI libraries
601  #     mpi_libs=  #     mpi_libs=
602  #     mpi_fort=`which mpif77 2>/dev/null`  #     mpi_fort=`which mpif77 2>/dev/null`
# Line 333  EOF Line 615  EOF
615  #       if test "x${RETVAL}" = x0 ; then  #       if test "x${RETVAL}" = x0 ; then
616  #           a=`cat out`  #           a=`cat out`
617  #           for i in $a ; do  #           for i in $a ; do
618  #               case $i in  #               case $i in
619  #                   -*)  #                   -*)
620  #                       mpi_libs="$mpi_libs $i" ;;  #                       mpi_libs="$mpi_libs $i" ;;
621  #               esac  #               esac
# Line 343  EOF Line 625  EOF
625  #       fi  #       fi
626  #       rm -f test.f out  #       rm -f test.f out
627  #     fi  #     fi
   
628  }  }
629    
630  #  Parse the package dependency information  #  Parse the package dependency information
# Line 352  get_pdepend_list()  { Line 633  get_pdepend_list()  {
633      #  strip the comments and then convert the dependency file into      #  strip the comments and then convert the dependency file into
634      #  two arrays: PNAME, DNAME      #  two arrays: PNAME, DNAME
635      cat $1 | sed -e 's/#.*$//g' \      cat $1 | sed -e 's/#.*$//g' \
636          | $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}' \
637          > ./.pd_tmp          > ./.pd_tmp
638        RETVAL=$?
639        if test ! "x${RETVAL}" = x0 ; then
640          echo "Error: unable to parse package dependencies -- please check PKG_DEPEND=\"$1\""
641          exit 1
642        fi
643      . ./.pd_tmp      . ./.pd_tmp
644      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.  
   
     -[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.  
   
     -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.  
   
     -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  
645  }  }
646    
647  #  Build a CPP macro to automate calling C routines from FORTRAN  #  Build a CPP macro to automate calling C routines from FORTRAN
648  get_fortran_c_namemangling()  {  get_fortran_c_namemangling()  {
649    
650        #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
651        if test ! "x$FC_NAMEMANGLE" = x ; then
652            return 0
653        fi
654        echo " running: get_fortran_c_namemangling()" >> $LOGFILE
655    
656      default_nm="#define FC_NAMEMANGLE(X) X ## _"      default_nm="#define FC_NAMEMANGLE(X) X ## _"
657        
658      cat > genmake_test.c <<EOF      cat > genmake_test.c <<EOF
659  void tcall( char * string ) { tsub( string ); }  void tcall( char * string ) { tsub( string ); }
660  EOF  EOF
661      $MAKE genmake_test.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_test.c"
662        echo ' '$COMM >> $LOGFILE
663        $COMM >> $LOGFILE 2>&1
664      RETVAL=$?      RETVAL=$?
665      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
666          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
667          cat <<EOF>> genmake_errors          cat <<EOF>> $LOGFILE
668    
669  WARNING: C test compile fails   WARNING: C test compile fails
670  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
671  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
672  EOF  EOF
673          return 1          return 1
674      fi      fi
675      c_tcall=`nm genmake_test.o | grep 'T ' | grep tcall | cut -d ' ' -f 3`      c_tcall=`nm genmake_test.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
676      RETVAL=$?      RETVAL=$?
677      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
678          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
679          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
680    
681  WARNING: The "nm" command failed.   WARNING: The "nm" command failed.
682  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
683  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
684  EOF  EOF
685          return 1          return 1
686      fi      fi
687      cat > genmake_tcomp.f <<EOF      cat > genmake_tcomp.$FS <<EOF
688        subroutine tcall( string )        subroutine tcall( string )
689        character*(*) string        character*(*) string
690        call tsub( string )        call tsub( string )
691        end        end
692  EOF  EOF
693      $FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1      COMM="$FC $FFLAGS -c genmake_tcomp.$FS"
694        echo ' '$COMM >> $LOGFILE
695        $COMM >> $LOGFILE 2>&1
696      RETVAL=$?      RETVAL=$?
697      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
698          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
699          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
700    
701  WARNING: FORTRAN test compile fails -- please see "genmake_errors"   WARNING: FORTRAN test compile fails -- please see '$LOGFILE'
702  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
703  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
704  EOF  EOF
705          return 1          return 1
706      fi      fi
707      f_tcall=`nm genmake_tcomp.o | grep 'T ' | grep tcall | cut -d ' ' -f 3`      f_tcall=`nm genmake_tcomp.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
708      RETVAL=$?      RETVAL=$?
709      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
710          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
711          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
712    
713  WARNING: The "nm" command failed.   WARNING: The "nm" command failed.
714  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
715  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
716  EOF  EOF
717          return 1          return 1
718      fi      fi
# Line 556  EOF Line 738  EOF
738    
739      #  cleanup the testing files      #  cleanup the testing files
740      rm -f genmake_tcomp.* genmake_test.*      rm -f genmake_tcomp.* genmake_test.*
 }  
741    
742        echo " --> set FC_NAMEMANGLE='$FC_NAMEMANGLE'" >> $LOGFILE
743    }
744    
745  check_HAVE_CLOC()  {  check_HAVE_CLOC()  {
746        echo >> $LOGFILE
747        echo "running: check_HAVE_CLOC()" >> $LOGFILE
748      get_fortran_c_namemangling      get_fortran_c_namemangling
749      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
750  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 576  void FC_NAMEMANGLE(cloc) ( double *curti Line 761  void FC_NAMEMANGLE(cloc) ( double *curti
761   *curtim = *curtim/1.E6;   *curtim = *curtim/1.E6;
762  }  }
763  EOF  EOF
764      make genmake_tc_1.o >> genmake_tc.log 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
765        echo $COMM >> $LOGFILE
766        $COMM >> $LOGFILE 2>&1
767      RET_C=$?      RET_C=$?
768      cat <<EOF > genmake_tc_2.f      cat <<EOF > genmake_tc_2.$FS
769        program hello        program hello
770        Real*8 wtime        REAL*8 wtime
771        external cloc        external cloc
772        call cloc(wtime)        call cloc(wtime)
773        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
774        end program hello        end
775  EOF  EOF
776      $FC $FFLAGS -o genmake_tc genmake_tc_2.f genmake_tc_1.o >> genmake_tc.log 2>&1      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
777        echo $COMM >> $LOGFILE
778        $COMM >> $LOGFILE 2>&1
779      RET_F=$?      RET_F=$?
780      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> $LOGFILE 2>&1
781      RETVAL=$?      RETVAL=$?
782      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
783          HAVE_CLOC=t          HAVE_CLOC=t
         DEFINES="$DEFINES -DHAVE_CLOC"  
784      fi      fi
785      rm -f genmake_tc*      rm -f genmake_tc*
786        echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE
787    }
788    
789    check_HAVE_SIGREG()  {
790        if test ! "x$HAVE_SIGREG" = x ; then
791            return
792        fi
793        echo >> $LOGFILE
794        echo "running: check_HAVE_SIGREG()" >> $LOGFILE
795        get_fortran_c_namemangling
796        cat <<EOF > genmake_tc_1.c
797    $FC_NAMEMANGLE
798    #include <stdlib.h>
799    #include <stdio.h>
800    #include <signal.h>
801    #include <errno.h>
802    #include <ucontext.h>
803    
804    int * ip;
805    
806    static void killhandler(
807        unsigned int sn, siginfo_t  si, struct ucontext *sc )
808    {
809        *ip = *ip + 1;
810        return;
811    }
812    
813    void FC_NAMEMANGLE(sigreg) (int * aip)
814    {
815        struct sigaction s;
816        ip = aip;
817        s.sa_flags = SA_SIGINFO;
818        s.sa_sigaction = (void *)killhandler;
819        if(sigaction (SIGTERM,&s,(struct sigaction *)NULL)) {
820            printf("Sigaction returned error = %d\n", errno);
821            exit(0);
822        }
823        return;
824    }
825    EOF
826        COMM="$CC $CFLAGS -c genmake_tc_1.c"
827        echo $COMM >> $LOGFILE
828        $COMM >> $LOGFILE 2>&1
829        RET_C=$?
830        cat <<EOF > genmake_tc_2.$FS
831          program hello
832          integer anint
833          common /iv/ anint
834          external sigreg
835          call sigreg(anint)
836          end
837    EOF
838        cat genmake_tc_2.$FS >> $LOGFILE
839        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
840        echo $COMM >> $LOGFILE
841        $COMM >> $LOGFILE 2>&1
842        RETVAL=$?
843        if test "x$RETVAL" = x0 ; then
844            HAVE_SIGREG=t
845        fi
846        rm -f genmake_tc*
847        echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE
848  }  }
849    
850    check_HAVE_SETRLSTK()  {
851        if test ! "x$HAVE_SETRLSTK" = x ; then
852            return
853        fi
854        echo >> $LOGFILE
855        echo "running: check_HAVE_SETRLSTK()" >> $LOGFILE
856        get_fortran_c_namemangling
857        cat <<EOF > genmake_tc_1.c
858    $FC_NAMEMANGLE
859    #include <sys/time.h>
860    #include <sys/resource.h>
861    #include <unistd.h>
862    void FC_NAMEMANGLE(setrlstk) ()
863    {
864        struct rlimit rls;
865        rls.rlim_cur = RLIM_INFINITY;
866        rls.rlim_max = RLIM_INFINITY;
867        setrlimit(RLIMIT_STACK, &rls);
868        return;
869    }
870    EOF
871        COMM="$CC $CFLAGS -c genmake_tc_1.c"
872        echo $COMM >> $LOGFILE
873        $COMM >> $LOGFILE 2>&1
874        RET_C=$?
875        cat <<EOF > genmake_tc_2.$FS
876          program hello
877          external setrlstk
878          call setrlstk()
879          end
880    EOF
881        cat genmake_tc_2.$FS >> $LOGFILE
882        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
883        echo $COMM >> $LOGFILE
884        $COMM >> $LOGFILE 2>&1
885        RETVAL=$?
886        if test "x$RETVAL" = x0 ; then
887            HAVE_SETRLSTK=t
888        fi
889        rm -f genmake_tc*
890        echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE
891    }
892    
893    check_HAVE_STAT()  {
894        echo >> $LOGFILE
895        echo "running: check_HAVE_STAT()" >> $LOGFILE
896        get_fortran_c_namemangling
897        cat <<EOF > genmake_tc_1.c
898    $FC_NAMEMANGLE
899    #include <stdio.h>
900    #include <stdlib.h>
901    #include <unistd.h>
902    #include <sys/stat.h>
903    #include <sys/types.h>
904    void FC_NAMEMANGLE(tfsize) ( int *nbyte )
905    {
906        char name[512];
907        struct stat astat;
908    
909        name[0] = 'a'; name[1] = '\0';
910        if (! stat(name, &astat))
911            *nbyte = (int)(astat.st_size);
912        else
913            *nbyte = -1;
914    }
915    EOF
916        COMM="$CC $CFLAGS -c genmake_tc_1.c"
917        echo $COMM >> $LOGFILE
918        $COMM >> genmake_tc.log 2>&1
919        RET_C=$?
920        cat <<EOF > genmake_tc_2.$FS
921          program hello
922          integer nbyte
923          call tfsize(nbyte)
924          print *," HELLO WORLD", nbyte
925          end
926    EOF
927        cat genmake_tc_2.$FS >> $LOGFILE
928        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
929        echo $COMM >> $LOGFILE
930        $COMM >> genmake_tc.log 2>&1
931        RETVAL=$?
932        if test "x$RETVAL" = x0 ; then
933            HAVE_STAT=t
934        fi
935        rm -f genmake_tc*
936        echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE
937    }
938    
939  check_netcdf_libs()  {  check_netcdf_libs()  {
940      cat <<EOF > genmake_tnc.for      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
941            return
942        fi
943        echo >> $LOGFILE
944        echo "running: check_netcdf_libs()" >> $LOGFILE
945        cat <<EOF > genmake_tnc.F
946        program fgennc        program fgennc
947  #include "netcdf.inc"  #include "netcdf.inc"
948    EOF
949        if test ! "x$MPI" = x ; then
950            echo '#include "mpif.h"' >> genmake_tnc.F
951        fi
952        cat <<EOF >> genmake_tnc.F
953        integer iret, ncid, xid        integer iret, ncid, xid
954        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
955        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
# Line 611  check_netcdf_libs()  { Line 959  check_netcdf_libs()  {
959        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
960        end        end
961  EOF  EOF
962      $CPP genmake_tnc.for > genmake_tnc.f  \      echo "===  genmake_tnc.F  >>>" > genmake_tnc.log
963          &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1      cat genmake_tnc.F >> genmake_tnc.log
964        echo "<<<  genmake_tnc.F  ===" >> genmake_tnc.log
965        RET_CPP=f
966        COMM="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES"
967        echo "$COMM" >> genmake_tnc.log
968        eval $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t
969        if test "x$RET_CPP" = xf ; then
970            echo "  WARNING: CPP failed to pre-process the netcdf test." \
971                >> genmake_tnc.log
972            echo "    Please check that \$INCLUDES is properly set." \
973                >> genmake_tnc.log
974        fi
975        echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log
976        echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc.o $LIBS" >> genmake_tnc.log
977        $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
978            &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
979      RET_COMPILE=$?      RET_COMPILE=$?
980      test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1      cat genmake_tnc.log >> $LOGFILE
981      RETVAL=$?  
982      if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then      #EH3  Remove test program execution for machines that either disallow
983        #EH3  execution or cannot support it (eg. cross-compilers)
984        #EH3
985        #EH3 test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
986        #EH3 RETVAL=$?
987        #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
988    
989        if test "x$RET_COMPILE" = x0 ; then
990          HAVE_NETCDF=t          HAVE_NETCDF=t
991            echo "check_netcdf: successful" >> $LOGFILE
992      else      else
993          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
994          $CPP genmake_tnc.for > genmake_tnc.f  \          echo "==> try again with added '-lnetcdf'" > genmake_tnc.log
995              &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \          echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
996              $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
997            echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
998            cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null  \
999                &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
1000                &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
1001          RET_COMPILE=$?          RET_COMPILE=$?
1002          test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1          echo >> $LOGFILE
1003          RETVAL=$?          cat genmake_tnc.log >> $LOGFILE
1004          if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then          if test "x$RET_COMPILE" = x0 ; then
1005              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
1006              HAVE_NETCDF=t              HAVE_NETCDF=t
1007                echo "check_netcdf: successful" >> $LOGFILE
1008          else          else
1009              cat genmake_tnc.log >> genmake_warnings          # try again with "-lnetcdff" added to the libs
1010                echo "==> try again with added '-lnetcdff -lnetcdf'" > genmake_tnc.log
1011                echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
1012                echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
1013                echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
1014                cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null  \
1015                    &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
1016                    &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdff -lnetcdf >> genmake_tnc.log 2>&1
1017                RET_COMPILE=$?
1018                echo >> $LOGFILE
1019                cat genmake_tnc.log >> $LOGFILE
1020                if test "x$RET_COMPILE" = x0 ; then
1021                    LIBS="$LIBS -lnetcdff -lnetcdf"
1022                    HAVE_NETCDF=t
1023                    echo "check_netcdf: successful" >> $LOGFILE
1024                fi
1025          fi          fi
1026      fi      fi
1027      rm -f genmake_tnc*      rm -f genmake_tnc*
1028        echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE
1029  }  }
1030    
1031    check_lapack_libs()  {
1032        if test ! "x$SKIP_LAPACK_CHECK" = x ; then
1033            return
1034        fi
1035        echo >> $LOGFILE
1036        echo "running: check_lapack_libs()" >> $LOGFILE
1037        cat <<EOF > genmake_tla.F
1038          program fgenla
1039          integer info
1040          integer ipiv( 2 )
1041          double precision ab( 4, 2 ), b( 2 )
1042          data ab / 0., 0., 1., 2., 0., 2., 1., 0. /
1043          data b / 1., 1. /
1044          call dgbsv( 2, 1, 1, 1, ab, 4, ipiv, b, 2, info )
1045          IF (info .NE. 0) write(*,*) 'Error:', info
1046          write(*,*) b
1047          end
1048    EOF
1049        echo "===  genmake_tla.F  >>>" > genmake_tla.log
1050        cat genmake_tla.F >> genmake_tla.log
1051        echo "<<<  genmake_tla.F  ===" >> genmake_tla.log
1052        RET_CPP=f
1053        COMM="cat genmake_tla.F | $CPP $DEFINES $INCLUDES"
1054        echo "$COMM" >> genmake_tla.log
1055        eval $COMM > genmake_tla.$FS 2>/dev/null  &&  RET_CPP=t
1056        if test "x$RET_CPP" = xf ; then
1057            echo "  WARNING: CPP failed to pre-process the lapack test." \
1058                >> genmake_tla.log
1059            echo "    Please check that \$INCLUDES is properly set." \
1060                >> genmake_tla.log
1061        fi
1062        echo "$FC $FFLAGS $FOPTIM -c genmake_tla.$FS  \ " >> genmake_tla.log
1063        echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tla.o $LIBS" >> genmake_tla.log
1064        $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1065            &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS >> genmake_tla.log 2>&1
1066        RET_COMPILE=$?
1067        cat genmake_tla.log >> $LOGFILE
1068    
1069        # test program execution not always possible (see check_netcdf_libs)
1070        #
1071        #test -x ./genmake_tla  &&  ./genmake_tla >> genmake_tla.log 2>&1
1072        #RETVAL=$?
1073        #if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
1074    
1075        if test "x$RET_COMPILE" = x0 ; then
1076            HAVE_LAPACK=t
1077            echo "check_lapack: successful" >> $LOGFILE
1078        else
1079            # try again with "-llapack" added to the libs
1080            echo "==> try again with added '-llapack'" > genmake_tla.log
1081            echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1082            echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1083            echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack" >> genmake_tla.log
1084            cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1085                &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1086                &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack >> genmake_tla.log 2>&1
1087            RET_COMPILE=$?
1088            echo >> $LOGFILE
1089            cat genmake_tla.log >> $LOGFILE
1090            if test "x$RET_COMPILE" = x0 ; then
1091                LIBS="$LIBS -llapack"
1092                HAVE_LAPACK=t
1093                echo "check_lapack: successful" >> $LOGFILE
1094            else
1095            # try again with "-lf77blas -lcblas" added to the libs
1096                echo "==> try again with added '-llapack -lf77blas -lcblas'" > genmake_tla.log
1097                echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1098                echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1099                echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas" >> genmake_tla.log
1100                cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1101                    &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1102                    &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas >> genmake_tla.log 2>&1
1103                RET_COMPILE=$?
1104                echo >> $LOGFILE
1105                cat genmake_tla.log >> $LOGFILE
1106                if test "x$RET_COMPILE" = x0 ; then
1107                    LIBS="$LIBS -llapack -lf77blas -lcblas"
1108                    HAVE_LAPACK=t
1109                    echo "check_lapack: successful" >> $LOGFILE
1110                else
1111                # try again with "-latlas" added to the libs
1112                    echo "==> try again with added '-llapack -lf77blas -lcblas -latlas'" > genmake_tla.log
1113                    echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log
1114                    echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log
1115                    echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas" >> genmake_tla.log
1116                    cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null  \
1117                        &&  $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1  \
1118                        &&  $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas >> genmake_tla.log 2>&1
1119                    RET_COMPILE=$?
1120                    echo >> $LOGFILE
1121                    cat genmake_tla.log >> $LOGFILE
1122                    if test "x$RET_COMPILE" = x0 ; then
1123                        LIBS="$LIBS -llapack -lf77blas -lcblas -latlas"
1124                        HAVE_LAPACK=t
1125                        echo "check_lapack: successful" >> $LOGFILE
1126                    fi
1127                fi
1128            fi
1129        fi
1130        rm -f genmake_tla*
1131        echo " --> set HAVE_LAPACK='$HAVE_LAPACK'" >> $LOGFILE
1132    }
1133    
1134    
1135  ###############################################################################  ###############################################################################
# Line 649  PLATFORM= Line 1143  PLATFORM=
1143  LN=  LN=
1144  S64=  S64=
1145  KPP=  KPP=
1146  FC=  #FC=
1147  CPP=  #CC=gcc
1148    #CPP=
1149  LINK=  LINK=
1150  DEFINES=  DEFINES=
1151  PACKAGES=  PACKAGES=
1152  ENABLE=  ENABLE=
1153  DISABLE=  DISABLE=
1154  MAKEFILE=  # MAKEFILE=
1155  MAKEDEPEND=  # MAKEDEPEND=
1156  PDEPEND=  PKG_DEPEND=
1157  DUMPSTATE=t  PKG_GROUPS=
1158  PDEFAULT=  DUMPSTATE=f
1159  OPTFILE=  OPTFILE=
1160  INCLUDES="-I."  INCLUDES="-I. $INCLUDES"
1161  FFLAGS=  FFLAGS=
1162  FOPTIM=  FOPTIM=
1163    FEXTRAFLAGS=
1164    USE_EXTENDED_SRC=
1165    EXTENDED_SRC_FLAG=
1166    GET_FC_VERSION=
1167  CFLAGS=  CFLAGS=
1168  KFLAGS1=  KFLAGS1=
1169  KFLAGS2=  KFLAGS2=
# Line 675  NOOPTFILES= Line 1174  NOOPTFILES=
1174  NOOPTFLAGS=  NOOPTFLAGS=
1175  MPI=  MPI=
1176  MPIPATH=  MPIPATH=
1177    OMP=
1178    OMPFLAG=
1179    USE_R4=
1180    TS=
1181    PAPIS=
1182    PCLS=
1183    FOOLAD=
1184    PAPI=
1185    PCL=
1186    HPMT=
1187    GSL=
1188    DEVEL=
1189    HAVE_TEST_L=
1190    
1191  # DEFINES checked by test compilation  # DEFINES checked by test compilation or command-line
1192  HAVE_SYSTEM=  HAVE_SYSTEM=
1193  HAVE_FDATE=  HAVE_FDATE=
1194  FC_NAMEMANGLE=  FC_NAMEMANGLE=
1195  HAVE_CLOC=  HAVE_CLOC=
1196    # HAVE_SETRLSTK=
1197    HAVE_STAT=
1198  HAVE_NETCDF=  HAVE_NETCDF=
1199  HAVE_ETIME=  HAVE_ETIME=
1200    IGNORE_TIME=
1201    HAVE_LAPACK=
1202    
1203  MODS=  MODS=
1204  TOOLSDIR=  TOOLSDIR=
# Line 693  STANDARDDIRS="USE_THE_DEFAULT" Line 1209  STANDARDDIRS="USE_THE_DEFAULT"
1209  G2ARGS=  G2ARGS=
1210  BASH=  BASH=
1211  PWD=`pwd`  PWD=`pwd`
1212  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
1213  AWK=awk  test "x$AWK" = x   &&  AWK=awk
1214  THISHOSTNAME=`hostname`  EMBED_SRC=
1215    THISHOST=`hostname`
1216  THISCWD=`pwd`  THISCWD=`pwd`
1217  THISDATE=`date`  THISDATE=`date`
1218    THISUSER=`echo $USER`
1219    THISVER=
1220  MACHINE=`uname -a`  MACHINE=`uname -a`
1221  EXECUTABLE=  EXECUTABLE=
1222  EXEHOOK=  EXEHOOK=
1223  EXEDIR=  EXEDIR=
 PACKAGES_CONF=  
1224  IEEE=  IEEE=
1225  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
1226      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
# Line 723  FTL_TAF_FLAGS= Line 1241  FTL_TAF_FLAGS=
1241  SVD_TAMC_FLAGS=  SVD_TAMC_FLAGS=
1242  TAMC_EXTRA=  TAMC_EXTRA=
1243    
   
1244  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1245  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PKG_DEPEND PKG_GROUPS DISABLE ENABLE MAKEFILE MAKEDEPEND PLATFORM"
1246  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CC MPI OMP USE_R4 TS PAPIS PCLS PAPI PCL HPMT IEEE DEVEL GSL FEXTRAFLAGS"
1247    gm_s3="ROOTDIR STANDARDDIRS MODS DUMPSTATE"
1248    
1249  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1250  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "  gm_s4="LN S64 LINK MAKE PACKAGES INCLUDES FFLAGS FOPTIM"
1251  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
1252  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s6="TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"
1253  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s7="PWD THISHOST THISUSER THISDATE THISVER MACHINE"
1254  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"  gm_s8="FC_NAMEMANGLE HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME HAVE_LAPACK"
1255    
1256  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1257  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
1258  gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"  gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
1259  gm_s12="TAF_EXTRA TAMC_EXTRA"  gm_s12="TAF_EXTRA TAMC_EXTRA"
1260    
1261  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7"  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8"
1262  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"  gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
1263    
1264  cat <<EOF  cat <<EOF
1265    
1266  GENMAKE :  GENMAKE :
1267    
1268  A program for GENerating MAKEfiles for the MITgcm project.  For a  A program for GENerating MAKEfiles for the MITgcm project.
1269  quick list of options, use "genmake -h" or for more detail see:     For a quick list of options, use "genmake2 -h"
1270    or for more detail see the Developer's HOWTO manual at:
1271    http://mitgcm.org/devel_HOWTO/     http://mitgcm.org/public/docs.html
1272    
1273  EOF  EOF
1274    
1275    LOGFILE="genmake.log"
1276    #- clean-up previous genmake logfiles:
1277    rm -f genmake_state genmake_*optfile $LOGFILE
1278    
1279  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
1280  gm_local="genmake_local"  gm_local="genmake_local"
 for i in . $MODS ; do  
     if test -r $i/$gm_local ; then  
         . $i/$gm_local  
         break  
     fi  
 done  
1281  printf "  getting local config information:  "  printf "  getting local config information:  "
1282  if test -e $gm_local ; then  if test -f $gm_local ; then
1283      echo "using $gm_local"      echo "using $gm_local"
1284      . $gm_local      . $gm_local
1285      # echo "DISABLE=$DISABLE"      # echo "DISABLE=$DISABLE"
# Line 772  else Line 1288  else
1288      echo "none found"      echo "none found"
1289  fi  fi
1290    
1291  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
 #OPTIONS=  
 #n=0  
 #for i ; do  
 #   echo "$i  $n"  
 #   setvar="OPTIONS[$n]='$i'"  
 #   #  echo "  $setvar"  
 #   eval "$setvar"  
 #   n=$(( $n + 1 ))  
 #done  
1292  #parse_options  #parse_options
1293  ac_prev=  ac_prev=
1294  for ac_option ; do  for ac_option in "$@" ; do
1295    
1296      G2ARGS="$G2ARGS \"$ac_option\""      G2ARGS="$G2ARGS \"$ac_option\""
1297    
# Line 794  for ac_option ; do Line 1301  for ac_option ; do
1301          ac_prev=          ac_prev=
1302          continue          continue
1303      fi      fi
1304        
1305      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
1306        
1307      case $ac_option in      case $ac_option in
1308            
1309          -help | --help | -h | --h)          -help | --help | -h | --h)
1310              usage ;;              usage ;;
1311            
1312          -nooptfile | --nooptfile)          -nooptfile | --nooptfile)
1313              OPTFILE="NONE" ;;              OPTFILE="NONE" ;;
1314          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
1315              ac_prev=OPTFILE ;;              ac_prev=OPTFILE ;;
1316          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
1317              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
1318            
1319          -adoptfile | --adoptfile | -adof | --adof)          -adoptfile | --adoptfile | -adof | --adof)
1320              ac_prev=AD_OPTFILE ;;              ac_prev=AD_OPTFILE ;;
1321          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
1322              AD_OPTFILE=$ac_optarg ;;              AD_OPTFILE=$ac_optarg ;;
1323            
1324          -pdepend | --pdepend)          -pdepend | --pdepend)
1325              ac_prev=PDEPEND ;;              ac_prev=PKG_DEPEND ;;
1326          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
1327              PDEPEND=$ac_optarg ;;              PKG_DEPEND=$ac_optarg ;;
1328            
1329          -pdefault | --pdefault)          -pgroups | --pgroups)
1330              ac_prev=PDEFAULT ;;              ac_prev=PKG_GROUPS ;;
1331          -pdefault=* | --pdefault=*)          -pgroups=* | --pgroups=*)
1332              PDEFAULT=$ac_optarg ;;              PKG_GROUPS=$ac_optarg ;;
1333            
1334          -make | --make | -m | --m)          -make | --make | -m | --m)
1335              ac_prev=MAKE ;;              ac_prev=MAKE ;;
1336          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
1337              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
1338            
1339          -bash | --bash)          -bash | --bash)
1340              ac_prev=BASH ;;              ac_prev=BASH ;;
1341          -bash=* | --bash=*)          -bash=* | --bash=*)
1342              BASH=$ac_optarg ;;              BASH=$ac_optarg ;;
1343            
1344          -makedepend | --makedepend | -md | --md)          -makedepend | --makedepend | -md | --md)
1345              ac_prev=MAKEDEPEND ;;              ac_prev=MAKEDEPEND ;;
1346          -makedepend=* | --makedepend=* | -md=* | --md=*)          -makedepend=* | --makedepend=* | -md=* | --md=*)
1347              MAKEDEPEND=$ac_optarg ;;              MAKEDEPEND=$ac_optarg ;;
1348            
1349          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -ma | --ma)
1350              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
1351          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -ma=* | --ma=*)
1352              MAKEFILE=$ac_optarg ;;              MAKEFILE=$ac_optarg ;;
1353            
1354          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)
1355              echo "ERROR: The platform option has been removed.  Please specify"              echo "ERROR: The platform option has been removed.  Please specify"
1356              echo "  the build options using the \"optfile\" mechanism."              echo "  the build options using the \"optfile\" mechanism."
1357              echo              echo
1358              usage              usage
1359              ;;              ;;
1360            
1361          -rootdir | --rootdir | -rd | --rd)          -rootdir | --rootdir | -rd | --rd)
1362              ac_prev=ROOTDIR ;;              ac_prev=ROOTDIR ;;
1363          -rootdir=* | --rootdir=* | -rd=* | --rd=*)          -rootdir=* | --rootdir=* | -rd=* | --rd=*)
1364              ROOTDIR=$ac_optarg ;;              ROOTDIR=$ac_optarg ;;
1365            
1366          -mods | --mods | -mo | --mo)          -mods | --mods | -mo | --mo)
1367              ac_prev=MODS ;;              ac_prev=MODS ;;
1368          -mods=* | --mods=* | -mo=* | --mo=*)          -mods=* | --mods=* | -mo=* | --mo=*)
1369              MODS=$ac_optarg ;;              MODS=$ac_optarg ;;
1370            
1371          -disable | --disable)          -disable | --disable)
1372              ac_prev=DISABLE ;;              ac_prev=DISABLE ;;
1373          -disable=* | --disable=*)          -disable=* | --disable=*)
1374              DISABLE=$ac_optarg ;;              DISABLE=$ac_optarg ;;
1375            
1376          -enable | --enable)          -enable | --enable)
1377              ac_prev=ENABLE ;;              ac_prev=ENABLE ;;
1378          -enable=* | --enable=*)          -enable=* | --enable=*)
1379              ENABLE=$ac_optarg ;;              ENABLE=$ac_optarg ;;
1380            
1381          -standarddirs | --standarddirs)          -standarddirs | --standarddirs)
1382              ac_prev=STANDARDDIRS ;;              ac_prev=STANDARDDIRS ;;
1383          -standarddirs=* | --standarddirs=*)          -standarddirs=* | --standarddirs=*)
# Line 880  for ac_option ; do Line 1387  for ac_option ; do
1387  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1388  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1389  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1390                
1391            -cc | --cc)
1392                ac_prev=CC ;;
1393            -cc=* | --cc=*)
1394                CC=$ac_optarg ;;
1395    
1396          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1397              ac_prev=FC ;;              ac_prev=FC ;;
1398          -fc=* | --fc=*)          -fc=* | --fc=*)
1399              FC=$ac_optarg ;;              FC=$ac_optarg ;;
1400            
1401          -fs | --fs)          -fs | --fs)
1402              ac_prev=FS ;;              ac_prev=FS ;;
1403          -fs=* | --fs=*)          -fs=* | --fs=*)
1404              FS=$ac_optarg ;;              FS=$ac_optarg ;;
1405            
1406          -fs90 | --fs90)          -fs90 | --fs90)
1407              ac_prev=FS90 ;;              ac_prev=FS90 ;;
1408          -fs90=* | --fs90=*)          -fs90=* | --fs90=*)
1409              FS90=$ac_optarg ;;              FS90=$ac_optarg ;;
1410            
1411            -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )
1412                USE_R4=true ;;
1413    
1414          -ieee | --ieee)          -ieee | --ieee)
1415              IEEE=true ;;              IEEE=true ;;
1416          -noieee | --noieee)          -noieee | --noieee)
1417              IEEE= ;;              echo "Warning: ignore option '$ac_option' (default is already without '-ieee')" ;;
1418            -devel | --devel)
1419                IEEE=true ; DEVEL=true ;;
1420            -gsl | --gsl)
1421                GSL=true ;;
1422    
1423            -ts | --ts)
1424                TS=true ;;
1425            -papis | --papis)
1426                PAPIS=true ;;
1427            -pcls | --pcls)
1428                PCLS=true ;;
1429            -foolad | --foolad)
1430                FOOLAD=true ;;
1431            -papi | --papi)
1432                PAPI=true ;;
1433            -pcl | --pcl)
1434                PCL=true ;;
1435            -hpmt | --hpmt)
1436                HPMT=true ;;
1437    
1438          -mpi | --mpi)          -mpi | --mpi)
1439              MPI=true ;;              MPI=true ;;
1440          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
1441              MPIPATH=$ac_optarg              MPIPATH=$ac_optarg
1442              MPI=true ;;              MPI=true ;;
1443            
1444  #       -jam | --jam)          -omp | --omp)
1445  #           JAM=1 ;;              OMP=true ;;
1446  #       -nojam | --nojam)          -omp=* | --omp=*)
1447  #           JAM=0 ;;              OMPFLAG=$ac_optarg
1448                        OMP=true ;;
1449    
1450          -ds | --ds)          -ds | --ds)
1451              DUMPSTATE=t ;;              DUMPSTATE=t ;;
1452            
1453            -extra_flag | --extra_flag)
1454                ac_prev=FEXTRAFLAGS ;;
1455            -extra_flag=* | --extra_flag=*)
1456                FEXTRAFLAGS=$ac_optarg ;;
1457    
1458          -taf_extra | --taf_extra)          -taf_extra | --taf_extra)
1459              ac_prev=TAF_EXTRA ;;              ac_prev=TAF_EXTRA ;;
1460          -taf_extra=* | --taf_extra=*)          -taf_extra=* | --taf_extra=*)
# Line 925  for ac_option ; do Line 1465  for ac_option ; do
1465          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1466              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1467    
1468            -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1469                IGNORE_TIME="-DIGNORE_TIME" ;;
1470    
1471            -es | --es | -embed-source | --embed-source)
1472                EMBED_SRC=t ;;
1473    
1474          -*)          -*)
1475              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
1476              usage              usage
1477              ;;              ;;
1478            
1479          *)          *)
1480              echo "Error: unrecognized argument: "$ac_option              echo "Error: unrecognized argument: "$ac_option
1481              usage              usage
1482              ;;              ;;
1483            
1484      esac      esac
1485        
1486  done  done
1487    
1488  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1489      echo      echo
1490      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
1491      echo "  file.  This file format is no longer supported.  Please see:"      echo "  file.  This file format is no longer supported.  For directions on"
1492      echo      echo "  how to setup and use the new \"genmake2\" script, please see:"
1493      echo "    http://mitgcm.org/devel_HOWTO/"      echo "    http://mitgcm.org/public/devel_HOWTO/"
1494        echo "  and send an email to MITgcm-support@mitgcm.org if you need help."
1495        echo "WARNING: ignore \"./.genmakerc\" and continue."
1496      echo      echo
     echo "  for directions on how to setup and use the new \"genmake2\" input"  
     echo "  files and send an email to MITgcm-support@mitgcm.org if you want help."  
     echo  
1497  fi  fi
1498    
1499    #  Find the MITgcm ${ROOTDIR}
1500  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1501      if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1502        if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesupp -a -d ../pkg ; then
1503          ROOTDIR=".."          ROOTDIR=".."
1504      else      else
1505          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
1506              if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then              if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
1507                  ROOTDIR=$d                  ROOTDIR=$d
1508                  printf "Warning:  ROOTDIR was not specified but there appears to be"                  printf "Warning: ROOTDIR was not specified ;"
1509                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."                  echo " try using a local copy of MITgcm found at \"$ROOTDIR\""
1510                  break                  break
1511              fi              fi
1512          done          done
# Line 976  if test ! -d ${ROOTDIR} ; then Line 1523  if test ! -d ${ROOTDIR} ; then
1523      exit 1      exit 1
1524  fi  fi
1525    
1526  echo "  getting OPTFILE information:  "  #  Find the MITgcm ${THISVER}
1527    version_file="${ROOTDIR}/doc/tag-index"
1528    if test -f $version_file ; then
1529        THISVER=`$AWK '/^checkpoint/{print $1; exit}' $version_file`
1530    #-  remove ./BUILD_INFO.h file if older than version_file
1531        if test -f ./BUILD_INFO.h -a ./BUILD_INFO.h -ot $version_file ; then
1532            echo "  remove ./BUILD_INFO.h (older than ${version_file})"
1533            rm -f ./BUILD_INFO.h
1534        fi
1535    fi
1536    
1537    if test "x$MAKEFILE" = x ; then
1538        MAKEFILE="Makefile"
1539    fi
1540    
1541    echo "  getting OPTFILE information:"
1542  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1543      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
1544          echo "Warning: no OPTFILE specified so we'll look for possible settings"          echo "Warning: no OPTFILE specified so we'll look for possible settings"
1545          printf "\n===  Searching for possible settings for OPTFILE  ===\n"          printf "\n===  Searching for possible settings for OPTFILE  ===\n"
1546          find_possible_configs          find_possible_optfile
1547      else      else
1548          OPTFILE=$MITGCM_OF          OPTFILE=$MITGCM_OF
1549      fi      fi
# Line 996  if test "x$OPTFILE" != xNONE ; then Line 1558  if test "x$OPTFILE" != xNONE ; then
1558              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1559              exit 1              exit 1
1560          fi          fi
1561          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" = xt ; then
1562              cp -f $OPTFILE "genmake_optfile"              cp -f $OPTFILE "genmake_optfile"
1563          fi          fi
1564      else      else
# Line 1005  if test "x$OPTFILE" != xNONE ; then Line 1567  if test "x$OPTFILE" != xNONE ; then
1567      fi      fi
1568  fi  fi
1569    
1570  #  Check for broken systems that cannot correctly distinguish *.F and *.f files  echo "  getting AD_OPTFILE information:"
 # check_for_broken_Ff  
   
 echo "  getting AD_OPTFILE information:  "  
1571  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1572      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" = x ; then
1573          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
# Line 1026  if test "x${AD_OPTFILE}" != xNONE ; then Line 1585  if test "x${AD_OPTFILE}" != xNONE ; then
1585              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1586              exit 1              exit 1
1587          fi          fi
1588          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" = xt ; then
1589              cp -f $AD_OPTFILE "genmake_ad_optfile"              cp -f $AD_OPTFILE "genmake_ad_optfile"
1590          fi          fi
1591      else      else
# Line 1035  if test "x${AD_OPTFILE}" != xNONE ; then Line 1594  if test "x${AD_OPTFILE}" != xNONE ; then
1594      fi      fi
1595  fi  fi
1596    
1597  #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #====================================================================
1598    #  Set default values if not set by the optfile
1599    #
1600    #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1601  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1602  if test ! "x$BASH" = x ; then  if test ! "x$BASH" = x ; then
1603      # add a trailing space so that it works within the Makefile syntax (see below)      # add a trailing space so that it works within the Makefile syntax (see below)
# Line 1051  Error: no Fortran compiler: please speci Line 1613  Error: no Fortran compiler: please speci
1613  EOF  EOF
1614      exit 1      exit 1
1615  fi  fi
1616    if test "x$GET_FC_VERSION" != x ; then
1617      echo "Get compiler version using: $FC $GET_FC_VERSION" >> $LOGFILE
1618      ff=`echo $FC | sed 's/ .*//'` ; xx=`echo $ff | sed 's/^./& /' | sed 's/ .*//'`
1619      if test $xx != '/' ; then which $ff >> $LOGFILE ; fi
1620      $FC $GET_FC_VERSION > genmake_fc_vers1 2> genmake_fc_vers2
1621      if test -s genmake_fc_vers1 ; then
1622        cat genmake_fc_vers1 >> $LOGFILE
1623      else
1624        cat genmake_fc_vers2 >> $LOGFILE
1625      fi
1626      echo "<-- compiler version ----" >> $LOGFILE
1627      rm -f genmake_fc_vers1 genmake_fc_vers2
1628    fi
1629    
1630    if test "x$CC" = x ; then
1631        look_for_C_compilers
1632    fi
1633    
1634  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1635      LINK=$FC      LINK=$FC
1636  fi  fi
# Line 1058  if test "x$MAKE" = x ; then Line 1638  if test "x$MAKE" = x ; then
1638      MAKE="make"      MAKE="make"
1639  fi  fi
1640  if test "x$CPP" = x ; then  if test "x$CPP" = x ; then
1641      CPP=cpp      CPP="cpp -traditional -P"
1642  fi  fi
1643  #EH3 === UGLY ===  #EH3 === UGLY ===
1644  #  The following is an ugly little hack to check for $CPP in /lib/ and  #  The following is an ugly little hack to check for $CPP in /lib/ and
# Line 1085  EOF Line 1665  EOF
1665  else  else
1666      rm -f test_cpp      rm -f test_cpp
1667  fi  fi
1668  if test "x$MAKEDEPEND" = x ; then  
1669      MAKEDEPEND=makedepend  look_for_makedepend
1670  fi  
1671    #  Check that soft-link command is set and usable
1672  if test "x$LN" = x ; then  if test "x$LN" = x ; then
1673      LN="ln -s"      LN="ln -s"
1674  fi  fi
# Line 1097  RETVAL=$? Line 1678  RETVAL=$?
1678  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
1679      cat <<EOF 1>&2      cat <<EOF 1>&2
1680    
1681  Error: The command "ln -s" failed -- please specify a working soft-link  Error: The command "$LN" failed -- please specify a working soft-link
1682    command in the optfile.    command in the optfile.
1683    
1684  EOF  EOF
1685      exit 1      exit 1
1686  fi  fi
1687    test -L genmake_tlink > /dev/null 2>&1
1688    RETVAL=$?
1689    if test "x$RETVAL" = x0 ; then
1690        HAVE_TEST_L=t
1691    fi
1692  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
1693    
1694  #  Check for broken *.F/*.f handling and fix if possible  #  Check for broken *.F/*.f handling and fix if possible
# Line 1112  if test ! "x$MPI" = x ; then Line 1698  if test ! "x$MPI" = x ; then
1698        echo "  Turning on MPI cpp macros"        echo "  Turning on MPI cpp macros"
1699        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1700  fi  fi
1701    if test ! "x$OMP" = x ; then
1702          echo "  Add OMPFLAG and turn on OpenMP cpp macros"
1703          FFLAGS="$FFLAGS $OMPFLAG"
1704          F90FLAGS="$F90FLAGS $OMPFLAG"
1705          DEFINES="$DEFINES -DUSE_OMP_THREADING"
1706    fi
1707    
1708    if test ! "x$USE_R4" = x ; then
1709          echo "  Turning on LET_RS_BE_REAL4 cpp flag"
1710          DEFINES="$DEFINES -DLET_RS_BE_REAL4"
1711    fi
1712    
1713    if test ! "x$TS" = x ; then
1714          echo "  Turning on timing per timestep"
1715          if test ! "x$FOOLAD" = x ; then
1716                DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"
1717          else
1718                DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1719          fi
1720          PACKAGES="$PACKAGES showflops"
1721    fi
1722    if test ! "x$PAPIS" = x ; then
1723          echo "  Turning on PAPI flop summary per timestep"
1724          echo "  Please make sure PAPIINC, PAPILIB are defined"
1725          if test ! "x$FOOLAD" = x ; then
1726                DEFINES="$DEFINES -DUSE_PAPI_FLOPS_SFP"
1727          else
1728                DEFINES="$DEFINES -DUSE_PAPI_FLOPS"
1729          fi
1730          INCLUDES="$INCLUDES $PAPIINC"
1731          LIBS="$LIBS $PAPILIB"
1732          PACKAGES="$PACKAGES showflops"
1733    fi
1734    if test ! "x$PCLS" = x ; then
1735          echo "  Turning on PCL counter summary per timestep"
1736          echo "  Please make sure PCLINC, PCLLIB are defined"
1737          if test ! "x$FOOLAD" = x ; then
1738                DEFINES="$DEFINES -DUSE_PCL_FLOPS_SFP"
1739          else
1740                DEFINES="$DEFINES -DUSE_PCL_FLOPS"
1741          fi
1742          INCLUDES="$INCLUDES $PCLINC"
1743          LIBS="$LIBS $PCLLIB"
1744          PACKAGES="$PACKAGES showflops"
1745    fi
1746    if test ! "x$PAPI" = x ; then
1747          if test ! "x$PAPIS" = x ; then
1748              echo "  PAPI performance analysis and flop summary per timestep cannot co-exist!"
1749              echo "  Sticking with PAPI flop summary per timestep!"
1750          else
1751              echo "  Turning on performance analysis with PAPI"
1752              echo "  Please make sure PAPIINC, PAPILIB are defined"
1753              DEFINES="$DEFINES -DUSE_PAPI"
1754              INCLUDES="$INCLUDES $PAPIINC"
1755              LIBS="$LIBS $PAPILIB"
1756          fi
1757    fi
1758    if test ! "x$PCL" = x ; then
1759          if test ! "x$PCLS" = x ; then
1760              echo "  PCL performance analysis and flop summary per timestep cannot co-exist!"
1761              echo "  Sticking with PCL flop summary per timestep!"
1762          else
1763              echo "  Turning on performance analysis with PCL"
1764              echo "  Please make sure PCLINC, PCLLIB are defined"
1765              DEFINES="$DEFINES -DUSE_PCL"
1766              INCLUDES="$INCLUDES $PCLINC"
1767              LIBS="$LIBS $PCLLIB"
1768          fi
1769    fi
1770    if test ! "x$HPMT" = x ; then
1771          if test ! "x$PAPI" = x ; then
1772              echo "  PAPI and the HPM Toolkit cannot co-exist!"
1773              echo "  Sticking with PAPI!"
1774          else if test ! "x$PCL" = x ; then
1775              echo "  PCL and the HPM Toolkit cannot co-exist!"
1776              echo "  Sticking with PCL!"
1777          else
1778              echo "  Turning on performance analysis with the HPM Toolkit"
1779              echo "  Please make sure HPMTINC, HPMTLIB are defined"
1780              DEFINES="$DEFINES -DUSE_LIBHPM"
1781              INCLUDES="$INCLUDES $HPMTINC"
1782              LIBS="$LIBS $HPMTLIB"
1783          fi
1784          fi
1785    fi
1786    if test ! "x$GSL" = x ; then
1787          echo "  Turning on use of GSL to control floating point calculations"
1788          echo "  Please make sure GSLINC, GSLLIB are defined"
1789          DEFINES="$DEFINES -DUSE_GSL_IEEE"
1790          INCLUDES="$INCLUDES $GSLINC"
1791          LIBS="$LIBS $GSLLIB"
1792    fi
1793    #- if USE_EXTENDED_SRC is set, add EXTENDED_SRC_FLAG to FFLAGS :
1794    if test ! "x$USE_EXTENDED_SRC" = x ; then
1795          FFLAGS="$FFLAGS $EXTENDED_SRC_FLAG"
1796          F90FIXEDFORMAT="$F90FIXEDFORMAT $EXTENDED_SRC_FLAG"
1797    fi
1798    
1799  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1800  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1801  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1802        program hello        program hello
1803        call system('echo hi')        call system('echo hi')
1804        end        end
1805  EOF  EOF
1806  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1807  RETVAL=$?  RETVAL=$?
1808  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1809      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 1133  fi Line 1816  fi
1816  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1817    
1818  printf "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1819  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1820        program hello        program hello
1821        CHARACTER(128) string        CHARACTER*(128) string
1822        string = ' '        string = ' '
1823        call fdate( string )        call fdate( string )
1824        print *, string        print *, string
1825        end        end
1826  EOF  EOF
1827  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1828  RETVAL=$?  RETVAL=$?
1829  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1830      HAVE_FDATE=t      HAVE_FDATE=t
# Line 1154  fi Line 1837  fi
1837  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1838    
1839  printf "  Do we have the etime() command using $FC...  "  printf "  Do we have the etime() command using $FC...  "
1840  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1841        program hello        program hello
1842        REAL*4 ACTUAL, TARRAY(2)        REAL*4 ACTUAL, TARRAY(2)
1843        EXTERNAL ETIME        EXTERNAL ETIME
# Line 1163  cat > genmake_tcomp.f <<EOF Line 1846  cat > genmake_tcomp.f <<EOF
1846        print *, tarray        print *, tarray
1847        end        end
1848  EOF  EOF
1849  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1850  RETVAL=$?  RETVAL=$?
1851  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1852      HAVE_ETIME=t      HAVE_ETIME=t
# Line 1178  rm -f genmake_tcomp* Line 1861  rm -f genmake_tcomp*
1861  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1862  check_HAVE_CLOC  check_HAVE_CLOC
1863  if test "x$HAVE_CLOC" != x ; then  if test "x$HAVE_CLOC" != x ; then
1864        DEFINES="$DEFINES -DHAVE_CLOC"
1865        echo "yes"
1866    else
1867        echo "no"
1868        if test "x$EMBED_SRC" = xt ; then
1869            echo "    WARNING: you requested file embedding but it has"
1870            echo "      been disabled since C code cannot be called"
1871            EMBED_SRC=
1872        fi
1873    fi
1874    rm -f genmake_t*
1875    
1876    printf "  Can we unlimit the stack size using $FC...  "
1877    check_HAVE_SETRLSTK
1878    if test "x$HAVE_SETRLSTK" = xt ; then
1879        DEFINES="$DEFINES -DHAVE_SETRLSTK"
1880        echo "yes"
1881    else
1882        echo "no"
1883    fi
1884    rm -f genmake_t*
1885    
1886    printf "  Can we register a signal handler using $FC...  "
1887    check_HAVE_SIGREG
1888    if test "x$HAVE_SIGREG" = xt ; then
1889        DEFINES="$DEFINES -DHAVE_SIGREG"
1890        echo "yes"
1891    else
1892        echo "no"
1893    fi
1894    rm -f genmake_t*
1895    
1896    printf "  Can we use stat() through C calls...  "
1897    check_HAVE_STAT
1898    if test "x$HAVE_STAT" != x ; then
1899        DEFINES="$DEFINES -DHAVE_STAT"
1900      echo "yes"      echo "yes"
1901  else  else
1902      echo "no"      echo "no"
# Line 1187  rm -f genmake_t* Line 1906  rm -f genmake_t*
1906  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1907  check_netcdf_libs  check_netcdf_libs
1908  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
1909        DEFINES="$DEFINES -DHAVE_NETCDF"
1910      echo "yes"      echo "yes"
1911  else  else
1912      echo "no"      echo "no"
1913  fi  fi
1914    
1915    printf "  Can we create LAPACK-enabled binaries...  "
1916    check_lapack_libs
1917    if test "x$HAVE_LAPACK" != x ; then
1918        DEFINES="$DEFINES -DHAVE_LAPACK"
1919        echo "yes"
1920    else
1921        echo "no"
1922    fi
1923    DEFINES="$DEFINES $IGNORE_TIME"
1924    
1925    if test "x$EMBED_SRC" = xt ; then
1926        build_embed_encode
1927    fi
1928    if test "x$EMBED_SRC" = xt ; then
1929        ENABLE="$ENABLE embed_files"
1930    #   DEFINES="$DEFINES -DHAVE_EMBED_SRC"
1931    fi
1932    
1933  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1934  printf "  Adding MODS directories:  "  printf "  Adding MODS directories: "
1935  for d in $MODS ; do  for d in $MODS ; do
1936      if test ! -d $d ; then      if test ! -d $d ; then
1937          echo          echo
1938          echo "Error: MODS directory \"$d\" not found!"          echo "Error: MODS directory \"$d\" not found!"
1939          exit 1          exit 1
1940      else      else
1941          printf " $d"          printf "$d "
1942          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1943          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
1944      fi      fi
1945  done  done
1946  echo  echo
1947    
1948  if test "x$MAKEFILE" = x ; then  #if test "x${PLATFORM}" = x ; then
1949      MAKEFILE="Makefile"  #    PLATFORM=$p_PLATFORM
1950  fi  #fi
 if test "x${PLATFORM}" = x ; then  
     PLATFORM=$p_PLATFORM  
 fi  
1951    
1952  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1953      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1954        if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1955          EXEDIR=../exe          EXEDIR=../exe
1956      else      else
1957          EXEDIR=.          EXEDIR=.
# Line 1235  if test ! -d ${TOOLSDIR} ; then Line 1970  if test ! -d ${TOOLSDIR} ; then
1970      exit 1      exit 1
1971  fi  fi
1972  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1973      S64='$(TOOLSDIR)/set64bitConst.sh'      echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1974        RETVAL=$?
1975        if test "x${RETVAL}" = x0 ; then
1976            S64='$(TOOLSDIR)/set64bitConst.sh'
1977        else
1978            echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1979            RETVAL=$?
1980            if test "x${RETVAL}" = x0 ; then
1981                S64='$(TOOLSDIR)/set64bitConst.csh'
1982            else
1983                cat <<EOF
1984    
1985    ERROR: neither of the two default scripts:
1986    
1987        ${TOOLSDIR}/set64bitConst.sh
1988        ${TOOLSDIR}/set64bitConst.csh
1989    
1990      are working so please check paths or specify (with \$S64) a
1991      working version of this script.
1992    
1993    EOF
1994                exit 1
1995            fi
1996        fi
1997  fi  fi
1998  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1999    
2000  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
2001    
2002    #  Set Standard Code Directories:
2003    if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
2004        STANDARDDIRS="eesupp model"
2005    fi
2006    #  if model in Standard-Code-Dir, add eesupp (needed to compile model)
2007    echo " $STANDARDDIRS " | grep ' model ' > /dev/null 2>&1
2008    ckM=$?
2009    echo " $STANDARDDIRS " | grep ' eesupp ' > /dev/null 2>&1
2010    ckE=$?
2011    if test $ckM = 0 -a $ckE = 1 ; then
2012        STANDARDDIRS="$STANDARDDIRS eesupp"
2013    fi
2014    
2015  #  We have a special set of source files in eesupp/src which are  #  We have a special set of source files in eesupp/src which are
2016  #  generated from some template source files. We'll make them first so  #  generated from some template source files. We'll make them first so
2017  #  they appear as regular source code  #  they appear as regular source code
2018  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
2019      echo "  Making source files in eesupp from templates"      echo "  Making source files in eesupp from templates"
2020      ( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1      ( cd $ROOTDIR"/eesupp/src/" && $MAKE clean_old && $MAKE \
2021        ) > make_eesupp.errors 2>&1
2022      RETVAL=$?      RETVAL=$?
2023      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
2024          rm -f make_eesupp.errors          rm -f make_eesupp.errors
# Line 1257  if test -r $ROOTDIR"/eesupp/src/Makefile Line 2029  if test -r $ROOTDIR"/eesupp/src/Makefile
2029      fi      fi
2030  fi  fi
2031    
2032  #same for exch2  #same for pkg/exch2 and pkg/regrid
2033  if test -r $ROOTDIR"/pkg/exch2/Makefile" ; then  for pdir in exch2 regrid ; do
2034      echo "  Making source files in exch2 from  templates"      if test -r $ROOTDIR"/pkg/${pdir}/Makefile" ; then
2035      ( cd $ROOTDIR"/pkg/exch2/" && $MAKE ) > make_exch2.errors 2>&1          echo "  Making source files in pkg/${pdir} from templates"
2036      RETVAL=$?          ( cd $ROOTDIR"/pkg/"${pdir} && $MAKE clean_old && $MAKE \
2037      if test "x${RETVAL}" = x0 ; then          ) > make_${pdir}.errors 2>&1
2038          rm -f make_exch2.errors          RETVAL=$?
2039      else          if test "x${RETVAL}" = x0 ; then
2040          echo "Error: problem encountered while building source files in exch2:"              rm -f make_${pdir}.errors
2041          cat make_exch2.errors 1>&2          else
2042          exit 1              echo "Error: problem encountered while building source files in pkg/${pdir}:"
2043                cat make_${pdir}.errors 1>&2
2044                exit 1
2045            fi
2046      fi      fi
2047  fi  done
2048    
2049  printf "\n===  Determining package settings  ===\n"  printf "\n===  Determining package settings  ===\n"
2050  if  test "x${PDEPEND}" = x ; then  if  test "x${PKG_DEPEND}" = x ; then
2051      tmp=$ROOTDIR"/pkg/pkg_depend"      tmp=$ROOTDIR"/pkg/pkg_depend"
2052      if test -r $tmp ; then      if test -r $tmp ; then PKG_DEPEND=$tmp ; fi
2053          PDEPEND=$tmp  fi
2054      else  if  test "x${PKG_DEPEND}" = x ; then
2055          echo "Warning:  No package dependency information was specified."          echo "Warning:  No package dependency information was specified."
2056          echo "  Please check that ROOTDIR/pkg/pkg_depend exists."          echo "  Please check that ROOTDIR/pkg/pkg_depend exists."
     fi  
2057  else  else
2058      if test ! -r ${PDEPEND} ; then      if test ! -r ${PKG_DEPEND} ; then
2059          echo "Error:  can't read package dependency info from PDEPEND=\"$PDEPEND\""          echo "Error:  can't read package dependency info from PKG_DEPEND=\"$PKG_DEPEND\""
2060          exit 1          exit 1
2061      fi      fi
2062        echo "  getting package dependency info from  $PKG_DEPEND"
2063    #  Strip the comments and then convert the dependency file into arrays: PNAME, DNAME
2064        get_pdepend_list $PKG_DEPEND
2065  fi  fi
2066  echo "  getting package dependency info from  $PDEPEND"  
2067  #  Strip the comments and then convert the dependency file into  # A default package groups file "$ROOTDIR/pkg/pkg_groups" is provided
2068  #  two arrays: PNAME, DNAME  #  to define the "default_pkg_list" and package groups (for convenience, one
2069  cat $PDEPEND | sed -e 's/#.*$//g' \  #  can specify a group of packages using names like "ocean" and "atmosphere").
2070      | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \  if test "x${PKG_GROUPS}" = x ; then
2071      > ./.pd_tmp      tmp=$ROOTDIR"/pkg/pkg_groups"
2072  RETVAL=$?      if test -r $tmp ; then PKG_GROUPS=$tmp ; fi
2073  if test ! "x${RETVAL}" = x0 ; then  fi
2074      echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""  if test "x${PKG_GROUPS}" = x ; then
2075      exit 1          echo "Warning:  No package groups information was specified."
2076            echo "  Please check that ROOTDIR/pkg/pkg_groups exists."
2077    else
2078        if test ! -r ${PKG_GROUPS} ; then
2079            echo "Error:  can't read package groups info from PKG_GROUPS=\"$PKG_GROUPS\""
2080            exit 1
2081        fi
2082        echo "  getting package groups info from      $PKG_GROUPS"
2083  fi  fi
 . ./.pd_tmp  
 rm -f ./.pd_tmp  
2084    
2085  #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"  #  Search for packages to compile.
2086  #  file should eventually be added so that, for convenience, one can  echo "  checking list of packages to compile:"
2087  #  specify groups of packages using names like "ocean" and "atmosphere".  PKG_LIST=
2088  echo "  checking default package list:  "  if test "x${PKG_LIST}" = x ; then
 if test "x${PDEFAULT}" = x ; then  
2089      for i in "." $MODS ; do      for i in "." $MODS ; do
2090          if test -r $i"/packages.conf" ; then          if test -r $i"/packages.conf" ; then
2091                  PDEFAULT=$i"/packages.conf"                  PKG_LIST=$i"/packages.conf"
2092                  break                  break
2093          fi          fi
2094      done      done
2095  fi  fi
2096  if test "x${PDEFAULT}" = x ; then  if test "x${PKG_LIST}" = x ; then
2097      PDEFAULT="$ROOTDIR/pkg/pkg_default"      pkg_list='default_pkg_list'
2098  fi      if test "x${PKG_GROUPS}" = x ; then
2099  if test "x${PDEFAULT}" = xNONE ; then          echo "Error:  need package groups info to expand pkg_list=\"$pkg_list\""
2100      echo "    default packages file disabled"          exit 1
2101        fi
2102  else  else
2103      if test ! -r $PDEFAULT ; then      if test ! -r $PKG_LIST ; then
2104          echo "Warning:  can't read default packages from PDEFAULT=\"$PDEFAULT\""          echo "Error:  can't read package list from PKG_LIST=\"$PKG_LIST\""
2105            exit 1
2106      else      else
2107          echo "    using PDEFAULT=\"$PDEFAULT\""          echo "    using PKG_LIST=\"$PKG_LIST\""
2108          #  Strip the comments and add all the names          #  Strip the comments and add all the names
2109          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`          pkg_list=`cat $PKG_LIST | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
2110          RETVAL=$?          RETVAL=$?
2111          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
2112              printf "Error: can't parse default package list "              printf "Error: can't parse package list "
2113              echo "-- please check PDEFAULT=\"$PDEFAULT\""              echo "-- please check PKG_LIST=\"$PKG_LIST\""
2114              exit 1              exit 1
2115          fi          fi
         for i in $def ; do  
             PACKAGES="$PACKAGES $i"  
         done  
         echo "    before group expansion packages are: $PACKAGES"  
         while ! expand_pkg_groups; do echo > /dev/null; done  
         echo "    after group expansion packages are:  $PACKAGES"  
2116      fi      fi
2117  fi  fi
2118    for i in $pkg_list ; do
2119        PACKAGES="$PACKAGES $i"
2120    done
2121    echo     "    before group expansion packages are:$PACKAGES"
2122    if test "x${PKG_GROUPS}" != x ; then
2123        RET=1
2124        while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
2125        echo "    after group expansion packages are: $PACKAGES"
2126    fi
2127    
2128  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
2129    echo "" > ./.tmp_pack
2130  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2131      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
2132  done  done
# Line 1367  PACKAGES="$PACKAGES $ENABLE" Line 2154  PACKAGES="$PACKAGES $ENABLE"
2154  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2155      j=`echo $i | sed 's/[-+]//'`      j=`echo $i | sed 's/[-+]//'`
2156      if test ! -d "$ROOTDIR/pkg/$j" ; then      if test ! -d "$ROOTDIR/pkg/$j" ; then
2157          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
2158          exit 1          exit 1
2159      fi      fi
2160      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
2161  done  done
# Line 1377  for i in `grep -v "-" ./.tmp_pack | sort Line 2164  for i in `grep -v "-" ./.tmp_pack | sort
2164      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
2165  done  done
2166  rm -f ./.tmp_pack  rm -f ./.tmp_pack
2167  echo "    packages are:  $PACKAGES"  echo "    packages are: $PACKAGES"
2168    
2169    #  Check for package MNC: if NetCDF is available, then build the MNC
2170    #  template files ; otherwise, delete mnc from the list of packages.
2171    echo " $PACKAGES " | grep ' mnc ' > /dev/null 2>&1
2172    mnc_in=$?
2173    if test "x$HAVE_NETCDF" != xt ; then
2174        if test "x$mnc_in" = x0 ; then
2175            cat <<EOF
2176    *********************************************************************
2177    WARNING: the "mnc" package was enabled but tests failed to compile
2178      NetCDF applications.  Please check that:
2179    
2180      1) NetCDF is correctly installed for this compiler and
2181      2) the LIBS variable (within the "optfile") specifies the correct
2182           NetCDF library to link against.
2183    
2184      Due to this failure, the "mnc" package is now DISABLED.
2185    *********************************************************************
2186    EOF
2187            PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
2188            DISABLE="$DISABLE mnc"
2189        else
2190        #  this prevent to add mnc (due to pdepend rules) if not available
2191            DISABLE="$DISABLE mnc"
2192        fi
2193    else
2194        # we have NetCDF, we try to build MNC template files
2195        ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
2196        RETVAL=$?
2197        if test "x${RETVAL}" = x0 ; then
2198            rm -f make_mnc.errors
2199        else
2200            echo "Error: problem encountered while building source files in pkg/mnc:"
2201            cat make_mnc.errors 1>&2
2202            if test "x$mnc_in" = x0 ; then
2203                exit 1
2204            else
2205                DISABLE="$DISABLE mnc"
2206            fi
2207        fi
2208    fi
2209    
2210    #  Check for package PROFILES: if NetCDF is not available,
2211    #  then delete profiles from the list of available packages.
2212    if test "x$HAVE_NETCDF" != xt ; then
2213        echo " $PACKAGES " | grep ' profiles ' > /dev/null 2>&1
2214        RETVAL=$?
2215        if test "x$RETVAL" = x0 ; then
2216            cat <<EOF
2217    *********************************************************************
2218    WARNING: the "profiles" package was enabled but tests failed to
2219      compile NetCDF applications.  Please check that:
2220    
2221      1) NetCDF is correctly installed for this compiler and
2222      2) the LIBS variable (within the "optfile") specifies the correct
2223           NetCDF library to link against.
2224    
2225      Due to this failure, the "profiles" package is now DISABLED.
2226    *********************************************************************
2227    EOF
2228            PACKAGES=`echo $PACKAGES | sed -e 's/profiles//g'`
2229            DISABLE="$DISABLE profiles"
2230        else
2231        #  this prevent to add profiles (due to pdepend rules) if not available
2232            DISABLE="$DISABLE profiles"
2233        fi
2234    fi
2235    
2236    #  Check for package RADTRANS: if LAPACK is not available,
2237    #  then issue a warning that the direct radtrans solver is not available.
2238    if test "x$HAVE_LAPACK" != xt ; then
2239        echo " $PACKAGES " | grep ' radtrans ' > /dev/null 2>&1
2240        RETVAL=$?
2241        if test "x$RETVAL" = x0 ; then
2242            cat <<EOF
2243    *********************************************************************
2244    WARNING: the "radtrans" package was enabled but tests failed to
2245      compile LAPACK applications.  This means that the direct radtrans
2246      solver is not available and compilation will fail if it is enabled.
2247      If you want to use the direct solver, please check that:
2248    
2249      1) LAPACK is correctly installed for this compiler and
2250      2) the LIBS variable (within the "optfile") specifies the correct
2251         LAPACK library to link against.
2252    *********************************************************************
2253    EOF
2254        fi
2255    fi
2256    
2257  echo "  applying package dependency rules"  if  test "x${PKG_DEPEND}" != x ; then
2258  ck=    echo "  applying package dependency rules"
2259  while test "x$ck" != xtt ; do    ck=
2260      while test "x$ck" != xtt ; do
2261      i=0      i=0
2262      # rtot=${#PNAME[@]}      # rtot=${#PNAME[@]}
2263      rtot=$nname      rtot=$nname
2264      while test $i -lt $rtot ; do      while test $i -le $rtot ; do
2265    
2266          #  Is $pname in the current $PACKAGES list?          #  Is $pname in the current $PACKAGES list?
2267          #  pname=${PNAME[$i]}          #  pname=${PNAME[$i]}
# Line 1397  while test "x$ck" != xtt ; do Line 2273  while test "x$ck" != xtt ; do
2273                  pin="t"                  pin="t"
2274              fi              fi
2275          done          done
2276            #  or in the current $STANDARDDIRS list?
2277            for p in $STANDARDDIRS ; do
2278                if test "x$p" = "x$pname" ; then pin="t" ; fi
2279            done
2280    
2281          #  Is the DNAME entry a (+) or (-) rule ?          #  Is the DNAME entry a (+) or (-) rule ?
2282          tmp="dname=\"\$DNAME_$i\""          tmp="dname=\"\$DNAME_$i\""
# Line 1419  while test "x$ck" != xtt ; do Line 2299  while test "x$ck" != xtt ; do
2299    
2300          #  Do we need to add $dname according to the dependency rules?          #  Do we need to add $dname according to the dependency rules?
2301          if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then          if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then
2302                #echo "   " $pname ": need to add :" $dname
2303              in_dis="f"              in_dis="f"
2304              for dis in $DISABLE ; do              for dis in $DISABLE ; do
2305                  if test "x$dis" = "x$dname" ; then                  if test "x$dis" = "x$dname" ; then
# Line 1439  while test "x$ck" != xtt ; do Line 2320  while test "x$ck" != xtt ; do
2320          #  Do we need to get rid of $dname according to the dependency rules?          #  Do we need to get rid of $dname according to the dependency rules?
2321          if test "x$pin" = xt -a "x$plus" = "x-" -a "x$din" = xt; then          if test "x$pin" = xt -a "x$plus" = "x-" -a "x$din" = xt; then
2322              echo "Error: can't satisfy package dependencies:"              echo "Error: can't satisfy package dependencies:"
2323              echo "  \"$pname\" was requested but is disallowed by"              echo "  \"$pname\" was requested but is disallowed by"
2324              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
2325              exit 1              exit 1
2326          fi          fi
2327          i=$(( $i + 1 ))          i=`echo "$i + 1" | bc -l`
2328            #i=$(( $i + 1 ))
2329      done      done
2330      ck=$ck"t"      ck=$ck"t"
2331  done    done
2332  echo "    packages are:  $PACKAGES"    echo "    packages are: $PACKAGES"
2333    fi
2334  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2335      adr="$ROOTDIR/pkg/$i"      adr="$ROOTDIR/pkg/$i"
2336      if test -d $adr ; then      if test -d $adr ; then
# Line 1462  for i in $PACKAGES ; do Line 2345  for i in $PACKAGES ; do
2345      fi      fi
2346  done  done
2347    
 #  Build MNC templates and check for ability to build and use NetCDF  
 echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1  
 RETVAL=$?  
 if test "x$RETVAL" = x0 ; then  
     ( cd $ROOTDIR"/pkg/mnc" && $MAKE templates ) > make_mnc.errors 2>&1  
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         rm -f make_mnc.errors  
     else  
         echo "Error: problem encountered while building source files in pkg/mnc:"  
         cat make_mnc.errors 1>&2  
         exit 1  
     fi  
     if test "x$HAVE_NETCDF" != xt ; then  
         cat <<EOF  
   
 WARNING: the "mnc" package has been enabled but tests failed to  
   compile and/or execute NetCDF applications.  Please check that:  
   
   1) NetCDF is installed for your compiler and  
   2) the LIBS variable (within the 'optfile") specifies the correct  
        NetCDF library to link against.  
     
 EOF  
     fi  
 fi  
   
2348  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
2349  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
2350  #  The following UGLY HACK sets multiple "#undef"s and it needs to go  #  The following UGLY HACK sets multiple "#undef"s and it needs to go
2351  #  away.  On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h  #  away.  On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h
2352  #  file would eventually be split up so that all package-related #define  #  file would eventually be split up so that all package-related #define
2353  #  statements could be separated and handled only by genmake.  #  statements could be separated and handled only by genmake.
2354  names=`ls -1 "$ROOTDIR/pkg"`  names=`ls -1 "$ROOTDIR/pkg"`
# Line 1508  for n in $names ; do Line 2364  for n in $names ; do
2364              fi              fi
2365          done          done
2366          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
2367              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
2368              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
2369          fi          fi
2370      fi      fi
2371  done  done
2372  ENABLED_PACKAGES=  ENABLED_PACKAGES=
2373  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2374      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`      def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
2375      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
2376  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
2377    
2378  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
2379      case $i in      case $i in
2380          aim_v23)          aim_v23)
2381              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
2382              echo "Warning: ALLOW_AIM is set to enable aim_v23."              echo "Warning: ALLOW_AIM is set to enable aim_v23."
2383              ;;              ;;
2384      esac      esac
# Line 1530  for i in $PACKAGES ; do Line 2386  for i in $PACKAGES ; do
2386    
2387  done  done
2388    
2389  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS='$STANDARDDIRS'"
2390  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
 if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then  
     STANDARDDIRS="eesupp model"  
 fi  
2391  if test "x$STANDARDDIRS" != x ; then  if test "x$STANDARDDIRS" != x ; then
2392      for d in $STANDARDDIRS ; do      for d in $STANDARDDIRS ; do
2393          adr="$ROOTDIR/$d/src"          adr="$ROOTDIR/$d/src"
# Line 1567  for i in $spaths ; do Line 2420  for i in $spaths ; do
2420      if test -f $try -a -r $try -a "x$CPP_OPTIONS" = x ; then      if test -f $try -a -r $try -a "x$CPP_OPTIONS" = x ; then
2421          echo "    found CPP_OPTIONS=\"$try\""          echo "    found CPP_OPTIONS=\"$try\""
2422          CPP_OPTIONS="$try"          CPP_OPTIONS="$try"
2423          # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h          # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
2424          for n in $names ; do          for n in $names ; do
2425              test_for_package_in_cpp_options $CPP_OPTIONS $n              test_for_package_in_cpp_options $CPP_OPTIONS $n
2426          done          done
2427      fi      fi
2428      try="$i/CPP_EEOPTIONS.h"      try="$i/CPP_EEOPTIONS.h"
2429      if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" = x ; then      if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" = x ; then
2430          echo "    found CPP_EEOPTIONS=\"$try\""          echo "    found CPP_EEOPTIONS=\"$try\""
2431          # New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h          # New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h
2432  #**** not yet enabled ****  #**** not yet enabled ****
2433  #        test_for_mpi_in_cpp_eeoptions $try  #        test_for_mpi_in_cpp_eeoptions $try
2434  #**** not yet enabled ****  #**** not yet enabled ****
# Line 1589  fi Line 2442  fi
2442    
2443  #  Here, we build the list of files to be "run through" the adjoint  #  Here, we build the list of files to be "run through" the adjoint
2444  #  compiler.  #  compiler.
2445  if test -f ./ad_files ; then  if test -f ./adSrcFiles.tmp ; then
2446      rm -f ./ad_files      rm -f ./adSrcFiles.tmp
2447  fi  fi
2448  echo "  Creating the list of files for the adjoint compiler."  echo "  Creating the list of files for the adjoint compiler."
2449    touch adSrcFiles.tmp
2450  for i in $SOURCEDIRS ; do  for i in $SOURCEDIRS ; do
2451      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2452      for j in $list_files ; do      for j in $list_files ; do
2453          cat $i/$j >> ad_files          cat $i/$j >> adSrcFiles.tmp
2454      done      done
2455  done  done
2456    if test ! "x"$FS = "x.f" ; then
2457        cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f
2458        mv -f adSrcFiles.tmp_f adSrcFiles.tmp
2459    fi
2460    
2461  echo  echo
2462  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
2463  echo "  setting INCLUDES"  echo "  setting INCLUDES"
2464  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
2465      if ! test -d $i ; then      if test ! -d $i ; then
 #       INCLUDES="$INCLUDES -I$i"  
 #   else  
2466          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
2467      fi      fi
2468  done  done
2469    
2470    if test ! "x$DIVA" = x ; then
2471        echo "  Creating the pseudo-MPI include directory"
2472        INCLUDES="-I./mpi_headers $INCLUDES"
2473        rm -rf ./mpi_headers
2474        mkdir -p ./mpi_headers
2475    
2476        if test "x$MPIINCLUDEDIR" = x ; then
2477            if test "x$MPIHOME" = x ; then
2478                MPIHOME='/usr'
2479            fi
2480            MPIINCLUDEDIR='$MPIHOME/include'
2481        fi
2482    
2483        if test -r $MPIINCLUDEDIR/mpif.h ; then
2484            for i in $MPI_HEADER_FILES; do
2485                cp -p $MPIINCLUDEDIR/$i ./mpi_headers
2486            done
2487    
2488            perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h
2489        else
2490            echo " We cannot create a copy of mpif.h!"
2491    #       exit -1
2492        fi
2493    fi
2494    
2495  echo "  Determining the list of source and include files"  echo "  Determining the list of source and include files"
2496  rm -rf .links.tmp  rm -rf .links.tmp
2497  mkdir .links.tmp  mkdir .links.tmp
2498    touch .links.tmp/foo
2499    if test ! -r ".links.tmp/foo" ; then
2500        echo
2501        echo "ERROR : something is wrong with your directory permissions or"
2502        echo "   your user file-creation mask (\"umask\") since creating a"
2503        echo "   sub-dir, touch-ing a file within it, and then reading it is"
2504        echo "   not working.  Please try setting your umask to something"
2505        echo "   sane such as:"
2506        echo
2507        echo "      umask 0002"
2508        echo
2509        echo "   and please verify that you have the proper permissions for"
2510        echo "   creating sub-directories and then reading files created"
2511        echo "   within them."
2512        echo
2513        exit 1
2514    fi
2515    rm -f .links.tmp/foo
2516    
2517    if test "x$OPENAD" != x ; then
2518        OAD_DONT_COMPILE="/dev/null"
2519        OAD_DONT_TRANSFORM="/dev/null"
2520        OAD_KEEP_ORIGINAL="/dev/null"
2521        OAD_CB2M_FILES="/dev/null"
2522        echo "  looking for dontCompile file:  "
2523        for i in "." $MODS ; do
2524            if test -r $i"/dontCompile" ; then
2525                OAD_DONT_COMPILE=$i"/dontCompile"
2526                echo "     found $OAD_DONT_COMPILE"
2527                break
2528            fi
2529        done
2530        echo "  looking for dontTransform file:  "
2531        for i in "." $MODS ; do
2532            if test -r $i"/dontTransform" ; then
2533                OAD_DONT_TRANSFORM=$i"/dontTransform"
2534                echo "     found $OAD_DONT_TRANSFORM"
2535                break
2536            fi
2537        done
2538        echo "  looking for keepOriginal file:  "
2539        for i in "." $MODS ; do
2540            if test -r $i"/keepOriginal" ; then
2541                OAD_KEEP_ORIGINAL=$i"/keepOriginal"
2542                echo "     found $OAD_KEEP_ORIGINAL"
2543                break
2544            fi
2545        done
2546        echo "  looking for cb2mFiles:  "
2547        for i in "." $MODS ; do
2548            if test -r $i"/cb2mFiles" ; then
2549                OAD_CB2M_FILES=$i"/cb2mFiles"
2550                echo "     found $OAD_CB2M_FILES"
2551                break
2552            fi
2553        done
2554        echo "   OpenAD exceptions:  "
2555    fi
2556    
2557  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
2558  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
2559  printf 'SRCFILES = '    > srclist.inc  printf 'F77_SRC_FILES = ' > F77srclist.tmp
2560  printf 'CSRCFILES = '   > csrclist.inc  printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp
2561  printf 'F90SRCFILES = ' > f90srclist.inc  printf 'C_SRC_FILES = '   > csrclist.tmp
2562  printf 'HEADERFILES = ' > hlist.inc  printf 'F90_SRC_FILES = ' > F90srclist.tmp
2563  printf 'AD_FLOW_FILES = ' > ad_flow_files.inc  printf 'H_SRC_FILES = '   > hsrclist.tmp
2564    printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp
2565  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2566  for d in $alldirs ; do  for d in $alldirs ; do
2567      deplist=      deplist=
2568      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
2569      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
2570        if test "x$OPENAD" != x ; then
2571            sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2572        fi
2573      for sf in $sfiles ; do      for sf in $sfiles ; do
2574          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
2575              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2576                  case $d/$sf in                  ignore_f=f
2577                    ./$PACKAGES_DOT_H)                  case $d/$sf in
2578                      ./$PACKAGES_DOT_H)
2579                            ignore_f=t
2580                            ;;
2581                      ./AD_CONFIG.h)
2582                            ignore_f=t
2583                          ;;                          ;;
2584                    ./AD_CONFIG.h)                    ./FC_NAMEMANGLE.h)
2585                            ignore_f=t
2586                          ;;                          ;;
2587                    ./FC_NAMEMANGLE.h)                    ./BUILD_INFO.h)
2588                            ignore_f=t
2589                          ;;                          ;;
2590                    *)                    ./EMBEDDED_FILES.h)
2591                          touch .links.tmp/$sf                          ignore_f=t
                         deplist="$deplist $sf"  
2592                          ;;                          ;;
2593                  esac                    *)
2594                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`                          #  For the local directory *ONLY*,
2595                  case $extn in                          #  ignore all soft-links
2596                      F)                          if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
2597                          echo    " \\"  >> srclist.inc                              ignore_f=t
2598                          printf " $sf" >> srclist.inc                          else
2599                                touch .links.tmp/$sf
2600                                deplist="$deplist $sf"
2601                            fi
2602                            ;;
2603                    esac
2604                    if test "x$ignore_f" = xf ; then
2605                        extn=`echo $sf | $AWK -F. '{print $NF}'`
2606                        case $extn in
2607                          F)
2608                            echo    " \\"  >> F77srclist.tmp
2609                            printf " $sf" >> F77srclist.tmp
2610                            if test "x$OPENAD" != x ; then
2611                                basename=${sf%%.F}
2612                                isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`
2613                                if test -z "$isAD" ; then
2614                                    toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`
2615                                    if test -z "$toBeIgnored" ; then
2616                                        echo    " \\"  >> nonADF77srclist.tmp
2617                                        printf " $sf" >> nonADF77srclist.tmp
2618                                    else
2619                                        echo "    not to be compiled   :  $sf"
2620                                    fi
2621                                else # file is initially listed as an AD file we want to exclude it
2622                                     # or we want to retain the untransformed version
2623                                    notToBeTransformed=`egrep ^$basename'[      ]*' ${OAD_DONT_TRANSFORM}`
2624                                    untransformedVersionToBeKept=`egrep ^$basename'[      ]*' ${OAD_KEEP_ORIGINAL}`
2625                                    if test -n "$notToBeTransformed"; then
2626                                        echo "    not to be transformed:  $sf"
2627                                    fi
2628                                    if test -n "$untransformedVersionToBeKept" ; then
2629                                        echo "    original to be kept  :  $sf"
2630                                    fi
2631                                    if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2632                                        echo    " \\"  >> nonADF77srclist.tmp
2633                                        printf " $sf" >> nonADF77srclist.tmp
2634                                    fi
2635                                fi
2636                            fi
2637                          ;;                          ;;
2638                      F90)                      F90)
2639                          echo    " \\"  >> f90srclist.inc                          echo    " \\"  >> F90srclist.tmp
2640                          printf " $sf" >> f90srclist.inc                          printf " $sf" >> F90srclist.tmp
2641                          ;;                          ;;
2642                      c)                      c)
2643                          echo    " \\"  >> csrclist.inc                          echo    " \\"  >> csrclist.tmp
2644                          printf " $sf" >> csrclist.inc                          printf " $sf" >> csrclist.tmp
2645                          ;;                          ;;
2646                      h)                      h)
2647                          echo    " \\"  >> hlist.inc                          echo    " \\"  >> hsrclist.tmp
2648                          printf " $sf" >> hlist.inc                          printf " $sf" >> hsrclist.tmp
2649                          ;;                          ;;
2650                      flow)                      flow)
2651                          echo    " \\"  >> ad_flow_files.inc                          echo    " \\"  >> ad_flow_files.tmp
2652                          printf " $sf" >> ad_flow_files.inc                          printf " $sf" >> ad_flow_files.tmp
2653                          ;;                          ;;
2654                  esac                     esac
2655                    fi
2656              fi              fi
2657          fi          fi
2658      done      done
2659      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2660          if test "$d" != "." ; then
2661          echo "" >> srclinks.tmp          echo "" >> srclinks.tmp
2662          echo "#  These files are linked from $d" >> srclinks.tmp          echo "#  These files are linked from $d" >> srclinks.tmp
2663          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> srclinks.tmp
2664          printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp  # We need to make sure that the link isn't already there.
2665    # This may happen when make thinks that a header file has to be "remade"
2666    # because a module it depends on has changed.  In this case we do nothing.
2667            printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp
2668          fi
2669      fi      fi
2670  done  done
2671  rm -rf .links.tmp  rm -rf .links.tmp
2672  echo "" >> srclist.inc  echo "" >> F77srclist.tmp
2673  echo "" >> csrclist.inc  echo "" >> nonADF77srclist.tmp
2674  echo "" >> f90srclist.inc  echo "" >> csrclist.tmp
2675  echo "" >> hlist.inc  echo "" >> F90srclist.tmp
2676  echo "" >> ad_flow_files.inc  echo "" >> hsrclist.tmp
2677    echo "" >> ad_flow_files.tmp
2678    
2679    CMDLINE=$0
2680    for xx in "$@" ; do nw=`echo $xx | wc -w`
2681        if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
2682                            else CMDLINE="$CMDLINE '$xx'" ; fi
2683    done
2684    
2685  if test -e $MAKEFILE ; then  if test -f $MAKEFILE ; then
2686      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.old"
2687  fi  fi
2688  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
2689  echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE  echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE
# Line 1691  echo "#    $MACHINE" >> $MAKEFILE Line 2691  echo "#    $MACHINE" >> $MAKEFILE
2691  echo "# This makefile was generated automatically on" >> $MAKEFILE  echo "# This makefile was generated automatically on" >> $MAKEFILE
2692  echo "#    $THISDATE" >> $MAKEFILE  echo "#    $THISDATE" >> $MAKEFILE
2693  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2694  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $CMDLINE"  >> $MAKEFILE
2695  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2696  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2697    
2698  EXE_AD=$EXECUTABLE"_ad"  EXE_AD=$EXECUTABLE"_ad"
2699  EXE_FTL=$EXECUTABLE"_ftl"  EXE_FTL=$EXECUTABLE"_ftl"
# Line 1702  EXE_SVD=$EXECUTABLE"_svd" Line 2702  EXE_SVD=$EXECUTABLE"_svd"
2702  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2703  #  #
2704  # OPTFILE="$OPTFILE"  # OPTFILE="$OPTFILE"
2705  #  #
2706  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
2707  # SOURCEDIRS   : Directories containing the source (.F) files  # SOURCEDIRS   : Directories containing the source (.F) files
2708  # INCLUDEDIRS  : Directories containing the header-source (.h) files  # INCLUDEDIRS  : Directories containing the header-source (.h) files
# Line 1722  cat >>$MAKEFILE <<EOF Line 2722  cat >>$MAKEFILE <<EOF
2722  # LIBS         : Library flags /or/ additional optimization/debugging flags  # LIBS         : Library flags /or/ additional optimization/debugging flags
2723    
2724  ROOTDIR     = ${ROOTDIR}  ROOTDIR     = ${ROOTDIR}
2725  BUILDDIR    = ${BUILDDIR}    BUILDDIR    = ${BUILDDIR}
2726  SOURCEDIRS  = ${SOURCEDIRS}  SOURCEDIRS  = ${SOURCEDIRS}
2727  INCLUDEDIRS = ${INCLUDEDIRS}  INCLUDEDIRS = ${INCLUDEDIRS}
2728  EXEDIR      = ${EXEDIR}  EXEDIR      = ${EXEDIR}
# Line 1739  ENABLED_PACKAGES = ${ENABLED_PACKAGES} Line 2739  ENABLED_PACKAGES = ${ENABLED_PACKAGES}
2739  DISABLED_PACKAGES = ${DISABLED_PACKAGES}  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
2740    
2741  # These files are created by Makefile  # These files are created by Makefile
2742  SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h  SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h
   
2743  EOF  EOF
2744    
2745  #  Note: figure out some way to add Hyades JAM libraries here  if test "x$EMBED_SRC" = xt ; then
2746        echo "EMBEDDED_FILES = EMBEDDED_FILES.h" >>$MAKEFILE
2747    else
2748        echo "EMBEDDED_FILES = " >>$MAKEFILE
2749    fi
2750    
2751  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2752  # Unix ln (link)  # Unix ln (link)
2753  LN = ${LN}  LN = ${LN}
# Line 1758  KPP = ${KPP} Line 2761  KPP = ${KPP}
2761  FC = ${FC}  FC = ${FC}
2762  # Fortran compiler  # Fortran compiler
2763  F90C = ${F90C}  F90C = ${F90C}
2764    # C compiler
2765    CC = ${CC}
2766  # Link editor  # Link editor
2767  LINK = ${LINK} ${LDADD}  LINK = ${LINK} ${LDADD}
2768    
# Line 1769  INCLUDES = ${INCLUDES} Line 2774  INCLUDES = ${INCLUDES}
2774  KFLAGS1 = ${KFLAGS1}  KFLAGS1 = ${KFLAGS1}
2775  KFLAGS2 = ${KFLAGS2}  KFLAGS2 = ${KFLAGS2}
2776  # Optim./debug for FC  # Optim./debug for FC
2777  FFLAGS = ${FFLAGS}  FFLAGS = ${FFLAGS} ${FEXTRAFLAGS}
2778  FOPTIM = ${FOPTIM}  FOPTIM = ${FOPTIM}
2779  # Optim./debug for FC  # Optim./debug for FC
2780  F90FLAGS = ${F90FLAGS}  F90FLAGS = ${F90FLAGS}
2781  F90OPTIM = ${F90OPTIM}  F90OPTIM = ${F90OPTIM}
2782    F90FIXEDFORMAT = ${F90FIXEDFORMAT}
2783  # Flags for CC  # Flags for CC
2784  CFLAGS = ${CFLAGS}  CFLAGS = ${CFLAGS}
2785  # Files that should not be optimized  # Files that should not be optimized
2786  NOOPTFILES = ${NOOPTFILES}  NOOPTFILES = ${NOOPTFILES}
2787  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2788  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2789  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS}
2790  # Name of the Mekfile  # Name of the makefile
2791  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2792    
2793  EOF  EOF
2794    
2795  cat srclist.inc       >> $MAKEFILE  cat F77srclist.tmp      >> $MAKEFILE
2796  cat csrclist.inc      >> $MAKEFILE  cat nonADF77srclist.tmp >> $MAKEFILE
2797  cat f90srclist.inc    >> $MAKEFILE  cat csrclist.tmp        >> $MAKEFILE
2798  cat hlist.inc         >> $MAKEFILE  cat F90srclist.tmp      >> $MAKEFILE
2799  cat ad_flow_files.inc >> $MAKEFILE  cat hsrclist.tmp        >> $MAKEFILE
2800    cat ad_flow_files.tmp   >> $MAKEFILE
2801    
2802    rm -f F77srclist.tmp nonADF77srclist.tmp csrclist.tmp F90srclist.tmp hsrclist.tmp ad_flow_files.tmp
2803    
2804  echo >> $MAKEFILE  echo >> $MAKEFILE
2805  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE  
2806  echo 'F90FILES =  $(F90SRCFILES:.F=.'$FS90')' >> $MAKEFILE  # add definitions for preprocessed sources
2807  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  # and note that not all systems allow case sensitive extensions
2808    # hence the $FS and $FS90 here.
2809    # for fixed format f90 files we use ff90 or FF90 resp
2810    # but these are not expected to be the original source files
2811    
2812    echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE
2813    echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE
2814    echo 'OBJFILES= $(F77_SRC_FILES:.F=.o) $(C_SRC_FILES:.c=.o) $(F90_SRC_FILES:.F90=.o)' >> $MAKEFILE
2815    echo 'FLOWFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE
2816  echo >> $MAKEFILE  echo >> $MAKEFILE
2817  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
2818  echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE  echo '.SUFFIXES: .o .'$FS' .p .F .c .f'$FS90' .'$FS90' .FF90 .F90 .flowdir .flow' >> $MAKEFILE
 rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc  
 rm -f ad_flow_files.inc  
2819    
2820  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2821    
2822  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
2823  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(EMBEDDED_FILES)
2824          @echo Creating \$@ ...          @echo Creating \$@ ...
2825          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2826    
2827  depend:  depend:
2828          @make links          @make -f \$(MAKEFILE) links
2829          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
2830          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2831          -rm -f makedepend.out          -rm -f makedepend.out
2832    
2833  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  lib: libmitgcmuv.a
2834    
2835  small_f: \$(F77FILES) \$(F90FILES)  libmitgcmuv.a: \$(OBJFILES)
2836            ar rcv libmitgcmuv.a \$(OBJFILES)
2837            ar d   libmitgcmuv.a main.o
2838    
2839    obj: \$(OBJFILES)
2840    
2841    links: \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(SPECIAL_FILES)
2842    
2843    small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
2844    
2845  output.txt: \$(EXECUTABLE)  output.txt: \$(EXECUTABLE)
2846          @printf 'running ... '          @printf 'running ... '
2847          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
2848    
2849    # remove most of the files that "make" generates
2850  clean:  clean:
2851          -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2852            -rm -rf *.o
2853            -rm -rf *.$FS *.flowdir
2854            -rm -rf *.f$FS90 \$(AD_CLEAN) ad_input*
2855    
2856    # remove most of the files that "make" and "make depend" generate
2857  Clean:  Clean:
2858          @make clean          @make -f \$(MAKEFILE) clean
2859          @make cleanlinks          @make -f \$(MAKEFILE) cleanlinks
2860          -rm -f \$(SPECIAL_FILES)          -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old
2861          -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak          -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log taf_ftl.log
2862            -rm -f genmake_warnings genmake_errors make.log
2863    
2864    # remove also the executable, files that "genmake2" generates (except Makefile)
2865    #         and output from a run (plus log files from testreport)
2866  CLEAN:  CLEAN:
2867          @make Clean          @make -f \$(MAKEFILE) Clean
2868            -rm -f \$(EXECUTABLE) \$(EXE_AD) \$(EXE_FTL) *.bak
2869            -rm -f $LOGFILE genmake_state genmake_*optfile
2870            -rm -f SIZE.h.mpi genmake.tr_log make.tr_log
2871          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2872          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2873          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2874          -rm -f \$(EXECUTABLE) output.txt STD*          -rm -f *.txt STD* *diagnostics.log datetime
2875            -rm -f *_MIT_CE_000.opt0000 costfunction*0000
2876            -rm -rf mnc_test_*
2877    
 #eh3 Makefile: makefile  
2878  makefile:  makefile:
2879          $THIS_SCRIPT $G2ARGS          $THIS_SCRIPT $G2ARGS
2880  cleanlinks:  cleanlinks:
2881          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2882    
2883  # Special targets ($SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are created by make
2884  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2885          @echo Creating \$@ ...          @echo Creating \$@ ...
2886          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@
2887  AD_CONFIG.h:  AD_CONFIG.h:
2888          @echo Creating \$@ ...          @echo Creating \$@ ...
2889          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > \$@          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > \$@
2890  FC_NAMEMANGLE.h:  FC_NAMEMANGLE.h:
2891          @echo Creating \$@ ...          @echo Creating \$@ ...
2892          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
2893    
2894    BUILD_INFO.h:
2895            @echo Creating \$@ ...
2896    EOF
2897    
2898    test ! "x$THISVER" = x  && echo "       -echo \"#define THISVER '$THISVER'\" > \$@"   >> $MAKEFILE
2899    test ! "x$THISUSER" = x && echo "       -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2900    test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2901    test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2902    
2903    if test "x$EMBED_SRC" = xt ; then
2904        cat >>$MAKEFILE <<EOF
2905    
2906    decode_files.o : EMBEDDED_FILES.h
2907    
2908    ##  \$(F77_PP_SRC_FILES)
2909    all_fF.tar.gz : \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2910            @echo Creating \$@ ...
2911            -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2912            -rm -f all_fF.tar.gz
2913            -gzip all_fF.tar
2914    
2915    EMBEDDED_FILES.h : all_fF.tar.gz
2916            @echo Creating \$@ ...
2917            -\${ROOTDIR}/tools/embed_encode/encode_files EMBEDDED_FILES.h all_fF.tar.gz
2918    
2919    EOF
2920    fi
2921    
2922    cat >>$MAKEFILE <<EOF
2923    
2924  # The normal chain of rules is (  .F - .$FS - .o  )  # The normal chain of rules is (  .F - .$FS - .o  )
2925    
2926  %.o : %.F  ## This nullifies any default implicit rules concerning these two file types:
2927    ## %.o : %.F
2928    
2929  .F.$FS:  .F.$FS:
2930          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2931  .$FS.o:  .$FS.o:
2932          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2933    .F.o:
2934            \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2935  .F90.$FS90:  .F90.$FS90:
2936          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2937    .FF90.f$FS90:
2938            \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2939  .$FS90.o:  .$FS90.o:
2940          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2941    .f$FS90.o:
2942            cp \$< \$(basename  \$<).f90
2943            \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$(F90FIXEDFORMAT) \$(basename  \$<).f90
2944  .c.o:  .c.o:
2945          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
2946    .flow.flowdir:
2947            \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2948    
2949  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2950  .F.p:  .F.p:
# Line 1873  FC_NAMEMANGLE.h: Line 2952  FC_NAMEMANGLE.h:
2952  .p.$FS:  .p.$FS:
2953          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
2954    
2955    EOF
2956    
2957  #=========================================  #=========================================
2958  #===  Automatic Differentiation Rules  ===  #===  Automatic Differentiation Rules  ===
2959    #===  for TAMC/TAF  ======================
2960    
2961    if test "x$OPENAD" = x ; then
2962    
2963    cat >>$MAKEFILE <<EOF
2964    
2965  TAMC           = ${TAMC}  TAMC           = ${TAMC}
2966  TAF            = ${TAF}  TAF            = ${TAF}
# Line 1889  ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF Line 2975  ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF
2975  ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"  ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
2976  for i in $ad_vars ; do  for i in $ad_vars ; do
2977      name=$i      name=$i
2978      t1="t2=\$"`echo $i`      t1="t2=\$"`echo "$i"`
2979      eval $t1      eval $t1
2980      printf "%-20s = " $name >> $MAKEFILE      printf "%-20s = " $name >> $MAKEFILE
2981      echo $t2 >> $MAKEFILE      echo "$t2" | sed -e 's| \+| |g' >> $MAKEFILE
2982  done  done
2983    
2984  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
2985  echo >> $MAKEFILE  echo >> $MAKEFILE
2986  printf "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
2987  AD_FILES=`cat ad_files`  AD_FILES=`cat adSrcFiles.tmp`
2988  for i in $AD_FILES ; do  for i in $AD_FILES ; do
2989      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
2990      printf " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
2991  done  done
2992  echo >> $MAKEFILE  echo >> $MAKEFILE
2993  rm -f ad_files  rm -f adSrcFiles.tmp
2994    
2995  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2996    
2997  # ... AD ...  # ... AD ...
2998  adall: ad_taf  adall: \$(EXE_AD)
2999  adtaf: ad_taf_output.f  adtaf: ad_taf_output.$FS
3000  adtamc: ad_tamc_output.f  adtamc: ad_tamc_output.$FS
3001    
3002  ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES)
3003          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3004          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3005          -rm -f ad_config.template          -rm -f ad_config.template
3006          @make \$(F77FILES)          @make -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3007          @make \$(AD_FLOW_FILES)          @make -f \$(MAKEFILE) \$(FLOWFILES)
3008          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f          cat \$(FLOWFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS
3009    
3010  ad_taf_output.f: ad_input_code.f  ad_taf_output.$FS: ad_input_code.$FS
3011          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3012          cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f          ls -l ad_input_code_ad.$FS
3013            cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
3014    
3015  adtafonly:  adtafonly:
3016          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3017          cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f          ls -l ad_input_code_ad.$FS
3018            cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
3019    
3020    \${EXE_AD}: ad_taf_output.o \$(OBJFILES)
3021            \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
3022    
3023    ad_tamc_output.$FS: ad_input_code.$FS
3024            \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
3025            cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
3026    
3027  ad_taf: ad_taf_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
3028          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
3029    
3030  ad_tamc_output.f: ad_input_code.f  adonlyfwd:
3031          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
         cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.f  
3032    
3033  ad_tamc: ad_tamc_output.o \$(OBJFILES)  adtrick:
3034          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
3035    
3036    adobj: ad_taf_output.o \$(OBJFILES)
3037    
3038  # ... FTL ...  # ... FTL ...
3039  ftlall: ftl_taf  ftlall: \$(EXE_FTL)
3040  ftltaf: ftl_taf_output.f  ftltaf: ftl_taf_output.$FS
3041  ftltamc: ftl_tamc_output.f  ftltamc: ftl_tamc_output.$FS
3042    
3043  ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)
3044          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ftl_config.template
3045          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
3046          -rm -f ftl_config.template          -rm -f ftl_config.template
3047          @make \$(F77FILES)          @make -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3048          @make \$(AD_FLOW_FILES)          @make -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3049          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ftl_input_code.$FS
3050    
3051  ftl_taf_output.f: ftl_input_code.f  ftl_taf_output.$FS: ftl_input_code.$FS
3052          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3053          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f          ls -l ftl_input_code_ftl.$FS
3054            cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
3055    
3056  ftltafonly:  ftltafonly:
3057          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3058          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f          ls -l ftl_input_code_ftl.$FS
3059            cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
3060  ftl_taf: ftl_taf_output.o \$(OBJFILES)  
3061          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)  \${EXE_FTL}: ftl_taf_output.o \$(OBJFILES)
3062            \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
3063  ftl_tamc_output.f: ftl_input_code.f  
3064          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f  ftl_tamc_output.$FS: ftl_input_code.$FS
3065          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.f          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
3066            cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS
3067    
3068  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
3069          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
   
3070    
3071  # ... SVD ...  # ... SVD ...
3072  svdtaf: ad_taf_output.f ftl_taf_output.f  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
3073  svdall: svd_taf          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"
3074            @echo "--->>> Do make svdall afterwards to compile. <<<---"
3075    svdall: svd_touch svd_taf
3076    
3077  svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES)  svd_taf: \$(OBJFILES)
3078          \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS)          \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS)
3079    
3080            @echo "--->>> Only COMPILE svd code! <<<---"
3081            @echo "--->>> Assumes you previously <<<---"
3082            @echo "--->>> did make svdtaf        <<<---"
3083    
3084    svd_touch:
3085            @echo "--->>> Only COMPILE svd code! <<<---"
3086            @echo "--->>> Assumes you previously <<<---"
3087            @echo "--->>> did make svdtaf        <<<---"
3088            touch ad_taf_output.$FS ftl_taf_output.$FS
3089            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
3090            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
3091            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ftl_config.template
3092            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
3093            -rm -f ftl_config.template
3094    
3095  #=========================================  EOF
3096    
3097    fi
3098    
3099    #===  for OpenAD  ========================
3100    
3101    if test "x$OPENAD" != x ; then
3102    
3103    # ============ begin OpenAD specific section ==============
3104    
3105    cat >>$MAKEFILE <<EOF
3106    
3107    # all the source files linked from the various locations:
3108    ALL_LINKED_FILES= \
3109    \$(F77_SRC_FILES) \
3110    \$(C_SRC_FILES) \
3111    \$(H_SRC_FILES) \
3112    \$(F90_SRC_FILES) \
3113    \$(SPECIAL_FILES)
3114    
3115    ifndef OPENADROOT
3116      \$(error "Error:  environment variable OPENADROOT not defined!")
3117    endif
3118    
3119    ifndef XAIFSCHEMAROOT
3120      \$(error "Error:  environment variable XAIFSCHEMAROOT not defined!")
3121    endif
3122    
3123    ifndef XAIFBOOSTERROOT
3124      \$(error "Error:  environment variable XAIFBOOSTERROOT not defined!")
3125    endif
3126    
3127    EOF
3128    
3129    echo "  Add the source list for common block to module conversion "
3130    echo >> $MAKEFILE
3131    printf "CB2M_F90_SRC_NAMES = " >> $MAKEFILE
3132    for i in `cat ${OAD_CB2M_FILES}` ; do
3133      echo    " \\" >> $MAKEFILE
3134      printf " $i" >> $MAKEFILE
3135    done
3136    echo >> $MAKEFILE
3137    
3138    echo "  Add the source list for AD code generation"
3139    echo >> $MAKEFILE
3140    printf "AD_FILES = " >> $MAKEFILE
3141    for i in `cat ${OAD_CB2M_FILES}` ; do
3142      echo    " \\" >> $MAKEFILE
3143      printf " ${i}_mod.f$FS90" >> $MAKEFILE
3144    done
3145    AD_FILES=`cat adSrcFiles.tmp`
3146    for i in $AD_FILES ; do
3147      basename=${i%%.f}
3148      toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`
3149      if test -z "$toBeIgnored" ; then
3150        echo    " \\" >> $MAKEFILE
3151        printf " $i" >> $MAKEFILE
3152      fi
3153    done
3154    echo >> $MAKEFILE
3155    rm -f adSrcFiles.tmp
3156    
3157    cat >>$MAKEFILE <<EOF
3158    
3159    adAll: \$(EXE_AD)
3160    .PHONY: adAll
3161    
3162    CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))
3163    
3164    .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90)
3165    
3166    .PHONY: adDepend
3167    adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90)
3168            \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
3169            \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
3170            -rm -f makedepend.out
3171    
3172    OPENAD_SUPPORT_F90_SRC_FILES = \
3173    w2f__types.F90 \
3174    OAD_active.F90 \
3175    OAD_cp.F90 \
3176    OAD_rev.F90 \
3177    OAD_tape.F90
3178    
3179    OPENAD_SUPPORT_C_SRC_FILES = \
3180    iaddr.c \
3181    timeRatio.c
3182    
3183    f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)
3184            cat \$^ > \$@
3185    
3186    f95_test.f90: all_mods.xb.x2w.w2f.pp.f$FS90 \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
3187            cat \$^ > \$@
3188    
3189    f95_test.out: f95_test_mods.f90 f95_test.f90
3190            f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1
3191            f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1
3192    
3193    CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)
3194    
3195    AD_OBJ_FILES_S1=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o)  OAD_intrinsics_oad.o \$(CB2M_AD_FILES:.f$FS90=_oad.o)
3196    
3197    AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o)
3198    
3199    \$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.tag \$(AD_OBJ_FILES_S2)
3200            \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)
3201    
3202    # create sources files modules from header files containing common blocks
3203    %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk
3204            ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk
3205    
3206    # create new header files with USE statements for the new modules made above
3207    %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk
3208            ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
3209    
3210    # change the include directives of everybody to refer to  the new header files with the USE statements
3211    %_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash
3212            ../OAD_support/cb2mUseModules.bash $< ${MPI}
3213    
3214    # makefile debug rule
3215    small_f: \$(CB2M_F90_PP_SRC_FILES)
3216    .PHONY: small_f
3217    
3218    ad_output.txt: \$(EXE_AD)
3219            @printf 'linking data files ... '
3220            \$(LN) -f ../input_ad/data* ../input_ad/eedata .
3221            \$(LN) -f ../../global_ocean.90x40x15/input/*.bin .
3222            @printf 'running ... '
3223            @./\$(EXE_AD) > \$@
3224    
3225    ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3226            cat \$^ > \$@
3227    
3228    # canonicalizer
3229    ad_input_code_sf.pre.f90 : \$(CB2M_AD_FILES)
3230            \${OPENADFORTTK_BASE}/tools/SourceProcessing/preProcess.py --timing --r8 -H -S  -o \$@ \$^
3231    
3232    # replace stop statements (to avoid the implied unstructured control flow)  with print statements
3233    ad_input_code_sf.pre.s2p.f90 : ad_input_code_sf.pre.f90
3234            cat \$< | sed -f ../OAD_support/stop2print.sed > ad_input_code_sf.pre.s2p.f90
3235    
3236    # F -> WHIRL
3237    ad_input_code_sf.pre.s2p.B: ad_input_code_sf.pre.s2p.f90
3238            \${OPEN64ROOT}/crayf90/sgi/mfef90 -r8 -z -F ad_input_code_sf.pre.s2p.f90
3239    
3240    # WHIRL -> XAIF
3241    ad_input_code_sf.pre.s2p.xaif : ad_input_code_sf.pre.s2p.B
3242            \${OPENADFORTTK}/bin/whirl2xaif -s -n --debug 1 -o \$@ \$<
3243    
3244    # XAIF -> XAIF'
3245    ad_input_code_sf.pre.s2p.xb.xaif : ad_input_code_sf.pre.s2p.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd
3246            \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r
3247    
3248    # XAIF' -> WHIRL'
3249    ad_input_code_sf.pre.s2p.xb.x2w.B : ad_input_code_sf.pre.s2p.xb.xaif
3250            \${OPENADFORTTK}/bin/xaif2whirl --debug 1 ad_input_code_sf.pre.s2p.B \$<
3251    
3252    # WHIRL' -> F'
3253    ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.B
3254            \${OPEN64ROOT}/whirl2f/whirl2f -FLIST:ftn_file=\$@ -openad \$<
3255    
3256    # insert template directives
3257    ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 ../OAD_support/insertTemplateDir.bash
3258            ../OAD_support/insertTemplateDir.bash \$< \$@
3259    
3260    PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F
3261    # postprocess F'
3262    postProcess.tag: ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90 \$(PPEXTRAS:.F=.f) | w2f__types.f90
3263            \${OPENADFORTTK_BASE}/tools/SourceProcessing/postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed --separateOutput --pathSuffix "" --filenameSuffix "_oad" -m r -i ../OAD_support/ad_inline.f \$<
3264            # the target is a placeholder to trigger a single execution of the rule
3265            touch \$@
3266    # put this so make knows about the postprocessing output
3267    OAD_intrinsics_oad.f \$(CB2M_AD_FILES:.f$FS90=_oad.f): postProcess.tag
3268    
3269    # link the XAIF schema files
3270    %.xsd:
3271            \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3272    
3273    # link the support files:
3274    \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):
3275            \$(LN) ../OAD_support/\$@ .
3276    
3277    AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag \$(PPEXTRAS:.F=.f)
3278    
3279    # ============ end OpenAD specific section ==============
3280    
3281  EOF  EOF
3282    
3283    fi
3284    
3285    #=========================================
3286    
3287  if test "x$EXEHOOK" != x ; then  if test "x$EXEHOOK" != x ; then
3288      printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE      printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
3289  fi  fi
# Line 2019  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 3319  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
3319  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
3320    
3321  # Create special header files  # Create special header files
3322  $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" $DISABLED_PACKAGES " " "Enabled packages:" $ENABLED_PACKAGES > $PACKAGES_DOT_H".tmp"  $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" $DISABLED_PACKAGES " " "Enabled packages:" $ENABLED_PACKAGES > $PACKAGES_DOT_H".tmp"
3323  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
3324      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
3325  else  else
# Line 2033  else Line 3333  else
3333      fi      fi
3334  fi  fi
3335  if test ! -f AD_CONFIG.h ; then  if test ! -f AD_CONFIG.h ; then
3336      $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > AD_CONFIG.h      $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > AD_CONFIG.h
3337  fi  fi
3338    
   
3339  #  Write the "state" for future records  #  Write the "state" for future records
3340  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" = xt ; then
3341      printf "" > genmake_state      printf "" > genmake_state
3342      for i in $gm_state ; do      for i in $gm_state ; do
3343          t1="t2=\$$i"          t1="t2=\$$i"
3344          eval $t1          eval $t1
3345          echo "$i='$t2'" >> genmake_state          echo "$i='$t2'" | sed -e 's/  */ /g' >> genmake_state
3346      done      done
3347  fi  fi

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

  ViewVC Help
Powered by ViewVC 1.1.22