/[MITgcm]/MITgcm/tools/genmake2
ViewVC logotype

Diff of /MITgcm/tools/genmake2

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.143 by edhill, Tue Feb 14 16:21:09 2006 UTC revision 1.213 by jmc, Fri Nov 5 16:28:59 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 138  EOF Line 145  EOF
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 186  look_for_makedepend()  { Line 193  look_for_makedepend()  {
193          cat <<EOF >> $MAKEFILE          cat <<EOF >> $MAKEFILE
194  #   THIS IS A TEST MAKEFILE GENERATED BY "genmake2"  #   THIS IS A TEST MAKEFILE GENERATED BY "genmake2"
195  #  #
196  #   Some "makedepend" implementations will die if they cannot  #   Some "makedepend" implementations will die if they cannot
197  #   find a Makefile -- so this file is here to gives them an  #   find a Makefile -- so this file is here to gives them an
198  #   empty one to find and parse.  #   empty one to find and parse.
199  EOF  EOF
200          cat <<EOF >> genmake_tc.f          cat <<EOF >> genmake_tc.f
# Line 204  EOF Line 211  EOF
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              build_cyrus_makedepend              build_cyrus_makedepend
217              RETVAL=$?              RETVAL=$?
# Line 261  build_embed_encode() Line 268  build_embed_encode()
268              return 1              return 1
269          fi          fi
270          clist="cc gcc c89 $CC"          clist="cc gcc c89 $CC"
271          for ic in $clist ; do          for ic in $clist ; do
272              comm="$ic -o encode_files encode_files.c"              comm="$ic -o encode_files encode_files.c"
273              ( cd $ROOTDIR/tools/embed_encode && $comm ) > /dev/null 2>&1              ( cd $ROOTDIR/tools/embed_encode && $comm ) > /dev/null 2>&1
274              RETVAL=$?              RETVAL=$?
# Line 283  build_embed_encode() Line 290  build_embed_encode()
290  }  }
291    
292    
293  # Guess possible config options for this host  #  look for possible C compilers
294  find_possible_configs()  {  look_for_C_compilers() {
295        echo >> $LOGFILE
296      tmp1=`uname`"_"`uname -m`      echo "running: look_for_C_compilers()" >> $LOGFILE
297      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`      rm -f ./genmake_hello.c  ./genmake_hello
298      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`      cat >> genmake_hello.c << EOF
     tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`  
     tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`  
     tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`  
     PLATFORM=$tmp3  
     echo $PLATFORM | grep cygwin > /dev/null 2>&1  &&  PLATFORM=cygwin_ia32  
     OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`  
     echo "  The platform appears to be:  $PLATFORM"  
       
     echo "test" > test  
     ln -s ./test link  
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         LN="ln -s"  
     else  
         echo "Error: \"ln -s\" does not appear to work on this system!"  
         echo "  For help, please contact <MITgcm-support@mitgcm.org>."  
         exit 1  
     fi  
     rm -f test link  
   
     if test "x$CPP" = x ; then  
         CPP="cpp -traditional -P"  
     fi  
   
     look_for_makedepend  
   
     #================================================================  
     #  look for possible C compilers  
     tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc"  
     p_CC=  
     for c in $tmp ; do  
         rm -f ./genmake_hello.c  ./genmake_hello  
         cat >> genmake_hello.c << EOF  
299  #include <stdio.h>  #include <stdio.h>
300  int main(int argc, char **argv) {  int main(int argc, char **argv) {
301    printf("Hello!\n");    printf("Hello!\n");
302    return 0;    return 0;
303  }  }
304  EOF  EOF
305          $c -o genmake_hello genmake_hello.c > /dev/null 2>&1      tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc icc"
306        p_CC=
307        for c in $tmp ; do
308            COMM="$c $CFLAGS -o genmake_hello genmake_hello.c"
309            echo $COMM >> $LOGFILE
310            $COMM >> $LOGFILE 2>&1
311          RETVAL=$?          RETVAL=$?
312          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
313                echo " $c test successful" >> $LOGFILE
314              p_CC="$p_CC $c"              p_CC="$p_CC $c"
315          fi          fi
316      done      done
# Line 346  Error: No C compilers were found in your Line 326  Error: No C compilers were found in your
326  EOF  EOF
327          exit 1          exit 1
328      else      else
329          echo "  The possible C compilers found in your path are:"          echo "  The possible C compilers found in your path are: $p_CC" | tee -a $LOGFILE
         echo "   "$p_CC  
330          if test "x$CC" = x ; then          if test "x$CC" = x ; then
331              CC=`echo $p_CC | $AWK '{print $1}'`              CC=`echo $p_CC | $AWK '{print $1}'`
332              echo "  Setting C compiler to: "$CC              echo "  Setting C compiler to: "$CC
333          fi          fi
334      fi      fi
335        echo " --> set CC='$CC'" >> $LOGFILE
336    }
337    
338    # Guess possible config options for this host
339    find_possible_optfile()  {
340    
341        tmp1=`uname`"_"`uname -m`
342        tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
343        tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
344        tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
345        tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
346        tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
347        PLATFORM=$tmp3
348        echo $PLATFORM | grep cygwin > /dev/null 2>&1  &&  PLATFORM=cygwin_ia32
349        OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
350        echo "  The platform appears to be:  $PLATFORM"
351    
352    #    echo "test" > test
353    #    ln -s ./test link
354    #    RETVAL=$?
355    #    if test "x${RETVAL}" = x0 ; then
356    #       LN="ln -s"
357    #    else
358    #       echo "Error: \"ln -s\" does not appear to work on this system!"
359    #       echo "  For help, please contact <MITgcm-support@mitgcm.org>."
360    #       exit 1
361    #    fi
362    #    rm -f test link
363    #
364    #    if test "x$CPP" = x ; then
365    #       CPP="cpp -traditional -P"
366    #    fi
367    #
368    #    look_for_makedepend
369    #
370    #    look_for_C_compilers
371    
372      #================================================================      #================================================================
373      #  look for possible FORTRAN compilers      #  look for possible FORTRAN compilers
374      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 gfortran"      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc ifort f90 f95 mpif77 mpf77 mpxlf95 gfortran g95"
375      p_FC=      p_FC=
376      for c in $tmp ; do      for c in $tmp ; do
377          rm -f ./hello.f ./hello          rm -f ./hello.f ./hello
# Line 408  EOF Line 423  EOF
423               echo "  I looked for the file "$OPTFILE" but did not find it"               echo "  I looked for the file "$OPTFILE" but did not find it"
424          fi          fi
425      fi      fi
426  #    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  
427      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
428          cat 1>&2 <<EOF          cat 1>&2 <<EOF
429    
# Line 434  Error: No options file was found in:  $R Line 439  Error: No options file was found in:  $R
439  EOF  EOF
440          exit 1          exit 1
441      fi      fi
442        
443  #     # look for possible MPI libraries  #     # look for possible MPI libraries
444  #     mpi_libs=  #     mpi_libs=
445  #     mpi_fort=`which mpif77 2>/dev/null`  #     mpi_fort=`which mpif77 2>/dev/null`
# Line 453  EOF Line 458  EOF
458  #       if test "x${RETVAL}" = x0 ; then  #       if test "x${RETVAL}" = x0 ; then
459  #           a=`cat out`  #           a=`cat out`
460  #           for i in $a ; do  #           for i in $a ; do
461  #               case $i in  #               case $i in
462  #                   -*)  #                   -*)
463  #                       mpi_libs="$mpi_libs $i" ;;  #                       mpi_libs="$mpi_libs $i" ;;
464  #               esac  #               esac
# Line 472  get_pdepend_list()  { Line 477  get_pdepend_list()  {
477      #  strip the comments and then convert the dependency file into      #  strip the comments and then convert the dependency file into
478      #  two arrays: PNAME, DNAME      #  two arrays: PNAME, DNAME
479      cat $1 | sed -e 's/#.*$//g' \      cat $1 | sed -e 's/#.*$//g' \
480          | $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}' \
481          > ./.pd_tmp          > ./.pd_tmp
482        RETVAL=$?
483        if test ! "x${RETVAL}" = x0 ; then
484          echo "Error: unable to parse package dependencies -- please check PKG_DEPEND=\"$1\""
485          exit 1
486        fi
487      . ./.pd_tmp      . ./.pd_tmp
488      rm -f ./.pd_tmp      rm -f ./.pd_tmp
489    
     printf "PNAME = "${}  
490  }  }
491    
492    
# Line 500  Usage: "$0" [OPTIONS] Line 509  Usage: "$0" [OPTIONS]
509        -optfile NAME | --optfile NAME | -of NAME | --of NAME        -optfile NAME | --optfile NAME | -of NAME | --of NAME
510        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
511            Use "NAME" as the optfile.  By default, an attempt will be            Use "NAME" as the optfile.  By default, an attempt will be
512            made to find an appropriate "standard" optfile in the            made to find an appropriate "standard" optfile in the
513            tools/build_options/ directory.            tools/build_options/ directory.
514    
515      -pdepend NAME | --pdepend NAME      -pdepend NAME | --pdepend NAME
516        -pdepend=NAME | --pdepend=NAME        -pdepend=NAME | --pdepend=NAME
517            Get package dependency information from "NAME".            Get package dependency information from "NAME".
518    
519      -pdefault NAME | --pdefault NAME      -pgroups NAME | --pgroups NAME
520        -pdefault=NAME | --pdefault=NAME        -pgroups=NAME | --pgroups=NAME
521            Get the default package list from "NAME".            Get the package groups information from "NAME".
522    
523        -bash NAME
524              Explicitly specify the Bourne or BASH shell to use
525    
526      -make NAME | -m NAME      -make NAME | -m NAME
527        --make=NAME | -m=NAME        --make=NAME | -m=NAME
528            Use "NAME" for the MAKE program. The default is "make" but            Use "NAME" for the MAKE program. The default is "make" but
529            many platforms, "gmake" is the preferred choice.            many platforms, "gmake" is the preferred choice.
530    
531      -makefile NAME | -mf NAME      -makefile NAME | -mf NAME
# Line 527  Usage: "$0" [OPTIONS] Line 539  Usage: "$0" [OPTIONS]
539      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
540        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
541            Specify the location of the MITgcm ROOTDIR as "NAME".            Specify the location of the MITgcm ROOTDIR as "NAME".
542            By default, genamke will try to find the location by            By default, genamke will try to find the location by
543            looking in parent directories (up to the 5th parent).            looking in parent directories (up to the 5th parent).
544    
545      -mods NAME | --mods NAME | -mo NAME | --mo NAME      -mods NAME | --mods NAME | -mo NAME | --mo NAME
546        -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME        -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME
547            Here, "NAME" specifies a list of directories that are            Here, "NAME" specifies a list of directories that are
548            used for additional source code.  Files found in the            used for additional source code.  Files found in the
549            "mods list" are given preference over files of the same            "mods list" are given preference over files of the same
550            name found elsewhere.            name found elsewhere.
551    
552      -disable NAME | --disable NAME      -disable NAME | --disable NAME
553        -disable=NAME | --disable=NAME        -disable=NAME | --disable=NAME
554            Here "NAME" specifies a list of packages that we don't            Here "NAME" specifies a list of packages that we don't
555            want to use.  If this violates package dependencies,            want to use.  If this violates package dependencies,
556            genamke will exit with an error message.            genamke will exit with an error message.
557    
558      -enable NAME | --enable NAME      -enable NAME | --enable NAME
559        -enable=NAME | --enable=NAME        -enable=NAME | --enable=NAME
560            Here "NAME" specifies a list of packages that we wish            Here "NAME" specifies a list of packages that we wish
561            to specifically enable.  If this violates package            to specifically enable.  If this violates package
562            dependencies, genamke will exit with an error message.            dependencies, genamke will exit with an error message.
563    
564      -standarddirs NAME | --standarddirs NAME      -standarddirs NAME | --standarddirs NAME
565        -standarddirs=NAME | --standarddirs=NAME        -standarddirs=NAME | --standarddirs=NAME
566            Here, "NAME" specifies a list of directories to be            Here, "NAME" specifies a list of directories to be
567            used as the "standard" code.            used as the "standard" code.
568    
569      -fortran NAME | --fortran NAME | -fc NAME | --fc NAME      -fortran NAME | --fortran NAME | -fc NAME | --fc NAME
570        -fc=NAME | --fc=NAME        -fc=NAME | --fc=NAME
571            Use "NAME" as the fortran compiler.  By default, genmake            Use "NAME" as the fortran compiler.  By default, genmake
572            will search for a working compiler by trying a list of            will search for a working compiler by trying a list of
573            "usual suspects" such as g77, f77, etc.            "usual suspects" such as g77, f77, etc.
574    
575      -cc NAME | --cc NAME | -cc=NAME | --cc=NAME      -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
576            Use "NAME" as the C compiler.  By default, genmake            Use "NAME" as the C compiler.  By default, genmake
577            will search for a working compiler by trying a list of            will search for a working compiler by trying a list of
578            "usual suspects" such as gcc, c89, cc, etc.            "usual suspects" such as gcc, c89, cc, etc.
579    
580      -[no]ieee | --[no]ieee      -[no]ieee | --[no]ieee
581            Do or don't use IEEE numerics.  Note that this option            Do or don't use IEEE numerics.  Note that this option
582            *only* works if it is supported by the OPTFILE that            *only* works if it is supported by the OPTFILE that
583            is being used.            is being used.
584    
585        -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4
586              Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW)
587              *only* works if CPP_EEOPTIONS.h allows this.
588    
589      -ignoretime | -ignore_time | --ignoretime | --ignore_time      -ignoretime | -ignore_time | --ignoretime | --ignore_time
590            Ignore all the "wall clock" routines entirely.  This will            Ignore all the "wall clock" routines entirely.  This will
591            not in any way hurt the model results -- it simply means            not in any way hurt the model results -- it simply means
592            that the code that checks how long the model spends in            that the code that checks how long the model spends in
593            various routines will give junk values.            various routines will give junk values.
594    
595      -ts | --ts      -ts | --ts
596            Produce timing information per timestep            Produce timing information per timestep
597      -papis | --papis      -papis | --papis
598            Produce summary MFlop/s with PAPI per timestep            Produce summary MFlop/s (and IPC) with PAPI per timestep
599        -pcls | --pcls
600              Produce summary MFlop/s etc. with PCL per timestep
601      -foolad | --foolad      -foolad | --foolad
602            Fool the AD code generator            Fool the AD code generator
603      -papi | --papi      -papi | --papi
604            Performance analysis with PAPI            Performance analysis with PAPI
605        -pcl | --pcl
606              Performance analysis with PCL
607      -hpmt | --hpmt      -hpmt | --hpmt
608            Performance analysis with the HPM Toolkit            Performance analysis with the HPM Toolkit
609    
610      -gsl | --gsl      -gsl | --gsl
611            Use GSL to control floating point rounding and precision            Use GSL to control floating point rounding and precision
612        -devel | --devel
613              Add additional warning and debugging flags for development
614    
615      -mpi | --mpi      -mpi | --mpi
616            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
# Line 597  Usage: "$0" [OPTIONS] Line 619  Usage: "$0" [OPTIONS]
619            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
620            from \$PATH/lib and use binaries from \$PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
621    
622        -omp | --omp
623              Activate OpenMP code + use Compiler option OMPFLAG
624        -omp=OMPFLAG | --omp=OMPFLAG
625              Activate OpenMP code + use Compiler option OMPFLAG
626    
627      -es | --es | -embed-source | --embed-source      -es | --es | -embed-source | --embed-source
628            Embed a tarball containing the full source code            Embed a tarball containing the full source code
629            (including the Makefile, etc.) used to build the            (including the Makefile, etc.) used to build the
630            executable [off by default]            executable [off by default]
631    
632      -bash NAME    While it is most often a single word, the "NAME" variables specified
           Explicitly specify the Bourne or BASH shell to use  
   
   While it is most often a single word, the "NAME" variables specified  
633    above can in many cases be a space-delimited string such as:    above can in many cases be a space-delimited string such as:
634    
635      --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'      --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'
# Line 616  Usage: "$0" [OPTIONS] Line 640  Usage: "$0" [OPTIONS]
640    
641    For more detailed genmake documentation, please see:    For more detailed genmake documentation, please see:
642    
643      http://mitgcm.org/devel_HOWTO/      http://mitgcm.org/public/devel_HOWTO/
644    
645  EOF  EOF
646    
# Line 630  get_fortran_c_namemangling()  { Line 654  get_fortran_c_namemangling()  {
654      if test ! "x$FC_NAMEMANGLE" = x ; then      if test ! "x$FC_NAMEMANGLE" = x ; then
655          return 0          return 0
656      fi      fi
657        echo " running: get_fortran_c_namemangling()" >> $LOGFILE
658    
659      default_nm="#define FC_NAMEMANGLE(X) X ## _"      default_nm="#define FC_NAMEMANGLE(X) X ## _"
660        
661      cat > genmake_test.c <<EOF      cat > genmake_test.c <<EOF
662  void tcall( char * string ) { tsub( string ); }  void tcall( char * string ) { tsub( string ); }
663  EOF  EOF
664      $MAKE genmake_test.o >> genmake_warnings 2>&1  #   $MAKE genmake_test.o >> $LOGFILE 2>&1
665        COMM="$CC $CFLAGS -c genmake_test.c"
666        echo ' '$COMM >> $LOGFILE
667        $COMM >> $LOGFILE 2>&1
668      RETVAL=$?      RETVAL=$?
669      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
670          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
671          cat <<EOF>> genmake_errors          cat <<EOF>> $LOGFILE
672    
673  WARNING: C test compile fails   WARNING: C test compile fails
674  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
675  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
676  EOF  EOF
677          return 1          return 1
678      fi      fi
# Line 652  EOF Line 680  EOF
680      RETVAL=$?      RETVAL=$?
681      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
682          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
683          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
684    
685  WARNING: The "nm" command failed.   WARNING: The "nm" command failed.
686  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
687  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
688  EOF  EOF
689          return 1          return 1
690      fi      fi
# Line 666  EOF Line 694  EOF
694        call tsub( string )        call tsub( string )
695        end        end
696  EOF  EOF
697      $FC $FFLAGS -c genmake_tcomp.$FS >> genmake_warnings 2>&1      COMM="$FC $FFLAGS -c genmake_tcomp.$FS"
698        echo ' '$COMM >> $LOGFILE
699        $COMM >> $LOGFILE 2>&1
700      RETVAL=$?      RETVAL=$?
701      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
702          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
703          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
704    
705  WARNING: FORTRAN test compile fails -- please see "genmake_errors"   WARNING: FORTRAN test compile fails -- please see '$LOGFILE'
706  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
707  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
708  EOF  EOF
709          return 1          return 1
710      fi      fi
# Line 682  EOF Line 712  EOF
712      RETVAL=$?      RETVAL=$?
713      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
714          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
715          cat <<EOF>> genmake_warnings          cat <<EOF>> $LOGFILE
716    
717  WARNING: The "nm" command failed.   WARNING: The "nm" command failed.
718  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'   WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
719  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.   WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
720  EOF  EOF
721          return 1          return 1
722      fi      fi
# Line 712  EOF Line 742  EOF
742    
743      #  cleanup the testing files      #  cleanup the testing files
744      rm -f genmake_tcomp.* genmake_test.*      rm -f genmake_tcomp.* genmake_test.*
745    
746        echo " --> set FC_NAMEMANGLE='$FC_NAMEMANGLE'" >> $LOGFILE
747  }  }
748    
749    
750  check_HAVE_CLOC()  {  check_HAVE_CLOC()  {
751        echo >> $LOGFILE
752        echo "running: check_HAVE_CLOC()" >> $LOGFILE
753      get_fortran_c_namemangling      get_fortran_c_namemangling
754      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
755  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 732  void FC_NAMEMANGLE(cloc) ( double *curti Line 766  void FC_NAMEMANGLE(cloc) ( double *curti
766   *curtim = *curtim/1.E6;   *curtim = *curtim/1.E6;
767  }  }
768  EOF  EOF
769      make genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
770        echo $COMM >> $LOGFILE
771        $COMM >> $LOGFILE 2>&1
772      RET_C=$?      RET_C=$?
773      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
774        program hello        program hello
# Line 742  EOF Line 778  EOF
778        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
779        end        end
780  EOF  EOF
781      $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
782        echo $COMM >> $LOGFILE
783        $COMM >> $LOGFILE 2>&1
784      RET_F=$?      RET_F=$?
785      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> $LOGFILE 2>&1
786      RETVAL=$?      RETVAL=$?
787      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
788          HAVE_CLOC=t          HAVE_CLOC=t
789          DEFINES="$DEFINES -DHAVE_CLOC"          DEFINES="$DEFINES -DHAVE_CLOC"
790      fi      fi
791      rm -f genmake_tc*      rm -f genmake_tc*
792        echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE
793  }  }
794    
795    
796  check_HAVE_SIGREG()  {  check_HAVE_SIGREG()  {
797        if test ! "x$HAVE_SIGREG" = x ; then
798            return
799        fi
800        echo >> $LOGFILE
801        echo "running: check_HAVE_SIGREG()" >> $LOGFILE
802      get_fortran_c_namemangling      get_fortran_c_namemangling
803      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
804  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 786  void FC_NAMEMANGLE(sigreg) (int * aip) Line 830  void FC_NAMEMANGLE(sigreg) (int * aip)
830      return;      return;
831  }  }
832  EOF  EOF
833      make genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
834        echo $COMM >> $LOGFILE
835        $COMM >> $LOGFILE 2>&1
836      RET_C=$?      RET_C=$?
837      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
838        program hello        program hello
# Line 796  EOF Line 842  EOF
842        call sigreg(anint)        call sigreg(anint)
843        end        end
844  EOF  EOF
845      echo >> genmake_warnings      cat genmake_tc_2.$FS >> $LOGFILE
     echo "running: check_HAVE_SIGREG()" >> genmake_warnings  
     cat genmake_tc_2.$FS >> genmake_warnings  
846      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
847      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
848      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
849      RETVAL=$?      RETVAL=$?
850      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
851          HAVE_SIGREG=t          HAVE_SIGREG=t
852          DEFINES="$DEFINES -DHAVE_SIGREG"          DEFINES="$DEFINES -DHAVE_SIGREG"
853      fi      fi
854      rm -f genmake_tc*      rm -f genmake_tc*
855        echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE
856  }  }
857    
858    
859  check_HAVE_SETRLSTK()  {  check_HAVE_SETRLSTK()  {
860        if test "x$HAVE_SETRLSTK" = xt ; then
861            DEFINES="$DEFINES -DHAVE_SETRLSTK"
862            return
863        fi  
864        if test ! "x$HAVE_SETRLSTK" = x ; then
865            return
866        fi
867        echo >> $LOGFILE
868        echo "running: check_HAVE_SETRLSTK()" >> $LOGFILE
869      get_fortran_c_namemangling      get_fortran_c_namemangling
870      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
871  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 827  void FC_NAMEMANGLE(setrlstk) () Line 881  void FC_NAMEMANGLE(setrlstk) ()
881      return;      return;
882  }  }
883  EOF  EOF
884      make genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
885        echo $COMM >> $LOGFILE
886        $COMM >> $LOGFILE 2>&1
887      RET_C=$?      RET_C=$?
888      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
889        program hello        program hello
# Line 835  EOF Line 891  EOF
891        call setrlstk()        call setrlstk()
892        end        end
893  EOF  EOF
894      echo >> genmake_warnings      cat genmake_tc_2.$FS >> $LOGFILE
     echo "running: check_HAVE_SETRLSTK()" >> genmake_warnings  
     cat genmake_tc_2.$FS >> genmake_warnings  
895      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
896      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
897      $COMM >> genmake_warnings 2>&1      $COMM >> $LOGFILE 2>&1
898      RETVAL=$?      RETVAL=$?
899      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
900          HAVE_SETRLSTK=t          HAVE_SETRLSTK=t
901          DEFINES="$DEFINES -DHAVE_SETRLSTK"          DEFINES="$DEFINES -DHAVE_SETRLSTK"
902      fi      fi
903      rm -f genmake_tc*      rm -f genmake_tc*
904        echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE
905  }  }
906    
907    
908  check_HAVE_STAT()  {  check_HAVE_STAT()  {
909        echo >> $LOGFILE
910        echo "running: check_HAVE_STAT()" >> $LOGFILE
911      get_fortran_c_namemangling      get_fortran_c_namemangling
912      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
913  $FC_NAMEMANGLE  $FC_NAMEMANGLE
# Line 871  void FC_NAMEMANGLE(tfsize) ( int *nbyte Line 928  void FC_NAMEMANGLE(tfsize) ( int *nbyte
928          *nbyte = -1;          *nbyte = -1;
929  }  }
930  EOF  EOF
931      make genmake_tc_1.o >> genmake_tc.log 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
932        echo $COMM >> $LOGFILE
933        $COMM >> genmake_tc.log 2>&1
934      RET_C=$?      RET_C=$?
935      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
936        program hello        program hello
# Line 880  EOF Line 939  EOF
939        print *," HELLO WORLD", nbyte        print *," HELLO WORLD", nbyte
940        end        end
941  EOF  EOF
942      echo >> genmake_warnings      cat genmake_tc_2.$FS >> $LOGFILE
     echo "running: check_HAVE_STAT()" >> genmake_warnings  
     cat genmake_tc_2.$FS >> genmake_warnings  
943      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
944      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
945      $COMM >> genmake_tc.log 2>&1      $COMM >> genmake_tc.log 2>&1
946      RETVAL=$?      RETVAL=$?
947      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
# Line 892  EOF Line 949  EOF
949          DEFINES="$DEFINES -DHAVE_STAT"          DEFINES="$DEFINES -DHAVE_STAT"
950      fi      fi
951      rm -f genmake_tc*      rm -f genmake_tc*
952        echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE
953  }  }
954    
955    
# Line 899  check_netcdf_libs()  { Line 957  check_netcdf_libs()  {
957      if test ! "x$SKIP_NETCDF_CHECK" = x ; then      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
958          return          return
959      fi      fi
960      echo >> genmake_warnings      echo >> $LOGFILE
961      echo "running: check_netcdf_libs()" >> genmake_warnings      echo "running: check_netcdf_libs()" >> $LOGFILE
962      cat <<EOF > genmake_tnc.F      cat <<EOF > genmake_tnc.F
963        program fgennc        program fgennc
964  #include "netcdf.inc"  #include "netcdf.inc"
# Line 918  EOF Line 976  EOF
976        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
977        end        end
978  EOF  EOF
979      echo "===  genmake_tnc.F  ===" > genmake_tnc.log      echo "===  genmake_tnc.F  >>>" > genmake_tnc.log
980      cat genmake_tnc.F >> genmake_tnc.log      cat genmake_tnc.F >> genmake_tnc.log
981      echo "===  genmake_tnc.F  ===" >> genmake_tnc.log      echo "<<<  genmake_tnc.F  ===" >> genmake_tnc.log
982      RET_CPP=f      RET_CPP=f
983      COMM="$CPP $DEFINES $INCLUDES genmake_tnc.F"      COMM="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES"
984      echo "$COMM" >> genmake_tnc.log      echo "$COMM" >> genmake_tnc.log
985      $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t      eval $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t
986      if test "x$RET_CPP" = xf ; then      if test "x$RET_CPP" = xf ; then
987          echo "  WARNING: CPP failed to pre-process the netcdf test." \          echo "  WARNING: CPP failed to pre-process the netcdf test." \
988              >> genmake_tnc.log              >> genmake_tnc.log
# Line 932  EOF Line 990  EOF
990              >> genmake_tnc.log              >> genmake_tnc.log
991      fi      fi
992      echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log      echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log
993      echo "  &&  $LINK -o genmake_tnc.o $LIBS" >> genmake_tnc.log      echo "  &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc.o $LIBS" >> genmake_tnc.log
994      $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \      $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
995          &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1          &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
996      RET_COMPILE=$?      RET_COMPILE=$?
997      cat genmake_tnc.log >> genmake_warnings      cat genmake_tnc.log >> $LOGFILE
998    
999      #EH3  Remove test program execution for machines that either disallow      #EH3  Remove test program execution for machines that either disallow
1000      #EH3  execution or cannot support it (eg. cross-compilers)      #EH3  execution or cannot support it (eg. cross-compilers)
# Line 947  EOF Line 1005  EOF
1005    
1006      if test "x$RET_COMPILE" = x0 ; then      if test "x$RET_COMPILE" = x0 ; then
1007          HAVE_NETCDF=t          HAVE_NETCDF=t
1008            echo "check_netcdf: successful" >> $LOGFILE
1009      else      else
1010          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
1011          echo "try again with added '-lnetcdf'" > genmake_tnc.log          echo "==> try again with added '-lnetcdf'" > genmake_tnc.log
1012          echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log          echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
1013          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
1014          echo " &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log          echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
1015          $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \          cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null  \
1016              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
1017              &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1              &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
1018          RET_COMPILE=$?          RET_COMPILE=$?
1019          cat genmake_tnc.log >> genmake_warnings          echo >> $LOGFILE
1020            cat genmake_tnc.log >> $LOGFILE
1021          if test "x$RET_COMPILE" = x0 ; then          if test "x$RET_COMPILE" = x0 ; then
1022              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
1023              HAVE_NETCDF=t              HAVE_NETCDF=t
1024                echo "check_netcdf: successful" >> $LOGFILE
1025            else
1026            # try again with "-lnetcdff" added to the libs
1027                echo "==> try again with added '-lnetcdff -lnetcdf'" > genmake_tnc.log
1028                echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
1029                echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
1030                echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
1031                cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null  \
1032                    &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
1033                    &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdff -lnetcdf >> genmake_tnc.log 2>&1
1034                RET_COMPILE=$?
1035                echo >> $LOGFILE
1036                cat genmake_tnc.log >> $LOGFILE
1037                if test "x$RET_COMPILE" = x0 ; then
1038                    LIBS="$LIBS -lnetcdff -lnetcdf"
1039                    HAVE_NETCDF=t
1040                    echo "check_netcdf: successful" >> $LOGFILE
1041                fi
1042          fi          fi
1043      fi      fi
1044      rm -f genmake_tnc*      rm -f genmake_tnc*
1045        echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE
1046  }  }
1047    
1048    
# Line 989  ENABLE= Line 1068  ENABLE=
1068  DISABLE=  DISABLE=
1069  # MAKEFILE=  # MAKEFILE=
1070  # MAKEDEPEND=  # MAKEDEPEND=
1071  PDEPEND=  PKG_DEPEND=
1072  DUMPSTATE=t  PKG_GROUPS=
1073  PDEFAULT=  DUMPSTATE=f
1074  OPTFILE=  OPTFILE=
1075  INCLUDES="-I. $INCLUDES"  INCLUDES="-I. $INCLUDES"
1076  FFLAGS=  FFLAGS=
1077  FOPTIM=  FOPTIM=
1078    FEXTRAFLAGS=
1079    USE_EXTENDED_SRC=
1080    EXTENDED_SRC_FLAG=
1081  CFLAGS=  CFLAGS=
1082  KFLAGS1=  KFLAGS1=
1083  KFLAGS2=  KFLAGS2=
# Line 1006  NOOPTFILES= Line 1088  NOOPTFILES=
1088  NOOPTFLAGS=  NOOPTFLAGS=
1089  MPI=  MPI=
1090  MPIPATH=  MPIPATH=
1091    OMP=
1092    OMPFLAG=
1093    USE_R4=
1094  TS=  TS=
1095  PAPIS=  PAPIS=
1096    PCLS=
1097  FOOLAD=  FOOLAD=
1098  PAPI=  PAPI=
1099    PCL=
1100  HPMT=  HPMT=
1101  GSL=  GSL=
1102    DEVEL=
1103  HAVE_TEST_L=  HAVE_TEST_L=
1104    
1105  # DEFINES checked by test compilation or command-line  # DEFINES checked by test compilation or command-line
# Line 1019  HAVE_SYSTEM= Line 1107  HAVE_SYSTEM=
1107  HAVE_FDATE=  HAVE_FDATE=
1108  FC_NAMEMANGLE=  FC_NAMEMANGLE=
1109  HAVE_CLOC=  HAVE_CLOC=
1110  HAVE_SETRLSTK=  # HAVE_SETRLSTK=
1111  HAVE_STAT=  HAVE_STAT=
1112  HAVE_NETCDF=  HAVE_NETCDF=
1113  HAVE_ETIME=  HAVE_ETIME=
# Line 1067  FTL_TAF_FLAGS= Line 1155  FTL_TAF_FLAGS=
1155  SVD_TAMC_FLAGS=  SVD_TAMC_FLAGS=
1156  TAMC_EXTRA=  TAMC_EXTRA=
1157    
   
1158  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1159  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"
1160  gm_s2="FC CPP IEEE TS PAPIS PAPI HPMT GSL MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC IEEE USE_R4 TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI OMP DUMPSTATE STANDARDDIRS"
1161    
1162  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1163  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "  gm_s3="LN S64 LINK MAKE PACKAGES INCLUDES FFLAGS FOPTIM FEXTRAFLAGS"
1164  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
1165  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD THISHOST THISUSER THISDATE THISVER MACHINE"
1166  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
1167  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"  gm_s7="FC_NAMEMANGLE HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME"
1168    
1169  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1170  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 1091  cat <<EOF Line 1178  cat <<EOF
1178    
1179  GENMAKE :  GENMAKE :
1180    
1181  A program for GENerating MAKEfiles for the MITgcm project.  For a  A program for GENerating MAKEfiles for the MITgcm project.
1182  quick list of options, use "genmake -h" or for more detail see:     For a quick list of options, use "genmake2 -h"
1183    or for more detail see the Developer's HOWTO manual at:
1184    http://mitgcm.org/devel_HOWTO/     http://mitgcm.org/public/docs.html
1185    
1186  EOF  EOF
1187    
1188    LOGFILE="genmake.log"
1189    #- clean-up previous genmake logfiles:
1190    rm -f genmake_state genmake_*optfile $LOGFILE
1191    
1192  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
1193  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  
1194  printf "  getting local config information:  "  printf "  getting local config information:  "
1195  if test -f $gm_local ; then  if test -f $gm_local ; then
1196      echo "using $gm_local"      echo "using $gm_local"
# Line 1117  else Line 1202  else
1202  fi  fi
1203    
1204  #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  
1205  #parse_options  #parse_options
1206  ac_prev=  ac_prev=
1207  for ac_option in "$@" ; do  for ac_option in "$@" ; do
# Line 1138  for ac_option in "$@" ; do Line 1214  for ac_option in "$@" ; do
1214          ac_prev=          ac_prev=
1215          continue          continue
1216      fi      fi
1217        
1218      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
1219        
1220      case $ac_option in      case $ac_option in
1221                    
1222          -help | --help | -h | --h)          -help | --help | -h | --h)
# Line 1159  for ac_option in "$@" ; do Line 1235  for ac_option in "$@" ; do
1235              AD_OPTFILE=$ac_optarg ;;              AD_OPTFILE=$ac_optarg ;;
1236                    
1237          -pdepend | --pdepend)          -pdepend | --pdepend)
1238              ac_prev=PDEPEND ;;              ac_prev=PKG_DEPEND ;;
1239          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
1240              PDEPEND=$ac_optarg ;;              PKG_DEPEND=$ac_optarg ;;
1241                    
1242          -pdefault | --pdefault)          -pgroups | --pgroups)
1243              ac_prev=PDEFAULT ;;              ac_prev=PKG_GROUPS ;;
1244          -pdefault=* | --pdefault=*)          -pgroups=* | --pgroups=*)
1245              PDEFAULT=$ac_optarg ;;              PKG_GROUPS=$ac_optarg ;;
1246                    
1247          -make | --make | -m | --m)          -make | --make | -m | --m)
1248              ac_prev=MAKE ;;              ac_prev=MAKE ;;
# Line 1250  for ac_option in "$@" ; do Line 1326  for ac_option in "$@" ; do
1326          -noieee | --noieee)          -noieee | --noieee)
1327              IEEE= ;;              IEEE= ;;
1328    
1329            -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )
1330                USE_R4=true ;;
1331    
1332          -ts | --ts)          -ts | --ts)
1333              TS=true ;;              TS=true ;;
1334          -papis | --papis)          -papis | --papis)
1335              PAPIS=true ;;              PAPIS=true ;;
1336            -pcls | --pcls)
1337                PCLS=true ;;
1338          -foolad | --foolad)          -foolad | --foolad)
1339              FOOLAD=true ;;              FOOLAD=true ;;
1340          -papi | --papi)          -papi | --papi)
1341              PAPI=true ;;              PAPI=true ;;
1342            -pcl | --pcl)
1343                PCL=true ;;
1344          -hpmt | --hpmt)          -hpmt | --hpmt)
1345              HPMT=true ;;              HPMT=true ;;
1346    
1347          -gsl | --gsl)          -gsl | --gsl)
1348              GSL=true ;;              GSL=true ;;
1349    
1350            -devel | --devel)
1351                DEVEL=true ;;
1352    
1353          -mpi | --mpi)          -mpi | --mpi)
1354              MPI=true ;;              MPI=true ;;
1355          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
1356              MPIPATH=$ac_optarg              MPIPATH=$ac_optarg
1357              MPI=true ;;              MPI=true ;;
1358                    
1359  #       -jam | --jam)          -omp | --omp)
1360  #           JAM=1 ;;              OMP=true ;;
1361  #       -nojam | --nojam)          -omp=* | --omp=*)
1362  #           JAM=0 ;;              OMPFLAG=$ac_optarg
1363                OMP=true ;;
1364                    
1365          -ds | --ds)          -ds | --ds)
1366              DUMPSTATE=t ;;              DUMPSTATE=t ;;
# Line 1305  for ac_option in "$@" ; do Line 1392  for ac_option in "$@" ; do
1392              ;;              ;;
1393                    
1394      esac      esac
1395        
1396  done  done
1397    
1398    
1399  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1400      echo      echo
1401      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
1402      echo "  file.  This file format is no longer supported.  Please see:"      echo "  file.  This file format is no longer supported.  For directions on"
1403      echo      echo "  how to setup and use the new \"genmake2\" script, please see:"
1404      echo "    http://mitgcm.org/devel_HOWTO/"      echo "    http://mitgcm.org/devel_HOWTO/"
1405        echo "  and send an email to MITgcm-support@mitgcm.org if you need help."
1406        echo "WARNING: ignore \"./.genmakerc\" and continue."
1407      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  
1408  fi  fi
1409    
1410  #  Find the MITgcm ${ROOTDIR}  #  Find the MITgcm ${ROOTDIR}
1411  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1412      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1413      if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesupp -a -d ../pkg ; then
1414          ROOTDIR=".."          ROOTDIR=".."
1415      else      else
1416          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
# Line 1349  if test ! -d ${ROOTDIR} ; then Line 1435  if test ! -d ${ROOTDIR} ; then
1435  fi  fi
1436    
1437  #  Find the MITgcm ${THISVER}  #  Find the MITgcm ${THISVER}
1438  if test -f "${ROOTDIR}/doc/tag-index" ; then  version_file="${ROOTDIR}/doc/tag-index"
1439      THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`  if test -f $version_file ; then
1440        THISVER=`$AWK '/^checkpoint/{print $1; exit}' $version_file`
1441    #-  remove ./BUILD_INFO.h file if older than version_file
1442        if test -f ./BUILD_INFO.h -a ./BUILD_INFO.h -ot $version_file ; then
1443            echo "  remove ./BUILD_INFO.h (older than ${version_file})"
1444            rm -f ./BUILD_INFO.h
1445        fi
1446  fi  fi
1447    
1448  if test "x$MAKEFILE" = x ; then  if test "x$MAKEFILE" = x ; then
# Line 1362  if test "x${OPTFILE}" = x ; then Line 1454  if test "x${OPTFILE}" = x ; then
1454      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
1455          echo "Warning: no OPTFILE specified so we'll look for possible settings"          echo "Warning: no OPTFILE specified so we'll look for possible settings"
1456          printf "\n===  Searching for possible settings for OPTFILE  ===\n"          printf "\n===  Searching for possible settings for OPTFILE  ===\n"
1457          find_possible_configs          find_possible_optfile
1458      else      else
1459          OPTFILE=$MITGCM_OF          OPTFILE=$MITGCM_OF
1460      fi      fi
# Line 1377  if test "x$OPTFILE" != xNONE ; then Line 1469  if test "x$OPTFILE" != xNONE ; then
1469              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1470              exit 1              exit 1
1471          fi          fi
1472          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" = xt ; then
1473              cp -f $OPTFILE "genmake_optfile"              cp -f $OPTFILE "genmake_optfile"
1474          fi          fi
1475      else      else
# Line 1404  if test "x${AD_OPTFILE}" != xNONE ; then Line 1496  if test "x${AD_OPTFILE}" != xNONE ; then
1496              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1497              exit 1              exit 1
1498          fi          fi
1499          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" = xt ; then
1500              cp -f $AD_OPTFILE "genmake_ad_optfile"              cp -f $AD_OPTFILE "genmake_ad_optfile"
1501          fi          fi
1502      else      else
# Line 1432  Error: no Fortran compiler: please speci Line 1524  Error: no Fortran compiler: please speci
1524  EOF  EOF
1525      exit 1      exit 1
1526  fi  fi
1527    
1528  if test "x$CC" = x ; then  if test "x$CC" = x ; then
1529      CC=cc      look_for_C_compilers
1530    #   CC=cc
1531  #     cat <<EOF 1>&2  #     cat <<EOF 1>&2
1532  # Error: no C compiler: please specify using one of the following:  # Error: no C compiler: please specify using one of the following:
1533  #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"  #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"
# Line 1442  if test "x$CC" = x ; then Line 1536  if test "x$CC" = x ; then
1536  # EOF  # EOF
1537  #     exit 1  #     exit 1
1538  fi  fi
1539    
1540  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1541      LINK=$FC      LINK=$FC
1542  fi  fi
# Line 1449  if test "x$MAKE" = x ; then Line 1544  if test "x$MAKE" = x ; then
1544      MAKE="make"      MAKE="make"
1545  fi  fi
1546  if test "x$CPP" = x ; then  if test "x$CPP" = x ; then
1547      CPP=cpp      CPP="cpp -traditional -P"
1548  fi  fi
1549  #EH3 === UGLY ===  #EH3 === UGLY ===
1550  #  The following is an ugly little hack to check for $CPP in /lib/ and  #  The following is an ugly little hack to check for $CPP in /lib/ and
# Line 1476  EOF Line 1571  EOF
1571  else  else
1572      rm -f test_cpp      rm -f test_cpp
1573  fi  fi
1574    
1575  look_for_makedepend  look_for_makedepend
1576    
1577    #  Check that soft-link command is set and usable
1578  if test "x$LN" = x ; then  if test "x$LN" = x ; then
1579      LN="ln -s"      LN="ln -s"
1580  fi  fi
# Line 1486  RETVAL=$? Line 1584  RETVAL=$?
1584  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
1585      cat <<EOF 1>&2      cat <<EOF 1>&2
1586    
1587  Error: The command "ln -s" failed -- please specify a working soft-link  Error: The command "$LN" failed -- please specify a working soft-link
1588    command in the optfile.    command in the optfile.
1589    
1590  EOF  EOF
# Line 1506  if test ! "x$MPI" = x ; then Line 1604  if test ! "x$MPI" = x ; then
1604        echo "  Turning on MPI cpp macros"        echo "  Turning on MPI cpp macros"
1605        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1606  fi  fi
1607    if test ! "x$OMP" = x ; then
1608          echo "  Add OMPFLAG and turn on OpenMP cpp macros"
1609          FFLAGS="$FFLAGS $OMPFLAG"
1610          F90FLAGS="$F90FLAGS $OMPFLAG"
1611          DEFINES="$DEFINES -DUSE_OMP_THREADING"
1612    fi
1613    
1614    if test ! "x$USE_R4" = x ; then
1615          echo "  Turning on LET_RS_BE_REAL4 cpp flag"
1616          DEFINES="$DEFINES -DLET_RS_BE_REAL4"
1617    fi
1618    
1619  if test ! "x$TS" = x ; then  if test ! "x$TS" = x ; then
1620        echo "  Turning on timing per timestep"        echo "  Turning on timing per timestep"
# Line 1514  if test ! "x$TS" = x ; then Line 1623  if test ! "x$TS" = x ; then
1623        else        else
1624              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1625        fi        fi
1626          PACKAGES="$PACKAGES showflops"
1627  fi  fi
1628  if test ! "x$PAPIS" = x ; then  if test ! "x$PAPIS" = x ; then
1629        echo "  Turning on PAPI flop summary per timestep"        echo "  Turning on PAPI flop summary per timestep"
# Line 1525  if test ! "x$PAPIS" = x ; then Line 1635  if test ! "x$PAPIS" = x ; then
1635        fi        fi
1636        INCLUDES="$INCLUDES $PAPIINC"        INCLUDES="$INCLUDES $PAPIINC"
1637        LIBS="$LIBS $PAPILIB"        LIBS="$LIBS $PAPILIB"
1638          PACKAGES="$PACKAGES showflops"
1639    fi
1640    if test ! "x$PCLS" = x ; then
1641          echo "  Turning on PCL counter summary per timestep"
1642          echo "  Please make sure PCLINC, PCLLIB are defined"
1643          if test ! "x$FOOLAD" = x ; then
1644                DEFINES="$DEFINES -DUSE_PCL_FLOPS_SFP"
1645          else
1646                DEFINES="$DEFINES -DUSE_PCL_FLOPS"
1647          fi
1648          INCLUDES="$INCLUDES $PCLINC"
1649          LIBS="$LIBS $PCLLIB"
1650          PACKAGES="$PACKAGES showflops"
1651  fi  fi
1652  if test ! "x$PAPI" = x ; then  if test ! "x$PAPI" = x ; then
1653        if test ! "x$PAPIS" = x ; then        if test ! "x$PAPIS" = x ; then
# Line 1538  if test ! "x$PAPI" = x ; then Line 1661  if test ! "x$PAPI" = x ; then
1661            LIBS="$LIBS $PAPILIB"            LIBS="$LIBS $PAPILIB"
1662        fi        fi
1663  fi  fi
1664    if test ! "x$PCL" = x ; then
1665          if test ! "x$PCLS" = x ; then
1666              echo "  PCL performance analysis and flop summary per timestep cannot co-exist!"
1667              echo "  Sticking with PCL flop summary per timestep!"
1668          else
1669              echo "  Turning on performance analysis with PCL"
1670              echo "  Please make sure PCLINC, PCLLIB are defined"
1671              DEFINES="$DEFINES -DUSE_PCL"
1672              INCLUDES="$INCLUDES $PCLINC"
1673              LIBS="$LIBS $PCLLIB"
1674          fi
1675    fi
1676  if test ! "x$HPMT" = x ; then  if test ! "x$HPMT" = x ; then
1677        if test ! "x$PAPI" = x ; then        if test ! "x$PAPI" = x ; then
1678            echo "  PAPI and the HPM Toolkit cannot co-exist!"            echo "  PAPI and the HPM Toolkit cannot co-exist!"
1679            echo "  Sticking with PAPI!"            echo "  Sticking with PAPI!"
1680          else if test ! "x$PCL" = x ; then
1681              echo "  PCL and the HPM Toolkit cannot co-exist!"
1682              echo "  Sticking with PCL!"
1683        else        else
1684            echo "  Turning on performance analysis with the HPM Toolkit"            echo "  Turning on performance analysis with the HPM Toolkit"
1685            echo "  Please make sure HPMTINC, HPMTLIB are defined"            echo "  Please make sure HPMTINC, HPMTLIB are defined"
# Line 1549  if test ! "x$HPMT" = x ; then Line 1687  if test ! "x$HPMT" = x ; then
1687            INCLUDES="$INCLUDES $HPMTINC"            INCLUDES="$INCLUDES $HPMTINC"
1688            LIBS="$LIBS $HPMTLIB"            LIBS="$LIBS $HPMTLIB"
1689        fi        fi
1690          fi
1691  fi  fi
1692  if test ! "x$GSL" = x ; then  if test ! "x$GSL" = x ; then
1693        echo "  Turning on use of GSL to control floating point calculations"        echo "  Turning on use of GSL to control floating point calculations"
# Line 1557  if test ! "x$GSL" = x ; then Line 1696  if test ! "x$GSL" = x ; then
1696        INCLUDES="$INCLUDES $GSLINC"        INCLUDES="$INCLUDES $GSLINC"
1697        LIBS="$LIBS $GSLLIB"        LIBS="$LIBS $GSLLIB"
1698  fi  fi
1699    #- if USE_EXTENDED_SRC is set, add EXTENDED_SRC_FLAG to FFLAGS :
1700    if test ! "x$USE_EXTENDED_SRC" = x ; then
1701          FFLAGS="$FFLAGS $EXTENDED_SRC_FLAG"
1702          F90FIXEDFORMAT="$F90FIXEDFORMAT $EXTENDED_SRC_FLAG"
1703    fi
1704    
1705  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1706  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
# Line 1636  rm -f genmake_t* Line 1780  rm -f genmake_t*
1780    
1781  printf "  Can we unlimit the stack size using $FC...  "  printf "  Can we unlimit the stack size using $FC...  "
1782  check_HAVE_SETRLSTK  check_HAVE_SETRLSTK
1783  if test "x$HAVE_SETRLSTK" != x ; then  if test "x$HAVE_SETRLSTK" = xt ; then
1784      echo "yes"      echo "yes"
1785  else  else
1786      echo "no"      echo "no"
# Line 1645  rm -f genmake_t* Line 1789  rm -f genmake_t*
1789    
1790  printf "  Can we register a signal handler using $FC...  "  printf "  Can we register a signal handler using $FC...  "
1791  check_HAVE_SIGREG  check_HAVE_SIGREG
1792  if test "x$HAVE_SIGREG" != x ; then  if test "x$HAVE_SIGREG" = xt ; then
1793      echo "yes"      echo "yes"
1794  else  else
1795      echo "no"      echo "no"
# Line 1679  fi Line 1823  fi
1823    
1824    
1825  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1826  printf "  Adding MODS directories:  "  printf "  Adding MODS directories: "
1827  for d in $MODS ; do  for d in $MODS ; do
1828      if test ! -d $d ; then      if test ! -d $d ; then
1829          echo          echo
1830          echo "Error: MODS directory \"$d\" not found!"          echo "Error: MODS directory \"$d\" not found!"
1831          exit 1          exit 1
1832      else      else
1833          printf " $d"          printf "$d "
1834          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1835          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
1836      fi      fi
1837  done  done
1838  echo  echo
1839    
1840  if test "x${PLATFORM}" = x ; then  #if test "x${PLATFORM}" = x ; then
1841      PLATFORM=$p_PLATFORM  #    PLATFORM=$p_PLATFORM
1842  fi  #fi
1843    
1844  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1845      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
# Line 1735  ERROR: neither of the two default script Line 1879  ERROR: neither of the two default script
1879      ${TOOLSDIR}/set64bitConst.sh      ${TOOLSDIR}/set64bitConst.sh
1880      ${TOOLSDIR}/set64bitConst.csh      ${TOOLSDIR}/set64bitConst.csh
1881    
1882    are working so please check paths or specify (with \$S64) a    are working so please check paths or specify (with \$S64) a
1883    working version of this script.    working version of this script.
1884    
1885  EOF  EOF
# Line 1747  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSD Line 1891  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSD
1891    
1892  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
1893    
1894    #  Set Standard Code Directories:
1895    if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
1896        STANDARDDIRS="eesupp model"
1897    fi
1898    #  if model in Standard-Code-Dir, add eesupp (needed to compile model)
1899    echo " $STANDARDDIRS " | grep ' model ' > /dev/null 2>&1
1900    ckM=$?
1901    echo " $STANDARDDIRS " | grep ' eesupp ' > /dev/null 2>&1
1902    ckE=$?
1903    if test $ckM = 0 -a $ckE = 1 ; then
1904        STANDARDDIRS="$STANDARDDIRS eesupp"
1905    fi
1906    
1907  #  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
1908  #  generated from some template source files. We'll make them first so  #  generated from some template source files. We'll make them first so
1909  #  they appear as regular source code  #  they appear as regular source code
1910  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
1911      echo "  Making source files in eesupp from templates"      echo "  Making source files in eesupp from templates"
1912      ( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1      ( cd $ROOTDIR"/eesupp/src/" && $MAKE clean_old && $MAKE \
1913        ) > make_eesupp.errors 2>&1
1914      RETVAL=$?      RETVAL=$?
1915      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
1916          rm -f make_eesupp.errors          rm -f make_eesupp.errors
# Line 1763  if test -r $ROOTDIR"/eesupp/src/Makefile Line 1921  if test -r $ROOTDIR"/eesupp/src/Makefile
1921      fi      fi
1922  fi  fi
1923    
1924  #same for exch2  #same for pkg/exch2 and pkg/regrid
1925  if test -r $ROOTDIR"/pkg/exch2/Makefile" ; then  for pdir in exch2 regrid ; do
1926      echo "  Making source files in exch2 from  templates"      if test -r $ROOTDIR"/pkg/${pdir}/Makefile" ; then
1927      ( cd $ROOTDIR"/pkg/exch2/" && $MAKE ) > make_exch2.errors 2>&1          echo "  Making source files in pkg/${pdir} from templates"
1928      RETVAL=$?          ( cd $ROOTDIR"/pkg/"${pdir} && $MAKE clean_old && $MAKE \
1929      if test "x${RETVAL}" = x0 ; then          ) > make_${pdir}.errors 2>&1
1930          rm -f make_exch2.errors          RETVAL=$?
1931      else          if test "x${RETVAL}" = x0 ; then
1932          echo "Error: problem encountered while building source files in exch2:"              rm -f make_${pdir}.errors
1933          cat make_exch2.errors 1>&2          else
1934          exit 1              echo "Error: problem encountered while building source files in pkg/${pdir}:"
1935                cat make_${pdir}.errors 1>&2
1936                exit 1
1937            fi
1938      fi      fi
1939  fi  done
1940    
1941  printf "\n===  Determining package settings  ===\n"  printf "\n===  Determining package settings  ===\n"
1942  if  test "x${PDEPEND}" = x ; then  if  test "x${PKG_DEPEND}" = x ; then
1943      tmp=$ROOTDIR"/pkg/pkg_depend"      tmp=$ROOTDIR"/pkg/pkg_depend"
1944      if test -r $tmp ; then      if test -r $tmp ; then PKG_DEPEND=$tmp ; fi
1945          PDEPEND=$tmp  fi
1946      else  if  test "x${PKG_DEPEND}" = x ; then
1947          echo "Warning:  No package dependency information was specified."          echo "Warning:  No package dependency information was specified."
1948          echo "  Please check that ROOTDIR/pkg/pkg_depend exists."          echo "  Please check that ROOTDIR/pkg/pkg_depend exists."
     fi  
1949  else  else
1950      if test ! -r ${PDEPEND} ; then      if test ! -r ${PKG_DEPEND} ; then
1951          echo "Error:  can't read package dependency info from PDEPEND=\"$PDEPEND\""          echo "Error:  can't read package dependency info from PKG_DEPEND=\"$PKG_DEPEND\""
1952          exit 1          exit 1
1953      fi      fi
1954        echo "  getting package dependency info from  $PKG_DEPEND"
1955    #  Strip the comments and then convert the dependency file into arrays: PNAME, DNAME
1956        get_pdepend_list $PKG_DEPEND
1957  fi  fi
1958  echo "  getting package dependency info from  $PDEPEND"  
1959  #  Strip the comments and then convert the dependency file into  # A default package groups file "$ROOTDIR/pkg/pkg_groups" is provided
1960  #  two arrays: PNAME, DNAME  #  to define the "default_pkg_list" and package groups (for convenience, one
1961  cat $PDEPEND | sed -e 's/#.*$//g' \  #  can specify a group of packages using names like "ocean" and "atmosphere").
1962      | $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
1963      > ./.pd_tmp      tmp=$ROOTDIR"/pkg/pkg_groups"
1964  RETVAL=$?      if test -r $tmp ; then PKG_GROUPS=$tmp ; fi
1965  if test ! "x${RETVAL}" = x0 ; then  fi
1966      echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""  if test "x${PKG_GROUPS}" = x ; then
1967      exit 1          echo "Warning:  No package groups information was specified."
1968            echo "  Please check that ROOTDIR/pkg/pkg_groups exists."
1969    else
1970        if test ! -r ${PKG_GROUPS} ; then
1971            echo "Error:  can't read package groups info from PKG_GROUPS=\"$PKG_GROUPS\""
1972            exit 1
1973        fi
1974        echo "  getting package groups info from      $PKG_GROUPS"
1975  fi  fi
 . ./.pd_tmp  
 rm -f ./.pd_tmp  
1976    
1977  #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"  #  Search for packages to compile.
1978  #  file should eventually be added so that, for convenience, one can  echo "  checking list of packages to compile:"
1979  #  specify groups of packages using names like "ocean" and "atmosphere".  PKG_LIST=
1980  echo "  checking default package list:  "  if test "x${PKG_LIST}" = x ; then
 if test "x${PDEFAULT}" = x ; then  
1981      for i in "." $MODS ; do      for i in "." $MODS ; do
1982          if test -r $i"/packages.conf" ; then          if test -r $i"/packages.conf" ; then
1983                  PDEFAULT=$i"/packages.conf"                  PKG_LIST=$i"/packages.conf"
1984                  break                  break
1985          fi          fi
1986      done      done
1987  fi  fi
1988  if test "x${PDEFAULT}" = x ; then  if test "x${PKG_LIST}" = x ; then
1989      PDEFAULT="$ROOTDIR/pkg/pkg_default"      pkg_list='default_pkg_list'
1990  fi      if test "x${PKG_GROUPS}" = x ; then
1991  if test "x${PDEFAULT}" = xNONE ; then          echo "Error:  need package groups info to expand pkg_list=\"$pkg_list\""
1992      echo "    default packages file disabled"          exit 1
1993        fi
1994  else  else
1995      if test ! -r $PDEFAULT ; then      if test ! -r $PKG_LIST ; then
1996          echo "Warning:  can't read default packages from PDEFAULT=\"$PDEFAULT\""          echo "Error:  can't read package list from PKG_LIST=\"$PKG_LIST\""
1997            exit 1
1998      else      else
1999          echo "    using PDEFAULT=\"$PDEFAULT\""          echo "    using PKG_LIST=\"$PKG_LIST\""
2000          #  Strip the comments and add all the names          #  Strip the comments and add all the names
2001          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}'`
2002          RETVAL=$?          RETVAL=$?
2003          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
2004              printf "Error: can't parse default package list "              printf "Error: can't parse package list "
2005              echo "-- please check PDEFAULT=\"$PDEFAULT\""              echo "-- please check PKG_LIST=\"$PKG_LIST\""
2006              exit 1              exit 1
2007          fi          fi
         for i in $def ; do  
             PACKAGES="$PACKAGES $i"  
         done  
         echo "    before group expansion packages are: $PACKAGES"  
         RET=1  
         while test $RET = 1 ; do expand_pkg_groups; RET=$?; done  
         echo "    after group expansion packages are:  $PACKAGES"  
2008      fi      fi
2009  fi  fi
2010    for i in $pkg_list ; do
2011        PACKAGES="$PACKAGES $i"
2012    done
2013    echo     "    before group expansion packages are:$PACKAGES"
2014    if test "x${PKG_GROUPS}" != x ; then
2015        RET=1
2016        while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
2017        echo "    after group expansion packages are: $PACKAGES"
2018    fi
2019    
2020  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
2021    echo "" > ./.tmp_pack
2022  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2023      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
2024  done  done
# Line 1874  PACKAGES="$PACKAGES $ENABLE" Line 2046  PACKAGES="$PACKAGES $ENABLE"
2046  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2047      j=`echo $i | sed 's/[-+]//'`      j=`echo $i | sed 's/[-+]//'`
2048      if test ! -d "$ROOTDIR/pkg/$j" ; then      if test ! -d "$ROOTDIR/pkg/$j" ; then
2049          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
2050          exit 1          exit 1
2051      fi      fi
2052      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
# Line 1884  for i in `grep -v "-" ./.tmp_pack | sort Line 2056  for i in `grep -v "-" ./.tmp_pack | sort
2056      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
2057  done  done
2058  rm -f ./.tmp_pack  rm -f ./.tmp_pack
2059  echo "    packages are:  $PACKAGES"  echo "    packages are: $PACKAGES"
2060    
2061  #  Check availability of NetCDF and then either build the MNC template  #  Check for package MNC: if NetCDF is available, then build the MNC
2062  #  files or delete mnc from the list of available packages.  #  template files ; otherwise, delete mnc from the list of packages.
2063  echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1  echo " $PACKAGES " | grep ' mnc ' > /dev/null 2>&1
2064  RETVAL=$?  mnc_in=$?
2065  if test "x$RETVAL" = x0 ; then  if test "x$HAVE_NETCDF" != xt ; then
2066      if test "x$HAVE_NETCDF" != xt ; then      if test "x$mnc_in" = x0 ; then
2067          cat <<EOF          cat <<EOF
   
2068  *********************************************************************  *********************************************************************
2069  WARNING: the "mnc" package was enabled but tests failed to compile  WARNING: the "mnc" package was enabled but tests failed to compile
2070    NetCDF applications.  Please check that:    NetCDF applications.  Please check that:
2071    
2072    1) NetCDF is correctly installed for this compiler and    1) NetCDF is correctly installed for this compiler and
2073    2) the LIBS variable (within the "optfile") specifies the correct    2) the LIBS variable (within the "optfile") specifies the correct
2074         NetCDF library to link against.         NetCDF library to link against.
2075    
2076    Due to this failure, the "mnc" package is now DISABLED.    Due to this failure, the "mnc" package is now DISABLED.
2077  *********************************************************************  *********************************************************************
   
2078  EOF  EOF
2079          PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`          PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
2080          DISABLE="$DISABLE mnc"          DISABLE="$DISABLE mnc"
2081      else      else
2082          ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1      #  this prevent to add mnc (due to pdepend rules) if not available
2083          RETVAL=$?          DISABLE="$DISABLE mnc"
2084          if test "x${RETVAL}" = x0 ; then      fi
2085              rm -f make_mnc.errors  else
2086        # we have NetCDF, we try to build MNC template files
2087        ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
2088        RETVAL=$?
2089        if test "x${RETVAL}" = x0 ; then
2090            rm -f make_mnc.errors
2091        else
2092            echo "Error: problem encountered while building source files in pkg/mnc:"
2093            cat make_mnc.errors 1>&2
2094            if test "x$mnc_in" = x0 ; then
2095                exit 1
2096          else          else
2097              echo "Error: problem encountered while building source files in pkg/mnc:"              DISABLE="$DISABLE mnc"
             cat make_mnc.errors 1>&2  
             exit 1  
2098          fi          fi
2099      fi      fi
2100  fi  fi
2101    
2102  echo "  applying package dependency rules"  #  Check for package PROFILES: if NetCDF is not available,
2103  ck=  #  then delete profiles from the list of available packages.
2104  while test "x$ck" != xtt ; do  if test "x$HAVE_NETCDF" != xt ; then
2105        echo " $PACKAGES " | grep ' profiles ' > /dev/null 2>&1
2106        RETVAL=$?
2107        if test "x$RETVAL" = x0 ; then
2108            cat <<EOF
2109    *********************************************************************
2110    WARNING: the "profiles" package was enabled but tests failed to
2111      compile NetCDF applications.  Please check that:
2112    
2113      1) NetCDF is correctly installed for this compiler and
2114      2) the LIBS variable (within the "optfile") specifies the correct
2115           NetCDF library to link against.
2116    
2117      Due to this failure, the "profiles" package is now DISABLED.
2118    *********************************************************************
2119    EOF
2120            PACKAGES=`echo $PACKAGES | sed -e 's/profiles//g'`
2121            DISABLE="$DISABLE profiles"
2122        else
2123        #  this prevent to add profiles (due to pdepend rules) if not available
2124            DISABLE="$DISABLE profiles"
2125        fi
2126    fi
2127    
2128    if  test "x${PKG_DEPEND}" != x ; then
2129      echo "  applying package dependency rules"
2130      ck=
2131      while test "x$ck" != xtt ; do
2132      i=0      i=0
2133      # rtot=${#PNAME[@]}      # rtot=${#PNAME[@]}
2134      rtot=$nname      rtot=$nname
2135      while test $i -lt $rtot ; do      while test $i -le $rtot ; do
2136    
2137          #  Is $pname in the current $PACKAGES list?          #  Is $pname in the current $PACKAGES list?
2138          #  pname=${PNAME[$i]}          #  pname=${PNAME[$i]}
# Line 1939  while test "x$ck" != xtt ; do Line 2144  while test "x$ck" != xtt ; do
2144                  pin="t"                  pin="t"
2145              fi              fi
2146          done          done
2147            #  or in the current $STANDARDDIRS list?
2148            for p in $STANDARDDIRS ; do
2149                if test "x$p" = "x$pname" ; then pin="t" ; fi
2150            done
2151    
2152          #  Is the DNAME entry a (+) or (-) rule ?          #  Is the DNAME entry a (+) or (-) rule ?
2153          tmp="dname=\"\$DNAME_$i\""          tmp="dname=\"\$DNAME_$i\""
# Line 1961  while test "x$ck" != xtt ; do Line 2170  while test "x$ck" != xtt ; do
2170    
2171          #  Do we need to add $dname according to the dependency rules?          #  Do we need to add $dname according to the dependency rules?
2172          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
2173                #echo "   " $pname ": need to add :" $dname
2174              in_dis="f"              in_dis="f"
2175              for dis in $DISABLE ; do              for dis in $DISABLE ; do
2176                  if test "x$dis" = "x$dname" ; then                  if test "x$dis" = "x$dname" ; then
# Line 1981  while test "x$ck" != xtt ; do Line 2191  while test "x$ck" != xtt ; do
2191          #  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?
2192          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
2193              echo "Error: can't satisfy package dependencies:"              echo "Error: can't satisfy package dependencies:"
2194              echo "  \"$pname\" was requested but is disallowed by"              echo "  \"$pname\" was requested but is disallowed by"
2195              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
2196              exit 1              exit 1
2197          fi          fi
# Line 1989  while test "x$ck" != xtt ; do Line 2199  while test "x$ck" != xtt ; do
2199          #i=$(( $i + 1 ))          #i=$(( $i + 1 ))
2200      done      done
2201      ck=$ck"t"      ck=$ck"t"
2202  done    done
2203  echo "    packages are:  $PACKAGES"    echo "    packages are: $PACKAGES"
2204    fi
2205  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2206      adr="$ROOTDIR/pkg/$i"      adr="$ROOTDIR/pkg/$i"
2207      if test -d $adr ; then      if test -d $adr ; then
# Line 2007  done Line 2218  done
2218    
2219  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
2220  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
2221  #  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
2222  #  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
2223  #  file would eventually be split up so that all package-related #define  #  file would eventually be split up so that all package-related #define
2224  #  statements could be separated and handled only by genmake.  #  statements could be separated and handled only by genmake.
2225  names=`ls -1 "$ROOTDIR/pkg"`  names=`ls -1 "$ROOTDIR/pkg"`
# Line 2036  for i in $PACKAGES ; do Line 2247  for i in $PACKAGES ; do
2247  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
2248    
2249  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
2250      case $i in      case $i in
2251          aim_v23)          aim_v23)
2252              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
2253              echo "Warning: ALLOW_AIM is set to enable aim_v23."              echo "Warning: ALLOW_AIM is set to enable aim_v23."
# Line 2046  for i in $PACKAGES ; do Line 2257  for i in $PACKAGES ; do
2257    
2258  done  done
2259    
2260  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS='$STANDARDDIRS'"
2261  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
 if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then  
     STANDARDDIRS="eesupp model"  
 fi  
2262  if test "x$STANDARDDIRS" != x ; then  if test "x$STANDARDDIRS" != x ; then
2263      for d in $STANDARDDIRS ; do      for d in $STANDARDDIRS ; do
2264          adr="$ROOTDIR/$d/src"          adr="$ROOTDIR/$d/src"
# Line 2105  fi Line 2313  fi
2313    
2314  #  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
2315  #  compiler.  #  compiler.
2316  if test -f ./ad_files ; then  if test -f ./adSrcFiles.tmp ; then
2317      rm -f ./ad_files      rm -f ./adSrcFiles.tmp
2318  fi  fi
2319  echo "  Creating the list of files for the adjoint compiler."  echo "  Creating the list of files for the adjoint compiler."
2320    touch adSrcFiles.tmp
2321  for i in $SOURCEDIRS ; do  for i in $SOURCEDIRS ; do
2322      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2323      for j in $list_files ; do      for j in $list_files ; do
2324          cat $i/$j >> ad_files          cat $i/$j >> adSrcFiles.tmp
2325      done      done
2326  done  done
2327  if test ! "x"$FS = "x.f" ; then  if test ! "x"$FS = "x.f" ; then
2328      cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f      cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f
2329      mv -f ad_files_f ad_files      mv -f adSrcFiles.tmp_f adSrcFiles.tmp
2330  fi  fi
2331    
2332  echo  echo
# Line 2141  if test ! "x$DIVA" = x ; then Line 2350  if test ! "x$DIVA" = x ; then
2350          fi          fi
2351          MPIINCLUDEDIR='$MPIHOME/include'          MPIINCLUDEDIR='$MPIHOME/include'
2352      fi      fi
2353        
2354      if test -r $MPIINCLUDEDIR/mpif.h ; then      if test -r $MPIINCLUDEDIR/mpif.h ; then
2355          for i in $MPI_HEADER_FILES; do          for i in $MPI_HEADER_FILES; do
2356              cp -p $MPIINCLUDEDIR/$i ./mpi_headers              cp -p $MPIINCLUDEDIR/$i ./mpi_headers
# Line 2150  if test ! "x$DIVA" = x ; then Line 2359  if test ! "x$DIVA" = x ; then
2359          perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h          perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h
2360      else      else
2361          echo " We cannot create a copy of mpif.h!"          echo " We cannot create a copy of mpif.h!"
2362          exit -1  #       exit -1
2363      fi      fi
2364  fi  fi
2365    
# Line 2175  if test ! -r ".links.tmp/foo" ; then Line 2384  if test ! -r ".links.tmp/foo" ; then
2384      exit 1      exit 1
2385  fi  fi
2386  rm -f .links.tmp/foo  rm -f .links.tmp/foo
2387    
2388    if test "x$OPENAD" != x ; then
2389        OAD_DONT_COMPILE="/dev/null"
2390        OAD_DONT_TRANSFORM="/dev/null"
2391        OAD_KEEP_ORIGINAL="/dev/null"
2392        OAD_CB2M_FILES="/dev/null"
2393        echo "  looking for dontCompile file:  "
2394        for i in "." $MODS ; do
2395            if test -r $i"/dontCompile" ; then
2396                OAD_DONT_COMPILE=$i"/dontCompile"
2397                echo "     found $OAD_DONT_COMPILE"
2398                break
2399            fi
2400        done
2401        echo "  looking for dontTransform file:  "
2402        for i in "." $MODS ; do
2403            if test -r $i"/dontTransform" ; then
2404                OAD_DONT_TRANSFORM=$i"/dontTransform"
2405                echo "     found $OAD_DONT_TRANSFORM"
2406                break
2407            fi
2408        done
2409        echo "  looking for keepOriginal file:  "
2410        for i in "." $MODS ; do
2411            if test -r $i"/keepOriginal" ; then
2412                OAD_KEEP_ORIGINAL=$i"/keepOriginal"
2413                echo "     found $OAD_KEEP_ORIGINAL"
2414                break
2415            fi
2416        done
2417        echo "  looking for cb2mFiles:  "
2418        for i in "." $MODS ; do
2419            if test -r $i"/cb2mFiles" ; then
2420                OAD_CB2M_FILES=$i"/cb2mFiles"
2421                echo "     found $OAD_CB2M_FILES"
2422                break
2423            fi
2424        done
2425        echo "   OpenAD exceptions:  "
2426    fi
2427    
2428  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
2429  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
2430  printf 'SRCFILES = '    > srclist.inc  printf 'F77_SRC_FILES = ' > F77srclist.tmp
2431  printf 'CSRCFILES = '   > csrclist.inc  printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp
2432  printf 'F90SRCFILES = ' > f90srclist.inc  printf 'C_SRC_FILES = '   > csrclist.tmp
2433  printf 'HEADERFILES = ' > hlist.inc  printf 'F90_SRC_FILES = ' > F90srclist.tmp
2434  printf 'AD_FLOW_FILES = ' > ad_flow_files.inc  printf 'H_SRC_FILES = '   > hsrclist.tmp
2435    printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp
2436  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2437  for d in $alldirs ; do  for d in $alldirs ; do
2438      deplist=      deplist=
2439      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
2440      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
2441        if test "x$OPENAD" != x ; then
2442            sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2443        fi
2444      for sf in $sfiles ; do      for sf in $sfiles ; do
2445          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
2446              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
# Line 2221  for d in $alldirs ; do Line 2475  for d in $alldirs ; do
2475                  if test "x$ignore_f" = xf ; then                  if test "x$ignore_f" = xf ; then
2476                      extn=`echo $sf | $AWK -F. '{print $NF}'`                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2477                      case $extn in                      case $extn in
2478                          F)                        F)
2479                              echo    " \\"  >> srclist.inc                          echo    " \\"  >> F77srclist.tmp
2480                              printf " $sf" >> srclist.inc                          printf " $sf" >> F77srclist.tmp
2481                              ;;                          if test "x$OPENAD" != x ; then
2482                          F90)                              basename=${sf%%.F}
2483                              echo    " \\"  >> f90srclist.inc                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`
2484                              printf " $sf" >> f90srclist.inc                              if test -z "$isAD" ; then
2485                              ;;                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`
2486                          c)                                  if test -z "$toBeIgnored" ; then
2487                              echo    " \\"  >> csrclist.inc                                      echo    " \\"  >> nonADF77srclist.tmp
2488                              printf " $sf" >> csrclist.inc                                      printf " $sf" >> nonADF77srclist.tmp
2489                              ;;                                  else
2490                          h)                                      echo "    not to be compiled   :  $sf"
2491                              echo    " \\"  >> hlist.inc                                  fi
2492                              printf " $sf" >> hlist.inc                              else # file is initially listed as an AD file we want to exclude it
2493                              ;;                                   # or we want to retain the untransformed version
2494                          flow)                                  notToBeTransformed=`egrep ^$basename'[      ]*' ${OAD_DONT_TRANSFORM}`
2495                              echo    " \\"  >> ad_flow_files.inc                                  untransformedVersionToBeKept=`egrep ^$basename'[      ]*' ${OAD_KEEP_ORIGINAL}`
2496                              printf " $sf" >> ad_flow_files.inc                                  if test -n "$notToBeTransformed"; then
2497                              ;;                                      echo "    not to be transformed:  $sf"
2498                      esac                                  fi
2499                  fi                                  if test -n "$untransformedVersionToBeKept" ; then
2500                                        echo "    original to be kept  :  $sf"
2501                                    fi
2502                                    if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2503                                        echo    " \\"  >> nonADF77srclist.tmp
2504                                        printf " $sf" >> nonADF77srclist.tmp
2505                                    fi
2506                                fi
2507                            fi
2508                            ;;
2509                        F90)
2510                            echo    " \\"  >> F90srclist.tmp
2511                            printf " $sf" >> F90srclist.tmp
2512                            ;;
2513                        c)
2514                            echo    " \\"  >> csrclist.tmp
2515                            printf " $sf" >> csrclist.tmp
2516                            ;;
2517                        h)
2518                            echo    " \\"  >> hsrclist.tmp
2519                            printf " $sf" >> hsrclist.tmp
2520                            ;;
2521                        flow)
2522                            echo    " \\"  >> ad_flow_files.tmp
2523                            printf " $sf" >> ad_flow_files.tmp
2524                            ;;
2525                       esac
2526                    fi
2527              fi              fi
2528          fi          fi
2529      done      done
2530      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2531          echo "" >> srclinks.tmp        if test "$d" != "." ; then
2532            echo "" >> srclinks.tmp
2533          echo "#  These files are linked from $d" >> srclinks.tmp          echo "#  These files are linked from $d" >> srclinks.tmp
2534          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> srclinks.tmp
2535          printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp  # We need to make sure that the link isn't already there.
2536    # This may happen when make thinks that a header file has to be "remade"
2537    # because a module it depends on has changed.  In this case we do nothing.
2538            printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp
2539          fi
2540      fi      fi
2541  done  done
2542  rm -rf .links.tmp  rm -rf .links.tmp
2543  echo "" >> srclist.inc  echo "" >> F77srclist.tmp
2544  echo "" >> csrclist.inc  echo "" >> nonADF77srclist.tmp
2545  echo "" >> f90srclist.inc  echo "" >> csrclist.tmp
2546  echo "" >> hlist.inc  echo "" >> F90srclist.tmp
2547  echo "" >> ad_flow_files.inc  echo "" >> hsrclist.tmp
2548    echo "" >> ad_flow_files.tmp
2549    
2550    CMDLINE=$0
2551    for xx in "$@" ; do nw=`echo $xx | wc -w`
2552        if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
2553                            else CMDLINE="$CMDLINE '$xx'" ; fi
2554    done
2555    
2556  if test -f $MAKEFILE ; then  if test -f $MAKEFILE ; then
2557      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.old"
2558  fi  fi
2559  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
2560  echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE  echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE
# Line 2269  echo "#    $MACHINE" >> $MAKEFILE Line 2562  echo "#    $MACHINE" >> $MAKEFILE
2562  echo "# This makefile was generated automatically on" >> $MAKEFILE  echo "# This makefile was generated automatically on" >> $MAKEFILE
2563  echo "#    $THISDATE" >> $MAKEFILE  echo "#    $THISDATE" >> $MAKEFILE
2564  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2565  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $CMDLINE"  >> $MAKEFILE
2566  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2567  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2568    
# Line 2280  EXE_SVD=$EXECUTABLE"_svd" Line 2573  EXE_SVD=$EXECUTABLE"_svd"
2573  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2574  #  #
2575  # OPTFILE="$OPTFILE"  # OPTFILE="$OPTFILE"
2576  #  #
2577  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
2578  # SOURCEDIRS   : Directories containing the source (.F) files  # SOURCEDIRS   : Directories containing the source (.F) files
2579  # INCLUDEDIRS  : Directories containing the header-source (.h) files  # INCLUDEDIRS  : Directories containing the header-source (.h) files
# Line 2300  cat >>$MAKEFILE <<EOF Line 2593  cat >>$MAKEFILE <<EOF
2593  # LIBS         : Library flags /or/ additional optimization/debugging flags  # LIBS         : Library flags /or/ additional optimization/debugging flags
2594    
2595  ROOTDIR     = ${ROOTDIR}  ROOTDIR     = ${ROOTDIR}
2596  BUILDDIR    = ${BUILDDIR}    BUILDDIR    = ${BUILDDIR}
2597  SOURCEDIRS  = ${SOURCEDIRS}  SOURCEDIRS  = ${SOURCEDIRS}
2598  INCLUDEDIRS = ${INCLUDEDIRS}  INCLUDEDIRS = ${INCLUDEDIRS}
2599  EXEDIR      = ${EXEDIR}  EXEDIR      = ${EXEDIR}
# Line 2326  else Line 2619  else
2619      echo "EMBEDDED_FILES = " >>$MAKEFILE      echo "EMBEDDED_FILES = " >>$MAKEFILE
2620  fi  fi
2621    
 #  Note: figure out some way to add Hyades JAM libraries here  
2622  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2623  # Unix ln (link)  # Unix ln (link)
2624  LN = ${LN}  LN = ${LN}
# Line 2353  INCLUDES = ${INCLUDES} Line 2645  INCLUDES = ${INCLUDES}
2645  KFLAGS1 = ${KFLAGS1}  KFLAGS1 = ${KFLAGS1}
2646  KFLAGS2 = ${KFLAGS2}  KFLAGS2 = ${KFLAGS2}
2647  # Optim./debug for FC  # Optim./debug for FC
2648  FFLAGS = ${FFLAGS}  FFLAGS = ${FFLAGS} ${FEXTRAFLAGS}
2649  FOPTIM = ${FOPTIM}  FOPTIM = ${FOPTIM}
2650  # Optim./debug for FC  # Optim./debug for FC
2651  F90FLAGS = ${F90FLAGS}  F90FLAGS = ${F90FLAGS}
2652  F90OPTIM = ${F90OPTIM}  F90OPTIM = ${F90OPTIM}
2653    F90FIXEDFORMAT = ${F90FIXEDFORMAT}
2654  # Flags for CC  # Flags for CC
2655  CFLAGS = ${CFLAGS}  CFLAGS = ${CFLAGS}
2656  # Files that should not be optimized  # Files that should not be optimized
# Line 2370  MAKEFILE=${MAKEFILE} Line 2663  MAKEFILE=${MAKEFILE}
2663    
2664  EOF  EOF
2665    
2666  cat srclist.inc       >> $MAKEFILE  cat F77srclist.tmp      >> $MAKEFILE
2667  cat csrclist.inc      >> $MAKEFILE  cat nonADF77srclist.tmp >> $MAKEFILE
2668  cat f90srclist.inc    >> $MAKEFILE  cat csrclist.tmp        >> $MAKEFILE
2669  cat hlist.inc         >> $MAKEFILE  cat F90srclist.tmp      >> $MAKEFILE
2670  cat ad_flow_files.inc >> $MAKEFILE  cat hsrclist.tmp        >> $MAKEFILE
2671    cat ad_flow_files.tmp   >> $MAKEFILE
2672    
2673    rm -f F77srclist.tmp nonADF77srclist.tmp csrclist.tmp F90srclist.tmp hsrclist.tmp ad_flow_files.tmp
2674    
2675  echo >> $MAKEFILE  echo >> $MAKEFILE
2676  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE  
2677  echo 'F90FILES =  $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE  # add definitions for preprocessed sources
2678  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  # and note that not all systems allow case sensitive extensions
2679    # hence the $FS and $FS90 here.
2680    # for fixed format f90 files we use ff90 or FF90 resp
2681    # but these are not expected to be the original source files
2682    
2683    echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE
2684    echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE
2685    echo 'OBJFILES= $(F77_SRC_FILES:.F=.o) $(C_SRC_FILES:.c=.o) $(F90_SRC_FILES:.F90=.o)' >> $MAKEFILE
2686    echo 'FLOFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE
2687  echo >> $MAKEFILE  echo >> $MAKEFILE
2688  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
2689  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  
2690    
2691  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2692    
2693  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
2694  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES) \$(EMBEDDED_FILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(EMBEDDED_FILES)
2695          @echo Creating \$@ ...          @echo Creating \$@ ...
2696          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2697  depend:  depend:
2698          @make links          @make links
2699          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
2700          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2701          -rm -f makedepend.out          -rm -f makedepend.out
2702    
# Line 2401  lib: libmitgcmuv.a Line 2704  lib: libmitgcmuv.a
2704    
2705  libmitgcmuv.a: \$(OBJFILES)  libmitgcmuv.a: \$(OBJFILES)
2706          ar rcv libmitgcmuv.a \$(OBJFILES)          ar rcv libmitgcmuv.a \$(OBJFILES)
2707            ar d   libmitgcmuv.a main.o
2708    
2709  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  links: \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(SPECIAL_FILES)
2710    
2711  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
2712    
2713  output.txt: \$(EXECUTABLE)  output.txt: \$(EXECUTABLE)
2714          @printf 'running ... '          @printf 'running ... '
2715          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
2716    
2717    # remove most of the files that "make" generates
2718  clean:  clean:
2719          -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2720            -rm -rf *.o
2721            -rm -rf *.$FS *.flowdir
2722            -rm -rf *.f$FS90 \$(AD_CLEAN) ad_input*
2723    
2724    # remove most of the files that "make" and "make depend" generate
2725  Clean:  Clean:
2726          @make clean          @make clean
2727          @make cleanlinks          @make cleanlinks
2728          -rm -f \$(SPECIAL_FILES)          -rm -f \$(SPECIAL_FILES) f90mkdepend.log
2729          -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
2730            -rm -f genmake_warnings genmake_errors make.log
2731    
2732    # remove also the executable, files that "genmake2" generates (except Makefile)
2733    #         and output from a run (plus log files from testreport)
2734  CLEAN:  CLEAN:
2735          @make Clean          @make Clean
2736            -rm -f \$(EXECUTABLE) \$(EXE_AD) *.bak $MAKEFILE.old
2737            -rm -f $LOGFILE genmake_state genmake_*optfile genmake.tr_log make.tr_log
2738          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2739          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2740          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2741          -rm -f \$(EXECUTABLE) output.txt STD*          -rm -f *.txt STD* *diagnostics.log datetime
2742            -rm -f *_MIT_CE_000.opt0000 costfunction*0000
2743            -rm -rf mnc_test_*
2744    
 #eh3 Makefile: makefile  
2745  makefile:  makefile:
2746          $THIS_SCRIPT $G2ARGS          $THIS_SCRIPT $G2ARGS
2747  cleanlinks:  cleanlinks:
2748          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2749    
2750  # Special targets (SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are created by make
2751  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2752          @echo Creating \$@ ...          @echo Creating \$@ ...
2753          @$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 2455  if test "x$EMBED_SRC" = xt ; then Line 2772  if test "x$EMBED_SRC" = xt ; then
2772    
2773  decode_files.o : EMBEDDED_FILES.h  decode_files.o : EMBEDDED_FILES.h
2774    
2775  ##  \$(F77FILES)  ##  \$(F77_PP_SRC_FILES)
2776  all_fF.tar.gz : \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(F77FILES) Makefile  all_fF.tar.gz : \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2777          @echo Creating \$@ ...          @echo Creating \$@ ...
2778          -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(F77FILES) Makefile          -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2779          -rm -f all_fF.tar.gz          -rm -f all_fF.tar.gz
2780          -gzip all_fF.tar          -gzip all_fF.tar
2781    
# Line 2482  cat >>$MAKEFILE <<EOF Line 2799  cat >>$MAKEFILE <<EOF
2799          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2800  .F90.$FS90:  .F90.$FS90:
2801          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2802    .FF90.f$FS90:
2803            \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2804  .$FS90.o:  .$FS90.o:
2805          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2806    .f$FS90.o:
2807            cp \$< \$(basename  \$<).f90
2808            \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$(F90FIXEDFORMAT) \$(basename  \$<).f90
2809  .c.o:  .c.o:
2810          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
2811    .flow.flowdir:
2812            \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2813    
2814  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2815  .F.p:  .F.p:
# Line 2493  cat >>$MAKEFILE <<EOF Line 2817  cat >>$MAKEFILE <<EOF
2817  .p.$FS:  .p.$FS:
2818          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
2819    
2820    EOF
2821    
2822  #=========================================  #=========================================
2823  #===  Automatic Differentiation Rules  ===  #===  Automatic Differentiation Rules  ===
2824    #===  for TAMC/TAF  ======================
2825    
2826    if test "x$OPENAD" = x ; then
2827    
2828    cat >>$MAKEFILE <<EOF
2829    
2830  TAMC           = ${TAMC}  TAMC           = ${TAMC}
2831  TAF            = ${TAF}  TAF            = ${TAF}
# Line 2509  ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF Line 2840  ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF
2840  ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"  ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
2841  for i in $ad_vars ; do  for i in $ad_vars ; do
2842      name=$i      name=$i
2843      t1="t2=\$"`echo $i`      t1="t2=\$"`echo "$i"`
2844      eval $t1      eval $t1
2845      printf "%-20s = " $name >> $MAKEFILE      printf "%-20s = " $name >> $MAKEFILE
2846      echo $t2 >> $MAKEFILE      echo "$t2" | sed -e 's| \+| |g' >> $MAKEFILE
2847  done  done
2848    
2849  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
2850  echo >> $MAKEFILE  echo >> $MAKEFILE
2851  printf "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
2852  AD_FILES=`cat ad_files`  AD_FILES=`cat adSrcFiles.tmp`
2853  for i in $AD_FILES ; do  for i in $AD_FILES ; do
2854      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
2855      printf " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
2856  done  done
2857  echo >> $MAKEFILE  echo >> $MAKEFILE
2858  rm -f ad_files  rm -f adSrcFiles.tmp
2859    
2860  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2861    
2862  # ... AD ...  # ... AD ...
2863  adall: ad_taf  adall: \$(EXE_AD)
2864  adtaf: ad_taf_output.$FS  adtaf: ad_taf_output.$FS
2865  adtamc: ad_tamc_output.$FS  adtamc: ad_tamc_output.$FS
2866    
2867  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES)
2868          @$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
2869          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
2870          -rm -f ad_config.template          -rm -f ad_config.template
2871          @make \$(F77FILES)          @make \$(F77_PP_SRC_FILES)
2872          @make \$(AD_FLOW_FILES)          @make \$(FLOFILES)
2873          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS          cat \$(FLOFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS
2874    
2875  ad_taf_output.$FS: ad_input_code.$FS  ad_taf_output.$FS: ad_input_code.$FS
2876          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2877            ls -l ad_input_code_ad.$FS
2878          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2879    
2880  adtafonly:  adtafonly:
2881          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2882            ls -l ad_input_code_ad.$FS
2883          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2884    
2885  ad_taf: ad_taf_output.o \$(OBJFILES)  \${EXE_AD}: ad_taf_output.o \$(OBJFILES)
2886          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2887    
2888  ad_tamc_output.$FS: ad_input_code.$FS  ad_tamc_output.$FS: ad_input_code.$FS
2889          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2890          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
2891    
2892  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2893          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2894    
2895  adonlyfwd:  adonlyfwd:
2896          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2897    
2898  adtrick:  adtrick:
2899          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2900    
# Line 2570  ftlall: ftl_taf Line 2903  ftlall: ftl_taf
2903  ftltaf: ftl_taf_output.$FS  ftltaf: ftl_taf_output.$FS
2904  ftltamc: ftl_tamc_output.$FS  ftltamc: ftl_tamc_output.$FS
2905    
2906  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)
2907          @$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
2908          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
2909          -rm -f ftl_config.template          -rm -f ftl_config.template
2910          @make \$(F77FILES)          @make \$(F77_PP_SRC_FILES)
2911          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2912          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2913    
2914  ftl_taf_output.$FS: ftl_input_code.$FS  ftl_taf_output.$FS: ftl_input_code.$FS
2915          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2916            ls -l ftl_input_code_ftl.$FS
2917          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2918    
2919  ftltafonly:  ftltafonly:
2920          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2921            ls -l ftl_input_code_ftl.$FS
2922          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2923    
2924  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
2925          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2926    
2927  ftl_tamc_output.$FS: ftl_input_code.$FS  ftl_tamc_output.$FS: ftl_input_code.$FS
2928          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2929          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS
2930    
2931  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2932          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2933    
2934    
2935  # ... SVD ...  # ... SVD ...
# Line 2621  svd_touch: Line 2956  svd_touch:
2956          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
2957          -rm -f ftl_config.template          -rm -f ftl_config.template
2958    
2959  #=========================================  EOF
2960    
2961    fi
2962    
2963    #===  for OpenAD  ========================
2964    
2965    if test "x$OPENAD" != x ; then
2966    
2967    # ============ begin OpenAD specific section ==============
2968    
2969    cat >>$MAKEFILE <<EOF
2970    
2971    # all the source files linked from the various locations:
2972    ALL_LINKED_FILES= \
2973    \$(F77_SRC_FILES) \
2974    \$(C_SRC_FILES) \
2975    \$(H_SRC_FILES) \
2976    \$(F90_SRC_FILES) \
2977    \$(SPECIAL_FILES)
2978    
2979    ifndef OPENADROOT
2980      \$(error "Error:  environment variable OPENADROOT not defined!")
2981    endif
2982    
2983    ifndef XAIFSCHEMAROOT
2984      \$(error "Error:  environment variable XAIFSCHEMAROOT not defined!")
2985    endif
2986    
2987    ifndef XAIFBOOSTERROOT
2988      \$(error "Error:  environment variable XAIFBOOSTERROOT not defined!")
2989    endif
2990    
2991    EOF
2992    
2993    echo "  Add the source list for common block to module conversion "
2994    echo >> $MAKEFILE
2995    printf "CB2M_F90_SRC_NAMES = " >> $MAKEFILE
2996    for i in `cat ${OAD_CB2M_FILES}` ; do
2997      echo    " \\" >> $MAKEFILE
2998      printf " $i" >> $MAKEFILE
2999    done
3000    echo >> $MAKEFILE
3001    
3002    echo "  Add the source list for AD code generation"
3003    echo >> $MAKEFILE
3004    printf "AD_FILES = " >> $MAKEFILE
3005    for i in `cat ${OAD_CB2M_FILES}` ; do
3006      echo    " \\" >> $MAKEFILE
3007      printf " ${i}_mod.f$FS90" >> $MAKEFILE
3008    done
3009    AD_FILES=`cat adSrcFiles.tmp`
3010    for i in $AD_FILES ; do
3011      basename=${i%%.f}
3012      toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`
3013      if test -z "$toBeIgnored" ; then
3014        echo    " \\" >> $MAKEFILE
3015        printf " $i" >> $MAKEFILE
3016      fi
3017    done
3018    echo >> $MAKEFILE
3019    rm -f adSrcFiles.tmp
3020    
3021    cat >>$MAKEFILE <<EOF
3022    
3023    adAll: \$(EXE_AD)
3024    .PHONY: adAll
3025    
3026    CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))
3027    
3028    .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90)
3029    
3030    .PHONY: adDepend
3031    adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90)
3032            \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
3033            \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
3034            -rm -f makedepend.out
3035    
3036    OPENAD_SUPPORT_F90_SRC_FILES = \
3037    w2f__types.F90 \
3038    OAD_active.F90 \
3039    OAD_cp.F90 \
3040    OAD_rev.F90 \
3041    OAD_tape.F90
3042    
3043    OPENAD_SUPPORT_C_SRC_FILES = \
3044    iaddr.c \
3045    timeRatio.c
3046    
3047    f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)
3048            cat \$^ > \$@
3049    
3050    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
3051            cat \$^ > \$@
3052    
3053    f95_test.out: f95_test_mods.f90 f95_test.f90
3054            f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1
3055            f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1
3056    
3057    # the file included below is created by the
3058    # postProcessor and its inclusion sets the
3059    # variable POSTPROCESSEDFILES
3060    # used below. Because the file is made during
3061    # make it won't be read until the second (recursive)
3062    # invocation in the rule below
3063    -include postProcess.make
3064    
3065    AD_OBJ_FILES_S1=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) \$(POSTPROCESSEDFILES:.f$FS90=.o)
3066    
3067    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)
3068    
3069    postProcess.comp: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.tag \$(AD_OBJ_FILES_S1)
3070    ifeq (\$(MAKELEVEL),0)
3071            \$(MAKE) adAll
3072    else
3073            touch \$@
3074    endif
3075    
3076    \$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.comp \$(AD_OBJ_FILES_S2)
3077    ifeq (\$(MAKELEVEL),1)
3078            \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)
3079    else
3080            touch \$@
3081    endif
3082    
3083    # makefile debug rule
3084    openad: ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
3085    .PHONY: openad
3086    
3087    # create the module files
3088    %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk
3089            ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk
3090    
3091    # create the header files
3092    %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk
3093            ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
3094    
3095    # change everybody else to use the new module files:
3096    %_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash
3097            ../OAD_support/cb2mUseModules.bash $< ${MPI}
3098    
3099    # makefile debug rule
3100    small_f: \$(CB2M_F90_PP_SRC_FILES)
3101    .PHONY: small_f
3102    
3103    ad_output.txt: \$(EXE_AD)
3104            @printf 'linking data files ... '
3105            \$(LN) -f ../input_ad/data* ../input_ad/eedata .
3106            \$(LN) -f ../../global_ocean.90x40x15/input/*.bin .
3107            @printf 'running ... '
3108            @./\$(EXE_AD) > \$@
3109    
3110    CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)
3111    ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3112            cat \$^ > \$@
3113    
3114    # strip all comments and blanks to reduce
3115    # the file size in order to reduce perl's memory requirements
3116    ad_input_code_sf.f$FS90 : ad_input_code.f$FS90
3117            cat \$^ | sed -f ../OAD_support/strip.sed | sed -f ../OAD_support/stop2print.sed > \$@
3118    
3119    # mfef90 preprocessing
3120    # expand statement functions
3121    # expose mfef90 specific substring handling
3122    # add the w2f__types module
3123    ad_input_code_sf.w2f.f$FS90: ad_input_code_sf.f$FS90 mfef90 whirl2f whirl2f_be w2f__types.f90
3124            ./mfef90 -r8 -z -F -N132 \$<
3125            mv \$<.B \$(basename \$<).B
3126            ./whirl2f -openad \$(basename \$<).B
3127            cat w2f__types.f90 \$(basename \$<).w2f.f > \$@
3128    
3129    # canonicalizer
3130    ad_input_code_sf.w2f.pre.f$FS90: ad_input_code_sf.w2f.f$FS90 preProcess.py
3131            ./preProcess.py --timing --r8 -H -S \$< -o \$@
3132    
3133    # F -> WHIRL
3134    # note that the canonicalized version cuts off at col 72
3135    # doing this also for string constants which is ok as long
3136    # as we are in fixed mode and cut of exactly there.
3137    # Otherwise mfef90 patches in spaces to fill up to 72 (or 132)
3138    # characters respectively.
3139    ad_input_code_sf.w2f.pre.B: ad_input_code_sf.w2f.pre.f$FS90 mfef90
3140            ./mfef90 -r8 -z -F \$<
3141            mv \$<.B \$@
3142    
3143    # WHIRL -> XAIF
3144    ad_input_code_sf.w2f.pre.xaif : ad_input_code_sf.w2f.pre.B whirl2xaif
3145            ./whirl2xaif -s -n --debug 1 -o \$@ \$<
3146    
3147    # XAIF -> XAIF'
3148    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
3149            ./oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r
3150    
3151    # XAIF' -> WHIRL'
3152    ad_input_code_sf.w2f.pre.xb.x2w.B : ad_input_code_sf.w2f.pre.xb.xaif xaif2whirl
3153            ./xaif2whirl --debug 1 ad_input_code_sf.w2f.pre.B \$<
3154    
3155    # WHIRL' -> F'
3156    ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.B whirl2f whirl2f_be
3157            ./whirl2f -FLIST:ftn_file=\$@ -openad \$<
3158    
3159    # insert template directives
3160    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
3161            ../OAD_support/insertTemplateDir.bash \$< \$@
3162    
3163    PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F
3164    # postprocess F'
3165    postProcess.tag: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 postProcess.py \$(PPEXTRAS:.F=.f)
3166            # the target is a placeholder to signal execution of the rule
3167            touch \$@
3168            # this step also creates the file postProcess.make but we cannot
3169            # name it as the target or else make will try to remake it for
3170            # the include directive above for any rule, e.g. make clean
3171            ./postProcess.py --progress --timing --outputFormat=fixed -m r -i ../OAD_support/ad_inline.f --width 4 \$<
3172    
3173    # setup some links
3174    %.xsd:
3175            \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3176    
3177    mfef90:
3178            \$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 .
3179    
3180    # link the support files:
3181    \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):
3182            \$(LN) ../OAD_support/\$@ .
3183    
3184    whirl2xaif xaif2whirl:
3185            \$(LN) \${OPENADFORTTK}/bin/\$@ .
3186    
3187    preProcess.py postProcess.py:
3188            \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ .
3189    
3190    whirl2f whirl2f_be:
3191            \$(LN) \${OPEN64ROOT}/whirl2f/\$@ .
3192    
3193    oadDriver:
3194            \$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver \$@
3195    
3196    AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.make postProcess.tag postProcess.comp \$(PPEXTRAS:.F=.f)
3197    
3198    # ============ end OpenAD specific section ==============
3199    
3200  EOF  EOF
3201    
3202    fi
3203    
3204    #=========================================
3205    
3206  if test "x$EXEHOOK" != x ; then  if test "x$EXEHOOK" != x ; then
3207      printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE      printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
3208  fi  fi
# Line 2660  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 3238  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
3238  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
3239    
3240  # Create special header files  # Create special header files
3241  $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"
3242  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
3243      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
3244  else  else
# Line 2679  fi Line 3257  fi
3257    
3258    
3259  #  Write the "state" for future records  #  Write the "state" for future records
3260  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" = xt ; then
3261      printf "" > genmake_state      printf "" > genmake_state
3262      for i in $gm_state ; do      for i in $gm_state ; do
3263          t1="t2=\$$i"          t1="t2=\$$i"

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

  ViewVC Help
Powered by ViewVC 1.1.22