/[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.7 by edhill, Mon Sep 22 19:06:12 2003 UTC revision 1.21 by edhill, Wed Oct 22 18:00:49 2003 UTC
# Line 8  Line 8 
8  #   modified by aja 01/00  #   modified by aja 01/00
9  #   rewritten in bash by eh3 08/03  #   rewritten in bash by eh3 08/03
10    
11    # Search for particular CPP #cmds associated with packages
12    # usage: test_for_package_in_cpp_options CPP_file package_name
13    test_for_package_in_cpp_options() {
14        cpp_options=$1
15        pkg=$2
16        grep -i "#define.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1
17        RETVAL=$?
18        if test "x${RETVAL}" = x0 ; then
19            echo "Error: In $cpp_options there is an illegal line: #define ALLOW_$pkg"
20            exit 99
21        fi
22        grep -i "#undef.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1
23        RETVAL=$?
24        if test "x${RETVAL}" = x0 ; then
25            echo "Error: In $cpp_options there is an illegal line: #undef ALLOW_$pkg"
26            exit 99
27        fi
28        grep -i "#define.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1
29        RETVAL=$?
30        if test "x${RETVAL}" = x0 ; then
31            echo "Error: In $cpp_options there is an illegal line: #define DISABLE_$pkg"
32            exit 99
33        fi
34        grep -i "#undef.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1
35        RETVAL=$?
36        if test "x${RETVAL}" = x0 ; then
37            echo "Error: In $cpp_options there is an illegal line: #undef DISABLE_$pkg"
38            exit 99
39       fi
40    }
41    
42    # Read the $ROOTDIR/pkg/pkg_groups file and expand any references to
43    # the package list.
44    expand_pkg_groups() {
45        new_packages=
46        PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"
47        if test -r $PKG_GROUPS ; then
48            cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp
49            cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp
50            matched=0
51            for i in $PACKAGES ; do
52                line=`grep "^ *$i" ./p2.tmp`
53                RETVAL=$?
54                if test "x$RETVAL" = x0 ; then
55                    matched=1
56                    replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
57                    echo "    replacing \"$i\" with: $replace"
58                    new_packages="$new_packages $replace"
59                else
60                    new_packages="$new_packages $i"
61                fi
62            done
63            PACKAGES=$new_packages
64            rm -f ./p[1,2].tmp
65        else
66            echo "Warning: can't read package groups definition file: $PKG_GROUPS"
67        fi
68    }
69    
70  # Guess possible config options for this host  # Guess possible config options for this host
71  find_possible_configs()  {  find_possible_configs()  {
72    
73      p_PLATFORM=`uname`"-"`uname -m`      tmp1=`uname`"_"`uname -m`
74      echo "The platform appears to be:"      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
75      echo "  "$p_PLATFORM      PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
76        OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
77      p_LN=      echo "  The platform appears to be:  $PLATFORM"
78    #     if test "x$OFLIST" = x ; then
79    #       echo "  No pre-defined options files were found matching this platform"
80    #       echo "  but examples for other platforms can be found in:"
81    #       echo "    $ROOTDIR/tools/build_options"
82    #     else
83    #       echo "  Options files (located in $ROOTDIR/tools/build_options) that"
84    #       echo "  may work with this machine are:"
85    #       for i in $OFLIST ; do
86    #           echo "    $i"
87    #       done
88    #     fi
89        
90      echo "test" > test      echo "test" > test
91      ln -s ./test link      ln -s ./test link
92      RETVAL=$?      RETVAL=$?
93      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
94          p_LN="ln -s"          LN="ln -s"
95        else
96            echo "Error: \"ln -s\" does not appear to work on this system!"
97            echo "  For help, please contact <MITgcm-support@mitgcm.org>."
98            exit 1
99      fi      fi
100      rm -f test link      rm -f test link
101    
102      p_CPP=`which cpp`      if test "x$CPP" = x ; then
103                CPP="cpp -traditional -P"
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         p_LN="ln -s"  
104      fi      fi
     rm -f test link  
105    
106      # look for possible fortran compilers      # look for possible fortran compilers
107        tmp="$MITGCM_FC $FC g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
108      p_FC=      p_FC=
109      for c in f77 g77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 ; do      for c in $tmp ; do
110          which $c > /dev/null 2>&1          rm -f ./hello.f ./hello
111            cat >> hello.f <<EOF
112          program hello
113          do i=1,3
114            print *, 'hello world : ', i
115          enddo
116          end
117    EOF
118            $c -o hello hello.f > /dev/null 2>&1
119          RETVAL=$?          RETVAL=$?
120          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
121              p_FC="$p_FC $c"              p_FC="$p_FC $c"
122          fi          fi
123      done      done
124      echo "Possible FORTRAN compilers appear to be:  "      rm -f ./hello.f ./hello
125      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
126          echo "  None found!!!"          cat 1>&2 <<EOF
127    
128    Error: No Fortran compilers were found in your path.  Please specify one using:
129    
130        1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
131        2) a command-line option (eg. "-fc NAME"), or
132        3) the MITGCM_FC environment variable.
133    
134    EOF
135            exit 1
136      else      else
137          echo "  "$p_FC          echo "  The possible FORTRAN compilers found in your path are:"
138            echo "   "$p_FC
139            if test "x$FC" = x ; then
140                FC=`echo $p_FC | $AWK '{print $1}'`
141            fi
142      fi      fi
143    
144      # look for possible MPI libraries      for i in $p_FC ; do
145      mpi_libs=          p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
146      mpi_fort=`which mpif77 2>/dev/null`          if test -r $p_OF ; then
147      RETVAL=$?              OPTFILE=$p_OF
148      if test "x${RETVAL}" = x0 ; then              echo "  The options file:  $p_OF"
149          cat >>test.f <<EOF              echo "    appears to match so we'll use it."
150        PROGRAM HELLO              break
       DO 10, I=1,10  
       PRINT *,'Hello World'  
    10 CONTINUE  
       STOP  
       END  
 EOF  
         eval "$mpi_fort -showme test.f > out"  
         RETVAL=$?  
         if test "x${RETVAL}" = x0 ; then  
             a=`cat out`  
             for i in $a ; do  
                 case $i in  
                     -*)  
                         mpi_libs="$mpi_libs $i" ;;  
                 esac  
             done  
             echo "The MPI libs appear to be:"  
             echo "  "$mpi_libs  
151          fi          fi
152          rm -f test.f out      done
153        if test "x$OPTFILE" = x ; then
154            cat 1>&2 <<EOF
155    
156    Error: No options file was found in:  $ROOTDIR/tools/build_options/
157      that matches this platform ("$PLATFORM") and the compilers found in
158      your path.  Please specify an "optfile" using:
159    
160        1) the command line (eg. "-optfile=path/to/OPTFILE"), or
161        2) the MITGCM_OF environment variable.
162    
163      If you need help, please contact the developers at <MITgcm-support@mitgcm.org>.
164    
165    EOF
166            exit 1
167      fi      fi
168        
169    #     # look for possible MPI libraries
170    #     mpi_libs=
171    #     mpi_fort=`which mpif77 2>/dev/null`
172    #     RETVAL=$?
173    #     if test "x${RETVAL}" = x0 ; then
174    #       cat >>test.f <<EOF
175    #       PROGRAM HELLO
176    #       DO 10, I=1,10
177    #       PRINT *,'Hello World'
178    #    10 CONTINUE
179    #       STOP
180    #       END
181    # EOF
182    #       eval "$mpi_fort -showme test.f > out"
183    #       RETVAL=$?
184    #       if test "x${RETVAL}" = x0 ; then
185    #           a=`cat out`
186    #           for i in $a ; do
187    #               case $i in
188    #                   -*)
189    #                       mpi_libs="$mpi_libs $i" ;;
190    #               esac
191    #           done
192    #           echo "The MPI libs appear to be:"
193    #           echo "  "$mpi_libs
194    #       fi
195    #       rm -f test.f out
196    #     fi
197    
198  }  }
199    
# Line 86  get_pdepend_list()  { Line 203  get_pdepend_list()  {
203      #  strip the comments and then convert the dependency file into      #  strip the comments and then convert the dependency file into
204      #  two arrays: PNAME, DNAME      #  two arrays: PNAME, DNAME
205      cat $1 | sed -e 's/#.*$//g' \      cat $1 | sed -e 's/#.*$//g' \
206          | awk 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \          | $AWK 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \
207          > ./.pd_tmp          > ./.pd_tmp
208      source ./.pd_tmp      source ./.pd_tmp
209      rm -f ./.pd_tmp      rm -f ./.pd_tmp
# Line 123  usage()  { Line 240  usage()  {
240      echo "      -disable=NAME | --disable=NAME"      echo "      -disable=NAME | --disable=NAME"
241      echo "    -enable NAME | --enable NAME"      echo "    -enable NAME | --enable NAME"
242      echo "      -enable=NAME | --enable=NAME"      echo "      -enable=NAME | --enable=NAME"
243        echo "    -standarddirs NAME | --standarddirs NAME"
244        echo "      -standarddirs=NAME | --standarddirs=NAME"
245      echo "    -noopt NAME | --noopt NAME"      echo "    -noopt NAME | --noopt NAME"
246      echo "      -noopt=NAME | --noopt=NAME"      echo "      -noopt=NAME | --noopt=NAME"
247  #    echo "    -cpp NAME | --cpp NAME"  #    echo "    -cpp NAME | --cpp NAME"
# Line 172  S64= Line 291  S64=
291  KPP=  KPP=
292  FC=  FC=
293  LINK=  LINK=
294    DEFINES="-DWORDLENGTH=4"
295  PACKAGES=  PACKAGES=
296  ENABLE=  ENABLE=
297  DISABLE=  DISABLE=
298  MAKEFILE=  MAKEFILE=
299  MAKEDEPEND=  MAKEDEPEND=
300  PDEPEND=  PDEPEND=
301  DUMPSTATE=f  DUMPSTATE=t
302  PDEFAULT=  PDEFAULT=
303  OPTFILE=  OPTFILE=
304  INCLUDES="-I."  INCLUDES="-I."
# Line 196  MODS= Line 316  MODS=
316  TOOLSDIR=  TOOLSDIR=
317  SOURCEDIRS=  SOURCEDIRS=
318  INCLUDEDIRS=  INCLUDEDIRS=
319    STANDARDDIRS=
320    
321  PWD=`pwd`  PWD=`pwd`
322  MAKE=make  MAKE=make
323    AWK=awk
324  THISHOSTNAME=`hostname`  THISHOSTNAME=`hostname`
325  THISCWD=`pwd`  THISCWD=`pwd`
326  THISDATE=`date`  THISDATE=`date`
# Line 206  MACHINE=`uname -a` Line 328  MACHINE=`uname -a`
328  EXECUTABLE=  EXECUTABLE=
329  EXEHOOK=  EXEHOOK=
330  EXEDIR=  EXEDIR=
331    PACKAGES_CONF=
332    IEEE=
333    if test "x$MITGCM_IEEE" != x ; then
334        IEEE=$MITGCM_IEEE
335    fi
336    
337    AUTODIFF_PKG_USED=f
338    AD_OPTFILE=
339    TAF=
340    AD_TAF_FLAGS=
341    FTL_TAF_FLAGS=
342    SVD_TAF_FLAGS=
343    TAF_EXTRA=
344    TAMC=
345    AD_TAMC_FLAGS=
346    FTL_TAF_FLAGS=
347    SVD_TAMC_FLAGS=
348    TAMC_EXTRA=
349    
350    
351  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
352  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"
353  gm_s2="FC IEEE MPI JAM DUMPSTATE"  gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS"
354    
355  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
356  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "
357  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
358  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"
359  gm_s6="EXECUTABLE EXEHOOK EXEDIR"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
360    
361    #  The following are all related to adjoint/tangent-linear stuff
362    gm_s7="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
363    gm_s8="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
364    gm_s9="TAF_EXTRA TAMC_EXTRA"
365    
366  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6"  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8 $gm_s9"
367    
368    
369  echo  echo
370  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
371  gm_local="./gm_local"  gm_local="genmake_local"
372    for i in . $MODS ; do
373        if test -r $i/$gm_local ; then
374            source $i/$gm_local
375            break
376        fi
377    done
378  echo -n "  getting local config information:  "  echo -n "  getting local config information:  "
379  if test -e $gm_local ; then  if test -e $gm_local ; then
380      echo "using $gm_local"      echo "using $gm_local"
# Line 244  fi Line 396  fi
396  #   n=$(( $n + 1 ))  #   n=$(( $n + 1 ))
397  #done  #done
398  #parse_options  #parse_options
   
399  ac_prev=  ac_prev=
400  for ac_option ; do  for ac_option ; do
401    
# Line 269  for ac_option ; do Line 420  for ac_option ; do
420          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
421              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
422                    
423            -adoptfile | --adoptfile | -ad | --ad)
424                ac_prev=AD_OPTFILE ;;
425            -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
426                AD_OPTFILE=$ac_optarg ;;
427            
428          -pdepend | --pdepend)          -pdepend | --pdepend)
429              ac_prev=PDEPEND ;;              ac_prev=PDEPEND ;;
430          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
# Line 314  for ac_option ; do Line 470  for ac_option ; do
470          -enable=* | --enable=*)          -enable=* | --enable=*)
471              ENABLE=$ac_optarg ;;              ENABLE=$ac_optarg ;;
472                    
473            -standarddirs | --standarddirs)
474                ac_prev=STANDARDDIRS ;;
475            -standarddirs=* | --standarddirs=*)
476                STANDARDDIRS=$ac_optarg ;;
477    
478          -noopt | --noopt)          -noopt | --noopt)
479              ac_prev=NOOPT ;;              ac_prev=NOOPT ;;
480          -noopt=* | --noopt=*)          -noopt=* | --noopt=*)
# Line 330  for ac_option ; do Line 491  for ac_option ; do
491              FC=$ac_optarg ;;              FC=$ac_optarg ;;
492                    
493          -ieee | --ieee)          -ieee | --ieee)
494              IEEE=1 ;;              IEEE=true ;;
495          -noieee | --noieee)          -noieee | --noieee)
496              IEEE=0 ;;              IEEE= ;;
497                    
498          -mpi | --mpi)          -mpi | --mpi)
499              MPI=1 ;;              MPI=true ;;
500          -nompi | --nompi)          -nompi | --nompi)
501              MPI=0 ;;              MPI= ;;
502                    
503          -jam | --jam)          -jam | --jam)
504              JAM=1 ;;              JAM=1 ;;
# Line 347  for ac_option ; do Line 508  for ac_option ; do
508          -ds | --ds)          -ds | --ds)
509              DUMPSTATE=t ;;              DUMPSTATE=t ;;
510                    
511            -taf_extra | --taf_extra)
512                ac_prev=TAF_EXTRA ;;
513            -taf_extra=* | --taf_extra=*)
514                TAF_EXTRA=$ac_optarg ;;
515    
516            -tamc_extra | --tamc_extra)
517                ac_prev=TAMC_EXTRA ;;
518            -tamc_extra=* | --tamc_extra=*)
519                TAMC_EXTRA=$ac_optarg ;;
520    
521          -*)          -*)
522              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
523              usage              usage
# Line 361  for ac_option ; do Line 532  for ac_option ; do
532            
533  done  done
534    
535    if test -f ./.genmakerc ; then
536        echo
537        echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
538        echo "  file.  This file format is no longer supported.  Please see:"
539        echo
540        echo "    http://mitgcm.org/devel_HOWTO/"
541        echo
542        echo "  for directions on how to setup and use the new \"genmake2\" input"
543        echo "  files and send an email to MITgcm-support@mitgcm.org if you want help."
544        echo
545    fi
546    
547    if test "x${ROOTDIR}" = x ; then
548        if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
549            ROOTDIR=".."
550        else
551            for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
552                if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
553                    ROOTDIR=$d
554                    echo -n "Warning:  ROOTDIR was not specified but there appears to be"
555                    echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
556                    break
557                fi
558            done
559        fi
560    fi
561    if test "x${ROOTDIR}" = x ; then
562        echo "Error: Cannot determine ROOTDIR for MITgcm code."
563        echo "  Please specify a ROOTDIR using either an options "
564        echo "  file or a command-line option."
565        exit 1
566    fi
567    if test ! -d ${ROOTDIR} ; then
568        echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!"
569        exit 1
570    fi
571    
572  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
573  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
574      echo "Warning: no OPTFILE specified so we'll look for possible settings"      if test "x$MITGCM_OF" = x ; then
575      printf "\n===  Searching for possible settings for OPTFILE  ===\n"          echo "Warning: no OPTFILE specified so we'll look for possible settings"
576      find_possible_configs          printf "\n===  Searching for possible settings for OPTFILE  ===\n"
577  else          find_possible_configs
     if test "x$OPTFILE" = xNONE ; then  
         echo "    OPTFILE=NONE so we'll try to use default settings"  
578      else      else
579          if test -f "$OPTFILE" -a -r "$OPTFILE" ; then          OPTFILE=$MITGCM_OF
580              echo "    using OPTFILE=\"$OPTFILE\""      fi
581              source "$OPTFILE"  fi
582              RETVAL=$?  if test "x$OPTFILE" != xNONE ; then
583              if test "x$RETVAL" != x0 ; then      if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
584                  echo -n "Error: failed to source OPTFILE \"$OPTFILE\""          echo "    using OPTFILE=\"$OPTFILE\""
585                  echo "--please check that variable syntax is bash-compatible"          source "$OPTFILE"
586                  exit 1          RETVAL=$?
587              fi          if test "x$RETVAL" != x0 ; then
588              if test "x$DUMPSTATE" != xf ; then              echo -n "Error: failed to source OPTFILE \"$OPTFILE\""
589                  cp -f $OPTFILE "gm_optfile"              echo "--please check that variable syntax is bash-compatible"
             fi  
         else  
             echo "Error: can't read OPTFILE=\"$OPTFILE\""  
590              exit 1              exit 1
591          fi          fi
592            if test "x$DUMPSTATE" != xf ; then
593                cp -f $OPTFILE "genmake_optfile"
594            fi
595        else
596            echo "Error: can't read OPTFILE=\"$OPTFILE\""
597            exit 1
598      fi      fi
599  fi  fi
600    
601    echo "  getting AD_OPTFILE information:  "
602    if test "x${AD_OPTFILE}" = x ; then
603        if test "x$MITGCM_AD_OF" = x ; then
604            AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
605        else
606            AD_OPTFILE=$MITGCM_AD_OF
607        fi
608    fi
609    if test "x${AD_OPTFILE}" != xNONE ; then
610        if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then
611            echo "    using AD_OPTFILE=\"$AD_OPTFILE\""
612            source "$AD_OPTFILE"
613            RETVAL=$?
614            if test "x$RETVAL" != x0 ; then
615                echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
616                echo "--please check that variable syntax is bash-compatible"
617                exit 1
618            fi
619            if test "x$DUMPSTATE" != xf ; then
620                cp -f $AD_OPTFILE "genmake_ad_optfile"
621            fi
622        else
623            echo "Error: can't read AD_OPTFILE=\"$AD_OPTFILE\""
624            exit 1
625        fi
626    fi
627    
628    #  Check that FC, LINK, CPP, and S64 are defined.  If not, complain
629    #  and abort!
630    if test "x$FC" = x ; then
631        cat <<EOF 1>&2
632    
633    Error: no Fortran compiler: please specify using one of the following:
634      1) within the options file ("FC=...") as specified by "-of=OPTFILE"
635      2) the "-fc=XXX" command-line option
636      3) the "./genmake_local" file
637    EOF
638        exit 1
639    fi
640    if test "x$LINK" = x ; then
641        LINK=$FC
642    fi
643    if test "x$CPP" = x ; then
644        CPP="cpp"
645    fi
646    echo "#define A a" | $CPP > test_cpp 2>&1
647    RETVAL=$?
648    if test "x$RETVAL" != x0 ; then
649        cat <<EOF 1>&2
650    
651    Error: C pre-processor "$CPP" failed the test case: please specify using:
652    
653      1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
654      2) the "./genmake_local" file
655    
656    EOF
657        exit 1
658    else
659        rm -f test_cpp
660    fi
661    if test "x$MAKEDEPEND" = x ; then
662        MAKEDEPEND=makedepend
663    fi
664    
665  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
666  echo -n "  Adding MODS directories:  "  echo -n "  Adding MODS directories:  "
667  for d in $MODS ; do  for d in $MODS ; do
# Line 411  if test "x${PLATFORM}" = x ; then Line 684  if test "x${PLATFORM}" = x ; then
684      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
685  fi  fi
686    
 if test "x${ROOTDIR}" = x ; then  
     if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then  
         ROOTDIR=".."  
     else  
         for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do  
             if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then  
                 ROOTDIR=$d  
                 echo -n "Warning:  ROOTDIR was not specified but there appears to be"  
                 echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."  
                 break  
             fi  
         done  
     fi  
 fi  
 if test "x${ROOTDIR}" = x ; then  
     echo "Error: Cannot determine ROOTDIR for MITgcm code."  
     echo "  Please specify a ROOTDIR using either an options "  
     echo "  file or a command-line option."  
     exit 1  
 fi  
 if test ! -d ${ROOTDIR} ; then  
     echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!"  
     exit 1  
 fi  
   
687  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
688      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then
689          EXEDIR=../exe          EXEDIR=../exe
# Line 455  if test ! -d ${TOOLSDIR} ; then Line 703  if test ! -d ${TOOLSDIR} ; then
703      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"
704      exit 1      exit 1
705  fi  fi
706    if test "x$S64" = x ; then
707        S64='$(TOOLSDIR)/set64bitConst.sh'
708    fi
709    
710  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
711    
# Line 493  echo "  getting package dependency info Line 744  echo "  getting package dependency info
744  #  Strip the comments and then convert the dependency file into  #  Strip the comments and then convert the dependency file into
745  #  two arrays: PNAME, DNAME  #  two arrays: PNAME, DNAME
746  cat $PDEPEND | sed -e 's/#.*$//g' \  cat $PDEPEND | sed -e 's/#.*$//g' \
747      | awk 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \      | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
748      > ./.pd_tmp      > ./.pd_tmp
749  RETVAL=$?  RETVAL=$?
750  if test ! "x${RETVAL}" = x0 ; then  if test ! "x${RETVAL}" = x0 ; then
# Line 503  fi Line 754  fi
754  source ./.pd_tmp  source ./.pd_tmp
755  rm -f ./.pd_tmp  rm -f ./.pd_tmp
756    
757    #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"
758    #  file should eventually be added so that, for convenience, one can
759    #  specify groups of packages using names like "ocean" and "atmosphere".
760  echo  -n "  checking default package list:  "  echo  -n "  checking default package list:  "
761  if test "x${PDEFAULT}" = x ; then  if test "x${PDEFAULT}" = x ; then
762        for i in "." $MODS ; do
763            if test -r $i"/packages.conf" ; then
764                    PDEFAULT=$i"/packages.conf"
765                    break
766            fi
767        done
768    fi
769    if test "x${PDEFAULT}" = x ; then
770      PDEFAULT="$ROOTDIR/pkg/pkg_default"      PDEFAULT="$ROOTDIR/pkg/pkg_default"
771  fi  fi
772  if test "x${PDEFAULT}" = xNONE ; then  if test "x${PDEFAULT}" = xNONE ; then
# Line 516  else Line 778  else
778      else      else
779          echo "  using PDEFAULT=\"$PDEFAULT\""          echo "  using PDEFAULT=\"$PDEFAULT\""
780          #  Strip the comments and add all the names          #  Strip the comments and add all the names
781          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | awk '(NF>0){print $0}'`          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
782          RETVAL=$?          RETVAL=$?
783          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
784              echo -n "Error: can't parse default package list "              echo -n "Error: can't parse default package list "
# Line 526  else Line 788  else
788          for i in $def ; do          for i in $def ; do
789              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
790          done          done
791          echo "    packages are:  $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
792            expand_pkg_groups
793            echo "    after group expansion packages are:  $PACKAGES"
794      fi      fi
795  fi  fi
796    
# Line 545  for p in $PACKAGES ; do Line 809  for p in $PACKAGES ; do
809  done  done
810  PACKAGES="$pack"  PACKAGES="$pack"
811  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
812  rm -f ./.tmp_pack  echo "" > ./.tmp_pack
813  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
814  for i in $PACKAGES ; do  for i in $PACKAGES ; do
815      if test ! -d "$ROOTDIR/pkg/$i" ; then      if test ! -d "$ROOTDIR/pkg/$i" ; then
# Line 636  for i in $PACKAGES ; do Line 900  for i in $PACKAGES ; do
900      if test -d $adr ; then      if test -d $adr ; then
901          SOURCEDIRS="$SOURCEDIRS $adr"          SOURCEDIRS="$SOURCEDIRS $adr"
902          INCLUDEDIRS="$INCLUDEDIRS $adr"          INCLUDEDIRS="$INCLUDEDIRS $adr"
903            if test "x$i" = xautodiff ; then
904                AUTODIFF_PKG_USED=t
905            fi
906      else      else
907          echo "Error: the directory \"$adr\" for package $i doesn't exist"          echo "Error: the directory \"$adr\" for package $i doesn't exist"
908          exit 1          exit 1
# Line 661  done Line 928  done
928  # done  # done
929  # echo  # echo
930    
931  echo "  Setting package-specific CPP flags in CPP_OPTIONS.h:"  # Create a list of #define and #undef to enable/disable packages
932  CPP_OPTIONS=  PACKAGES_DOT_H=PACKAGES_CONFIG.h
933  spaths="$SOURCEDIRS"  cat <<EOF >$PACKAGES_DOT_H".tmp"
 for i in $spaths ; do  
     try="$i/CPP_OPTIONS.h"  
     #  echo -n "    trying $try : "  
     if test -f $try -a -r $try ; then  
         echo "    found CPP_OPTIONS=\"$try\""  
         CPP_OPTIONS="$try"  
         if test "x$i" != "x." ; then  
             cp -f $CPP_OPTIONS .  
         fi  
         break  
     fi  
 done  
 if test "x$CPP_OPTIONS" = x ; then  
     echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"  
     exit 1  
 fi  
 if test -e CPP_OPTIONS.h ; then  
     if test ! -e CPP_OPTIONS.h.bak ; then  
         cp -f CPP_OPTIONS.h CPP_OPTIONS.h.bak  
     fi  
     cat CPP_OPTIONS.h \  
         | awk 'BEGIN{p=1;} ($1=="C===" && $2=="GENMAKE"){p=0;} {if (p==1) print $0}' \  
         > CPP_OPTIONS.h.tmp  
 fi  
 cat <<EOF >>CPP_OPTIONS.h.tmp  
934  C=== GENMAKE v2 ===  C=== GENMAKE v2 ===
935  C  The following defines have been set by GENMAKE, so please edit  C  The following defines have been set by GENMAKE, so please do not
936  C  them only if you know what you're doing.  In general, you should  C  edit anything below these comments.  In general, you should
937  C  add or remove packages by re-running genmake with different  C  add or remove packages by re-running genmake with different
938  C  "-enable" and/or "-disable" options.  C  "-enable" and/or "-disable" options.
939    
940    #ifndef PACKAGES_H
941    #define PACKAGES_H
942    
943  C  Packages disabled by genmake:  C  Packages disabled by genmake:
944  EOF  EOF
945  #  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
# Line 713  for n in $names ; do Line 958  for n in $names ; do
958              fi              fi
959          done          done
960          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
961              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`
962              echo "#undef $undef" >> CPP_OPTIONS.h.tmp              echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"
963    #           DEFINES="$DEFINES -U$undef"
964    
965  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
966              case $n in              case $n in
# Line 724  for n in $names ; do Line 970  for n in $names ; do
970                  mom_vecinv)                  mom_vecinv)
971                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"
972                      ;;                      ;;
                 generic_advdiff)  
                     DEFINES="$DEFINES -DDISABLE_GENERIC_ADVDIFF"  
                     ;;  
973                  debug)                  debug)
974                      DEFINES="$DEFINES -DDISABLE_DEBUGMODE"                      DEFINES="$DEFINES -DDISABLE_DEBUGMODE"
975                      ;;                      ;;
# Line 736  for n in $names ; do Line 979  for n in $names ; do
979          fi          fi
980      fi      fi
981  done  done
982  cat <<EOF >>CPP_OPTIONS.h.tmp  cat <<EOF >>$PACKAGES_DOT_H".tmp"
983    
984  C  Packages enabled by genmake:  C  Packages enabled by genmake:
985  EOF  EOF
986  for i in $PACKAGES ; do  for i in $PACKAGES ; do
987      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`
988      echo "#define $def" >> CPP_OPTIONS.h.tmp      echo "#define $def" >> $PACKAGES_DOT_H".tmp"
989    #eh3 DEFINES="$DEFINES -D$def"
990    
991  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
992      case $i in      case $i in
993          aim_v23)          aim_v23)
994              echo "#define   ALLOW_AIM" >> CPP_OPTIONS.h.tmp              echo "#define   ALLOW_AIM" >> $PACKAGES_DOT_H".tmp"
995                DEFINES="$DEFINES -DALLOW_AIM"
996                echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"
997              ;;              ;;
998      esac      esac
999  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
1000    
1001  done  done
1002  mv -f CPP_OPTIONS.h.tmp CPP_OPTIONS.h  cat <<EOF >>$PACKAGES_DOT_H".tmp"
1003    
1004    #endif /* PACKAGES_H */
1005    EOF
1006    
1007    if test ! -f $PACKAGES_DOT_H ; then
1008        mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1009    else
1010        cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1011        RETVAL=$?
1012        if test "x$RETVAL" = x0 ; then
1013            rm -f $PACKAGES_DOT_H".tmp"
1014        else
1015            mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"
1016            mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1017        fi
1018    fi
1019    
1020  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
1021  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
1022  STANDARDDIRS=${STANDARDDIRS:-"eesupp model"}  if test "x$STANDARDDIRS" = x ; then
1023        STANDARDDIRS="eesupp model"
1024    fi
1025  for d in $STANDARDDIRS ; do  for d in $STANDARDDIRS ; do
1026      adr="$ROOTDIR/$d/src"      adr="$ROOTDIR/$d/src"
1027      if test ! -d $adr ; then      if test ! -d $adr ; then
# Line 777  for d in $STANDARDDIRS ; do Line 1041  for d in $STANDARDDIRS ; do
1041      fi      fi
1042  done  done
1043    
1044    echo " Searching for CPP_OPTIONS.h in order to warn about the presence"
1045    echo " of \"#define ALLOW_PKGNAME\"-type statements:"
1046    CPP_OPTIONS=
1047    spaths=". $INCLUDEDIRS"
1048    for i in $spaths ; do
1049        try="$i/CPP_OPTIONS.h"
1050        #  echo -n "    trying $try : "
1051        if test -f $try -a -r $try ; then
1052            echo "    found CPP_OPTIONS=\"$try\""
1053            CPP_OPTIONS="$try"
1054            break
1055        fi
1056    done
1057    if test "x$CPP_OPTIONS" = x ; then
1058        echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"
1059        exit 1
1060    fi
1061    # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
1062    names=`ls -1 "$ROOTDIR/pkg"`
1063    for n in $names ; do
1064        test_for_package_in_cpp_options $CPP_OPTIONS $n
1065    done
1066    
1067    
1068    #  Here, we build the list of files to be "run through" the adjoint
1069    #  compiler.
1070    if test -f ./ad_files ; then
1071        rm -f ./ad_files
1072    fi
1073    echo "  Creating the list of files for the adjoint compiler."
1074    for i in $SOURCEDIRS ; do
1075        list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
1076        for j in $list_files ; do
1077            cat $i/$j >> ad_files
1078        done
1079    done
1080    
1081    cat <<EOF > adjoint_sed
1082    s/call adopen(/call adopen ( mythid,\\
1083         \&           /g
1084    s/call adclose(/call adclose( mythid,\\
1085         \&           /g
1086    s/call adread(/call adread ( mythid,\\
1087         \&           /g
1088    s/call adwrite(/call adwrite( mythid,\\
1089         \&           /g
1090    
1091    EOF
1092    
1093  echo  echo
1094  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
1095  echo "  setting INCLUDES"  echo "  setting INCLUDES"
1096  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
1097      if test -d $i ; then      if ! test -d $i ; then
1098          INCLUDES="$INCLUDES -I$i"  #       INCLUDES="$INCLUDES -I$i"
1099      else  #   else
1100          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
1101      fi      fi
1102  done  done
# Line 798  echo -n 'SRCFILES = '    > srclist.inc Line 1110  echo -n 'SRCFILES = '    > srclist.inc
1110  echo -n 'CSRCFILES = '   > csrclist.inc  echo -n 'CSRCFILES = '   > csrclist.inc
1111  echo -n 'F90SRCFILES = ' > f90srclist.inc  echo -n 'F90SRCFILES = ' > f90srclist.inc
1112  echo -n 'HEADERFILES = ' > hlist.inc  echo -n 'HEADERFILES = ' > hlist.inc
1113  alldirs=". $SOURCEDIRS $INCLUDEDIRS"  echo -n 'AD_FLOW_FILES = ' > ad_flow_files.inc
1114    alldirs="$SOURCEDIRS $INCLUDEDIRS ."
1115  for d in $alldirs ; do  for d in $alldirs ; do
1116      deplist=      deplist=
1117      sfiles=`( cd $d; echo *.[h,c,F] )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
1118      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
1119      for sf in $sfiles ; do      for sf in $sfiles ; do
1120          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
1121              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
1122                  extn=`echo $sf | awk -F '.' '{print $NF}'`                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`
1123                  touch .links.tmp/$sf                  touch .links.tmp/$sf
1124                  deplist="$deplist $sf"                  deplist="$deplist $sf"
1125                  case $extn in                  case $extn in
# Line 826  for d in $alldirs ; do Line 1139  for d in $alldirs ; do
1139                          echo    " \\"  >> hlist.inc                          echo    " \\"  >> hlist.inc
1140                          echo -n " $sf" >> hlist.inc                          echo -n " $sf" >> hlist.inc
1141                          ;;                          ;;
1142                        flow)
1143                            echo    " \\"  >> ad_flow_files.inc
1144                            echo -n " $sf" >> ad_flow_files.inc
1145                            ;;
1146                  esac                  esac
1147              fi              fi
1148          fi          fi
# Line 842  echo "" >> srclist.inc Line 1159  echo "" >> srclist.inc
1159  echo "" >> csrclist.inc  echo "" >> csrclist.inc
1160  echo "" >> f90srclist.inc  echo "" >> f90srclist.inc
1161  echo "" >> hlist.inc  echo "" >> hlist.inc
1162    echo "" >> ad_flow_files.inc
1163    
1164  if test -e $MAKEFILE ; then  if test -e $MAKEFILE ; then
1165      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
# Line 855  echo "# by the command:" >> $MAKEFILE Line 1173  echo "# by the command:" >> $MAKEFILE
1173  echo "#    $0 $@" >> $MAKEFILE  echo "#    $0 $@" >> $MAKEFILE
1174  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
1175  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE
1176    
1177    EXE_AD=$EXECUTABLE"_ad"
1178    EXE_FTL=$EXECUTABLE"_ftl"
1179    EXE_SVD=$EXECUTABLE"_svd"
1180    
1181  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1182  #  #
1183  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
# Line 883  EXEDIR      = ${EXEDIR} Line 1206  EXEDIR      = ${EXEDIR}
1206  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
1207  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIR}
1208    
1209    #eh3  new defines for the adjoint work
1210    AUTODIFF    = ${ROOTDIR}/pkg/autodiff
1211    EXE_AD      = ${EXE_AD}
1212    EXE_FTL     = ${EXE_FTL}
1213    EXE_SVD     = ${EXE_SVD}
1214    
1215  EOF  EOF
1216    
1217  #  Note: figure out some way to add Hyades JAM libraries here  #  Note: figure out some way to add Hyades JAM libraries here
# Line 928  MAKEFILE=${MAKEFILE} Line 1257  MAKEFILE=${MAKEFILE}
1257    
1258  EOF  EOF
1259    
1260  cat srclist.inc    >> $MAKEFILE  cat srclist.inc       >> $MAKEFILE
1261  cat csrclist.inc   >> $MAKEFILE  cat csrclist.inc      >> $MAKEFILE
1262  cat f90srclist.inc >> $MAKEFILE  cat f90srclist.inc    >> $MAKEFILE
1263  cat hlist.inc      >> $MAKEFILE  cat hlist.inc         >> $MAKEFILE
1264    cat ad_flow_files.inc >> $MAKEFILE
1265    echo               >> $MAKEFILE
1266  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE
1267  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE
1268  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
1269    
1270  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc
1271    rm -f ad_flow_files.inc
1272    
1273  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1274    
# Line 964  clean: Line 1296  clean:
1296  Clean:  Clean:
1297          @make clean          @make clean
1298          @make cleanlinks          @make cleanlinks
1299          -rm -f Makefile.bak          -rm -f Makefile.bak genmake_state genmake_optfile make.log
1300  CLEAN:  CLEAN:
1301          @make Clean          @make Clean
1302          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
1303          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
1304          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1305          -rm -f \$(EXECUTABLE)          -rm -f \$(EXECUTABLE) output.txt
1306    
1307    #eh3 Makefile: makefile
1308  makefile:  makefile:
1309          ${0} $@          ${0} $@
1310  cleanlinks:  cleanlinks:
# Line 995  cleanlinks: Line 1328  cleanlinks:
1328  .p.f:  .p.f:
1329          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
1330    
1331    #=========================================
1332    #===  Automatic Differentiation Rules  ===
1333    
1334    TAMC           = ${TAMC}
1335    TAF            = ${TAF}
1336    
1337    TAF_EXTRA      = ${TAF_EXTRA}
1338    TAMC_EXTRA     = ${TAMC_EXTRA}
1339    
1340    EOF
1341    
1342    ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS"
1343    ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF_FLAGS"
1344    ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
1345    for i in $ad_vars ; do
1346        name=$i
1347        t1="t2=\$"`echo $i`
1348        eval $t1
1349        printf "%-20s = " $name >> $MAKEFILE
1350        echo $t2 >> $MAKEFILE
1351    done
1352    
1353    echo "  Add the source list for AD code generation"
1354    echo >> $MAKEFILE
1355    echo -n "AD_FILES = " >> $MAKEFILE
1356    AD_FILES=`cat ad_files`
1357    for i in $AD_FILES ; do
1358        echo    " \\" >> $MAKEFILE
1359        echo -n " $i" >> $MAKEFILE
1360    done
1361    echo >> $MAKEFILE
1362    rm -f ad_files
1363    
1364    cat >>$MAKEFILE <<EOF
1365    
1366    ad_input_code.f: \$(F77FILES)
1367            @make \$(AD_FLOW_FILES)
1368            cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f
1369    
1370    # ... AD ...
1371    ad: ad_taf
1372    ad_taf_f: ad_taf_output.f
1373    ad_tamc_f: ad_tamc_output.f
1374    
1375    ad_taf_output.f: ad_input_code.f
1376            \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f
1377            cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f
1378    
1379    ad_taf: ad_taf_output.o \$(OBJFILES)
1380            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
1381    
1382    ad_tamc_output.f: ad_input_code.f
1383            \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f
1384            cat ad_input_code_ad.f | sed -f adjoint_sed > ad_tamc_output.f
1385    
1386    ad_tamc: ad_tamc_output.o \$(OBJFILES)
1387            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
1388    
1389    
1390    # ... FTL ...
1391    ftl: ftl_taf
1392    ftl_taf_f: ftl_taf_output.f
1393    ftl_tamc_f: ftl_tamc_output.f
1394    
1395    ftl_taf_output.f: ad_input_code.f
1396            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f
1397            cat ad_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f
1398    
1399    ftl_taf: ftl_taf_output.o \$(OBJFILES)
1400            \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
1401    
1402    ftl_tamc_output.f: ad_input_code.f
1403            \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f
1404            cat ad_input_code_ftl.f | sed -f adjoint_sed > ftl_tamc_output.f
1405    
1406    ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
1407            \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
1408    
1409    
1410    # ... SVD ...
1411    svd: svd_taf
1412    svd_taf_f: svd_taf_output.f
1413    
1414    svd_taf_output.f: ad_input_code.f
1415            \$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f
1416            cat ad_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f
1417    
1418    svd_taf: svd_taf_output.o \$(OBJFILES)
1419            \$(LINK) -o ${EXE_SVD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS)
1420    
1421    
1422    #=========================================
1423    
1424  EOF  EOF
1425    
1426  if test "x$EXEHOOK" != x ; then  if test "x$EXEHOOK" != x ; then
# Line 1034  printf "\n===  Done  ===\n" Line 1460  printf "\n===  Done  ===\n"
1460    
1461  #  Write the "state" for future records  #  Write the "state" for future records
1462  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" != xf ; then
1463      echo -n "" > gm_state      echo -n "" > genmake_state
1464      for i in $gm_state ; do      for i in $gm_state ; do
1465          t1="t2=\$$i"          t1="t2=\$$i"
1466          eval $t1          eval $t1
1467          echo "$i='$t2'" >> gm_state          echo "$i='$t2'" >> genmake_state
1468      done      done
1469  fi  fi

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.22