/[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.86 by edhill, Sat Jul 17 02:52:14 2004 UTC revision 1.212 by jmc, Thu Nov 4 18:01:22 2010 UTC
# Line 13  Line 13 
13  test_for_package_in_cpp_options() {  test_for_package_in_cpp_options() {
14      cpp_options=$1      cpp_options=$1
15      pkg=$2      pkg=$2
16      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg[ ]"
17      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg[ ]"
18      test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg[ ]"
19      test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg[ ]"
20        test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg$"
21        test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg$"
22        test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg$"
23        test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg$"
24  }  }
25    
26  # Search for particular CPP #cmds associated with MPI  # Search for particular CPP #cmds associated with MPI
27  # usage: test_for_mpi_in_cpp_eeoptions CPP_file  # usage: test_for_mpi_in_cpp_eeoptions CPP_file
28  test_for_mpi_in_cpp_eeoptions() {  test_for_mpi_in_cpp_eeoptions() {
29      cpp_options=$1      cpp_options=$1
30      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI[ ]"
31      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI[ ]"
32      test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI[ ]"
33      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI" || exit 99      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI[ ]"
34        test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI$"
35        test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI$"
36        test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI$"
37        test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI$"
38  }  }
39    
40  # 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 47  test_for_string_in_file() {
47      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
48          printf "Error: In $file there is an illegal line: "          printf "Error: In $file there is an illegal line: "
49          grep -i "$strng" $file          grep -i "$strng" $file
50          return 1          exit 99
51      fi      fi
52      return 0      return 0
53  }  }
# Line 48  test_for_string_in_file() { Line 56  test_for_string_in_file() {
56  # the package list.  # the package list.
57  expand_pkg_groups() {  expand_pkg_groups() {
58      new_packages=      new_packages=
     PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"  
59      if test -r $PKG_GROUPS ; then      if test -r $PKG_GROUPS ; then
60          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
61          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 66  expand_pkg_groups() {
66              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
67                  matched=1                  matched=1
68                  replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`                  replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
69                  echo "    replacing \"$i\" with: $replace"                  echo "    replacing \"$i\" with:$replace"
70                  new_packages="$new_packages $replace"                  new_packages="$new_packages $replace"
71              else              else
72                  new_packages="$new_packages $i"                  new_packages="$new_packages $i"
# Line 102  EOF Line 109  EOF
109              check_for_broken_Ff              check_for_broken_Ff
110          else          else
111              cat <<EOF 2>&1              cat <<EOF 2>&1
112  ERROR: Your file system cannot distinguish between *.F and *.f files  ERROR: Your file system cannot distinguish between *.F and *.f files
113    (fails the "cp" test) and this program cannot find a suitable    (fails the "cp" test) and this program cannot find a suitable
114    replacement extension.  Please try a different build environment or    replacement extension.  Please try a different build environment or
115    contact the <MITgcm-support@mitgcm.org> list for help.    contact the <MITgcm-support@mitgcm.org> list for help.
116    
117  EOF  EOF
# Line 122  EOF Line 129  EOF
129        stop        stop
130        end        end
131  EOF  EOF
132      test -e Makefile  &&  mv -f Makefile Makefile.bak      test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"
133      cat <<EOF >> Makefile      cat <<EOF >> $MAKEFILE
 %.$tfs : %.F  
134  .SUFFIXES:  .SUFFIXES:
135  genmake_hello.$tfs: genmake_hello.F  .SUFFIXES: .$tfs .F
136          $LN genmake_hello.F genmake_hello.$tfs  .F.$tfs:
137            $LN \$< \$@
138  EOF  EOF
139      $MAKE "genmake_hello."$tfs > /dev/null 2>&1      $MAKE "genmake_hello."$tfs > /dev/null 2>&1
140      RETVAL=$?      RETVAL=$?
141      if test "x$RETVAL" != x0 -o ! -e "genmake_hello."$tfs ; then      if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then
142          if test "x$FS" = x ; then          if test "x$FS" = x ; then
143              FS='for'              FS='for'
144              FS90='fr9'              FS90='fr9'
145              check_for_broken_Ff              check_for_broken_Ff
146          else          else
147              cat <<EOF 2>&1              cat <<EOF 2>&1
148  ERROR: Your file system cannot distinguish between *.F and *.f files  ERROR: Your file system cannot distinguish between *.F and *.f files
149    (fails the "make/ln" test) and this program cannot find a suitable    (fails the "make/ln" test) and this program cannot find a suitable
150    replacement extension.  Please try a different build environment or    replacement extension.  Please try a different build environment or
151    contact the <MITgcm-support@mitgcm.org> list for help.    contact the <MITgcm-support@mitgcm.org> list for help.
152    
153  EOF  EOF
# Line 148  EOF Line 155  EOF
155              return              return
156          fi          fi
157      fi      fi
158      rm -f genmake_hello.* Makefile      rm -f genmake_hello.* $MAKEFILE
159      test -e Makefile  &&  mv -f Makefile.bak Makefile      test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
160    
161      #  If we make it here, use the extensions      #  If we make it here, use the extensions
162      FS=$tfs      FS=$tfs
# Line 181  look_for_makedepend()  { Line 188  look_for_makedepend()  {
188      if test "x${MAKEDEPEND}" = x ; then      if test "x${MAKEDEPEND}" = x ; then
189          which makedepend > /dev/null 2>&1          which makedepend > /dev/null 2>&1
190          RV0=$?          RV0=$?
191            test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"
192            #  echo 'MAKEFILE="'$MAKEFILE'"'
193            cat <<EOF >> $MAKEFILE
194    #   THIS IS A TEST MAKEFILE GENERATED BY "genmake2"
195    #
196    #   Some "makedepend" implementations will die if they cannot
197    #   find a Makefile -- so this file is here to gives them an
198    #   empty one to find and parse.
199    EOF
200          cat <<EOF >> genmake_tc.f          cat <<EOF >> genmake_tc.f
201        program test        program test
202        write(*,*) 'test'        write(*,*) 'test'
# Line 189  look_for_makedepend()  { Line 205  look_for_makedepend()  {
205  EOF  EOF
206          makedepend genmake_tc.f > /dev/null 2>&1          makedepend genmake_tc.f > /dev/null 2>&1
207          RV1=$?          RV1=$?
208            test -f $MAKEFILE  &&  rm -f $MAKEFILE
209            test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
210          if test "x${RV0}${RV1}" = x00 ; then          if test "x${RV0}${RV1}" = x00 ; then
211              MAKEDEPEND=makedepend              MAKEDEPEND=makedepend
212          else          else
213              echo "    a system-default makedepend was not found."              echo "    a system-default makedepend was not found."
214                
215              #  Try to build the cyrus implementation              #  Try to build the cyrus implementation
216              rm -f ./genmake_cy_md              build_cyrus_makedepend
             (  
                 cd $ROOTDIR/tools/cyrus-imapd-makedepend  \  
                     &&  ./configure > /dev/null 2>&1  \  
                     &&  make > /dev/null 2>&1  
                 if test -x ./makedepend.exe ; then  
                     $LN ./makedepend.exe ./makedepend  
                 fi  
                 ./makedepend ifparser.c > /dev/null 2>&1  \  
                     &&  echo "true"  
             ) > ./genmake_cy_md  
             grep true ./genmake_cy_md > /dev/null 2>&1  
217              RETVAL=$?              RETVAL=$?
218              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" != x0 ; then
                 MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'  
             else  
219                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
220              fi              fi
221              rm -f ./genmake_cy_md              rm -f ./genmake_cy_md
222          fi          fi
223        else
224            #  echo "MAKEDEPEND=${MAKEDEPEND}"
225            echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
226            RETVAL=$?
227            if test x"$RETVAL" = x0 ; then
228                build_cyrus_makedepend
229            fi
230      fi      fi
231  }  }
232    
233    
234    build_cyrus_makedepend()  {
235        rm -f ./genmake_cy_md
236        (
237            cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
238                &&  ./configure > /dev/null 2>&1  \
239                &&  make > /dev/null 2>&1
240            if test -x ./makedepend.exe ; then
241                $LN ./makedepend.exe ./makedepend
242            fi
243            ./makedepend ifparser.c > /dev/null 2>&1  \
244                &&  echo "true"
245        ) > ./genmake_cy_md
246        grep true ./genmake_cy_md > /dev/null 2>&1
247        RETVAL=$?
248        rm -f ./genmake_cy_md
249        if test "x$RETVAL" = x0 ; then
250            MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
251            return 0
252        else
253            echo "WARNING: unable to build cyrus-imapd-makedepend"
254            return 1
255        fi
256    }
257    
258    
259    build_embed_encode()
260    {
261        printf "  building the embed-encode utility...  "
262        if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then
263            if test ! -d "$ROOTDIR/tools/embed_encode" ; then
264                echo
265                echo "    Error: can't locate \"$ROOTDIR/tools/embed_encode\""
266                echo
267                EMBED_SRC=f
268                return 1
269            fi
270            clist="cc gcc c89 $CC"
271            for ic in $clist ; do
272                comm="$ic -o encode_files encode_files.c"
273                ( cd $ROOTDIR/tools/embed_encode && $comm ) > /dev/null 2>&1
274                RETVAL=$?
275                if test "x$RETVAL" = x0 ; then
276                    echo "OK"
277                    DEFINES="$DEFINES -DHAVE_EMBED_SRC"
278                    return 0
279                fi
280            done
281            echo
282            echo "    Error: unable to build $ROOTDIR/embed_encode/encode_files"
283            echo "      so it has been disabled"
284            echo
285            EMBED_SRC=f
286            return 1
287        fi
288        echo "OK"
289        DEFINES="$DEFINES -DHAVE_EMBED_SRC"
290    }
291    
292    
293    #  look for possible C compilers
294    look_for_C_compilers() {
295        tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc icc"
296        p_CC=
297        for c in $tmp ; do
298            rm -f ./genmake_hello.c  ./genmake_hello
299            cat >> genmake_hello.c << EOF
300    #include <stdio.h>
301    int main(int argc, char **argv) {
302      printf("Hello!\n");
303      return 0;
304    }
305    EOF
306            $c -o genmake_hello genmake_hello.c > /dev/null 2>&1
307            RETVAL=$?
308            if test "x${RETVAL}" = x0 ; then
309                p_CC="$p_CC $c"
310            fi
311        done
312        rm -f ./genmake_hello.c ./genmake_hello
313        if test "x${p_CC}" = x ; then
314            cat 1>&2 <<EOF
315    
316    Error: No C compilers were found in your path.  Please specify one using:
317    
318        1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
319        2) the CC or MITGCM_CC environment variables.
320    
321    EOF
322            exit 1
323        else
324            echo "  The possible C compilers found in your path are:"
325            echo "   "$p_CC
326            if test "x$CC" = x ; then
327                CC=`echo $p_CC | $AWK '{print $1}'`
328                echo "  Setting C compiler to: "$CC
329            fi
330        fi
331    }
332    
333  # Guess possible config options for this host  # Guess possible config options for this host
334  find_possible_configs()  {  find_possible_optfile()  {
335    
336      tmp1=`uname`"_"`uname -m`      tmp1=`uname`"_"`uname -m`
337      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
# Line 232  find_possible_configs()  { Line 343  find_possible_configs()  {
343      echo $PLATFORM | grep cygwin > /dev/null 2>&1  &&  PLATFORM=cygwin_ia32      echo $PLATFORM | grep cygwin > /dev/null 2>&1  &&  PLATFORM=cygwin_ia32
344      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
345      echo "  The platform appears to be:  $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  
346    
347      if test "x$CPP" = x ; then  #    echo "test" > test
348          CPP="cpp -traditional -P"  #    ln -s ./test link
349      fi  #    RETVAL=$?
350    #    if test "x${RETVAL}" = x0 ; then
351      look_for_makedepend  #       LN="ln -s"
352    #    else
353    #       echo "Error: \"ln -s\" does not appear to work on this system!"
354    #       echo "  For help, please contact <MITgcm-support@mitgcm.org>."
355    #       exit 1
356    #    fi
357    #    rm -f test link
358    #
359    #    if test "x$CPP" = x ; then
360    #       CPP="cpp -traditional -P"
361    #    fi
362    #
363    #    look_for_makedepend
364    #
365    #    look_for_C_compilers
366    
367      # look for possible fortran compilers      #================================================================
368      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"      #  look for possible FORTRAN compilers
369        tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc ifort f90 f95 mpif77 mpf77 mpxlf95 gfortran g95"
370      p_FC=      p_FC=
371      for c in $tmp ; do      for c in $tmp ; do
372          rm -f ./hello.f ./hello          rm -f ./hello.f ./hello
# Line 277  Error: No Fortran compilers were found i Line 391  Error: No Fortran compilers were found i
391    
392      1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),      1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
393      2) a command-line option (eg. "-fc NAME"), or      2) a command-line option (eg. "-fc NAME"), or
394      3) the MITGCM_FC environment variable.      3) the FC or MITGCM_FC environment variables.
395    
396  EOF  EOF
397          exit 1          exit 1
398      else      else
399          echo "  The possible FORTRAN compilers found in your path are:"          echo "  The possible FORTRAN compilers found in your path are:"
400          echo "   "$p_FC          echo "   "$p_FC
401          if test "x$FC" = x ; then      fi
402              FC=`echo $p_FC | $AWK '{print $1}'`  
403              echo "  Setting FORTRAN compiler to: "$FC      #  Use the first of the compilers found in the current PATH
404          fi      #  that has a correctly-named optfile
405        if test "x$OPTFILE" = x  -a  "x$FC" = x ; then
406            for i in $p_FC ; do
407                OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
408                if test -r $OPTFILE ; then
409                    echo "  Setting OPTFILE to: "$OPTFILE
410                    break
411                fi
412            done
413      fi      fi
414    
415      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
# Line 296  EOF Line 418  EOF
418               echo "  I looked for the file "$OPTFILE" but did not find it"               echo "  I looked for the file "$OPTFILE" but did not find it"
419          fi          fi
420      fi      fi
421  #    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  
422      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
423          cat 1>&2 <<EOF          cat 1>&2 <<EOF
424    
# Line 322  Error: No options file was found in:  $R Line 434  Error: No options file was found in:  $R
434  EOF  EOF
435          exit 1          exit 1
436      fi      fi
437        
438  #     # look for possible MPI libraries  #     # look for possible MPI libraries
439  #     mpi_libs=  #     mpi_libs=
440  #     mpi_fort=`which mpif77 2>/dev/null`  #     mpi_fort=`which mpif77 2>/dev/null`
# Line 341  EOF Line 453  EOF
453  #       if test "x${RETVAL}" = x0 ; then  #       if test "x${RETVAL}" = x0 ; then
454  #           a=`cat out`  #           a=`cat out`
455  #           for i in $a ; do  #           for i in $a ; do
456  #               case $i in  #               case $i in
457  #                   -*)  #                   -*)
458  #                       mpi_libs="$mpi_libs $i" ;;  #                       mpi_libs="$mpi_libs $i" ;;
459  #               esac  #               esac
# Line 360  get_pdepend_list()  { Line 472  get_pdepend_list()  {
472      #  strip the comments and then convert the dependency file into      #  strip the comments and then convert the dependency file into
473      #  two arrays: PNAME, DNAME      #  two arrays: PNAME, DNAME
474      cat $1 | sed -e 's/#.*$//g' \      cat $1 | sed -e 's/#.*$//g' \
475          | $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}' \
476          > ./.pd_tmp          > ./.pd_tmp
477        RETVAL=$?
478        if test ! "x${RETVAL}" = x0 ; then
479          echo "Error: unable to parse package dependencies -- please check PKG_DEPEND=\"$1\""
480          exit 1
481        fi
482      . ./.pd_tmp      . ./.pd_tmp
483      rm -f ./.pd_tmp      rm -f ./.pd_tmp
484    
     printf "PNAME = "${}  
485  }  }
486    
487    
# Line 388  Usage: "$0" [OPTIONS] Line 504  Usage: "$0" [OPTIONS]
504        -optfile NAME | --optfile NAME | -of NAME | --of NAME        -optfile NAME | --optfile NAME | -of NAME | --of NAME
505        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
506            Use "NAME" as the optfile.  By default, an attempt will be            Use "NAME" as the optfile.  By default, an attempt will be
507            made to find an appropriate "standard" optfile in the            made to find an appropriate "standard" optfile in the
508            tools/build_options/ directory.            tools/build_options/ directory.
509    
510      -pdepend NAME | --pdepend NAME      -pdepend NAME | --pdepend NAME
511        -pdepend=NAME | --pdepend=NAME        -pdepend=NAME | --pdepend=NAME
512            Get package dependency information from "NAME".            Get package dependency information from "NAME".
513    
514      -pdefault NAME | --pdefault NAME      -pgroups NAME | --pgroups NAME
515        -pdefault=NAME | --pdefault=NAME        -pgroups=NAME | --pgroups=NAME
516            Get the default package list from "NAME".            Get the package groups information from "NAME".
517    
518        -bash NAME
519              Explicitly specify the Bourne or BASH shell to use
520    
521      -make NAME | -m NAME      -make NAME | -m NAME
522        --make=NAME | -m=NAME        --make=NAME | -m=NAME
523            Use "NAME" for the MAKE program. The default is "make" but            Use "NAME" for the MAKE program. The default is "make" but
524            many platforms, "gmake" is the preferred choice.            many platforms, "gmake" is the preferred choice.
525    
526      -makefile NAME | -mf NAME      -makefile NAME | -mf NAME
# Line 415  Usage: "$0" [OPTIONS] Line 534  Usage: "$0" [OPTIONS]
534      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
535        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
536            Specify the location of the MITgcm ROOTDIR as "NAME".            Specify the location of the MITgcm ROOTDIR as "NAME".
537            By default, genamke will try to find the location by            By default, genamke will try to find the location by
538            looking in parent directories (up to the 5th parent).            looking in parent directories (up to the 5th parent).
539    
540      -mods NAME | --mods NAME | -mo NAME | --mo NAME      -mods NAME | --mods NAME | -mo NAME | --mo NAME
541        -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME        -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME
542            Here, "NAME" specifies a list of directories that are            Here, "NAME" specifies a list of directories that are
543            used for additional source code.  Files found in the            used for additional source code.  Files found in the
544            "mods list" are given preference over files of the same            "mods list" are given preference over files of the same
545            name found elsewhere.            name found elsewhere.
546    
547      -disable NAME | --disable NAME      -disable NAME | --disable NAME
548        -disable=NAME | --disable=NAME        -disable=NAME | --disable=NAME
549            Here "NAME" specifies a list of packages that we don't            Here "NAME" specifies a list of packages that we don't
550            want to use.  If this violates package dependencies,            want to use.  If this violates package dependencies,
551            genamke will exit with an error message.            genamke will exit with an error message.
552    
553      -enable NAME | --enable NAME      -enable NAME | --enable NAME
554        -enable=NAME | --enable=NAME        -enable=NAME | --enable=NAME
555            Here "NAME" specifies a list of packages that we wish            Here "NAME" specifies a list of packages that we wish
556            to specifically enable.  If this violates package            to specifically enable.  If this violates package
557            dependencies, genamke will exit with an error message.            dependencies, genamke will exit with an error message.
558    
559      -standarddirs NAME | --standarddirs NAME      -standarddirs NAME | --standarddirs NAME
560        -standarddirs=NAME | --standarddirs=NAME        -standarddirs=NAME | --standarddirs=NAME
561            Here, "NAME" specifies a list of directories to be            Here, "NAME" specifies a list of directories to be
562            used as the "standard" code.            used as the "standard" code.
563    
564      -fortran NAME | --fortran NAME | -fc NAME | --fc NAME      -fortran NAME | --fortran NAME | -fc NAME | --fc NAME
565        -fc=NAME | --fc=NAME        -fc=NAME | --fc=NAME
566            Use "NAME" as the fortran compiler.  By default, genmake            Use "NAME" as the fortran compiler.  By default, genmake
567            will search for a working compiler by trying a list of            will search for a working compiler by trying a list of
568            "usual suspects" such as g77, f77, etc.            "usual suspects" such as g77, f77, etc.
569    
570        -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
571              Use "NAME" as the C compiler.  By default, genmake
572              will search for a working compiler by trying a list of
573              "usual suspects" such as gcc, c89, cc, etc.
574    
575      -[no]ieee | --[no]ieee      -[no]ieee | --[no]ieee
576            Do or don't use IEEE numerics.  Note that this option            Do or don't use IEEE numerics.  Note that this option
577            *only* works if it is supported by the OPTFILE that            *only* works if it is supported by the OPTFILE that
578            is being used.            is being used.
579    
580        -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4
581              Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW)
582              *only* works if CPP_EEOPTIONS.h allows this.
583    
584        -ignoretime | -ignore_time | --ignoretime | --ignore_time
585              Ignore all the "wall clock" routines entirely.  This will
586              not in any way hurt the model results -- it simply means
587              that the code that checks how long the model spends in
588              various routines will give junk values.
589    
590        -ts | --ts
591              Produce timing information per timestep
592        -papis | --papis
593              Produce summary MFlop/s (and IPC) with PAPI per timestep
594        -pcls | --pcls
595              Produce summary MFlop/s etc. with PCL per timestep
596        -foolad | --foolad
597              Fool the AD code generator
598        -papi | --papi
599              Performance analysis with PAPI
600        -pcl | --pcl
601              Performance analysis with PCL
602        -hpmt | --hpmt
603              Performance analysis with the HPM Toolkit
604    
605        -gsl | --gsl
606              Use GSL to control floating point rounding and precision
607        -devel | --devel
608              Add additional warning and debugging flags for development
609    
610      -mpi | --mpi      -mpi | --mpi
611            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
612      -mpi=PATH | --mpi=PATH      -mpi=PATH | --mpi=PATH
613            Include MPI header files and link to MPI libraries using MPI_ROOT            Include MPI header files and link to MPI libraries using MPI_ROOT
614            set to PATH. i.e. Include files from $PATH/include, link to libraries            set to PATH. i.e. Include files from \$PATH/include, link to libraries
615            from $PATH/lib and use binaries from $PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
616    
617      -bash NAME      -omp | --omp
618            Explicitly specify the Bourne or BASH shell to use            Activate OpenMP code + use Compiler option OMPFLAG
619        -omp=OMPFLAG | --omp=OMPFLAG
620              Activate OpenMP code + use Compiler option OMPFLAG
621    
622        -es | --es | -embed-source | --embed-source
623              Embed a tarball containing the full source code
624              (including the Makefile, etc.) used to build the
625              executable [off by default]
626    
627    While it is most often a single word, the "NAME" variables specified    While it is most often a single word, the "NAME" variables specified
628    above can in many cases be a space-delimited string such as:    above can in many cases be a space-delimited string such as:
629    
630      --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'      --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'
# Line 474  Usage: "$0" [OPTIONS] Line 635  Usage: "$0" [OPTIONS]
635    
636    For more detailed genmake documentation, please see:    For more detailed genmake documentation, please see:
637    
638      http://mitgcm.org/devel_HOWTO/      http://mitgcm.org/public/devel_HOWTO/
639    
640  EOF  EOF
641    
# Line 483  EOF Line 644  EOF
644    
645  #  Build a CPP macro to automate calling C routines from FORTRAN  #  Build a CPP macro to automate calling C routines from FORTRAN
646  get_fortran_c_namemangling()  {  get_fortran_c_namemangling()  {
647    
648        #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
649        if test ! "x$FC_NAMEMANGLE" = x ; then
650            return 0
651        fi
652        echo " running: get_fortran_c_namemangling()" >> $LOGFILE
653    
654      default_nm="#define FC_NAMEMANGLE(X) X ## _"      default_nm="#define FC_NAMEMANGLE(X) X ## _"
655        
656      cat > genmake_test.c <<EOF      cat > genmake_test.c <<EOF
657  void tcall( char * string ) { tsub( string ); }  void tcall( char * string ) { tsub( string ); }
658  EOF  EOF
659      $MAKE genmake_test.o >> genmake_warnings 2>&1  #   $MAKE genmake_test.o >> $LOGFILE 2>&1
660        COMM="$CC $CFLAGS -c genmake_test.c"
661        echo ' '$COMM >> $LOGFILE
662        $COMM >> $LOGFILE 2>&1
663      RETVAL=$?      RETVAL=$?
664      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
665          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
666          cat <<EOF>> genmake_errors          cat <<EOF>> $LOGFILE
667    
668  WARNING: C test compile fails   WARNING: C test compile fails
669  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
670  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
671  EOF  EOF
672          return 1          return 1
673      fi      fi
674      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`
675      RETVAL=$?      RETVAL=$?
676      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
677          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
678          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
679    
680  WARNING: The "nm" command failed.   WARNING: The "nm" command failed.
681  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
682  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
683  EOF  EOF
684          return 1          return 1
685      fi      fi
686      cat > genmake_tcomp.f <<EOF      cat > genmake_tcomp.$FS <<EOF
687        subroutine tcall( string )        subroutine tcall( string )
688        character*(*) string        character*(*) string
689        call tsub( string )        call tsub( string )
690        end        end
691  EOF  EOF
692      $FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1      COMM="$FC $FFLAGS -c genmake_tcomp.$FS"
693        echo ' '$COMM >> $LOGFILE
694        $COMM >> $LOGFILE 2>&1
695      RETVAL=$?      RETVAL=$?
696      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
697          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
698          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
699    
700  WARNING: FORTRAN test compile fails -- please see "genmake_errors"   WARNING: FORTRAN test compile fails -- please see '$LOGFILE'
701  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
702  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
703  EOF  EOF
704          return 1          return 1
705      fi      fi
706      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`
707      RETVAL=$?      RETVAL=$?
708      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
709          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
710          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
711    
712  WARNING: The "nm" command failed.   WARNING: The "nm" command failed.
713  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
714  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
715  EOF  EOF
716          return 1          return 1
717      fi      fi
# Line 564  EOF Line 737  EOF
737    
738      #  cleanup the testing files      #  cleanup the testing files
739      rm -f genmake_tcomp.* genmake_test.*      rm -f genmake_tcomp.* genmake_test.*
740    
741        echo " --> set FC_NAMEMANGLE='$FC_NAMEMANGLE'" >> $LOGFILE
742  }  }
743    
744    
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 584  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
784          DEFINES="$DEFINES -DHAVE_CLOC"          DEFINES="$DEFINES -DHAVE_CLOC"
785      fi      fi
786      rm -f genmake_tc*      rm -f genmake_tc*
787        echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE
788    }
789    
790    
791    check_HAVE_SIGREG()  {
792        if test ! "x$HAVE_SIGREG" = x ; then
793            return
794        fi
795        echo >> $LOGFILE
796        echo "running: check_HAVE_SIGREG()" >> $LOGFILE
797        get_fortran_c_namemangling
798        cat <<EOF > genmake_tc_1.c
799    $FC_NAMEMANGLE
800    #include <stdlib.h>
801    #include <stdio.h>
802    #include <signal.h>
803    #include <errno.h>
804    #include <ucontext.h>
805    
806    int * ip;
807    
808    static void killhandler(
809        unsigned int sn, siginfo_t  si, struct ucontext *sc )
810    {
811        *ip = *ip + 1;
812        return;
813    }
814    
815    void FC_NAMEMANGLE(sigreg) (int * aip)
816    {
817        struct sigaction s;
818        ip = aip;
819        s.sa_flags = SA_SIGINFO;
820        s.sa_sigaction = (void *)killhandler;
821        if(sigaction (SIGTERM,&s,(struct sigaction *)NULL)) {
822            printf("Sigaction returned error = %d\n", errno);
823            exit(0);
824        }
825        return;
826    }
827    EOF
828        COMM="$CC $CFLAGS -c genmake_tc_1.c"
829        echo $COMM >> $LOGFILE
830        $COMM >> $LOGFILE 2>&1
831        RET_C=$?
832        cat <<EOF > genmake_tc_2.$FS
833          program hello
834          integer anint
835          common /iv/ anint
836          external sigreg
837          call sigreg(anint)
838          end
839    EOF
840        cat genmake_tc_2.$FS >> $LOGFILE
841        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
842        echo $COMM >> $LOGFILE
843        $COMM >> $LOGFILE 2>&1
844        RETVAL=$?
845        if test "x$RETVAL" = x0 ; then
846            HAVE_SIGREG=t
847            DEFINES="$DEFINES -DHAVE_SIGREG"
848        fi
849        rm -f genmake_tc*
850        echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE
851    }
852    
853    
854    check_HAVE_SETRLSTK()  {
855        if test "x$HAVE_SETRLSTK" = xt ; then
856            DEFINES="$DEFINES -DHAVE_SETRLSTK"
857            return
858        fi  
859        if test ! "x$HAVE_SETRLSTK" = x ; then
860            return
861        fi
862        echo >> $LOGFILE
863        echo "running: check_HAVE_SETRLSTK()" >> $LOGFILE
864        get_fortran_c_namemangling
865        cat <<EOF > genmake_tc_1.c
866    $FC_NAMEMANGLE
867    #include <sys/time.h>
868    #include <sys/resource.h>
869    #include <unistd.h>
870    void FC_NAMEMANGLE(setrlstk) ()
871    {
872        struct rlimit rls;
873        rls.rlim_cur = RLIM_INFINITY;
874        rls.rlim_max = RLIM_INFINITY;
875        setrlimit(RLIMIT_STACK, &rls);
876        return;
877    }
878    EOF
879        COMM="$CC $CFLAGS -c genmake_tc_1.c"
880        echo $COMM >> $LOGFILE
881        $COMM >> $LOGFILE 2>&1
882        RET_C=$?
883        cat <<EOF > genmake_tc_2.$FS
884          program hello
885          external setrlstk
886          call setrlstk()
887          end
888    EOF
889        cat genmake_tc_2.$FS >> $LOGFILE
890        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
891        echo $COMM >> $LOGFILE
892        $COMM >> $LOGFILE 2>&1
893        RETVAL=$?
894        if test "x$RETVAL" = x0 ; then
895            HAVE_SETRLSTK=t
896            DEFINES="$DEFINES -DHAVE_SETRLSTK"
897        fi
898        rm -f genmake_tc*
899        echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE
900    }
901    
902    
903    check_HAVE_STAT()  {
904        echo >> $LOGFILE
905        echo "running: check_HAVE_STAT()" >> $LOGFILE
906        get_fortran_c_namemangling
907        cat <<EOF > genmake_tc_1.c
908    $FC_NAMEMANGLE
909    #include <stdio.h>
910    #include <stdlib.h>
911    #include <unistd.h>
912    #include <sys/stat.h>
913    #include <sys/types.h>
914    void FC_NAMEMANGLE(tfsize) ( int *nbyte )
915    {
916        char name[512];
917        struct stat astat;
918    
919        name[0] = 'a'; name[1] = '\0';
920        if (! stat(name, &astat))
921            *nbyte = (int)(astat.st_size);
922        else
923            *nbyte = -1;
924    }
925    EOF
926        COMM="$CC $CFLAGS -c genmake_tc_1.c"
927        echo $COMM >> $LOGFILE
928        $COMM >> genmake_tc.log 2>&1
929        RET_C=$?
930        cat <<EOF > genmake_tc_2.$FS
931          program hello
932          integer nbyte
933          call tfsize(nbyte)
934          print *," HELLO WORLD", nbyte
935          end
936    EOF
937        cat genmake_tc_2.$FS >> $LOGFILE
938        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
939        echo $COMM >> $LOGFILE
940        $COMM >> genmake_tc.log 2>&1
941        RETVAL=$?
942        if test "x$RETVAL" = x0 ; then
943            HAVE_STAT=t
944            DEFINES="$DEFINES -DHAVE_STAT"
945        fi
946        rm -f genmake_tc*
947        echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE
948  }  }
949    
950    
951  check_netcdf_libs()  {  check_netcdf_libs()  {
952      cat <<EOF > genmake_tnc.for      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
953            return
954        fi
955        echo >> $LOGFILE
956        echo "running: check_netcdf_libs()" >> $LOGFILE
957        cat <<EOF > genmake_tnc.F
958        program fgennc        program fgennc
959  #include "netcdf.inc"  #include "netcdf.inc"
960    EOF
961        if test ! "x$MPI" = x ; then
962            echo '#include "mpif.h"' >> genmake_tnc.F
963        fi
964        cat <<EOF >> genmake_tnc.F
965        integer iret, ncid, xid        integer iret, ncid, xid
966        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
967        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
# Line 619  check_netcdf_libs()  { Line 971  check_netcdf_libs()  {
971        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
972        end        end
973  EOF  EOF
974      $CPP genmake_tnc.for > genmake_tnc.f  \      echo "===  genmake_tnc.F  >>>" > genmake_tnc.log
975          &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1      cat genmake_tnc.F >> genmake_tnc.log
976        echo "<<<  genmake_tnc.F  ===" >> genmake_tnc.log
977        RET_CPP=f
978        COMM="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES"
979        echo "$COMM" >> genmake_tnc.log
980        eval $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t
981        if test "x$RET_CPP" = xf ; then
982            echo "  WARNING: CPP failed to pre-process the netcdf test." \
983                >> genmake_tnc.log
984            echo "    Please check that \$INCLUDES is properly set." \
985                >> genmake_tnc.log
986        fi
987        echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log
988        echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc.o $LIBS" >> genmake_tnc.log
989        $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
990            &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
991      RET_COMPILE=$?      RET_COMPILE=$?
992      test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1      cat genmake_tnc.log >> $LOGFILE
993      RETVAL=$?  
994      if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then      #EH3  Remove test program execution for machines that either disallow
995        #EH3  execution or cannot support it (eg. cross-compilers)
996        #EH3
997        #EH3 test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
998        #EH3 RETVAL=$?
999        #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
1000    
1001        if test "x$RET_COMPILE" = x0 ; then
1002          HAVE_NETCDF=t          HAVE_NETCDF=t
1003            echo "check_netcdf: successful" >> $LOGFILE
1004      else      else
1005          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
1006          $CPP genmake_tnc.for > genmake_tnc.f  \          echo "==> try again with added '-lnetcdf'" > genmake_tnc.log
1007              &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \          echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
1008              $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
1009            echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
1010            cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null  \
1011                &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
1012                &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
1013          RET_COMPILE=$?          RET_COMPILE=$?
1014          test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1          echo >> $LOGFILE
1015          RETVAL=$?          cat genmake_tnc.log >> $LOGFILE
1016          if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then          if test "x$RET_COMPILE" = x0 ; then
1017              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
1018              HAVE_NETCDF=t              HAVE_NETCDF=t
1019                echo "check_netcdf: successful" >> $LOGFILE
1020          else          else
1021              cat genmake_tnc.log >> genmake_warnings          # try again with "-lnetcdff" added to the libs
1022                echo "==> try again with added '-lnetcdff -lnetcdf'" > genmake_tnc.log
1023                echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
1024                echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
1025                echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
1026                cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null  \
1027                    &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
1028                    &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdff -lnetcdf >> genmake_tnc.log 2>&1
1029                RET_COMPILE=$?
1030                echo >> $LOGFILE
1031                cat genmake_tnc.log >> $LOGFILE
1032                if test "x$RET_COMPILE" = x0 ; then
1033                    LIBS="$LIBS -lnetcdff -lnetcdf"
1034                    HAVE_NETCDF=t
1035                    echo "check_netcdf: successful" >> $LOGFILE
1036                fi
1037          fi          fi
1038      fi      fi
1039      rm -f genmake_tnc*      rm -f genmake_tnc*
1040        echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE
1041  }  }
1042    
1043    
# Line 657  PLATFORM= Line 1053  PLATFORM=
1053  LN=  LN=
1054  S64=  S64=
1055  KPP=  KPP=
1056  FC=  #FC=
1057  CPP=  #CC=gcc
1058    #CPP=
1059  LINK=  LINK=
1060  DEFINES=  DEFINES=
1061  PACKAGES=  PACKAGES=
1062  ENABLE=  ENABLE=
1063  DISABLE=  DISABLE=
1064  MAKEFILE=  # MAKEFILE=
1065  MAKEDEPEND=  # MAKEDEPEND=
1066  PDEPEND=  PKG_DEPEND=
1067  DUMPSTATE=t  PKG_GROUPS=
1068  PDEFAULT=  DUMPSTATE=f
1069  OPTFILE=  OPTFILE=
1070  INCLUDES="-I."  INCLUDES="-I. $INCLUDES"
1071  FFLAGS=  FFLAGS=
1072  FOPTIM=  FOPTIM=
1073    FEXTRAFLAGS=
1074    USE_EXTENDED_SRC=
1075    EXTENDED_SRC_FLAG=
1076  CFLAGS=  CFLAGS=
1077  KFLAGS1=  KFLAGS1=
1078  KFLAGS2=  KFLAGS2=
# Line 683  NOOPTFILES= Line 1083  NOOPTFILES=
1083  NOOPTFLAGS=  NOOPTFLAGS=
1084  MPI=  MPI=
1085  MPIPATH=  MPIPATH=
1086    OMP=
1087    OMPFLAG=
1088    USE_R4=
1089    TS=
1090    PAPIS=
1091    PCLS=
1092    FOOLAD=
1093    PAPI=
1094    PCL=
1095    HPMT=
1096    GSL=
1097    DEVEL=
1098    HAVE_TEST_L=
1099    
1100  # DEFINES checked by test compilation  # DEFINES checked by test compilation or command-line
1101  HAVE_SYSTEM=  HAVE_SYSTEM=
1102  HAVE_FDATE=  HAVE_FDATE=
1103  FC_NAMEMANGLE=  FC_NAMEMANGLE=
1104  HAVE_CLOC=  HAVE_CLOC=
1105    # HAVE_SETRLSTK=
1106    HAVE_STAT=
1107  HAVE_NETCDF=  HAVE_NETCDF=
1108  HAVE_ETIME=  HAVE_ETIME=
1109    IGNORE_TIME=
1110    
1111  MODS=  MODS=
1112  TOOLSDIR=  TOOLSDIR=
# Line 701  STANDARDDIRS="USE_THE_DEFAULT" Line 1117  STANDARDDIRS="USE_THE_DEFAULT"
1117  G2ARGS=  G2ARGS=
1118  BASH=  BASH=
1119  PWD=`pwd`  PWD=`pwd`
1120  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
1121  AWK=awk  test "x$AWK" = x   &&  AWK=awk
1122  THISHOSTNAME=`hostname`  EMBED_SRC=
1123    THISHOST=`hostname`
1124  THISCWD=`pwd`  THISCWD=`pwd`
1125  THISDATE=`date`  THISDATE=`date`
1126    THISUSER=`echo $USER`
1127    THISVER=
1128  MACHINE=`uname -a`  MACHINE=`uname -a`
1129  EXECUTABLE=  EXECUTABLE=
1130  EXEHOOK=  EXEHOOK=
# Line 731  FTL_TAF_FLAGS= Line 1150  FTL_TAF_FLAGS=
1150  SVD_TAMC_FLAGS=  SVD_TAMC_FLAGS=
1151  TAMC_EXTRA=  TAMC_EXTRA=
1152    
   
1153  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1154  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PKG_DEPEND PKG_GROUPS MAKEFILE MAKEDEPEND PLATFORM ROOTDIR MODS DISABLE ENABLE"
1155  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC IEEE USE_R4 TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI OMP DUMPSTATE STANDARDDIRS"
1156    
1157  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1158  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "  gm_s3="LN S64 LINK MAKE PACKAGES INCLUDES FFLAGS FOPTIM FEXTRAFLAGS"
1159  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
1160  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD THISHOST THISUSER THISDATE THISVER MACHINE"
1161  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
1162  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"  gm_s7="FC_NAMEMANGLE HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME"
1163    
1164  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1165  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
# Line 755  cat <<EOF Line 1173  cat <<EOF
1173    
1174  GENMAKE :  GENMAKE :
1175    
1176  A program for GENerating MAKEfiles for the MITgcm project.  For a  A program for GENerating MAKEfiles for the MITgcm project.
1177  quick list of options, use "genmake -h" or for more detail see:     For a quick list of options, use "genmake2 -h"
1178    or for more detail see the Developer's HOWTO manual at:
1179    http://mitgcm.org/devel_HOWTO/     http://mitgcm.org/public/docs.html
1180    
1181  EOF  EOF
1182    
1183    LOGFILE="genmake.log"
1184    #- clean-up previous genmake logfiles:
1185    rm -f genmake_state genmake_*optfile $LOGFILE
1186    
1187  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
1188  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  
1189  printf "  getting local config information:  "  printf "  getting local config information:  "
1190  if test -e $gm_local ; then  if test -f $gm_local ; then
1191      echo "using $gm_local"      echo "using $gm_local"
1192      . $gm_local      . $gm_local
1193      # echo "DISABLE=$DISABLE"      # echo "DISABLE=$DISABLE"
# Line 780  else Line 1196  else
1196      echo "none found"      echo "none found"
1197  fi  fi
1198    
1199  #  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  
1200  #parse_options  #parse_options
1201  ac_prev=  ac_prev=
1202  for ac_option ; do  for ac_option in "$@" ; do
1203    
1204      G2ARGS="$G2ARGS \"$ac_option\""      G2ARGS="$G2ARGS \"$ac_option\""
1205    
# Line 802  for ac_option ; do Line 1209  for ac_option ; do
1209          ac_prev=          ac_prev=
1210          continue          continue
1211      fi      fi
1212        
1213      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
1214        
1215      case $ac_option in      case $ac_option in
1216                    
1217          -help | --help | -h | --h)          -help | --help | -h | --h)
# Line 823  for ac_option ; do Line 1230  for ac_option ; do
1230              AD_OPTFILE=$ac_optarg ;;              AD_OPTFILE=$ac_optarg ;;
1231                    
1232          -pdepend | --pdepend)          -pdepend | --pdepend)
1233              ac_prev=PDEPEND ;;              ac_prev=PKG_DEPEND ;;
1234          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
1235              PDEPEND=$ac_optarg ;;              PKG_DEPEND=$ac_optarg ;;
1236                    
1237          -pdefault | --pdefault)          -pgroups | --pgroups)
1238              ac_prev=PDEFAULT ;;              ac_prev=PKG_GROUPS ;;
1239          -pdefault=* | --pdefault=*)          -pgroups=* | --pgroups=*)
1240              PDEFAULT=$ac_optarg ;;              PKG_GROUPS=$ac_optarg ;;
1241                    
1242          -make | --make | -m | --m)          -make | --make | -m | --m)
1243              ac_prev=MAKE ;;              ac_prev=MAKE ;;
# Line 888  for ac_option ; do Line 1295  for ac_option ; do
1295  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1296  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1297  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1298                        
1299            -cc | --cc)
1300                ac_prev=CC ;;
1301            -cc=* | --cc=*)
1302                CC=$ac_optarg ;;
1303            
1304          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1305              ac_prev=FC ;;              ac_prev=FC ;;
1306          -fc=* | --fc=*)          -fc=* | --fc=*)
# Line 909  for ac_option ; do Line 1321  for ac_option ; do
1321          -noieee | --noieee)          -noieee | --noieee)
1322              IEEE= ;;              IEEE= ;;
1323    
1324            -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )
1325                USE_R4=true ;;
1326    
1327            -ts | --ts)
1328                TS=true ;;
1329            -papis | --papis)
1330                PAPIS=true ;;
1331            -pcls | --pcls)
1332                PCLS=true ;;
1333            -foolad | --foolad)
1334                FOOLAD=true ;;
1335            -papi | --papi)
1336                PAPI=true ;;
1337            -pcl | --pcl)
1338                PCL=true ;;
1339            -hpmt | --hpmt)
1340                HPMT=true ;;
1341    
1342            -gsl | --gsl)
1343                GSL=true ;;
1344    
1345            -devel | --devel)
1346                DEVEL=true ;;
1347    
1348          -mpi | --mpi)          -mpi | --mpi)
1349              MPI=true ;;              MPI=true ;;
1350          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
1351              MPIPATH=$ac_optarg              MPIPATH=$ac_optarg
1352              MPI=true ;;              MPI=true ;;
1353                    
1354  #       -jam | --jam)          -omp | --omp)
1355  #           JAM=1 ;;              OMP=true ;;
1356  #       -nojam | --nojam)          -omp=* | --omp=*)
1357  #           JAM=0 ;;              OMPFLAG=$ac_optarg
1358                OMP=true ;;
1359                    
1360          -ds | --ds)          -ds | --ds)
1361              DUMPSTATE=t ;;              DUMPSTATE=t ;;
# Line 932  for ac_option ; do Line 1369  for ac_option ; do
1369              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1370          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1371              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1372            
1373            -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1374                IGNORE_TIME="-DIGNORE_TIME" ;;
1375    
1376            -es | --es | -embed-source | --embed-source)
1377                EMBED_SRC=t ;;
1378    
1379          -*)          -*)
1380              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
# Line 944  for ac_option ; do Line 1387  for ac_option ; do
1387              ;;              ;;
1388                    
1389      esac      esac
1390        
1391  done  done
1392    
1393    
1394  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1395      echo      echo
1396      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
1397      echo "  file.  This file format is no longer supported.  Please see:"      echo "  file.  This file format is no longer supported.  For directions on"
1398      echo      echo "  how to setup and use the new \"genmake2\" script, please see:"
1399      echo "    http://mitgcm.org/devel_HOWTO/"      echo "    http://mitgcm.org/devel_HOWTO/"
1400        echo "  and send an email to MITgcm-support@mitgcm.org if you need help."
1401        echo "WARNING: ignore \"./.genmakerc\" and continue."
1402      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  
1403  fi  fi
1404    
1405    #  Find the MITgcm ${ROOTDIR}
1406  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1407      if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1408        if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesupp -a -d ../pkg ; then
1409          ROOTDIR=".."          ROOTDIR=".."
1410      else      else
1411          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
# Line 984  if test ! -d ${ROOTDIR} ; then Line 1429  if test ! -d ${ROOTDIR} ; then
1429      exit 1      exit 1
1430  fi  fi
1431    
1432    #  Find the MITgcm ${THISVER}
1433    version_file="${ROOTDIR}/doc/tag-index"
1434    if test -f $version_file ; then
1435        THISVER=`$AWK '/^checkpoint/{print $1; exit}' $version_file`
1436    #-  remove ./BUILD_INFO.h file if older than version_file
1437        if test -f ./BUILD_INFO.h -a ./BUILD_INFO.h -ot $version_file ; then
1438            echo "  remove ./BUILD_INFO.h (older than ${version_file})"
1439            rm -f ./BUILD_INFO.h
1440        fi
1441    fi
1442    
1443    if test "x$MAKEFILE" = x ; then
1444        MAKEFILE="Makefile"
1445    fi
1446    
1447  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
1448  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1449      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
1450          echo "Warning: no OPTFILE specified so we'll look for possible settings"          echo "Warning: no OPTFILE specified so we'll look for possible settings"
1451          printf "\n===  Searching for possible settings for OPTFILE  ===\n"          printf "\n===  Searching for possible settings for OPTFILE  ===\n"
1452          find_possible_configs          find_possible_optfile
1453      else      else
1454          OPTFILE=$MITGCM_OF          OPTFILE=$MITGCM_OF
1455      fi      fi
# Line 1004  if test "x$OPTFILE" != xNONE ; then Line 1464  if test "x$OPTFILE" != xNONE ; then
1464              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1465              exit 1              exit 1
1466          fi          fi
1467          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" = xt ; then
1468              cp -f $OPTFILE "genmake_optfile"              cp -f $OPTFILE "genmake_optfile"
1469          fi          fi
1470      else      else
# Line 1013  if test "x$OPTFILE" != xNONE ; then Line 1473  if test "x$OPTFILE" != xNONE ; then
1473      fi      fi
1474  fi  fi
1475    
 #  Check for broken systems that cannot correctly distinguish *.F and *.f files  
 # check_for_broken_Ff  
   
1476  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:  "
1477  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1478      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" = x ; then
# Line 1034  if test "x${AD_OPTFILE}" != xNONE ; then Line 1491  if test "x${AD_OPTFILE}" != xNONE ; then
1491              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1492              exit 1              exit 1
1493          fi          fi
1494          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" = xt ; then
1495              cp -f $AD_OPTFILE "genmake_ad_optfile"              cp -f $AD_OPTFILE "genmake_ad_optfile"
1496          fi          fi
1497      else      else
# Line 1043  if test "x${AD_OPTFILE}" != xNONE ; then Line 1500  if test "x${AD_OPTFILE}" != xNONE ; then
1500      fi      fi
1501  fi  fi
1502    
1503  #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #====================================================================
1504    #  Set default values if not set by the optfile
1505    #
1506    #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1507  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1508  if test ! "x$BASH" = x ; then  if test ! "x$BASH" = x ; then
1509      # 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 1059  Error: no Fortran compiler: please speci Line 1519  Error: no Fortran compiler: please speci
1519  EOF  EOF
1520      exit 1      exit 1
1521  fi  fi
1522    
1523    if test "x$CC" = x ; then
1524        look_for_C_compilers
1525    #   CC=cc
1526    #     cat <<EOF 1>&2
1527    # Error: no C compiler: please specify using one of the following:
1528    #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1529    #   2) the "-cc=XXX" command-line option
1530    #   3) the "./genmake_local" file
1531    # EOF
1532    #     exit 1
1533    fi
1534    
1535  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1536      LINK=$FC      LINK=$FC
1537  fi  fi
# Line 1066  if test "x$MAKE" = x ; then Line 1539  if test "x$MAKE" = x ; then
1539      MAKE="make"      MAKE="make"
1540  fi  fi
1541  if test "x$CPP" = x ; then  if test "x$CPP" = x ; then
1542      CPP=cpp      CPP="cpp -traditional -P"
1543  fi  fi
1544  #EH3 === UGLY ===  #EH3 === UGLY ===
1545  #  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 1093  EOF Line 1566  EOF
1566  else  else
1567      rm -f test_cpp      rm -f test_cpp
1568  fi  fi
1569    
1570  look_for_makedepend  look_for_makedepend
1571    
1572    #  Check that soft-link command is set and usable
1573  if test "x$LN" = x ; then  if test "x$LN" = x ; then
1574      LN="ln -s"      LN="ln -s"
1575  fi  fi
# Line 1103  RETVAL=$? Line 1579  RETVAL=$?
1579  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
1580      cat <<EOF 1>&2      cat <<EOF 1>&2
1581    
1582  Error: The command "ln -s" failed -- please specify a working soft-link  Error: The command "$LN" failed -- please specify a working soft-link
1583    command in the optfile.    command in the optfile.
1584    
1585  EOF  EOF
1586      exit 1      exit 1
1587  fi  fi
1588    test -L genmake_tlink > /dev/null 2>&1
1589    RETVAL=$?
1590    if test "x$RETVAL" = x0 ; then
1591        HAVE_TEST_L=t
1592    fi
1593  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
1594    
1595  #  Check for broken *.F/*.f handling and fix if possible  #  Check for broken *.F/*.f handling and fix if possible
# Line 1118  if test ! "x$MPI" = x ; then Line 1599  if test ! "x$MPI" = x ; then
1599        echo "  Turning on MPI cpp macros"        echo "  Turning on MPI cpp macros"
1600        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1601  fi  fi
1602    if test ! "x$OMP" = x ; then
1603          echo "  Add OMPFLAG and turn on OpenMP cpp macros"
1604          FFLAGS="$FFLAGS $OMPFLAG"
1605          F90FLAGS="$F90FLAGS $OMPFLAG"
1606          DEFINES="$DEFINES -DUSE_OMP_THREADING"
1607    fi
1608    
1609    if test ! "x$USE_R4" = x ; then
1610          echo "  Turning on LET_RS_BE_REAL4 cpp flag"
1611          DEFINES="$DEFINES -DLET_RS_BE_REAL4"
1612    fi
1613    
1614    if test ! "x$TS" = x ; then
1615          echo "  Turning on timing per timestep"
1616          if test ! "x$FOOLAD" = x ; then
1617                DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"
1618          else
1619                DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1620          fi
1621          PACKAGES="$PACKAGES showflops"
1622    fi
1623    if test ! "x$PAPIS" = x ; then
1624          echo "  Turning on PAPI flop summary per timestep"
1625          echo "  Please make sure PAPIINC, PAPILIB are defined"
1626          if test ! "x$FOOLAD" = x ; then
1627                DEFINES="$DEFINES -DUSE_PAPI_FLOPS_SFP"
1628          else
1629                DEFINES="$DEFINES -DUSE_PAPI_FLOPS"
1630          fi
1631          INCLUDES="$INCLUDES $PAPIINC"
1632          LIBS="$LIBS $PAPILIB"
1633          PACKAGES="$PACKAGES showflops"
1634    fi
1635    if test ! "x$PCLS" = x ; then
1636          echo "  Turning on PCL counter summary per timestep"
1637          echo "  Please make sure PCLINC, PCLLIB are defined"
1638          if test ! "x$FOOLAD" = x ; then
1639                DEFINES="$DEFINES -DUSE_PCL_FLOPS_SFP"
1640          else
1641                DEFINES="$DEFINES -DUSE_PCL_FLOPS"
1642          fi
1643          INCLUDES="$INCLUDES $PCLINC"
1644          LIBS="$LIBS $PCLLIB"
1645          PACKAGES="$PACKAGES showflops"
1646    fi
1647    if test ! "x$PAPI" = x ; then
1648          if test ! "x$PAPIS" = x ; then
1649              echo "  PAPI performance analysis and flop summary per timestep cannot co-exist!"
1650              echo "  Sticking with PAPI flop summary per timestep!"
1651          else
1652              echo "  Turning on performance analysis with PAPI"
1653              echo "  Please make sure PAPIINC, PAPILIB are defined"
1654              DEFINES="$DEFINES -DUSE_PAPI"
1655              INCLUDES="$INCLUDES $PAPIINC"
1656              LIBS="$LIBS $PAPILIB"
1657          fi
1658    fi
1659    if test ! "x$PCL" = x ; then
1660          if test ! "x$PCLS" = x ; then
1661              echo "  PCL performance analysis and flop summary per timestep cannot co-exist!"
1662              echo "  Sticking with PCL flop summary per timestep!"
1663          else
1664              echo "  Turning on performance analysis with PCL"
1665              echo "  Please make sure PCLINC, PCLLIB are defined"
1666              DEFINES="$DEFINES -DUSE_PCL"
1667              INCLUDES="$INCLUDES $PCLINC"
1668              LIBS="$LIBS $PCLLIB"
1669          fi
1670    fi
1671    if test ! "x$HPMT" = x ; then
1672          if test ! "x$PAPI" = x ; then
1673              echo "  PAPI and the HPM Toolkit cannot co-exist!"
1674              echo "  Sticking with PAPI!"
1675          else if test ! "x$PCL" = x ; then
1676              echo "  PCL and the HPM Toolkit cannot co-exist!"
1677              echo "  Sticking with PCL!"
1678          else
1679              echo "  Turning on performance analysis with the HPM Toolkit"
1680              echo "  Please make sure HPMTINC, HPMTLIB are defined"
1681              DEFINES="$DEFINES -DUSE_LIBHPM"
1682              INCLUDES="$INCLUDES $HPMTINC"
1683              LIBS="$LIBS $HPMTLIB"
1684          fi
1685          fi
1686    fi
1687    if test ! "x$GSL" = x ; then
1688          echo "  Turning on use of GSL to control floating point calculations"
1689          echo "  Please make sure GSLINC, GSLLIB are defined"
1690          DEFINES="$DEFINES -DUSE_GSL_IEEE"
1691          INCLUDES="$INCLUDES $GSLINC"
1692          LIBS="$LIBS $GSLLIB"
1693    fi
1694    #- if USE_EXTENDED_SRC is set, add EXTENDED_SRC_FLAG to FFLAGS :
1695    if test ! "x$USE_EXTENDED_SRC" = x ; then
1696          FFLAGS="$FFLAGS $EXTENDED_SRC_FLAG"
1697          F90FIXEDFORMAT="$F90FIXEDFORMAT $EXTENDED_SRC_FLAG"
1698    fi
1699    
1700  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1701  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1702  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1703        program hello        program hello
1704        call system('echo hi')        call system('echo hi')
1705        end        end
1706  EOF  EOF
1707  $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
1708  RETVAL=$?  RETVAL=$?
1709  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1710      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 1139  fi Line 1717  fi
1717  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1718    
1719  printf "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1720  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1721        program hello        program hello
1722        CHARACTER(128) string        CHARACTER*(128) string
1723        string = ' '        string = ' '
1724        call fdate( string )        call fdate( string )
1725        print *, string        print *, string
1726        end        end
1727  EOF  EOF
1728  $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
1729  RETVAL=$?  RETVAL=$?
1730  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1731      HAVE_FDATE=t      HAVE_FDATE=t
# Line 1160  fi Line 1738  fi
1738  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1739    
1740  printf "  Do we have the etime() command using $FC...  "  printf "  Do we have the etime() command using $FC...  "
1741  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1742        program hello        program hello
1743        REAL*4 ACTUAL, TARRAY(2)        REAL*4 ACTUAL, TARRAY(2)
1744        EXTERNAL ETIME        EXTERNAL ETIME
# Line 1169  cat > genmake_tcomp.f <<EOF Line 1747  cat > genmake_tcomp.f <<EOF
1747        print *, tarray        print *, tarray
1748        end        end
1749  EOF  EOF
1750  $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
1751  RETVAL=$?  RETVAL=$?
1752  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1753      HAVE_ETIME=t      HAVE_ETIME=t
# Line 1187  if test "x$HAVE_CLOC" != x ; then Line 1765  if test "x$HAVE_CLOC" != x ; then
1765      echo "yes"      echo "yes"
1766  else  else
1767      echo "no"      echo "no"
1768        if test "x$EMBED_SRC" = xt ; then
1769            echo "    WARNING: you requested file embedding but it has"
1770            echo "      been disabled since C code cannot be called"
1771            EMBED_SRC=
1772        fi
1773    fi
1774    rm -f genmake_t*
1775    
1776    printf "  Can we unlimit the stack size using $FC...  "
1777    check_HAVE_SETRLSTK
1778    if test "x$HAVE_SETRLSTK" = xt ; then
1779        echo "yes"
1780    else
1781        echo "no"
1782    fi
1783    rm -f genmake_t*
1784    
1785    printf "  Can we register a signal handler using $FC...  "
1786    check_HAVE_SIGREG
1787    if test "x$HAVE_SIGREG" = xt ; then
1788        echo "yes"
1789    else
1790        echo "no"
1791    fi
1792    rm -f genmake_t*
1793    
1794    printf "  Can we use stat() through C calls...  "
1795    check_HAVE_STAT
1796    if test "x$HAVE_STAT" != x ; then
1797        echo "yes"
1798    else
1799        echo "no"
1800  fi  fi
1801  rm -f genmake_t*  rm -f genmake_t*
1802    
# Line 1197  if test "x$HAVE_NETCDF" != x ; then Line 1807  if test "x$HAVE_NETCDF" != x ; then
1807  else  else
1808      echo "no"      echo "no"
1809  fi  fi
1810    DEFINES="$DEFINES $IGNORE_TIME"
1811    
1812    if test "x$EMBED_SRC" = xt ; then
1813        build_embed_encode
1814    fi
1815    if test "x$EMBED_SRC" = xt ; then
1816        ENABLE="$ENABLE embed_files"
1817    fi
1818    
1819    
1820  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1821  printf "  Adding MODS directories:  "  printf "  Adding MODS directories: "
1822  for d in $MODS ; do  for d in $MODS ; do
1823      if test ! -d $d ; then      if test ! -d $d ; then
1824          echo          echo
1825          echo "Error: MODS directory \"$d\" not found!"          echo "Error: MODS directory \"$d\" not found!"
1826          exit 1          exit 1
1827      else      else
1828          printf " $d"          printf "$d "
1829          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1830          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
1831      fi      fi
1832  done  done
1833  echo  echo
1834    
1835  if test "x$MAKEFILE" = x ; then  #if test "x${PLATFORM}" = x ; then
1836      MAKEFILE="Makefile"  #    PLATFORM=$p_PLATFORM
1837  fi  #fi
 if test "x${PLATFORM}" = x ; then  
     PLATFORM=$p_PLATFORM  
 fi  
1838    
1839  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1840      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1841        if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1842          EXEDIR=../exe          EXEDIR=../exe
1843      else      else
1844          EXEDIR=.          EXEDIR=.
# Line 1241  if test ! -d ${TOOLSDIR} ; then Line 1857  if test ! -d ${TOOLSDIR} ; then
1857      exit 1      exit 1
1858  fi  fi
1859  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1860      S64='$(TOOLSDIR)/set64bitConst.sh'      echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1861        RETVAL=$?
1862        if test "x${RETVAL}" = x0 ; then
1863            S64='$(TOOLSDIR)/set64bitConst.sh'
1864        else
1865            echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1866            RETVAL=$?
1867            if test "x${RETVAL}" = x0 ; then
1868                S64='$(TOOLSDIR)/set64bitConst.csh'
1869            else
1870                cat <<EOF
1871    
1872    ERROR: neither of the two default scripts:
1873    
1874        ${TOOLSDIR}/set64bitConst.sh
1875        ${TOOLSDIR}/set64bitConst.csh
1876    
1877      are working so please check paths or specify (with \$S64) a
1878      working version of this script.
1879    
1880    EOF
1881                exit 1
1882            fi
1883        fi
1884  fi  fi
1885  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1886    
1887  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
1888    
1889    #  Set Standard Code Directories:
1890    if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
1891        STANDARDDIRS="eesupp model"
1892    fi
1893    #  if model in Standard-Code-Dir, add eesupp (needed to compile model)
1894    echo " $STANDARDDIRS " | grep ' model ' > /dev/null 2>&1
1895    ckM=$?
1896    echo " $STANDARDDIRS " | grep ' eesupp ' > /dev/null 2>&1
1897    ckE=$?
1898    if test $ckM = 0 -a $ckE = 1 ; then
1899        STANDARDDIRS="$STANDARDDIRS eesupp"
1900    fi
1901    
1902  #  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
1903  #  generated from some template source files. We'll make them first so  #  generated from some template source files. We'll make them first so
1904  #  they appear as regular source code  #  they appear as regular source code
1905  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
1906      echo "  Making source files in eesupp from templates"      echo "  Making source files in eesupp from templates"
1907      ( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1      ( cd $ROOTDIR"/eesupp/src/" && $MAKE clean_old && $MAKE \
1908        ) > make_eesupp.errors 2>&1
1909      RETVAL=$?      RETVAL=$?
1910      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
1911          rm -f make_eesupp.errors          rm -f make_eesupp.errors
# Line 1263  if test -r $ROOTDIR"/eesupp/src/Makefile Line 1916  if test -r $ROOTDIR"/eesupp/src/Makefile
1916      fi      fi
1917  fi  fi
1918    
1919  #same for exch2  #same for pkg/exch2 and pkg/regrid
1920  if test -r $ROOTDIR"/pkg/exch2/Makefile" ; then  for pdir in exch2 regrid ; do
1921      echo "  Making source files in exch2 from  templates"      if test -r $ROOTDIR"/pkg/${pdir}/Makefile" ; then
1922      ( cd $ROOTDIR"/pkg/exch2/" && $MAKE ) > make_exch2.errors 2>&1          echo "  Making source files in pkg/${pdir} from templates"
1923      RETVAL=$?          ( cd $ROOTDIR"/pkg/"${pdir} && $MAKE clean_old && $MAKE \
1924      if test "x${RETVAL}" = x0 ; then          ) > make_${pdir}.errors 2>&1
1925          rm -f make_exch2.errors          RETVAL=$?
1926      else          if test "x${RETVAL}" = x0 ; then
1927          echo "Error: problem encountered while building source files in exch2:"              rm -f make_${pdir}.errors
1928          cat make_exch2.errors 1>&2          else
1929          exit 1              echo "Error: problem encountered while building source files in pkg/${pdir}:"
1930                cat make_${pdir}.errors 1>&2
1931                exit 1
1932            fi
1933      fi      fi
1934  fi  done
1935    
1936  printf "\n===  Determining package settings  ===\n"  printf "\n===  Determining package settings  ===\n"
1937  if  test "x${PDEPEND}" = x ; then  if  test "x${PKG_DEPEND}" = x ; then
1938      tmp=$ROOTDIR"/pkg/pkg_depend"      tmp=$ROOTDIR"/pkg/pkg_depend"
1939      if test -r $tmp ; then      if test -r $tmp ; then PKG_DEPEND=$tmp ; fi
1940          PDEPEND=$tmp  fi
1941      else  if  test "x${PKG_DEPEND}" = x ; then
1942          echo "Warning:  No package dependency information was specified."          echo "Warning:  No package dependency information was specified."
1943          echo "  Please check that ROOTDIR/pkg/pkg_depend exists."          echo "  Please check that ROOTDIR/pkg/pkg_depend exists."
     fi  
1944  else  else
1945      if test ! -r ${PDEPEND} ; then      if test ! -r ${PKG_DEPEND} ; then
1946          echo "Error:  can't read package dependency info from PDEPEND=\"$PDEPEND\""          echo "Error:  can't read package dependency info from PKG_DEPEND=\"$PKG_DEPEND\""
1947          exit 1          exit 1
1948      fi      fi
1949        echo "  getting package dependency info from  $PKG_DEPEND"
1950    #  Strip the comments and then convert the dependency file into arrays: PNAME, DNAME
1951        get_pdepend_list $PKG_DEPEND
1952  fi  fi
1953  echo "  getting package dependency info from  $PDEPEND"  
1954  #  Strip the comments and then convert the dependency file into  # A default package groups file "$ROOTDIR/pkg/pkg_groups" is provided
1955  #  two arrays: PNAME, DNAME  #  to define the "default_pkg_list" and package groups (for convenience, one
1956  cat $PDEPEND | sed -e 's/#.*$//g' \  #  can specify a group of packages using names like "ocean" and "atmosphere").
1957      | $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
1958      > ./.pd_tmp      tmp=$ROOTDIR"/pkg/pkg_groups"
1959  RETVAL=$?      if test -r $tmp ; then PKG_GROUPS=$tmp ; fi
1960  if test ! "x${RETVAL}" = x0 ; then  fi
1961      echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""  if test "x${PKG_GROUPS}" = x ; then
1962      exit 1          echo "Warning:  No package groups information was specified."
1963            echo "  Please check that ROOTDIR/pkg/pkg_groups exists."
1964    else
1965        if test ! -r ${PKG_GROUPS} ; then
1966            echo "Error:  can't read package groups info from PKG_GROUPS=\"$PKG_GROUPS\""
1967            exit 1
1968        fi
1969        echo "  getting package groups info from      $PKG_GROUPS"
1970  fi  fi
 . ./.pd_tmp  
 rm -f ./.pd_tmp  
1971    
1972  #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"  #  Search for packages to compile.
1973  #  file should eventually be added so that, for convenience, one can  echo "  checking list of packages to compile:"
1974  #  specify groups of packages using names like "ocean" and "atmosphere".  PKG_LIST=
1975  echo "  checking default package list:  "  if test "x${PKG_LIST}" = x ; then
 if test "x${PDEFAULT}" = x ; then  
1976      for i in "." $MODS ; do      for i in "." $MODS ; do
1977          if test -r $i"/packages.conf" ; then          if test -r $i"/packages.conf" ; then
1978                  PDEFAULT=$i"/packages.conf"                  PKG_LIST=$i"/packages.conf"
1979                  break                  break
1980          fi          fi
1981      done      done
1982  fi  fi
1983  if test "x${PDEFAULT}" = x ; then  if test "x${PKG_LIST}" = x ; then
1984      PDEFAULT="$ROOTDIR/pkg/pkg_default"      pkg_list='default_pkg_list'
1985  fi      if test "x${PKG_GROUPS}" = x ; then
1986  if test "x${PDEFAULT}" = xNONE ; then          echo "Error:  need package groups info to expand pkg_list=\"$pkg_list\""
1987      echo "    default packages file disabled"          exit 1
1988        fi
1989  else  else
1990      if test ! -r $PDEFAULT ; then      if test ! -r $PKG_LIST ; then
1991          echo "Warning:  can't read default packages from PDEFAULT=\"$PDEFAULT\""          echo "Error:  can't read package list from PKG_LIST=\"$PKG_LIST\""
1992            exit 1
1993      else      else
1994          echo "    using PDEFAULT=\"$PDEFAULT\""          echo "    using PKG_LIST=\"$PKG_LIST\""
1995          #  Strip the comments and add all the names          #  Strip the comments and add all the names
1996          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}'`
1997          RETVAL=$?          RETVAL=$?
1998          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
1999              printf "Error: can't parse default package list "              printf "Error: can't parse package list "
2000              echo "-- please check PDEFAULT=\"$PDEFAULT\""              echo "-- please check PKG_LIST=\"$PKG_LIST\""
2001              exit 1              exit 1
2002          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"  
2003      fi      fi
2004  fi  fi
2005    for i in $pkg_list ; do
2006        PACKAGES="$PACKAGES $i"
2007    done
2008    echo     "    before group expansion packages are:$PACKAGES"
2009    if test "x${PKG_GROUPS}" != x ; then
2010        RET=1
2011        while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
2012        echo "    after group expansion packages are: $PACKAGES"
2013    fi
2014    
2015  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
2016    echo "" > ./.tmp_pack
2017  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2018      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
2019  done  done
# Line 1373  PACKAGES="$PACKAGES $ENABLE" Line 2041  PACKAGES="$PACKAGES $ENABLE"
2041  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2042      j=`echo $i | sed 's/[-+]//'`      j=`echo $i | sed 's/[-+]//'`
2043      if test ! -d "$ROOTDIR/pkg/$j" ; then      if test ! -d "$ROOTDIR/pkg/$j" ; then
2044          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
2045          exit 1          exit 1
2046      fi      fi
2047      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
# Line 1383  for i in `grep -v "-" ./.tmp_pack | sort Line 2051  for i in `grep -v "-" ./.tmp_pack | sort
2051      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
2052  done  done
2053  rm -f ./.tmp_pack  rm -f ./.tmp_pack
2054  echo "    packages are:  $PACKAGES"  echo "    packages are: $PACKAGES"
2055    
2056    #  Check for package MNC: if NetCDF is available, then build the MNC
2057    #  template files ; otherwise, delete mnc from the list of packages.
2058    echo " $PACKAGES " | grep ' mnc ' > /dev/null 2>&1
2059    mnc_in=$?
2060    if test "x$HAVE_NETCDF" != xt ; then
2061        if test "x$mnc_in" = x0 ; then
2062            cat <<EOF
2063    *********************************************************************
2064    WARNING: the "mnc" package was enabled but tests failed to compile
2065      NetCDF applications.  Please check that:
2066    
2067      1) NetCDF is correctly installed for this compiler and
2068      2) the LIBS variable (within the "optfile") specifies the correct
2069           NetCDF library to link against.
2070    
2071      Due to this failure, the "mnc" package is now DISABLED.
2072    *********************************************************************
2073    EOF
2074            PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
2075            DISABLE="$DISABLE mnc"
2076        else
2077        #  this prevent to add mnc (due to pdepend rules) if not available
2078            DISABLE="$DISABLE mnc"
2079        fi
2080    else
2081        # we have NetCDF, we try to build MNC template files
2082        ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
2083        RETVAL=$?
2084        if test "x${RETVAL}" = x0 ; then
2085            rm -f make_mnc.errors
2086        else
2087            echo "Error: problem encountered while building source files in pkg/mnc:"
2088            cat make_mnc.errors 1>&2
2089            if test "x$mnc_in" = x0 ; then
2090                exit 1
2091            else
2092                DISABLE="$DISABLE mnc"
2093            fi
2094        fi
2095    fi
2096    
2097  echo "  applying package dependency rules"  #  Check for package PROFILES: if NetCDF is not available,
2098  ck=  #  then delete profiles from the list of available packages.
2099  while test "x$ck" != xtt ; do  if test "x$HAVE_NETCDF" != xt ; then
2100        echo " $PACKAGES " | grep ' profiles ' > /dev/null 2>&1
2101        RETVAL=$?
2102        if test "x$RETVAL" = x0 ; then
2103            cat <<EOF
2104    *********************************************************************
2105    WARNING: the "profiles" package was enabled but tests failed to
2106      compile NetCDF applications.  Please check that:
2107    
2108      1) NetCDF is correctly installed for this compiler and
2109      2) the LIBS variable (within the "optfile") specifies the correct
2110           NetCDF library to link against.
2111    
2112      Due to this failure, the "profiles" package is now DISABLED.
2113    *********************************************************************
2114    EOF
2115            PACKAGES=`echo $PACKAGES | sed -e 's/profiles//g'`
2116            DISABLE="$DISABLE profiles"
2117        else
2118        #  this prevent to add profiles (due to pdepend rules) if not available
2119            DISABLE="$DISABLE profiles"
2120        fi
2121    fi
2122    
2123    if  test "x${PKG_DEPEND}" != x ; then
2124      echo "  applying package dependency rules"
2125      ck=
2126      while test "x$ck" != xtt ; do
2127      i=0      i=0
2128      # rtot=${#PNAME[@]}      # rtot=${#PNAME[@]}
2129      rtot=$nname      rtot=$nname
2130      while test $i -lt $rtot ; do      while test $i -le $rtot ; do
2131    
2132          #  Is $pname in the current $PACKAGES list?          #  Is $pname in the current $PACKAGES list?
2133          #  pname=${PNAME[$i]}          #  pname=${PNAME[$i]}
# Line 1403  while test "x$ck" != xtt ; do Line 2139  while test "x$ck" != xtt ; do
2139                  pin="t"                  pin="t"
2140              fi              fi
2141          done          done
2142            #  or in the current $STANDARDDIRS list?
2143            for p in $STANDARDDIRS ; do
2144                if test "x$p" = "x$pname" ; then pin="t" ; fi
2145            done
2146    
2147          #  Is the DNAME entry a (+) or (-) rule ?          #  Is the DNAME entry a (+) or (-) rule ?
2148          tmp="dname=\"\$DNAME_$i\""          tmp="dname=\"\$DNAME_$i\""
# Line 1425  while test "x$ck" != xtt ; do Line 2165  while test "x$ck" != xtt ; do
2165    
2166          #  Do we need to add $dname according to the dependency rules?          #  Do we need to add $dname according to the dependency rules?
2167          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
2168                #echo "   " $pname ": need to add :" $dname
2169              in_dis="f"              in_dis="f"
2170              for dis in $DISABLE ; do              for dis in $DISABLE ; do
2171                  if test "x$dis" = "x$dname" ; then                  if test "x$dis" = "x$dname" ; then
# Line 1445  while test "x$ck" != xtt ; do Line 2186  while test "x$ck" != xtt ; do
2186          #  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?
2187          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
2188              echo "Error: can't satisfy package dependencies:"              echo "Error: can't satisfy package dependencies:"
2189              echo "  \"$pname\" was requested but is disallowed by"              echo "  \"$pname\" was requested but is disallowed by"
2190              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
2191              exit 1              exit 1
2192          fi          fi
2193          i=$(( $i + 1 ))          i=`echo "$i + 1" | bc -l`
2194            #i=$(( $i + 1 ))
2195      done      done
2196      ck=$ck"t"      ck=$ck"t"
2197  done    done
2198  echo "    packages are:  $PACKAGES"    echo "    packages are: $PACKAGES"
2199    fi
2200  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2201      adr="$ROOTDIR/pkg/$i"      adr="$ROOTDIR/pkg/$i"
2202      if test -d $adr ; then      if test -d $adr ; then
# Line 1468  for i in $PACKAGES ; do Line 2211  for i in $PACKAGES ; do
2211      fi      fi
2212  done  done
2213    
 #  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  
   
2214  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
2215  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
2216  #  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
2217  #  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
2218  #  file would eventually be split up so that all package-related #define  #  file would eventually be split up so that all package-related #define
2219  #  statements could be separated and handled only by genmake.  #  statements could be separated and handled only by genmake.
2220  names=`ls -1 "$ROOTDIR/pkg"`  names=`ls -1 "$ROOTDIR/pkg"`
# Line 1514  for n in $names ; do Line 2230  for n in $names ; do
2230              fi              fi
2231          done          done
2232          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
2233              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
2234              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
2235          fi          fi
2236      fi      fi
2237  done  done
2238  ENABLED_PACKAGES=  ENABLED_PACKAGES=
2239  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2240      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`      def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
2241      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
2242  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
2243    
2244  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
2245      case $i in      case $i in
2246          aim_v23)          aim_v23)
2247              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
2248              echo "Warning: ALLOW_AIM is set to enable aim_v23."              echo "Warning: ALLOW_AIM is set to enable aim_v23."
# Line 1536  for i in $PACKAGES ; do Line 2252  for i in $PACKAGES ; do
2252    
2253  done  done
2254    
2255  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS='$STANDARDDIRS'"
2256  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
 if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then  
     STANDARDDIRS="eesupp model"  
 fi  
2257  if test "x$STANDARDDIRS" != x ; then  if test "x$STANDARDDIRS" != x ; then
2258      for d in $STANDARDDIRS ; do      for d in $STANDARDDIRS ; do
2259          adr="$ROOTDIR/$d/src"          adr="$ROOTDIR/$d/src"
# Line 1595  fi Line 2308  fi
2308    
2309  #  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
2310  #  compiler.  #  compiler.
2311  if test -f ./ad_files ; then  if test -f ./adSrcFiles.tmp ; then
2312      rm -f ./ad_files      rm -f ./adSrcFiles.tmp
2313  fi  fi
2314  echo "  Creating the list of files for the adjoint compiler."  echo "  Creating the list of files for the adjoint compiler."
2315    touch adSrcFiles.tmp
2316  for i in $SOURCEDIRS ; do  for i in $SOURCEDIRS ; do
2317      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2318      for j in $list_files ; do      for j in $list_files ; do
2319          cat $i/$j >> ad_files          cat $i/$j >> adSrcFiles.tmp
2320      done      done
2321  done  done
2322    if test ! "x"$FS = "x.f" ; then
2323        cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f
2324        mv -f adSrcFiles.tmp_f adSrcFiles.tmp
2325    fi
2326    
2327  echo  echo
2328  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
2329  echo "  setting INCLUDES"  echo "  setting INCLUDES"
2330  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
2331      if ! test -d $i ; then      if test ! -d $i ; then
 #       INCLUDES="$INCLUDES -I$i"  
 #   else  
2332          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
2333      fi      fi
2334  done  done
2335    
2336    if test ! "x$DIVA" = x ; then
2337        echo "  Creating the pseudo-MPI include directory"
2338        INCLUDES="-I./mpi_headers $INCLUDES"
2339        rm -rf ./mpi_headers
2340        mkdir -p ./mpi_headers
2341    
2342        if test "x$MPIINCLUDEDIR" = x ; then
2343            if test "x$MPIHOME" = x ; then
2344                MPIHOME='/usr'
2345            fi
2346            MPIINCLUDEDIR='$MPIHOME/include'
2347        fi
2348    
2349        if test -r $MPIINCLUDEDIR/mpif.h ; then
2350            for i in $MPI_HEADER_FILES; do
2351                cp -p $MPIINCLUDEDIR/$i ./mpi_headers
2352            done
2353    
2354            perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h
2355        else
2356            echo " We cannot create a copy of mpif.h!"
2357    #       exit -1
2358        fi
2359    fi
2360    
2361  echo "  Determining the list of source and include files"  echo "  Determining the list of source and include files"
2362  rm -rf .links.tmp  rm -rf .links.tmp
2363  mkdir .links.tmp  mkdir .links.tmp
2364    touch .links.tmp/foo
2365    if test ! -r ".links.tmp/foo" ; then
2366        echo
2367        echo "ERROR : something is wrong with your directory permissions or"
2368        echo "   your user file-creation mask (\"umask\") since creating a"
2369        echo "   sub-dir, touch-ing a file within it, and then reading it is"
2370        echo "   not working.  Please try setting your umask to something"
2371        echo "   sane such as:"
2372        echo
2373        echo "      umask 0002"
2374        echo
2375        echo "   and please verify that you have the proper permissions for"
2376        echo "   creating sub-directories and then reading files created"
2377        echo "   within them."
2378        echo
2379        exit 1
2380    fi
2381    rm -f .links.tmp/foo
2382    
2383    if test "x$OPENAD" != x ; then
2384        OAD_DONT_COMPILE="/dev/null"
2385        OAD_DONT_TRANSFORM="/dev/null"
2386        OAD_KEEP_ORIGINAL="/dev/null"
2387        OAD_CB2M_FILES="/dev/null"
2388        echo "  looking for dontCompile file:  "
2389        for i in "." $MODS ; do
2390            if test -r $i"/dontCompile" ; then
2391                OAD_DONT_COMPILE=$i"/dontCompile"
2392                echo "     found $OAD_DONT_COMPILE"
2393                break
2394            fi
2395        done
2396        echo "  looking for dontTransform file:  "
2397        for i in "." $MODS ; do
2398            if test -r $i"/dontTransform" ; then
2399                OAD_DONT_TRANSFORM=$i"/dontTransform"
2400                echo "     found $OAD_DONT_TRANSFORM"
2401                break
2402            fi
2403        done
2404        echo "  looking for keepOriginal file:  "
2405        for i in "." $MODS ; do
2406            if test -r $i"/keepOriginal" ; then
2407                OAD_KEEP_ORIGINAL=$i"/keepOriginal"
2408                echo "     found $OAD_KEEP_ORIGINAL"
2409                break
2410            fi
2411        done
2412        echo "  looking for cb2mFiles:  "
2413        for i in "." $MODS ; do
2414            if test -r $i"/cb2mFiles" ; then
2415                OAD_CB2M_FILES=$i"/cb2mFiles"
2416                echo "     found $OAD_CB2M_FILES"
2417                break
2418            fi
2419        done
2420        echo "   OpenAD exceptions:  "
2421    fi
2422    
2423  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
2424  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
2425  printf 'SRCFILES = '    > srclist.inc  printf 'F77_SRC_FILES = ' > F77srclist.tmp
2426  printf 'CSRCFILES = '   > csrclist.inc  printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp
2427  printf 'F90SRCFILES = ' > f90srclist.inc  printf 'C_SRC_FILES = '   > csrclist.tmp
2428  printf 'HEADERFILES = ' > hlist.inc  printf 'F90_SRC_FILES = ' > F90srclist.tmp
2429  printf 'AD_FLOW_FILES = ' > ad_flow_files.inc  printf 'H_SRC_FILES = '   > hsrclist.tmp
2430    printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp
2431  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2432  for d in $alldirs ; do  for d in $alldirs ; do
2433      deplist=      deplist=
2434      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
2435      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
2436        if test "x$OPENAD" != x ; then
2437            sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2438        fi
2439      for sf in $sfiles ; do      for sf in $sfiles ; do
2440          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
2441              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2442                    ignore_f=f
2443                  case $d/$sf in                  case $d/$sf in
2444                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
2445                            ignore_f=t
2446                          ;;                          ;;
2447                    ./AD_CONFIG.h)                    ./AD_CONFIG.h)
2448                            ignore_f=t
2449                          ;;                          ;;
2450                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
2451                            ignore_f=t
2452                            ;;
2453                      ./BUILD_INFO.h)
2454                            ignore_f=t
2455                            ;;
2456                      ./EMBEDDED_FILES.h)
2457                            ignore_f=t
2458                          ;;                          ;;
2459                    *)                    *)
2460                          touch .links.tmp/$sf                          #  For the local directory *ONLY*,
2461                          deplist="$deplist $sf"                          #  ignore all soft-links
2462                            if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
2463                                ignore_f=t
2464                            else
2465                                touch .links.tmp/$sf
2466                                deplist="$deplist $sf"
2467                            fi
2468                          ;;                          ;;
2469                  esac                  esac
2470                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`                  if test "x$ignore_f" = xf ; then
2471                  case $extn in                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2472                      F)                      case $extn in
2473                          echo    " \\"  >> srclist.inc                        F)
2474                          printf " $sf" >> srclist.inc                          echo    " \\"  >> F77srclist.tmp
2475                            printf " $sf" >> F77srclist.tmp
2476                            if test "x$OPENAD" != x ; then
2477                                basename=${sf%%.F}
2478                                isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`
2479                                if test -z "$isAD" ; then
2480                                    toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`
2481                                    if test -z "$toBeIgnored" ; then
2482                                        echo    " \\"  >> nonADF77srclist.tmp
2483                                        printf " $sf" >> nonADF77srclist.tmp
2484                                    else
2485                                        echo "    not to be compiled   :  $sf"
2486                                    fi
2487                                else # file is initially listed as an AD file we want to exclude it
2488                                     # or we want to retain the untransformed version
2489                                    notToBeTransformed=`egrep ^$basename'[      ]*' ${OAD_DONT_TRANSFORM}`
2490                                    untransformedVersionToBeKept=`egrep ^$basename'[      ]*' ${OAD_KEEP_ORIGINAL}`
2491                                    if test -n "$notToBeTransformed"; then
2492                                        echo "    not to be transformed:  $sf"
2493                                    fi
2494                                    if test -n "$untransformedVersionToBeKept" ; then
2495                                        echo "    original to be kept  :  $sf"
2496                                    fi
2497                                    if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2498                                        echo    " \\"  >> nonADF77srclist.tmp
2499                                        printf " $sf" >> nonADF77srclist.tmp
2500                                    fi
2501                                fi
2502                            fi
2503                          ;;                          ;;
2504                      F90)                      F90)
2505                          echo    " \\"  >> f90srclist.inc                          echo    " \\"  >> F90srclist.tmp
2506                          printf " $sf" >> f90srclist.inc                          printf " $sf" >> F90srclist.tmp
2507                          ;;                          ;;
2508                      c)                      c)
2509                          echo    " \\"  >> csrclist.inc                          echo    " \\"  >> csrclist.tmp
2510                          printf " $sf" >> csrclist.inc                          printf " $sf" >> csrclist.tmp
2511                          ;;                          ;;
2512                      h)                      h)
2513                          echo    " \\"  >> hlist.inc                          echo    " \\"  >> hsrclist.tmp
2514                          printf " $sf" >> hlist.inc                          printf " $sf" >> hsrclist.tmp
2515                          ;;                          ;;
2516                      flow)                      flow)
2517                          echo    " \\"  >> ad_flow_files.inc                          echo    " \\"  >> ad_flow_files.tmp
2518                          printf " $sf" >> ad_flow_files.inc                          printf " $sf" >> ad_flow_files.tmp
2519                          ;;                          ;;
2520                  esac                     esac
2521                    fi
2522              fi              fi
2523          fi          fi
2524      done      done
2525      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2526          echo "" >> srclinks.tmp        if test "$d" != "." ; then
2527            echo "" >> srclinks.tmp
2528          echo "#  These files are linked from $d" >> srclinks.tmp          echo "#  These files are linked from $d" >> srclinks.tmp
2529          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> srclinks.tmp
2530          printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp  # We need to make sure that the link isn't already there.
2531    # This may happen when make thinks that a header file has to be "remade"
2532    # because a module it depends on has changed.  In this case we do nothing.
2533            printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp
2534          fi
2535      fi      fi
2536  done  done
2537  rm -rf .links.tmp  rm -rf .links.tmp
2538  echo "" >> srclist.inc  echo "" >> F77srclist.tmp
2539  echo "" >> csrclist.inc  echo "" >> nonADF77srclist.tmp
2540  echo "" >> f90srclist.inc  echo "" >> csrclist.tmp
2541  echo "" >> hlist.inc  echo "" >> F90srclist.tmp
2542  echo "" >> ad_flow_files.inc  echo "" >> hsrclist.tmp
2543    echo "" >> ad_flow_files.tmp
2544    
2545    CMDLINE=$0
2546    for xx in "$@" ; do nw=`echo $xx | wc -w`
2547        if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
2548                            else CMDLINE="$CMDLINE '$xx'" ; fi
2549    done
2550    
2551  if test -e $MAKEFILE ; then  if test -f $MAKEFILE ; then
2552      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.old"
2553  fi  fi
2554  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
2555  echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE  echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE
# Line 1697  echo "#    $MACHINE" >> $MAKEFILE Line 2557  echo "#    $MACHINE" >> $MAKEFILE
2557  echo "# This makefile was generated automatically on" >> $MAKEFILE  echo "# This makefile was generated automatically on" >> $MAKEFILE
2558  echo "#    $THISDATE" >> $MAKEFILE  echo "#    $THISDATE" >> $MAKEFILE
2559  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2560  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $CMDLINE"  >> $MAKEFILE
2561  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2562  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2563    
2564  EXE_AD=$EXECUTABLE"_ad"  EXE_AD=$EXECUTABLE"_ad"
2565  EXE_FTL=$EXECUTABLE"_ftl"  EXE_FTL=$EXECUTABLE"_ftl"
# Line 1708  EXE_SVD=$EXECUTABLE"_svd" Line 2568  EXE_SVD=$EXECUTABLE"_svd"
2568  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2569  #  #
2570  # OPTFILE="$OPTFILE"  # OPTFILE="$OPTFILE"
2571  #  #
2572  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
2573  # SOURCEDIRS   : Directories containing the source (.F) files  # SOURCEDIRS   : Directories containing the source (.F) files
2574  # INCLUDEDIRS  : Directories containing the header-source (.h) files  # INCLUDEDIRS  : Directories containing the header-source (.h) files
# Line 1728  cat >>$MAKEFILE <<EOF Line 2588  cat >>$MAKEFILE <<EOF
2588  # LIBS         : Library flags /or/ additional optimization/debugging flags  # LIBS         : Library flags /or/ additional optimization/debugging flags
2589    
2590  ROOTDIR     = ${ROOTDIR}  ROOTDIR     = ${ROOTDIR}
2591  BUILDDIR    = ${BUILDDIR}    BUILDDIR    = ${BUILDDIR}
2592  SOURCEDIRS  = ${SOURCEDIRS}  SOURCEDIRS  = ${SOURCEDIRS}
2593  INCLUDEDIRS = ${INCLUDEDIRS}  INCLUDEDIRS = ${INCLUDEDIRS}
2594  EXEDIR      = ${EXEDIR}  EXEDIR      = ${EXEDIR}
# Line 1745  ENABLED_PACKAGES = ${ENABLED_PACKAGES} Line 2605  ENABLED_PACKAGES = ${ENABLED_PACKAGES}
2605  DISABLED_PACKAGES = ${DISABLED_PACKAGES}  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
2606    
2607  # These files are created by Makefile  # These files are created by Makefile
2608  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
   
2609  EOF  EOF
2610    
2611  #  Note: figure out some way to add Hyades JAM libraries here  if test "x$EMBED_SRC" = xt ; then
2612        echo "EMBEDDED_FILES = EMBEDDED_FILES.h" >>$MAKEFILE
2613    else
2614        echo "EMBEDDED_FILES = " >>$MAKEFILE
2615    fi
2616    
2617  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2618  # Unix ln (link)  # Unix ln (link)
2619  LN = ${LN}  LN = ${LN}
# Line 1764  KPP = ${KPP} Line 2627  KPP = ${KPP}
2627  FC = ${FC}  FC = ${FC}
2628  # Fortran compiler  # Fortran compiler
2629  F90C = ${F90C}  F90C = ${F90C}
2630    # C compiler
2631    CC = ${CC}
2632  # Link editor  # Link editor
2633  LINK = ${LINK} ${LDADD}  LINK = ${LINK} ${LDADD}
2634    
# Line 1775  INCLUDES = ${INCLUDES} Line 2640  INCLUDES = ${INCLUDES}
2640  KFLAGS1 = ${KFLAGS1}  KFLAGS1 = ${KFLAGS1}
2641  KFLAGS2 = ${KFLAGS2}  KFLAGS2 = ${KFLAGS2}
2642  # Optim./debug for FC  # Optim./debug for FC
2643  FFLAGS = ${FFLAGS}  FFLAGS = ${FFLAGS} ${FEXTRAFLAGS}
2644  FOPTIM = ${FOPTIM}  FOPTIM = ${FOPTIM}
2645  # Optim./debug for FC  # Optim./debug for FC
2646  F90FLAGS = ${F90FLAGS}  F90FLAGS = ${F90FLAGS}
2647  F90OPTIM = ${F90OPTIM}  F90OPTIM = ${F90OPTIM}
2648    F90FIXEDFORMAT = ${F90FIXEDFORMAT}
2649  # Flags for CC  # Flags for CC
2650  CFLAGS = ${CFLAGS}  CFLAGS = ${CFLAGS}
2651  # Files that should not be optimized  # Files that should not be optimized
2652  NOOPTFILES = ${NOOPTFILES}  NOOPTFILES = ${NOOPTFILES}
2653  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2654  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2655  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS}
2656  # Name of the Mekfile  # Name of the Mekfile
2657  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2658    
2659  EOF  EOF
2660    
2661  cat srclist.inc       >> $MAKEFILE  cat F77srclist.tmp      >> $MAKEFILE
2662  cat csrclist.inc      >> $MAKEFILE  cat nonADF77srclist.tmp >> $MAKEFILE
2663  cat f90srclist.inc    >> $MAKEFILE  cat csrclist.tmp        >> $MAKEFILE
2664  cat hlist.inc         >> $MAKEFILE  cat F90srclist.tmp      >> $MAKEFILE
2665  cat ad_flow_files.inc >> $MAKEFILE  cat hsrclist.tmp        >> $MAKEFILE
2666    cat ad_flow_files.tmp   >> $MAKEFILE
2667    
2668    rm -f F77srclist.tmp nonADF77srclist.tmp csrclist.tmp F90srclist.tmp hsrclist.tmp ad_flow_files.tmp
2669    
2670  echo >> $MAKEFILE  echo >> $MAKEFILE
2671  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE  
2672  echo 'F90FILES =  $(F90SRCFILES:.F=.'$FS90')' >> $MAKEFILE  # add definitions for preprocessed sources
2673  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  # and note that not all systems allow case sensitive extensions
2674    # hence the $FS and $FS90 here.
2675    # for fixed format f90 files we use ff90 or FF90 resp
2676    # but these are not expected to be the original source files
2677    
2678    echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE
2679    echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE
2680    echo 'OBJFILES= $(F77_SRC_FILES:.F=.o) $(C_SRC_FILES:.c=.o) $(F90_SRC_FILES:.F90=.o)' >> $MAKEFILE
2681    echo 'FLOFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE
2682  echo >> $MAKEFILE  echo >> $MAKEFILE
2683  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
2684  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  
2685    
2686  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2687    
2688  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
2689  \$(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)
2690          @echo Creating \$@ ...          @echo Creating \$@ ...
2691          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2692  depend:  depend:
2693          @make links          @make links
2694          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
2695          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2696          -rm -f makedepend.out          -rm -f makedepend.out
2697    
2698  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  lib: libmitgcmuv.a
2699    
2700  small_f: \$(F77FILES) \$(F90FILES)  libmitgcmuv.a: \$(OBJFILES)
2701            ar rcv libmitgcmuv.a \$(OBJFILES)
2702            ar d   libmitgcmuv.a main.o
2703    
2704    links: \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(SPECIAL_FILES)
2705    
2706    small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
2707    
2708  output.txt: \$(EXECUTABLE)  output.txt: \$(EXECUTABLE)
2709          @printf 'running ... '          @printf 'running ... '
2710          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
2711    
2712    # remove most of the files that "make" generates
2713  clean:  clean:
2714          -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2715            -rm -rf *.o
2716            -rm -rf *.$FS *.flowdir
2717            -rm -rf *.f$FS90 \$(AD_CLEAN) ad_input*
2718    
2719    # remove most of the files that "make" and "make depend" generate
2720  Clean:  Clean:
2721          @make clean          @make clean
2722          @make cleanlinks          @make cleanlinks
2723          -rm -f \$(SPECIAL_FILES)          -rm -f \$(SPECIAL_FILES) f90mkdepend.log
2724          -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
2725            -rm -f genmake_warnings genmake_errors make.log
2726    
2727    # remove also the executable, files that "genmake2" generates (except Makefile)
2728    #         and output from a run (plus log files from testreport)
2729  CLEAN:  CLEAN:
2730          @make Clean          @make Clean
2731            -rm -f \$(EXECUTABLE) \$(EXE_AD) *.bak $MAKEFILE.old
2732            -rm -f $LOGFILE genmake_state genmake_*optfile genmake.tr_log make.tr_log
2733          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2734          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2735          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2736          -rm -f \$(EXECUTABLE) output.txt STD*          -rm -f *.txt STD* *diagnostics.log datetime
2737            -rm -f *_MIT_CE_000.opt0000 costfunction*0000
2738            -rm -rf mnc_test_*
2739    
 #eh3 Makefile: makefile  
2740  makefile:  makefile:
2741          $THIS_SCRIPT $G2ARGS          $THIS_SCRIPT $G2ARGS
2742  cleanlinks:  cleanlinks:
2743          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2744    
2745  # Special targets ($SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are created by make
2746  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2747          @echo Creating \$@ ...          @echo Creating \$@ ...
2748          @$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) > \$@
# Line 1858  FC_NAMEMANGLE.h: Line 2753  FC_NAMEMANGLE.h:
2753          @echo Creating \$@ ...          @echo Creating \$@ ...
2754          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
2755    
2756    BUILD_INFO.h:
2757            @echo Creating \$@ ...
2758    EOF
2759    
2760    test ! "x$THISVER" = x  && echo "       -echo \"#define THISVER '$THISVER'\" > \$@"   >> $MAKEFILE
2761    test ! "x$THISUSER" = x && echo "       -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2762    test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2763    test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2764    
2765    if test "x$EMBED_SRC" = xt ; then
2766        cat >>$MAKEFILE <<EOF
2767    
2768    decode_files.o : EMBEDDED_FILES.h
2769    
2770    ##  \$(F77_PP_SRC_FILES)
2771    all_fF.tar.gz : \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2772            @echo Creating \$@ ...
2773            -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2774            -rm -f all_fF.tar.gz
2775            -gzip all_fF.tar
2776    
2777    EMBEDDED_FILES.h : all_fF.tar.gz
2778            @echo Creating \$@ ...
2779            -\${ROOTDIR}/tools/embed_encode/encode_files EMBEDDED_FILES.h all_fF.tar.gz
2780    
2781    EOF
2782    fi
2783    
2784    cat >>$MAKEFILE <<EOF
2785    
2786  # The normal chain of rules is (  .F - .$FS - .o  )  # The normal chain of rules is (  .F - .$FS - .o  )
2787    
2788  %.o : %.F  ## This nullifies any default implicit rules concerning these two file types:
2789    ## %.o : %.F
2790    
2791  .F.$FS:  .F.$FS:
2792          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
# Line 1868  FC_NAMEMANGLE.h: Line 2794  FC_NAMEMANGLE.h:
2794          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2795  .F90.$FS90:  .F90.$FS90:
2796          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2797    .FF90.f$FS90:
2798            \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2799  .$FS90.o:  .$FS90.o:
2800          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2801    .f$FS90.o:
2802            cp \$< \$(basename  \$<).f90
2803            \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$(F90FIXEDFORMAT) \$(basename  \$<).f90
2804  .c.o:  .c.o:
2805          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
2806    .flow.flowdir:
2807            \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2808    
2809  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2810  .F.p:  .F.p:
# Line 1879  FC_NAMEMANGLE.h: Line 2812  FC_NAMEMANGLE.h:
2812  .p.$FS:  .p.$FS:
2813          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
2814    
2815    EOF
2816    
2817  #=========================================  #=========================================
2818  #===  Automatic Differentiation Rules  ===  #===  Automatic Differentiation Rules  ===
2819    #===  for TAMC/TAF  ======================
2820    
2821    if test "x$OPENAD" = x ; then
2822    
2823    cat >>$MAKEFILE <<EOF
2824    
2825  TAMC           = ${TAMC}  TAMC           = ${TAMC}
2826  TAF            = ${TAF}  TAF            = ${TAF}
# Line 1895  ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF Line 2835  ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF
2835  ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"  ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
2836  for i in $ad_vars ; do  for i in $ad_vars ; do
2837      name=$i      name=$i
2838      t1="t2=\$"`echo $i`      t1="t2=\$"`echo "$i"`
2839      eval $t1      eval $t1
2840      printf "%-20s = " $name >> $MAKEFILE      printf "%-20s = " $name >> $MAKEFILE
2841      echo $t2 >> $MAKEFILE      echo "$t2" | sed -e 's| \+| |g' >> $MAKEFILE
2842  done  done
2843    
2844  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
2845  echo >> $MAKEFILE  echo >> $MAKEFILE
2846  printf "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
2847  AD_FILES=`cat ad_files`  AD_FILES=`cat adSrcFiles.tmp`
2848  for i in $AD_FILES ; do  for i in $AD_FILES ; do
2849      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
2850      printf " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
2851  done  done
2852  echo >> $MAKEFILE  echo >> $MAKEFILE
2853  rm -f ad_files  rm -f adSrcFiles.tmp
2854    
2855  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2856    
2857  # ... AD ...  # ... AD ...
2858  adall: ad_taf  adall: \$(EXE_AD)
2859  adtaf: ad_taf_output.f  adtaf: ad_taf_output.$FS
2860  adtamc: ad_tamc_output.f  adtamc: ad_tamc_output.$FS
2861    
2862  ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES)
2863          @$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 -UALLOW_ECCO_OPTIMIZATION > ad_config.template
2864          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
2865          -rm -f ad_config.template          -rm -f ad_config.template
2866          @make \$(F77FILES)          @make \$(F77_PP_SRC_FILES)
2867          @make \$(AD_FLOW_FILES)          @make \$(FLOFILES)
2868          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f          cat \$(FLOFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS
2869    
2870  ad_taf_output.f: ad_input_code.f  ad_taf_output.$FS: ad_input_code.$FS
2871          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2872          cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f          ls -l ad_input_code_ad.$FS
2873            cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2874    
2875  adtafonly:  adtafonly:
2876          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2877          cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f          ls -l ad_input_code_ad.$FS
2878            cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2879  ad_taf: ad_taf_output.o \$(OBJFILES)  
2880          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)  \${EXE_AD}: ad_taf_output.o \$(OBJFILES)
2881            \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2882  ad_tamc_output.f: ad_input_code.f  
2883          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f  ad_tamc_output.$FS: ad_input_code.$FS
2884          cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.f          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2885            cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
2886    
2887  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2888          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2889    
2890    adonlyfwd:
2891            patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2892    
2893    adtrick:
2894            patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2895    
2896  # ... FTL ...  # ... FTL ...
2897  ftlall: ftl_taf  ftlall: ftl_taf
2898  ftltaf: ftl_taf_output.f  ftltaf: ftl_taf_output.$FS
2899  ftltamc: ftl_tamc_output.f  ftltamc: ftl_tamc_output.$FS
2900    
2901  ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)
2902          @$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 -UALLOW_ECCO_OPTIMIZATION > ftl_config.template
2903          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
2904          -rm -f ftl_config.template          -rm -f ftl_config.template
2905          @make \$(F77FILES)          @make \$(F77_PP_SRC_FILES)
2906          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2907          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2908    
2909  ftl_taf_output.f: ftl_input_code.f  ftl_taf_output.$FS: ftl_input_code.$FS
2910          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2911          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f          ls -l ftl_input_code_ftl.$FS
2912            cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2913    
2914  ftltafonly:  ftltafonly:
2915          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2916          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f          ls -l ftl_input_code_ftl.$FS
2917            cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2918    
2919  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
2920          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2921    
2922  ftl_tamc_output.f: ftl_input_code.f  ftl_tamc_output.$FS: ftl_input_code.$FS
2923          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2924          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.f          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS
2925    
2926  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2927          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2928    
2929    
2930  # ... SVD ...  # ... SVD ...
2931  svdtaf: ad_taf_output.f ftl_taf_output.f  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
2932  svdall: svd_taf          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"
2933            @echo "--->>> Do make svdall afterwards to compile. <<<---"
2934    svdall: svd_touch svd_taf
2935    
2936  svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES)  svd_taf: \$(OBJFILES)
2937          \$(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)
2938    
2939            @echo "--->>> Only COMPILE svd code! <<<---"
2940            @echo "--->>> Assumes you previously <<<---"
2941            @echo "--->>> did make svdtaf        <<<---"
2942    
2943    svd_touch:
2944            @echo "--->>> Only COMPILE svd code! <<<---"
2945            @echo "--->>> Assumes you previously <<<---"
2946            @echo "--->>> did make svdtaf        <<<---"
2947            touch ad_taf_output.$FS ftl_taf_output.$FS
2948            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
2949            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
2950            @$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
2951            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2952            -rm -f ftl_config.template
2953    
2954  #=========================================  EOF
2955    
2956    fi
2957    
2958    #===  for OpenAD  ========================
2959    
2960    if test "x$OPENAD" != x ; then
2961    
2962    # ============ begin OpenAD specific section ==============
2963    
2964    cat >>$MAKEFILE <<EOF
2965    
2966    # all the source files linked from the various locations:
2967    ALL_LINKED_FILES= \
2968    \$(F77_SRC_FILES) \
2969    \$(C_SRC_FILES) \
2970    \$(H_SRC_FILES) \
2971    \$(F90_SRC_FILES) \
2972    \$(SPECIAL_FILES)
2973    
2974    ifndef OPENADROOT
2975      \$(error "Error:  environment variable OPENADROOT not defined!")
2976    endif
2977    
2978    ifndef XAIFSCHEMAROOT
2979      \$(error "Error:  environment variable XAIFSCHEMAROOT not defined!")
2980    endif
2981    
2982    ifndef XAIFBOOSTERROOT
2983      \$(error "Error:  environment variable XAIFBOOSTERROOT not defined!")
2984    endif
2985    
2986  EOF  EOF
2987    
2988    echo "  Add the source list for common block to module conversion "
2989    echo >> $MAKEFILE
2990    printf "CB2M_F90_SRC_NAMES = " >> $MAKEFILE
2991    for i in `cat ${OAD_CB2M_FILES}` ; do
2992      echo    " \\" >> $MAKEFILE
2993      printf " $i" >> $MAKEFILE
2994    done
2995    echo >> $MAKEFILE
2996    
2997    echo "  Add the source list for AD code generation"
2998    echo >> $MAKEFILE
2999    printf "AD_FILES = " >> $MAKEFILE
3000    for i in `cat ${OAD_CB2M_FILES}` ; do
3001      echo    " \\" >> $MAKEFILE
3002      printf " ${i}_mod.f$FS90" >> $MAKEFILE
3003    done
3004    AD_FILES=`cat adSrcFiles.tmp`
3005    for i in $AD_FILES ; do
3006      basename=${i%%.f}
3007      toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`
3008      if test -z "$toBeIgnored" ; then
3009        echo    " \\" >> $MAKEFILE
3010        printf " $i" >> $MAKEFILE
3011      fi
3012    done
3013    echo >> $MAKEFILE
3014    rm -f adSrcFiles.tmp
3015    
3016    cat >>$MAKEFILE <<EOF
3017    
3018    adAll: \$(EXE_AD)
3019    .PHONY: adAll
3020    
3021    CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))
3022    
3023    .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90)
3024    
3025    .PHONY: adDepend
3026    adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90)
3027            \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
3028            \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
3029            -rm -f makedepend.out
3030    
3031    OPENAD_SUPPORT_F90_SRC_FILES = \
3032    w2f__types.F90 \
3033    OAD_active.F90 \
3034    OAD_cp.F90 \
3035    OAD_rev.F90 \
3036    OAD_tape.F90
3037    
3038    OPENAD_SUPPORT_C_SRC_FILES = \
3039    iaddr.c \
3040    timeRatio.c
3041    
3042    f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)
3043            cat \$^ > \$@
3044    
3045    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
3046            cat \$^ > \$@
3047    
3048    f95_test.out: f95_test_mods.f90 f95_test.f90
3049            f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1
3050            f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1
3051    
3052    # the file included below is created by the
3053    # postProcessor and its inclusion sets the
3054    # variable POSTPROCESSEDFILES
3055    # used below. Because the file is made during
3056    # make it won't be read until the second (recursive)
3057    # invocation in the rule below
3058    -include postProcess.make
3059    
3060    AD_OBJ_FILES_S1=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) \$(POSTPROCESSEDFILES:.f$FS90=.o)
3061    
3062    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)
3063    
3064    postProcess.comp: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.tag \$(AD_OBJ_FILES_S1)
3065    ifeq (\$(MAKELEVEL),0)
3066            \$(MAKE) adAll
3067    else
3068            touch \$@
3069    endif
3070    
3071    \$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.comp \$(AD_OBJ_FILES_S2)
3072    ifeq (\$(MAKELEVEL),1)
3073            \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)
3074    else
3075            touch \$@
3076    endif
3077    
3078    # makefile debug rule
3079    openad: ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
3080    .PHONY: openad
3081    
3082    # create the module files
3083    %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk
3084            ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk
3085    
3086    # create the header files
3087    %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk
3088            ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
3089    
3090    # change everybody else to use the new module files:
3091    %_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash
3092            ../OAD_support/cb2mUseModules.bash $< ${MPI}
3093    
3094    # makefile debug rule
3095    small_f: \$(CB2M_F90_PP_SRC_FILES)
3096    .PHONY: small_f
3097    
3098    ad_output.txt: \$(EXE_AD)
3099            @printf 'linking data files ... '
3100            \$(LN) -f ../input_ad/data* ../input_ad/eedata .
3101            \$(LN) -f ../../global_ocean.90x40x15/input/*.bin .
3102            @printf 'running ... '
3103            @./\$(EXE_AD) > \$@
3104    
3105    CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)
3106    ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3107            cat \$^ > \$@
3108    
3109    # strip all comments and blanks to reduce
3110    # the file size in order to reduce perl's memory requirements
3111    ad_input_code_sf.f$FS90 : ad_input_code.f$FS90
3112            cat \$^ | sed -f ../OAD_support/strip.sed | sed -f ../OAD_support/stop2print.sed > \$@
3113    
3114    # mfef90 preprocessing
3115    # expand statement functions
3116    # expose mfef90 specific substring handling
3117    # add the w2f__types module
3118    ad_input_code_sf.w2f.f$FS90: ad_input_code_sf.f$FS90 mfef90 whirl2f whirl2f_be w2f__types.f90
3119            ./mfef90 -r8 -z -F -N132 \$<
3120            mv \$<.B \$(basename \$<).B
3121            ./whirl2f -openad \$(basename \$<).B
3122            cat w2f__types.f90 \$(basename \$<).w2f.f > \$@
3123    
3124    # canonicalizer
3125    ad_input_code_sf.w2f.pre.f$FS90: ad_input_code_sf.w2f.f$FS90 preProcess.py
3126            ./preProcess.py --timing --r8 -H -S \$< -o \$@
3127    
3128    # F -> WHIRL
3129    # note that the canonicalized version cuts off at col 72
3130    # doing this also for string constants which is ok as long
3131    # as we are in fixed mode and cut of exactly there.
3132    # Otherwise mfef90 patches in spaces to fill up to 72 (or 132)
3133    # characters respectively.
3134    ad_input_code_sf.w2f.pre.B: ad_input_code_sf.w2f.pre.f$FS90 mfef90
3135            ./mfef90 -r8 -z -F \$<
3136            mv \$<.B \$@
3137    
3138    # WHIRL -> XAIF
3139    ad_input_code_sf.w2f.pre.xaif : ad_input_code_sf.w2f.pre.B whirl2xaif
3140            ./whirl2xaif -s -n --debug 1 -o \$@ \$<
3141    
3142    # XAIF -> XAIF'
3143    ad_input_code_sf.w2f.pre.xb.xaif : ad_input_code_sf.w2f.pre.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd oadDriver
3144            ./oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r
3145    
3146    # XAIF' -> WHIRL'
3147    ad_input_code_sf.w2f.pre.xb.x2w.B : ad_input_code_sf.w2f.pre.xb.xaif xaif2whirl
3148            ./xaif2whirl --debug 1 ad_input_code_sf.w2f.pre.B \$<
3149    
3150    # WHIRL' -> F'
3151    ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.B whirl2f whirl2f_be
3152            ./whirl2f -FLIST:ftn_file=\$@ -openad \$<
3153    
3154    # insert template directives
3155    ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90 ../OAD_support/insertTemplateDir.bash
3156            ../OAD_support/insertTemplateDir.bash \$< \$@
3157    
3158    PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F
3159    # postprocess F'
3160    postProcess.tag: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 postProcess.py \$(PPEXTRAS:.F=.f)
3161            # the target is a placeholder to signal execution of the rule
3162            touch \$@
3163            # this step also creates the file postProcess.make but we cannot
3164            # name it as the target or else make will try to remake it for
3165            # the include directive above for any rule, e.g. make clean
3166            ./postProcess.py --progress --timing --outputFormat=fixed -m r -i ../OAD_support/ad_inline.f --width 4 \$<
3167    
3168    # setup some links
3169    %.xsd:
3170            \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3171    
3172    mfef90:
3173            \$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 .
3174    
3175    # link the support files:
3176    \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):
3177            \$(LN) ../OAD_support/\$@ .
3178    
3179    whirl2xaif xaif2whirl:
3180            \$(LN) \${OPENADFORTTK}/bin/\$@ .
3181    
3182    preProcess.py postProcess.py:
3183            \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ .
3184    
3185    whirl2f whirl2f_be:
3186            \$(LN) \${OPEN64ROOT}/whirl2f/\$@ .
3187    
3188    oadDriver:
3189            \$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver \$@
3190    
3191    AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.make postProcess.tag postProcess.comp \$(PPEXTRAS:.F=.f)
3192    
3193    # ============ end OpenAD specific section ==============
3194    
3195    EOF
3196    
3197    fi
3198    
3199    #=========================================
3200    
3201  if test "x$EXEHOOK" != x ; then  if test "x$EXEHOOK" != x ; then
3202      printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE      printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
3203  fi  fi
# Line 2025  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 3233  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
3233  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
3234    
3235  # Create special header files  # Create special header files
3236  $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"
3237  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
3238      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
3239  else  else
# Line 2044  fi Line 3252  fi
3252    
3253    
3254  #  Write the "state" for future records  #  Write the "state" for future records
3255  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" = xt ; then
3256      printf "" > genmake_state      printf "" > genmake_state
3257      for i in $gm_state ; do      for i in $gm_state ; do
3258          t1="t2=\$$i"          t1="t2=\$$i"

Legend:
Removed from v.1.86  
changed lines
  Added in v.1.212

  ViewVC Help
Powered by ViewVC 1.1.22