/[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.198 by mlosch, Fri Oct 9 11:13:27 2009 UTC revision 1.213 by jmc, Fri Nov 5 16:28:59 2010 UTC
# Line 56  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 67  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 110  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 146  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 194  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 212  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 269  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 291  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 icc"  
     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 354  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
# Line 416  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 442  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 461  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 480  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 508  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 535  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
# Line 617  Usage: "$0" [OPTIONS] Line 625  Usage: "$0" [OPTIONS]
625            Activate OpenMP code + use Compiler option OMPFLAG            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 635  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 649  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 671  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 685  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 701  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 731  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 752  void FC_NAMEMANGLE(cloc) ( double *curti Line 767  void FC_NAMEMANGLE(cloc) ( double *curti
767  }  }
768  EOF  EOF
769      COMM="$CC $CFLAGS -c genmake_tc_1.c"      COMM="$CC $CFLAGS -c genmake_tc_1.c"
770      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
771      $COMM >> genmake_warnings 2>&1      $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 764  EOF Line 779  EOF
779        end        end
780  EOF  EOF
781      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"
782      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
783      $COMM >> genmake_warnings 2>&1      $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    
# Line 781  check_HAVE_SIGREG()  { Line 797  check_HAVE_SIGREG()  {
797      if test ! "x$HAVE_SIGREG" = x ; then      if test ! "x$HAVE_SIGREG" = x ; then
798          return          return
799      fi      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 813  void FC_NAMEMANGLE(sigreg) (int * aip) Line 831  void FC_NAMEMANGLE(sigreg) (int * aip)
831  }  }
832  EOF  EOF
833      COMM="$CC $CFLAGS -c genmake_tc_1.c"      COMM="$CC $CFLAGS -c genmake_tc_1.c"
834      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
835      $COMM >> genmake_warnings 2>&1      $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 824  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    
# Line 847  check_HAVE_SETRLSTK()  { Line 864  check_HAVE_SETRLSTK()  {
864      if test ! "x$HAVE_SETRLSTK" = x ; then      if test ! "x$HAVE_SETRLSTK" = x ; then
865          return          return
866      fi      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 863  void FC_NAMEMANGLE(setrlstk) () Line 882  void FC_NAMEMANGLE(setrlstk) ()
882  }  }
883  EOF  EOF
884      COMM="$CC $CFLAGS -c genmake_tc_1.c"      COMM="$CC $CFLAGS -c genmake_tc_1.c"
885      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
886      $COMM >> genmake_warnings 2>&1      $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 872  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 909  void FC_NAMEMANGLE(tfsize) ( int *nbyte Line 929  void FC_NAMEMANGLE(tfsize) ( int *nbyte
929  }  }
930  EOF  EOF
931      COMM="$CC $CFLAGS -c genmake_tc_1.c"      COMM="$CC $CFLAGS -c genmake_tc_1.c"
932      echo $COMM >> genmake_warnings      echo $COMM >> $LOGFILE
933      $COMM >> genmake_tc.log 2>&1      $COMM >> genmake_tc.log 2>&1
934      RET_C=$?      RET_C=$?
935      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
# Line 919  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 931  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 938  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 957  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="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES"      COMM="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES"
984      echo "$COMM" >> genmake_tnc.log      echo "$COMM" >> genmake_tnc.log
# Line 975  EOF Line 994  EOF
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 $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1          &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
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 986  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 "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log          echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
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 $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log          echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
# Line 996  EOF Line 1016  EOF
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 $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1              &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
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          else
1026          # try again with "-lnetcdff" added to the libs          # try again with "-lnetcdff" added to the libs
1027              echo "try again with added '-lnetcdff -lnetcdf'" > genmake_tnc.log              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              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              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              echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
# Line 1010  EOF Line 1032  EOF
1032                  &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \                  &&  $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                  &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdff -lnetcdf >> genmake_tnc.log 2>&1
1034              RET_COMPILE=$?              RET_COMPILE=$?
1035              cat genmake_tnc.log >> genmake_warnings              echo >> $LOGFILE
1036                cat genmake_tnc.log >> $LOGFILE
1037              if test "x$RET_COMPILE" = x0 ; then              if test "x$RET_COMPILE" = x0 ; then
1038                  LIBS="$LIBS -lnetcdff -lnetcdf"                  LIBS="$LIBS -lnetcdff -lnetcdf"
1039                  HAVE_NETCDF=t                  HAVE_NETCDF=t
1040                    echo "check_netcdf: successful" >> $LOGFILE
1041              fi              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 1043  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=
# Line 1065  MPI= Line 1090  MPI=
1090  MPIPATH=  MPIPATH=
1091  OMP=  OMP=
1092  OMPFLAG=  OMPFLAG=
1093    USE_R4=
1094  TS=  TS=
1095  PAPIS=  PAPIS=
1096  PCLS=  PCLS=
# Line 1129  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 PCLS PAPI PCL HPMT GSL DEVEL MPI OMP 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 FEXTRAFLAGS"  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 1153  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"
1194  printf "  getting local config information:  "  printf "  getting local config information:  "
# Line 1185  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 1206  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 1297  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)
# Line 1360  for ac_option in "$@" ; do Line 1392  for ac_option in "$@" ; do
1392              ;;              ;;
1393                    
1394      esac      esac
1395        
1396  done  done
1397    
1398    
# Line 1372  if test -f ./.genmakerc ; then Line 1404  if test -f ./.genmakerc ; then
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."      echo "  and send an email to MITgcm-support@mitgcm.org if you need help."
1406      echo "WARNING: ignore \"./.genmakerc\" and continue."      echo "WARNING: ignore \"./.genmakerc\" and continue."
1407      echo      echo
1408  fi  fi
1409    
1410  #  Find the MITgcm ${ROOTDIR}  #  Find the MITgcm ${ROOTDIR}
# Line 1405  fi Line 1437  fi
1437  #  Find the MITgcm ${THISVER}  #  Find the MITgcm ${THISVER}
1438  version_file="${ROOTDIR}/doc/tag-index"  version_file="${ROOTDIR}/doc/tag-index"
1439  if test -f $version_file ; then  if test -f $version_file ; then
1440      THISVER=`grep '^checkpoint' $version_file | head -1`      THISVER=`$AWK '/^checkpoint/{print $1; exit}' $version_file`
1441  #-  remove ./BUILD_INFO.h file if older than version_file  #-  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      if test -f ./BUILD_INFO.h -a ./BUILD_INFO.h -ot $version_file ; then
1443          echo "  remove ./BUILD_INFO.h (older than ${version_file})"          echo "  remove ./BUILD_INFO.h (older than ${version_file})"
# Line 1422  if test "x${OPTFILE}" = x ; then Line 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 1437  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 1464  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 1492  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 1502  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 1509  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 1536  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 1546  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 1573  if test ! "x$OMP" = x ; then Line 1611  if test ! "x$OMP" = x ; then
1611        DEFINES="$DEFINES -DUSE_OMP_THREADING"        DEFINES="$DEFINES -DUSE_OMP_THREADING"
1612  fi  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"
1621        if test ! "x$FOOLAD" = x ; then        if test ! "x$FOOLAD" = x ; then
# Line 1794  for d in $MODS ; do Line 1837  for d in $MODS ; do
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 1836  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 1848  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 1868  fi Line 1925  fi
1925  for pdir in exch2 regrid ; do  for pdir in exch2 regrid ; do
1926      if test -r $ROOTDIR"/pkg/${pdir}/Makefile" ; then      if test -r $ROOTDIR"/pkg/${pdir}/Makefile" ; then
1927          echo "  Making source files in pkg/${pdir} from templates"          echo "  Making source files in pkg/${pdir} from templates"
1928          ( cd $ROOTDIR"/pkg/"${pdir} && $MAKE ) > make_${pdir}.errors 2>&1          ( cd $ROOTDIR"/pkg/"${pdir} && $MAKE clean_old && $MAKE \
1929            ) > make_${pdir}.errors 2>&1
1930          RETVAL=$?          RETVAL=$?
1931          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
1932              rm -f make_${pdir}.errors              rm -f make_${pdir}.errors
# Line 1881  for pdir in exch2 regrid ; do Line 1939  for pdir in exch2 regrid ; do
1939  done  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 1977  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 1987  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 for package MNC: if NetCDF is available, then build the MNC  #  Check for package MNC: if NetCDF is available, then build the MNC
2062  #  template files ; otherwise, delete mnc from the list of 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  #  Check for package PROFILES: if NetCDF is not available,  #  Check for package PROFILES: if NetCDF is not available,
2103  #  then delete profiles from the list of available packages.  #  then delete profiles from the list of available packages.
2104  echo $PACKAGES | grep ' profiles ' > /dev/null 2>&1  if test "x$HAVE_NETCDF" != xt ; then
2105  RETVAL=$?      echo " $PACKAGES " | grep ' profiles ' > /dev/null 2>&1
2106  if test "x$RETVAL" = x0 ; then      RETVAL=$?
2107      if test "x$HAVE_NETCDF" != xt ; then      if test "x$RETVAL" = x0 ; then
2108          cat <<EOF          cat <<EOF
   
2109  *********************************************************************  *********************************************************************
2110  WARNING: the "profiles" package was enabled but tests failed to  WARNING: the "profiles" package was enabled but tests failed to
2111    compile NetCDF applications.  Please check that:    compile NetCDF applications.  Please check that:
2112    
2113    1) NetCDF is correctly installed for this compiler and    1) NetCDF is correctly installed for this compiler and
2114    2) the LIBS variable (within the "optfile") specifies the correct    2) the LIBS variable (within the "optfile") specifies the correct
2115         NetCDF library to link against.         NetCDF library to link against.
2116    
2117    Due to this failure, the "profiles" package is now DISABLED.    Due to this failure, the "profiles" package is now DISABLED.
2118  *********************************************************************  *********************************************************************
   
2119  EOF  EOF
2120          PACKAGES=`echo $PACKAGES | sed -e 's/profiles//g'`          PACKAGES=`echo $PACKAGES | sed -e 's/profiles//g'`
2121          DISABLE="$DISABLE profiles"          DISABLE="$DISABLE profiles"
2122        else
2123        #  this prevent to add profiles (due to pdepend rules) if not available
2124            DISABLE="$DISABLE profiles"
2125      fi      fi
2126  fi  fi
2127    
2128  echo "  applying package dependency rules"  if  test "x${PKG_DEPEND}" != x ; then
2129  ck=    echo "  applying package dependency rules"
2130  while test "x$ck" != xtt ; do    ck=
2131      while test "x$ck" != xtt ; do
2132      i=0      i=0
2133      # rtot=${#PNAME[@]}      # rtot=${#PNAME[@]}
2134      rtot=$nname      rtot=$nname
# Line 2067  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 2110  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 2118  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 2136  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 2165  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 2175  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 2238  if test -f ./adSrcFiles.tmp ; then Line 2317  if test -f ./adSrcFiles.tmp ; then
2317      rm -f ./adSrcFiles.tmp      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
# Line 2270  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 2305  if test ! -r ".links.tmp/foo" ; then Line 2385  if test ! -r ".links.tmp/foo" ; then
2385  fi  fi
2386  rm -f .links.tmp/foo  rm -f .links.tmp/foo
2387    
2388  if test "x$OPENAD" != x ; then  if test "x$OPENAD" != x ; then
2389      OAD_DONT_COMPILE="/dev/null"      OAD_DONT_COMPILE="/dev/null"
2390      OAD_DONT_TRANSFORM="/dev/null"      OAD_DONT_TRANSFORM="/dev/null"
2391      OAD_KEEP_ORIGINAL="/dev/null"      OAD_KEEP_ORIGINAL="/dev/null"
# Line 2358  for d in $alldirs ; do Line 2438  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      if test "x$OPENAD" != x ; then
2442          sfiles=`( echo $sfiles | grep -v _cb2m\. )`          sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2443      fi      fi
2444      for sf in $sfiles ; do      for sf in $sfiles ; do
# Line 2398  for d in $alldirs ; do Line 2478  for d in $alldirs ; do
2478                        F)                        F)
2479                          echo    " \\"  >> F77srclist.tmp                          echo    " \\"  >> F77srclist.tmp
2480                          printf " $sf" >> F77srclist.tmp                          printf " $sf" >> F77srclist.tmp
2481                          if test "x$OPENAD" != x ; then                          if test "x$OPENAD" != x ; then
2482                              basename=${sf%%.F}                              basename=${sf%%.F}
2483                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`
2484                              if test -z "$isAD" ; then                              if test -z "$isAD" ; then
2485                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`
2486                                  if test -z "$toBeIgnored" ; then                                  if test -z "$toBeIgnored" ; then
2487                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> nonADF77srclist.tmp
2488                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> nonADF77srclist.tmp
2489                                  else                                  else
2490                                      echo "    not to be compiled   :  $sf"                                      echo "    not to be compiled   :  $sf"
2491                                  fi                                  fi
2492                              else # file is initially listed as an AD file we want to exclude it                              else # file is initially listed as an AD file we want to exclude it
2493                                   # or we want to retain the untransformed version                                   # or we want to retain the untransformed version
2494                                  notToBeTransformed=`egrep ^$basename'[      ]*' ${OAD_DONT_TRANSFORM}`                                  notToBeTransformed=`egrep ^$basename'[      ]*' ${OAD_DONT_TRANSFORM}`
2495                                  untransformedVersionToBeKept=`egrep ^$basename'[      ]*' ${OAD_KEEP_ORIGINAL}`                                  untransformedVersionToBeKept=`egrep ^$basename'[      ]*' ${OAD_KEEP_ORIGINAL}`
2496                                  if test -n "$notToBeTransformed"; then                                  if test -n "$notToBeTransformed"; then
2497                                      echo "    not to be transformed:  $sf"                                      echo "    not to be transformed:  $sf"
2498                                  fi                                  fi
2499                                  if test -n "$untransformedVersionToBeKept" ; then                                  if test -n "$untransformedVersionToBeKept" ; then
2500                                      echo "    original to be kept  :  $sf"                                      echo "    original to be kept  :  $sf"
2501                                  fi                                      fi
2502                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2503                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> nonADF77srclist.tmp
2504                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> nonADF77srclist.tmp
# Line 2474  for xx in "$@" ; do nw=`echo $xx | wc -w Line 2554  for xx in "$@" ; do nw=`echo $xx | wc -w
2554  done  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 2493  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 2513  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 2594  rm -f F77srclist.tmp nonADF77srclist.tmp Line 2674  rm -f F77srclist.tmp nonADF77srclist.tmp
2674    
2675  echo >> $MAKEFILE  echo >> $MAKEFILE
2676    
2677  # add definitions for preprocessed sources  # add definitions for preprocessed sources
2678  # and note that not all systems allow case sensitive extensions  # and note that not all systems allow case sensitive extensions
2679  # hence the $FS and $FS90 here.  # hence the $FS and $FS90 here.
2680  # for fixed format f90 files we use ff90 or FF90 resp  # for fixed format f90 files we use ff90 or FF90 resp
2681  # but these are not expected to be the original source files  # but these are not expected to be the original source files
2682    
2683  echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE  echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE
# Line 2634  output.txt: \$(EXECUTABLE) Line 2714  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 *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2720          -rm -rf *.o          -rm -rf *.o
2721          -rm -rf *.$FS *.flowdir          -rm -rf *.$FS *.flowdir
2722          -rm -rf *.f$FS90 \$(AD_CLEAN) ad_input*          -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
         -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log f90mkdepend.log *.bak  
2729          -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log          -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log
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) \$(EXE_AD) *.txt STD* *diagnostics.log datetime          -rm -f *.txt STD* *diagnostics.log datetime
2742          -rm -f *_MIT_CE_000.opt0000 costfunction*0000          -rm -f *_MIT_CE_000.opt0000 costfunction*0000
2743          -rm -rf mnc_test_*          -rm -rf mnc_test_*
2744    
 #eh3 Makefile: makefile  
2745  makefile:  makefile:
2746          $THIS_SCRIPT $G2ARGS          $THIS_SCRIPT $G2ARGS
2747  cleanlinks:  cleanlinks:
# Line 2685  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  ##  \$(F77_PP_SRC_FILES)  ##  \$(F77_PP_SRC_FILES)
2776  all_fF.tar.gz : \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile  all_fF.tar.gz : \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2777          @echo Creating \$@ ...          @echo Creating \$@ ...
2778          -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile          -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
# Line 2736  EOF Line 2823  EOF
2823  #===  Automatic Differentiation Rules  ===  #===  Automatic Differentiation Rules  ===
2824  #===  for TAMC/TAF  ======================  #===  for TAMC/TAF  ======================
2825    
2826  if test "x$OPENAD" = x ; then  if test "x$OPENAD" = x ; then
2827    
2828  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2829    
# Line 2796  adtafonly: Line 2883  adtafonly:
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  \${EXE_AD}: 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 2835  ftltafonly: Line 2922  ftltafonly:
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 2871  svd_touch: Line 2958  svd_touch:
2958    
2959  EOF  EOF
2960    
2961  fi  fi
2962    
2963  #===  for OpenAD  ========================  #===  for OpenAD  ========================
2964    
2965  if test "x$OPENAD" != x ; then  if test "x$OPENAD" != x ; then
2966    
2967  # ============ begin OpenAD specific section ==============  # ============ begin OpenAD specific section ==============
2968    
2969  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2970    
2971  # all the source files linked from the various locations:  # all the source files linked from the various locations:
2972  ALL_LINKED_FILES= \  ALL_LINKED_FILES= \
2973  \$(F77_SRC_FILES) \  \$(F77_SRC_FILES) \
2974  \$(C_SRC_FILES) \  \$(C_SRC_FILES) \
# Line 2933  rm -f adSrcFiles.tmp Line 3020  rm -f adSrcFiles.tmp
3020    
3021  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3022    
3023  adAll: \$(EXE_AD)  adAll: \$(EXE_AD)
3024  .PHONY: adAll  .PHONY: adAll
3025    
3026  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))
# Line 2951  w2f__types.F90 \ Line 3038  w2f__types.F90 \
3038  OAD_active.F90 \  OAD_active.F90 \
3039  OAD_cp.F90 \  OAD_cp.F90 \
3040  OAD_rev.F90 \  OAD_rev.F90 \
3041  OAD_tape.F90          OAD_tape.F90
3042    
3043  OPENAD_SUPPORT_C_SRC_FILES = \  OPENAD_SUPPORT_C_SRC_FILES = \
3044  iaddr.c \  iaddr.c \
# Line 2960  timeRatio.c Line 3047  timeRatio.c
3047  f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)  f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)
3048          cat \$^ > \$@          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  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 \$^ > \$@          cat \$^ > \$@
3052    
3053  f95_test.out: f95_test_mods.f90 f95_test.f90  f95_test.out: f95_test_mods.f90 f95_test.f90
3054          f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1          f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1
3055          f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1          f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1
3056    
3057  # the file included below is created by the  # the file included below is created by the
3058  # postProcessor and its inclusion sets the  # postProcessor and its inclusion sets the
3059  # variable POSTPROCESSEDFILES  # variable POSTPROCESSEDFILES
3060  # used below. Because the file is made during  # used below. Because the file is made during
3061  # make it won't be read until the second (recursive)  # make it won't be read until the second (recursive)
3062  # invocation in the rule below  # invocation in the rule below
3063  -include postProcess.make  -include postProcess.make
3064    
# Line 2997  endif Line 3084  endif
3084  openad: ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90  openad: ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
3085  .PHONY: openad  .PHONY: openad
3086    
3087  # create the module files  # create the module files
3088  %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk  %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk
3089          ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk          ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk
3090    
3091  # create the header files  # create the header files
3092  %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk  %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk
3093          ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)          ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
3094    
3095  # change everybody else to use the new module files:  # change everybody else to use the new module files:
# Line 3024  CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS9 Line 3111  CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS9
3111  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3112          cat \$^ > \$@          cat \$^ > \$@
3113    
3114  # strip all comments and blanks to reduce  # strip all comments and blanks to reduce
3115  # the file size in order to reduce perl's memory requirements  # the file size in order to reduce perl's memory requirements
3116  ad_input_code_sf.f$FS90 : ad_input_code.f$FS90  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 > \$@          cat \$^ | sed -f ../OAD_support/strip.sed | sed -f ../OAD_support/stop2print.sed > \$@
3118    
3119  # mfef90 preprocessing  # mfef90 preprocessing
3120  # expand statement functions  # expand statement functions
3121  # expose mfef90 specific substring handling  # expose mfef90 specific substring handling
3122  # add the w2f__types module  # 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  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 \$<          ./mfef90 -r8 -z -F -N132 \$<
3125          mv \$<.B \$(basename \$<).B          mv \$<.B \$(basename \$<).B
3126          ./whirl2f -openad \$(basename \$<).B          ./whirl2f -openad \$(basename \$<).B
3127          cat w2f__types.f90 \$(basename \$<).w2f.f > \$@          cat w2f__types.f90 \$(basename \$<).w2f.f > \$@
3128    
3129  # canonicalizer  # canonicalizer
3130  ad_input_code_sf.w2f.pre.f$FS90: ad_input_code_sf.w2f.f$FS90 preProcess.py  ad_input_code_sf.w2f.pre.f$FS90: ad_input_code_sf.w2f.f$FS90 preProcess.py
3131          ./preProcess.py --timing -H -S \$< -o \$@          ./preProcess.py --timing --r8 -H -S \$< -o \$@
3132    
3133  # F -> WHIRL  # F -> WHIRL
3134  # note that the canonicalized version cuts off at col 72  # note that the canonicalized version cuts off at col 72
3135  # doing this also for string constants which is ok as long  # doing this also for string constants which is ok as long
3136  # as we are in fixed mode and cut of exactly there.  # as we are in fixed mode and cut of exactly there.
3137  # Otherwise mfef90 patches in spaces to fill up to 72 (or 132)  # Otherwise mfef90 patches in spaces to fill up to 72 (or 132)
3138  # characters respectively.  # characters respectively.
3139  ad_input_code_sf.w2f.pre.B: ad_input_code_sf.w2f.pre.f$FS90 mfef90  ad_input_code_sf.w2f.pre.B: ad_input_code_sf.w2f.pre.f$FS90 mfef90
3140          ./mfef90 -r8 -z -F \$<          ./mfef90 -r8 -z -F \$<
# Line 3067  ad_input_code_sf.w2f.pre.xb.x2w.B : ad_i Line 3154  ad_input_code_sf.w2f.pre.xb.x2w.B : ad_i
3154    
3155  # WHIRL' -> F'  # 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  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 \$<          ./whirl2f -FLIST:ftn_file=\$@ -openad \$<
3158    
3159  # insert template directives  # 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  ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90 ../OAD_support/insertTemplateDir.bash
# Line 3076  ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f Line 3163  ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f
3163  PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F  PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F
3164  # postprocess F'  # postprocess F'
3165  postProcess.tag: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 postProcess.py \$(PPEXTRAS:.F=.f)  postProcess.tag: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 postProcess.py \$(PPEXTRAS:.F=.f)
3166          # the target is a placeholder to signal execution of the rule          # the target is a placeholder to signal execution of the rule
3167          touch \$@          touch \$@
3168          # this step also creates the file postProcess.make but we cannot          # 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          # 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          # the include directive above for any rule, e.g. make clean
3171          ./postProcess.py --progress --timing -m r -i ../OAD_support/ad_inline.f --width 4 \$<          ./postProcess.py --progress --timing --outputFormat=fixed -m r -i ../OAD_support/ad_inline.f --width 4 \$<
3172    
3173  # setup some links  # setup some links
3174  %.xsd:  %.xsd:
3175          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3176    
3177  mfef90:  mfef90:
3178          \$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 .          \$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 .
3179    
3180  # link the support files:  # link the support files:
3181  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):
3182          \$(LN) ../OAD_support/\$@ .          \$(LN) ../OAD_support/\$@ .
3183    
3184  whirl2xaif xaif2whirl:  whirl2xaif xaif2whirl:
3185          \$(LN) \${OPENADFORTTK}/bin/\$@ .          \$(LN) \${OPENADFORTTK}/bin/\$@ .
3186    
3187  preProcess.py postProcess.py:  preProcess.py postProcess.py:
3188          \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ .          \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ .
3189    
3190  whirl2f whirl2f_be:  whirl2f whirl2f_be:
# Line 3151  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 3170  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.198  
changed lines
  Added in v.1.213

  ViewVC Help
Powered by ViewVC 1.1.22