/[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.3 by cnh, Fri Aug 22 20:50:40 2003 UTC revision 1.33 by adcroft, Thu Nov 13 15:10:40 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      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
76        PLATFORM=`echo $tmp3 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
77      p_LN=      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
78        echo "  The platform appears to be:  $PLATFORM"
79    #     if test "x$OFLIST" = x ; then
80    #       echo "  No pre-defined options files were found matching this platform"
81    #       echo "  but examples for other platforms can be found in:"
82    #       echo "    $ROOTDIR/tools/build_options"
83    #     else
84    #       echo "  Options files (located in $ROOTDIR/tools/build_options) that"
85    #       echo "  may work with this machine are:"
86    #       for i in $OFLIST ; do
87    #           echo "    $i"
88    #       done
89    #     fi
90        
91      echo "test" > test      echo "test" > test
92      ln -s ./test link      ln -s ./test link
93      RETVAL=$?      RETVAL=$?
94      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
95          p_LN="ln -s"          LN="ln -s"
96        else
97            echo "Error: \"ln -s\" does not appear to work on this system!"
98            echo "  For help, please contact <MITgcm-support@mitgcm.org>."
99            exit 1
100      fi      fi
101      rm -f test link      rm -f test link
102    
103      p_CPP=`which cpp`      if test "x$CPP" = x ; then
104                CPP="cpp -traditional -P"
105      RETVAL=$?      fi
106      if test "x${RETVAL}" = x0 ; then  
107          p_LN="ln -s"      # makedepend is not always available
108        if test "x${MAKEDEPEND}" = x ; then
109          which makedepend >& /dev/null
110          RETVAL=$?
111          if test "x${RETVAL}" = x1 ; then
112             echo "    makedepend was not found. Using xmakedpend instead."
113             MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
114          fi
115      fi      fi
     rm -f test link  
116    
117      # look for possible fortran compilers      # look for possible fortran compilers
118        tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
119      p_FC=      p_FC=
120      for c in f77 g77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 ; do      for c in $tmp ; do
121          which $c > /dev/null 2>&1          rm -f ./hello.f ./hello
122            cat >> hello.f <<EOF
123          program hello
124          do i=1,3
125            print *, 'hello world : ', i
126          enddo
127          end
128    EOF
129            $c -o hello hello.f > /dev/null 2>&1
130          RETVAL=$?          RETVAL=$?
131          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
132              p_FC="$p_FC $c"              p_FC="$p_FC $c"
133          fi          fi
134      done      done
135      echo "Possible FORTRAN compilers appear to be:  "      rm -f ./hello.f ./hello
136      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
137          echo "  None found!!!"          cat 1>&2 <<EOF
138      else  
139          echo "  "$p_FC  Error: No Fortran compilers were found in your path.  Please specify one using:
140      fi  
141        1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
142        2) a command-line option (eg. "-fc NAME"), or
143        3) the MITGCM_FC environment variable.
144    
     # look for possible MPI libraries  
     mpi_libs=  
     mpi_fort=`which mpif77 2>/dev/null`  
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         cat >>test.f <<EOF  
       PROGRAM HELLO  
       DO 10, I=1,10  
       PRINT *,'Hello World'  
    10 CONTINUE  
       STOP  
       END  
145  EOF  EOF
146          eval "$mpi_fort -showme test.f > out"          exit 1
147          RETVAL=$?      else
148          if test "x${RETVAL}" = x0 ; then          echo "  The possible FORTRAN compilers found in your path are:"
149              a=`cat out`          echo "   "$p_FC
150              for i in $a ; do          if test "x$FC" = x ; then
151                  case $i in              FC=`echo $p_FC | $AWK '{print $1}'`
                     -*)  
                         mpi_libs="$mpi_libs $i" ;;  
                 esac  
             done  
             echo "The MPI libs appear to be:"  
             echo "  "$mpi_libs  
152          fi          fi
         rm -f test.f out  
153      fi      fi
154    
155  }      for i in $p_FC ; do
156            p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
157            if test -r $p_OF ; then
158                OPTFILE=$p_OF
159                echo "  The options file:  $p_OF"
160                echo "    appears to match so we'll use it."
161                break
162            fi
163        done
164        if test "x$OPTFILE" = x ; then
165            cat 1>&2 <<EOF
166    
167  parse_options()  {  Error: No options file was found in:  $ROOTDIR/tools/build_options/
168      that matches this platform ("$PLATFORM") and the compilers found in
169      your path.  Please specify an "optfile" using:
170    
171      ac_prev=      1) the command line (eg. "-optfile=path/to/OPTFILE"), or
172      for ac_option in "${OPTIONS[@]}" ; do      2) the MITGCM_OF environment variable.
173    
174      If you need help, please contact the developers at <MITgcm-support@mitgcm.org>.
175    
176    EOF
177            exit 1
178        fi
179        
180    #     # look for possible MPI libraries
181    #     mpi_libs=
182    #     mpi_fort=`which mpif77 2>/dev/null`
183    #     RETVAL=$?
184    #     if test "x${RETVAL}" = x0 ; then
185    #       cat >>test.f <<EOF
186    #       PROGRAM HELLO
187    #       DO 10, I=1,10
188    #       PRINT *,'Hello World'
189    #    10 CONTINUE
190    #       STOP
191    #       END
192    # EOF
193    #       eval "$mpi_fort -showme test.f > out"
194    #       RETVAL=$?
195    #       if test "x${RETVAL}" = x0 ; then
196    #           a=`cat out`
197    #           for i in $a ; do
198    #               case $i in
199    #                   -*)
200    #                       mpi_libs="$mpi_libs $i" ;;
201    #               esac
202    #           done
203    #           echo "The MPI libs appear to be:"
204    #           echo "  "$mpi_libs
205    #       fi
206    #       rm -f test.f out
207    #     fi
208    
         # echo "ac_option = :$ac_option:"  
           
         # If the previous option needs an argument, assign it.  
         if test -n "$ac_prev"; then  
             eval "$ac_prev=\$ac_option"  
             ac_prev=  
             continue  
         fi  
           
         ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`  
           
         case $ac_option in  
               
             -help | --help | -h | --h)  
                 usage ;;  
               
             -nooptfile | --nooptfile)  
                 OPTFILE="NONE" ;;  
             -optfile | --optfile | -of | --of)  
                 ac_prev=optfile ;;  
             -optfile=* | --optfile=* | -of=* | --of=*)  
                 OPTFILE=$ac_optarg ;;  
               
             -pdepend | --pdepend)  
                 ac_prev=pdepend ;;  
             -pdepend=* | --pdepend=*)  
                 PDEPEND=$ac_optarg ;;  
               
             -pdefault | --pdefault)  
                 ac_prev=pdefault ;;  
             -pdefault=* | --pdefault=*)  
                 PDEFAULT=$ac_optarg ;;  
               
             -makefile | -ma)  
                 ac_prev=makefile ;;  
             --makefile=* | -ma=*)  
                 MAKEFILE=$ac_optarg ;;  
               
             -platform | --platform | -pl | --pl)  
                 ac_prev=platform ;;  
             -platform=* | --platform=* | -pl=* | --pl=*)  
                 PLATFORM=$ac_optarg ;;  
   
             -rootdir | --rootdir | -rd | --rd)  
                 ac_prev=rootdir ;;  
             -rootdir=* | --rootdir=* | -rd=* | --rd=*)  
                 ROOTDIR=$ac_optarg ;;  
               
             -mods | --mods | -mo | --mo)  
                 ac_prev=mods ;;  
             -mods=* | --mods=* | -mo=* | --mo=*)  
                 MODS=$ac_optarg ;;  
               
             -disable | --disable)  
                 ac_prev=disable ;;  
             -disable=* | --disable=*)  
                 DISABLE=$ac_optarg ;;  
               
             -enable | --enable)  
                 ac_prev=enable ;;  
             -enable=* | --enable=*)  
                 ENABLE=$ac_optarg ;;  
               
             -noopt | --noopt)  
                 ac_prev=noopt ;;  
             -noopt=* | --noopt=*)  
                 NOOPT=$ac_optarg ;;  
               
 #           -cpp | --cpp)  
 #               ac_prev=cpp ;;  
 #           -cpp=* | --cpp=*)  
 #               CPP=$ac_optarg ;;  
               
             -fortran | --fortran | -fc | --fc)  
                 ac_prev=fc ;;  
             -fc=* | --fc=*)  
                 FC=$ac_optarg ;;  
               
             -ieee | --ieee)  
                 IEEE=1 ;;  
             -noieee | --noieee)  
                 IEEE=0 ;;  
               
             -mpi | --mpi)  
                 MPI=1 ;;  
             -nompi | --nompi)  
                 MPI=0 ;;  
               
             -jam | --jam)  
                 JAM=1 ;;  
             -nojam | --nojam)  
                 JAM=0 ;;  
               
             -*)  
                 echo "Error: unrecognized option: "$ac_option  
                 usage  
                 ;;  
               
             *)  
                 echo "Error: unrecognized argument: "$ac_option  
                 usage  
                 ;;  
               
         esac  
           
     done  
209  }  }
210    
211  #  Parse the package dependency information  #  Parse the package dependency information
# Line 199  get_pdepend_list()  { Line 214  get_pdepend_list()  {
214      #  strip the comments and then convert the dependency file into      #  strip the comments and then convert the dependency file into
215      #  two arrays: PNAME, DNAME      #  two arrays: PNAME, DNAME
216      cat $1 | sed -e 's/#.*$//g' \      cat $1 | sed -e 's/#.*$//g' \
217          | 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} }' \
218          > ./.pd_tmp          > ./.pd_tmp
219      source ./.pd_tmp      source ./.pd_tmp
220      rm -f ./.pd_tmp      rm -f ./.pd_tmp
# Line 222  usage()  { Line 237  usage()  {
237      echo "      -pdepend=NAME | --pdepend=NAME"      echo "      -pdepend=NAME | --pdepend=NAME"
238      echo "    -pdefault NAME | --pdefault NAME"      echo "    -pdefault NAME | --pdefault NAME"
239      echo "      -pdefault=NAME | --pdefault=NAME"      echo "      -pdefault=NAME | --pdefault=NAME"
240      echo "    -makefile NAME | -ma NAME"      echo "    -make NAME | -m NAME"
241      echo "      --makefile=NAME | -ma=NAME"      echo "      --make=NAME | -m=NAME"
242        echo "    -makefile NAME | -mf NAME"
243        echo "      --makefile=NAME | -mf=NAME"
244      echo "    -platform NAME | --platform NAME | -pl NAME | --pl NAME"      echo "    -platform NAME | --platform NAME | -pl NAME | --pl NAME"
245      echo "      -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME"      echo "      -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME"
246      echo "    -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME"      echo "    -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME"
# Line 234  usage()  { Line 251  usage()  {
251      echo "      -disable=NAME | --disable=NAME"      echo "      -disable=NAME | --disable=NAME"
252      echo "    -enable NAME | --enable NAME"      echo "    -enable NAME | --enable NAME"
253      echo "      -enable=NAME | --enable=NAME"      echo "      -enable=NAME | --enable=NAME"
254        echo "    -standarddirs NAME | --standarddirs NAME"
255        echo "      -standarddirs=NAME | --standarddirs=NAME"
256      echo "    -noopt NAME | --noopt NAME"      echo "    -noopt NAME | --noopt NAME"
257      echo "      -noopt=NAME | --noopt=NAME"      echo "      -noopt=NAME | --noopt=NAME"
258  #    echo "    -cpp NAME | --cpp NAME"  #    echo "    -cpp NAME | --cpp NAME"
# Line 255  usage()  { Line 274  usage()  {
274      exit 1      exit 1
275  }  }
276    
277  # Dump all important state  #  Build a CPP macro to automate calling C routines from FORTRAN
278  dump_state()  {  get_fortran_c_namemangling()  {
279      fname=$1      default_nm="#define FC_NAMEMANGLE(X) X ## _"
280      echo " " > $fname      
281        cat > genmake_test.c <<EOF
282    void tcall( char * string ) { tsub( string ); }
283    EOF
284        $MAKE genmake_test.o > genmake_test.log 2>&1
285      RETVAL=$?      RETVAL=$?
286      if test "x${RETVAL}" = x ; then      if test "x$RETVAL" != x0 ; then
287          echo "Error: cannot write to $fname"          cat genmake_test.log >> genmake_errors
288          exit 1          FC_NAMEMANGLE=$default_nm
289            echo
290            echo "WARNING: C test compile fails -- please see \"genmake_errors\""
291            echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'"
292            echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here."
293            return 1
294        fi
295        c_tcall=`nm genmake_test.o | grep tcall | cut -d ' ' -f 3`
296        RETVAL=$?
297        if test "x$RETVAL" != x0 ; then
298            FC_NAMEMANGLE=$default_nm
299            echo
300            echo "WARNING: The \"nm\" command failed."
301            echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'"
302            echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here."
303            return 1
304        fi
305        cat > genmake_tcomp.f <<EOF
306          subroutine tcall( string )
307          character*(*) string
308          call tsub( string )
309          end
310    EOF
311        $FC $FFLAGS $DEFINES -c genmake_tcomp.f > genmake_tcomp.log 2>&1
312        RETVAL=$?
313        if test "x$RETVAL" != x0 ; then
314            cat genmake_tcomp.log >> genmake_errors
315            FC_NAMEMANGLE=$default_nm
316            echo
317            echo "WARNING: FORTRAN test compile fails -- please see \"genmake_errors\""
318            echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'"
319            echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here."
320            return 1
321        fi
322        f_tcall=`nm genmake_tcomp.o | grep tcall | cut -d ' ' -f 3`
323        RETVAL=$?
324        if test "x$RETVAL" != x0 ; then
325            FC_NAMEMANGLE=$default_nm
326            echo
327            echo "WARNING: The \"nm\" command failed."
328            echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'"
329            echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here."
330            return 1
331      fi      fi
     echo "makefile "$makefile > $fname  
 }  
332    
333        c_a=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
334        f_a=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
335        c_b=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
336        f_b=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
337    
338  #eh3 # This is the generic configuration.      nmangle="X"
339  #eh3 set LN         = ( 'ln -s' )      if test "x$c_a" != "x$f_a" ; then
340  #eh3 set CPP        = ( '/lib/cpp -P' )          comm="echo x$f_a | sed -e 's|x$c_a||'"
341  #eh3 set S64        = ( '$(TOOLSDIR)/set64bitConst.sh' )          a=`eval $comm`
342  #eh3 set KPP        = (  )          nmangle="$a ## $nmangle"
343  #eh3 set FC         = ( 'f77' )      fi
344  #eh3 set LINK       = $FC      if test "x$c_b" != "x$f_b" ; then
345  #eh3 set MAKEDEPEND = ( 'makedepend' )          comm="echo x$f_b | sed -e 's|x$c_b||'"
346  #eh3 set INCLUDES   = ( -I. )          b=`eval $comm`
347  #eh3 set FFLAGS     = (  )          nmangle="$nmangle ## $b"
348  #eh3 set FOPTIM     = (  )      fi
349  #eh3 set CFLAGS     = (  )  
350  #eh3 set KFLAGS1    = (  )      FC_NAMEMANGLE="#define FC_NAMEMANGLE(X)  $nmangle"
351  #eh3 set KFLAGS2    = (  )  
352  #eh3 set LIBS       = (  )      #  cleanup the testing files
353  #eh3 set KPPFILES   = (  )      rm -f genmake_tcomp.* genmake_test.*
354  #eh3 if (! $?NOOPTFILES ) set NOOPTFILES = (  )  }
 #eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = (  )  
355    
356  #  Set defaults here  #  Set defaults here
357    COMMANDL="$0 $@"
358    
359  PLATFORM=  PLATFORM=
360  LN=  LN=
361  S64=  S64=
362  KPP=  KPP=
363  FC=  FC=
364  LINK=  LINK=
365    # DEFINES="-DWORDLENGTH=4"
366    DEFINES=
367  PACKAGES=  PACKAGES=
368  ENABLE=  ENABLE=
369  DISABLE=  DISABLE=
370  MAKEFILE=  MAKEFILE=
371  MAKEDEPEND=  MAKEDEPEND=
372  PDEPEND=  PDEPEND=
373    DUMPSTATE=t
374  PDEFAULT=  PDEFAULT=
375  OPTFILE=  OPTFILE=
376  INCLUDES="-I."  INCLUDES="-I."
# Line 313  KPPFILES= Line 384  KPPFILES=
384  NOOPTFILES=  NOOPTFILES=
385  NOOPTFLAGS=  NOOPTFLAGS=
386    
387    # DEFINES checked by test compilation
388    HAVE_SYSTEM=
389    HAVE_FDATE=
390    FC_NAMEMANGLE=
391    
392  MODS=  MODS=
393  TOOLSDIR=  TOOLSDIR=
394  SOURCEDIRS=  SOURCEDIRS=
395  INCLUDEDIRS=  INCLUDEDIRS=
396    STANDARDDIRS=
397    
398  PWD=`pwd`  PWD=`pwd`
399  MAKE=make  MAKE=make
400    AWK=awk
401  THISHOSTNAME=`hostname`  THISHOSTNAME=`hostname`
402  THISCWD=`pwd`  THISCWD=`pwd`
403  THISDATE=`date`  THISDATE=`date`
404  MACHINE=`uname -a`  MACHINE=`uname -a`
405    EXECUTABLE=
406    EXEHOOK=
407    EXEDIR=
408    PACKAGES_CONF=
409    IEEE=
410    if test "x$MITGCM_IEEE" != x ; then
411        IEEE=$MITGCM_IEEE
412    fi
413    
414    AUTODIFF_PKG_USED=f
415    AD_OPTFILE=
416    TAF=
417    AD_TAF_FLAGS=
418    FTL_TAF_FLAGS=
419    SVD_TAF_FLAGS=
420    TAF_EXTRA=
421    TAMC=
422    AD_TAMC_FLAGS=
423    FTL_TAF_FLAGS=
424    SVD_TAMC_FLAGS=
425    TAMC_EXTRA=
426    
427    
428    #  The following state can be set directly by command-line switches
429    gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"
430    gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS"
431    
432    #  The following state is not directly set by command-line switches
433    gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "
434    gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
435    gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"
436    gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
437    gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE"
438    
439    #  The following are all related to adjoint/tangent-linear stuff
440    gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
441    gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
442    gm_s12="TAF_EXTRA TAMC_EXTRA"
443    
444    gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7"
445    gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
446    
447    
448  echo  echo
449  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
450  gm_local="./gm_local"  gm_local="genmake_local"
451    for i in . $MODS ; do
452        if test -r $i/$gm_local ; then
453            source $i/$gm_local
454            break
455        fi
456    done
457  echo -n "  getting local config information:  "  echo -n "  getting local config information:  "
458  if test -e $gm_local ; then  if test -e $gm_local ; then
459      echo "using $gm_local"      echo "using $gm_local"
# Line 349  fi Line 475  fi
475  #   n=$(( $n + 1 ))  #   n=$(( $n + 1 ))
476  #done  #done
477  #parse_options  #parse_options
   
478  ac_prev=  ac_prev=
479  for ac_option ; do  for ac_option ; do
480    
# Line 370  for ac_option ; do Line 495  for ac_option ; do
495          -nooptfile | --nooptfile)          -nooptfile | --nooptfile)
496              OPTFILE="NONE" ;;              OPTFILE="NONE" ;;
497          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
498              ac_prev=optfile ;;              ac_prev=OPTFILE ;;
499          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
500              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
501                    
502            -adoptfile | --adoptfile | -ad | --ad)
503                ac_prev=AD_OPTFILE ;;
504            -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
505                AD_OPTFILE=$ac_optarg ;;
506            
507          -pdepend | --pdepend)          -pdepend | --pdepend)
508              ac_prev=pdepend ;;              ac_prev=PDEPEND ;;
509          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
510              PDEPEND=$ac_optarg ;;              PDEPEND=$ac_optarg ;;
511                    
512          -pdefault | --pdefault)          -pdefault | --pdefault)
513              ac_prev=pdefault ;;              ac_prev=PDEFAULT ;;
514          -pdefault=* | --pdefault=*)          -pdefault=* | --pdefault=*)
515              PDEFAULT=$ac_optarg ;;              PDEFAULT=$ac_optarg ;;
516                    
517          -makefile | -ma)          -make | --make | -m | --m)
518              ac_prev=makefile ;;              ac_prev=MAKE ;;
519          --makefile=* | -ma=*)          -make=* | --make=* | -m=* | --m=*)
520                MAKE=$ac_optarg ;;
521            
522            -makefile | --makefile | -ma | --ma)
523                ac_prev=MAKEFILE ;;
524            -makefile=* | --makefile=* | -ma=* | --ma=*)
525              MAKEFILE=$ac_optarg ;;              MAKEFILE=$ac_optarg ;;
526                    
527          -platform | --platform | -pl | --pl)          -platform | --platform | -pl | --pl)
528              ac_prev=platform ;;              ac_prev=PLATFORM ;;
529          -platform=* | --platform=* | -pl=* | --pl=*)          -platform=* | --platform=* | -pl=* | --pl=*)
530              PLATFORM=$ac_optarg ;;              PLATFORM=$ac_optarg ;;
531                    
532          -rootdir | --rootdir | -rd | --rd)          -rootdir | --rootdir | -rd | --rd)
533              ac_prev=rootdir ;;              ac_prev=ROOTDIR ;;
534          -rootdir=* | --rootdir=* | -rd=* | --rd=*)          -rootdir=* | --rootdir=* | -rd=* | --rd=*)
535              ROOTDIR=$ac_optarg ;;              ROOTDIR=$ac_optarg ;;
536                    
537          -mods | --mods | -mo | --mo)          -mods | --mods | -mo | --mo)
538              ac_prev=mods ;;              ac_prev=MODS ;;
539          -mods=* | --mods=* | -mo=* | --mo=*)          -mods=* | --mods=* | -mo=* | --mo=*)
540              MODS=$ac_optarg ;;              MODS=$ac_optarg ;;
541                    
542          -disable | --disable)          -disable | --disable)
543              ac_prev=disable ;;              ac_prev=DISABLE ;;
544          -disable=* | --disable=*)          -disable=* | --disable=*)
545              DISABLE=$ac_optarg ;;              DISABLE=$ac_optarg ;;
546                    
547          -enable | --enable)          -enable | --enable)
548              ac_prev=enable ;;              ac_prev=ENABLE ;;
549          -enable=* | --enable=*)          -enable=* | --enable=*)
550              ENABLE=$ac_optarg ;;              ENABLE=$ac_optarg ;;
551                    
552            -standarddirs | --standarddirs)
553                ac_prev=STANDARDDIRS ;;
554            -standarddirs=* | --standarddirs=*)
555                STANDARDDIRS=$ac_optarg ;;
556    
557          -noopt | --noopt)          -noopt | --noopt)
558              ac_prev=noopt ;;              ac_prev=NOOPT ;;
559          -noopt=* | --noopt=*)          -noopt=* | --noopt=*)
560              NOOPT=$ac_optarg ;;              NOOPT=$ac_optarg ;;
561                    
# Line 425  for ac_option ; do Line 565  for ac_option ; do
565  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
566                            
567          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
568              ac_prev=fc ;;              ac_prev=FC ;;
569          -fc=* | --fc=*)          -fc=* | --fc=*)
570              FC=$ac_optarg ;;              FC=$ac_optarg ;;
571                    
572          -ieee | --ieee)          -ieee | --ieee)
573              IEEE=1 ;;              IEEE=true ;;
574          -noieee | --noieee)          -noieee | --noieee)
575              IEEE=0 ;;              IEEE= ;;
576                    
577          -mpi | --mpi)          -mpi | --mpi)
578              MPI=1 ;;              MPI=true ;;
579          -nompi | --nompi)          -nompi | --nompi)
580              MPI=0 ;;              MPI= ;;
581                    
582          -jam | --jam)          -jam | --jam)
583              JAM=1 ;;              JAM=1 ;;
584          -nojam | --nojam)          -nojam | --nojam)
585              JAM=0 ;;              JAM=0 ;;
586                    
587            -ds | --ds)
588                DUMPSTATE=t ;;
589            
590            -taf_extra | --taf_extra)
591                ac_prev=TAF_EXTRA ;;
592            -taf_extra=* | --taf_extra=*)
593                TAF_EXTRA=$ac_optarg ;;
594    
595            -tamc_extra | --tamc_extra)
596                ac_prev=TAMC_EXTRA ;;
597            -tamc_extra=* | --tamc_extra=*)
598                TAMC_EXTRA=$ac_optarg ;;
599    
600          -*)          -*)
601              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
602              usage              usage
# Line 458  for ac_option ; do Line 611  for ac_option ; do
611            
612  done  done
613    
614    if test -f ./.genmakerc ; then
615        echo
616        echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
617        echo "  file.  This file format is no longer supported.  Please see:"
618        echo
619        echo "    http://mitgcm.org/devel_HOWTO/"
620        echo
621        echo "  for directions on how to setup and use the new \"genmake2\" input"
622        echo "  files and send an email to MITgcm-support@mitgcm.org if you want help."
623        echo
624    fi
625    
626    if test "x${ROOTDIR}" = x ; then
627        if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
628            ROOTDIR=".."
629        else
630            for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
631                if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
632                    ROOTDIR=$d
633                    echo -n "Warning:  ROOTDIR was not specified but there appears to be"
634                    echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
635                    break
636                fi
637            done
638        fi
639    fi
640    if test "x${ROOTDIR}" = x ; then
641        echo "Error: Cannot determine ROOTDIR for MITgcm code."
642        echo "  Please specify a ROOTDIR using either an options "
643        echo "  file or a command-line option."
644        exit 1
645    fi
646    if test ! -d ${ROOTDIR} ; then
647        echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!"
648        exit 1
649    fi
650    
651  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
652  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
653      echo "Warning: no OPTFILE specified so we'll look for possible settings"      if test "x$MITGCM_OF" = x ; then
654      printf "\n===  Searching for possible settings for OPTFILE  ===\n"          echo "Warning: no OPTFILE specified so we'll look for possible settings"
655      find_possible_configs          printf "\n===  Searching for possible settings for OPTFILE  ===\n"
656  else          find_possible_configs
     if test "x$OPTFILE" = xNONE ; then  
         echo "    OPTFILE=NONE so we'll try to use default settings"  
657      else      else
658          if test -f "$OPTFILE" -a -r "$OPTFILE" ; then          OPTFILE=$MITGCM_OF
659              echo "    using OPTFILE=\"$OPTFILE\""      fi
660              source "$OPTFILE"  fi
661              RETVAL=$?  if test "x$OPTFILE" != xNONE ; then
662              if test "x$RETVAL" != x0 ; then      if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
663                  echo -n "Error: failed to source OPTFILE \"$OPTFILE\""          echo "    using OPTFILE=\"$OPTFILE\""
664                  echo "--please check that variable syntax is bash-compatible"          source "$OPTFILE"
665                  exit 1          RETVAL=$?
666              fi          if test "x$RETVAL" != x0 ; then
667          else              echo -n "Error: failed to source OPTFILE \"$OPTFILE\""
668              echo "Error: can't read OPTFILE=\"$OPTFILE\""              echo "--please check that variable syntax is bash-compatible"
669              exit 1              exit 1
670          fi          fi
671            if test "x$DUMPSTATE" != xf ; then
672                cp -f $OPTFILE "genmake_optfile"
673            fi
674        else
675            echo "Error: can't read OPTFILE=\"$OPTFILE\""
676            exit 1
677        fi
678    fi
679    
680    echo "  getting AD_OPTFILE information:  "
681    if test "x${AD_OPTFILE}" = x ; then
682        if test "x$MITGCM_AD_OF" = x ; then
683            AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
684        else
685            AD_OPTFILE=$MITGCM_AD_OF
686        fi
687    fi
688    if test "x${AD_OPTFILE}" != xNONE ; then
689        if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then
690            echo "    using AD_OPTFILE=\"$AD_OPTFILE\""
691            source "$AD_OPTFILE"
692            RETVAL=$?
693            if test "x$RETVAL" != x0 ; then
694                echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
695                echo "--please check that variable syntax is bash-compatible"
696                exit 1
697            fi
698            if test "x$DUMPSTATE" != xf ; then
699                cp -f $AD_OPTFILE "genmake_ad_optfile"
700            fi
701        else
702            echo "Error: can't read AD_OPTFILE=\"$AD_OPTFILE\""
703            exit 1
704      fi      fi
705  fi  fi
706    
707    #  Check that FC, LINK, CPP, and S64 are defined.  If not, complain
708    #  and abort!
709    if test "x$FC" = x ; then
710        cat <<EOF 1>&2
711    
712    Error: no Fortran compiler: please specify using one of the following:
713      1) within the options file ("FC=...") as specified by "-of=OPTFILE"
714      2) the "-fc=XXX" command-line option
715      3) the "./genmake_local" file
716    EOF
717        exit 1
718    fi
719    if test "x$LINK" = x ; then
720        LINK=$FC
721    fi
722    if test "x$CPP" = x ; then
723        CPP="cpp"
724    fi
725    echo "#define A a" | $CPP > test_cpp 2>&1
726    RETVAL=$?
727    if test "x$RETVAL" != x0 ; then
728        cat <<EOF 1>&2
729    
730    Error: C pre-processor "$CPP" failed the test case: please specify using:
731    
732      1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
733      2) the "./genmake_local" file
734      3) with the CPP environment variable
735    
736    EOF
737        exit 1
738    else
739        rm -f test_cpp
740    fi
741    if test "x$MAKEDEPEND" = x ; then
742        MAKEDEPEND=makedepend
743    fi
744    
745    
746    printf "\n===  Checking system libraries  ===\n"
747    echo -n "  Do we have the system() command using $FC...  "
748    cat > genmake_tcomp.f <<EOF
749          program hello
750          call system('echo hi')
751          end
752    EOF
753    $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1
754    RETVAL=$?
755    if test "x$RETVAL" = x0 ; then
756        HAVE_SYSTEM=t
757        DEFINES="$DEFINES -DHAVE_SYSTEM"
758        echo "yes"
759    else
760        HAVE_SYSTEM=
761        echo "no"
762    fi
763    rm -f genmake_tcomp*
764    
765    echo -n "  Do we have the fdate() command using $FC...  "
766    cat > genmake_tcomp.f <<EOF
767          program hello
768          CHARACTER(128) string
769          string = ' '
770          call fdate( string )
771          print *, string
772          end
773    EOF
774    $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1
775    RETVAL=$?
776    if test "x$RETVAL" = x0 ; then
777        HAVE_FDATE=t
778        DEFINES="$DEFINES -DHAVE_FDATE"
779        echo "yes"
780    else
781        HAVE_FDATE=
782        echo "no"
783    fi
784    rm -f genmake_tcomp*
785    
786    echo "  The name mangling convention for $FC is...  "
787    #FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) X ## _"
788    if test "x$FC_NAMEMANGLE" = x ; then
789        get_fortran_c_namemangling
790    fi
791    echo "    '$FC_NAMEMANGLE'"
792    echo "$FC_NAMEMANGLE" > FC_NAMEMANGLE.h.template
793    cmp FC_NAMEMANGLE.h FC_NAMEMANGLE.h.template > /dev/null 2>&1
794    RETVAL=$?
795    if test "x$RETVAL" != x0 ; then
796        mv -f FC_NAMEMANGLE.h.template FC_NAMEMANGLE.h
797    fi
798    
799    
800  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
801  echo -n "  Adding MODS directories:  "  echo -n "  Adding MODS directories:  "
802  for d in $MODS ; do  for d in $MODS ; do
# Line 505  if test "x${PLATFORM}" = x ; then Line 819  if test "x${PLATFORM}" = x ; then
819      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
820  fi  fi
821    
 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  
   
822  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
823      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then
824          EXEDIR=../exe          EXEDIR=../exe
# Line 549  if test ! -d ${TOOLSDIR} ; then Line 838  if test ! -d ${TOOLSDIR} ; then
838      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"
839      exit 1      exit 1
840  fi  fi
841    if test "x$S64" = x ; then
842        S64='$(TOOLSDIR)/set64bitConst.sh'
843    fi
844    
845  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
846    
# Line 587  echo "  getting package dependency info Line 879  echo "  getting package dependency info
879  #  Strip the comments and then convert the dependency file into  #  Strip the comments and then convert the dependency file into
880  #  two arrays: PNAME, DNAME  #  two arrays: PNAME, DNAME
881  cat $PDEPEND | sed -e 's/#.*$//g' \  cat $PDEPEND | sed -e 's/#.*$//g' \
882      | 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}' \
883      > ./.pd_tmp      > ./.pd_tmp
884  RETVAL=$?  RETVAL=$?
885  if test ! "x${RETVAL}" = x0 ; then  if test ! "x${RETVAL}" = x0 ; then
# Line 597  fi Line 889  fi
889  source ./.pd_tmp  source ./.pd_tmp
890  rm -f ./.pd_tmp  rm -f ./.pd_tmp
891    
892    #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"
893    #  file should eventually be added so that, for convenience, one can
894    #  specify groups of packages using names like "ocean" and "atmosphere".
895  echo  -n "  checking default package list:  "  echo  -n "  checking default package list:  "
896  if test "x${PDEFAULT}" = x ; then  if test "x${PDEFAULT}" = x ; then
897        for i in "." $MODS ; do
898            if test -r $i"/packages.conf" ; then
899                    PDEFAULT=$i"/packages.conf"
900                    break
901            fi
902        done
903    fi
904    if test "x${PDEFAULT}" = x ; then
905      PDEFAULT="$ROOTDIR/pkg/pkg_default"      PDEFAULT="$ROOTDIR/pkg/pkg_default"
906  fi  fi
907  if test "x${PDEFAULT}" = xNONE ; then  if test "x${PDEFAULT}" = xNONE ; then
# Line 610  else Line 913  else
913      else      else
914          echo "  using PDEFAULT=\"$PDEFAULT\""          echo "  using PDEFAULT=\"$PDEFAULT\""
915          #  Strip the comments and add all the names          #  Strip the comments and add all the names
916          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | awk '(NF>0){print $0}'`          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
917          RETVAL=$?          RETVAL=$?
918          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
919              echo -n "Error: can't parse default package list "              echo -n "Error: can't parse default package list "
# Line 620  else Line 923  else
923          for i in $def ; do          for i in $def ; do
924              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
925          done          done
926          echo "    packages are:  $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
927            expand_pkg_groups
928            echo "    after group expansion packages are:  $PACKAGES"
929      fi      fi
930  fi  fi
931    
# Line 639  for p in $PACKAGES ; do Line 944  for p in $PACKAGES ; do
944  done  done
945  PACKAGES="$pack"  PACKAGES="$pack"
946  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
947  rm -f ./.tmp_pack  echo "" > ./.tmp_pack
948  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
949  for i in $PACKAGES ; do  for i in $PACKAGES ; do
950      if test ! -d "$ROOTDIR/pkg/$i" ; then      if test ! -d "$ROOTDIR/pkg/$i" ; then
# Line 730  for i in $PACKAGES ; do Line 1035  for i in $PACKAGES ; do
1035      if test -d $adr ; then      if test -d $adr ; then
1036          SOURCEDIRS="$SOURCEDIRS $adr"          SOURCEDIRS="$SOURCEDIRS $adr"
1037          INCLUDEDIRS="$INCLUDEDIRS $adr"          INCLUDEDIRS="$INCLUDEDIRS $adr"
1038            if test "x$i" = xautodiff ; then
1039                AUTODIFF_PKG_USED=t
1040            fi
1041      else      else
1042          echo "Error: the directory \"$adr\" for package $i doesn't exist"          echo "Error: the directory \"$adr\" for package $i doesn't exist"
1043          exit 1          exit 1
1044      fi      fi
1045  done  done
1046    
 #  This is compatible with the old genmake.  The "DISABLE_*" flags  
 #  need to be replaced by the "ALLOW_*" flags set below.  
 #  
 # echo -n "  Setting package-specific CPP flags:  "  
 # pkrm=( mom_fluxform mom_vecinv generic_advdiff )  
 # pkrmdef=( -DDISABLE_MOM_FLUXFORM -DDISABLE_MOM_VECINV -DDISABLE_GENERIC_ADVDIFF -DDISABLE_DEBUGMODE )  
 # echo -n "  "  
 # i=0  
 # while test $i -lt "${#pkrm[@]}" ; do  
 #     echo "$PACKAGES" | grep "${pk[$i]}" > /dev/null 2>&1  
 #     RETVAL=$?  
 #     if test "x$RETVAL" = x1 ; then  
 #       DEFINES="$DEFINES ${pkdef[$i]}"  
 #       echo -n " ${pkdef[$i]}"  
 #     fi  
 #     i=$(( $i + 1 ))  
 # done  
 # echo  
1047    
1048  echo "  Setting package-specific CPP flags in CPP_OPTIONS.h:"  # Create a list of #define and #undef to enable/disable packages
1049  CPP_OPTIONS=  PACKAGES_DOT_H=PACKAGES_CONFIG.h
1050  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  
1051  C=== GENMAKE v2 ===  C=== GENMAKE v2 ===
1052  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
1053  C  them only if you know what you're doing.  In general, you should  C  edit anything below these comments.  In general, you should
1054  C  add or remove packages by re-running genmake with different  C  add or remove packages by re-running genmake with different
1055  C  "-enable" and/or "-disable" options.  C  "-enable" and/or "-disable" options.
1056    
1057    #ifndef PACKAGES_H
1058    #define PACKAGES_H
1059    
1060  C  Packages disabled by genmake:  C  Packages disabled by genmake:
1061  EOF  EOF
1062  #  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 807  for n in $names ; do Line 1075  for n in $names ; do
1075              fi              fi
1076          done          done
1077          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1078              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`
1079              echo "#undef $undef" >> CPP_OPTIONS.h.tmp              echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"
   
 #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  
             case $n in  
                 mom_fluxform)  
                     DEFINES="$DEFINES -DDISABLE_MOM_FLUXFORM"  
                     ;;  
                 mom_vecinv)  
                     DEFINES="$DEFINES -DDISABLE_MOM_VECINV"  
                     ;;  
                 generic_advdiff)  
                     DEFINES="$DEFINES -DDISABLE_GENERIC_ADVDIFF"  
                     ;;  
                 debug)  
                     DEFINES="$DEFINES -DDISABLE_DEBUGMODE"  
                     ;;  
             esac  
 #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  
   
1080          fi          fi
1081      fi      fi
1082  done  done
1083  cat <<EOF >>CPP_OPTIONS.h.tmp  cat <<EOF >>$PACKAGES_DOT_H".tmp"
1084    
1085  C  Packages enabled by genmake:  C  Packages enabled by genmake:
1086  EOF  EOF
1087  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1088      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`
1089      echo "#define $def" >> CPP_OPTIONS.h.tmp      echo "#define $def" >> $PACKAGES_DOT_H".tmp"
1090    #eh3 DEFINES="$DEFINES -D$def"
1091    
1092  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
1093      case $i in      case $i in
1094          aim_v23)          aim_v23)
1095              echo "#define   ALLOW_AIM" >> CPP_OPTIONS.h.tmp              echo "#define   ALLOW_AIM" >> $PACKAGES_DOT_H".tmp"
1096                DEFINES="$DEFINES -DALLOW_AIM"
1097                echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"
1098              ;;              ;;
1099      esac      esac
1100  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
1101    
1102  done  done
1103  mv -f CPP_OPTIONS.h.tmp CPP_OPTIONS.h  cat <<EOF >>$PACKAGES_DOT_H".tmp"
1104    
1105    #endif /* PACKAGES_H */
1106    EOF
1107    
1108    if test ! -f $PACKAGES_DOT_H ; then
1109        mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1110    else
1111        cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1112        RETVAL=$?
1113        if test "x$RETVAL" = x0 ; then
1114            rm -f $PACKAGES_DOT_H".tmp"
1115        else
1116            mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"
1117            mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1118        fi
1119    fi
1120    
1121  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
1122  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
1123  STANDARDDIRS=${STANDARDDIRS:-"eesupp model"}  if test "x$STANDARDDIRS" = x ; then
1124        STANDARDDIRS="eesupp model"
1125    fi
1126  for d in $STANDARDDIRS ; do  for d in $STANDARDDIRS ; do
1127      adr="$ROOTDIR/$d/src"      adr="$ROOTDIR/$d/src"
1128      if test ! -d $adr ; then      if test ! -d $adr ; then
# Line 871  for d in $STANDARDDIRS ; do Line 1142  for d in $STANDARDDIRS ; do
1142      fi      fi
1143  done  done
1144    
1145    echo "  Searching for CPP_OPTIONS.h in order to warn about the presence"
1146    echo "    of \"#define ALLOW_PKGNAME\"-type statements:"
1147    CPP_OPTIONS=
1148    spaths=". $INCLUDEDIRS"
1149    for i in $spaths ; do
1150        try="$i/CPP_OPTIONS.h"
1151        #  echo -n "    trying $try : "
1152        if test -f $try -a -r $try ; then
1153            echo "    found CPP_OPTIONS=\"$try\""
1154            CPP_OPTIONS="$try"
1155            break
1156        fi
1157    done
1158    if test "x$CPP_OPTIONS" = x ; then
1159        echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"
1160        exit 1
1161    fi
1162    # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
1163    names=`ls -1 "$ROOTDIR/pkg"`
1164    for n in $names ; do
1165        test_for_package_in_cpp_options $CPP_OPTIONS $n
1166    done
1167    
1168    
1169    #  Here, we build the list of files to be "run through" the adjoint
1170    #  compiler.
1171    if test -f ./ad_files ; then
1172        rm -f ./ad_files
1173    fi
1174    echo "  Creating the list of files for the adjoint compiler."
1175    for i in $SOURCEDIRS ; do
1176        list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
1177        for j in $list_files ; do
1178            cat $i/$j >> ad_files
1179        done
1180    done
1181    
1182    cat <<EOF > adjoint_sed
1183    s/call adopen(/call adopen ( mythid,\\
1184         \&           /g
1185    s/call adclose(/call adclose( mythid,\\
1186         \&           /g
1187    s/call adread(/call adread ( mythid,\\
1188         \&           /g
1189    s/call adwrite(/call adwrite( mythid,\\
1190         \&           /g
1191    
1192    EOF
1193    
1194  echo  echo
1195  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
1196  echo "  setting INCLUDES"  echo "  setting INCLUDES"
1197  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
1198      if test -d $i ; then      if ! test -d $i ; then
1199          INCLUDES="$INCLUDES -I$i"  #       INCLUDES="$INCLUDES -I$i"
1200      else  #   else
1201          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
1202      fi      fi
1203  done  done
# Line 892  echo -n 'SRCFILES = '    > srclist.inc Line 1211  echo -n 'SRCFILES = '    > srclist.inc
1211  echo -n 'CSRCFILES = '   > csrclist.inc  echo -n 'CSRCFILES = '   > csrclist.inc
1212  echo -n 'F90SRCFILES = ' > f90srclist.inc  echo -n 'F90SRCFILES = ' > f90srclist.inc
1213  echo -n 'HEADERFILES = ' > hlist.inc  echo -n 'HEADERFILES = ' > hlist.inc
1214  alldirs=". $SOURCEDIRS $INCLUDEDIRS"  echo -n 'AD_FLOW_FILES = ' > ad_flow_files.inc
1215    alldirs="$SOURCEDIRS $INCLUDEDIRS ."
1216  for d in $alldirs ; do  for d in $alldirs ; do
1217      deplist=      deplist=
1218      sfiles=`( cd $d; echo *.[h,c,F] )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
1219      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
1220      for sf in $sfiles ; do      for sf in $sfiles ; do
1221          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
1222              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
1223                  extn=`echo $sf | awk -F '.' '{print $NF}'`                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`
1224                  touch .links.tmp/$sf                  touch .links.tmp/$sf
1225                  deplist="$deplist $sf"                  deplist="$deplist $sf"
1226                  case $extn in                  case $extn in
# Line 920  for d in $alldirs ; do Line 1240  for d in $alldirs ; do
1240                          echo    " \\"  >> hlist.inc                          echo    " \\"  >> hlist.inc
1241                          echo -n " $sf" >> hlist.inc                          echo -n " $sf" >> hlist.inc
1242                          ;;                          ;;
1243                        flow)
1244                            echo    " \\"  >> ad_flow_files.inc
1245                            echo -n " $sf" >> ad_flow_files.inc
1246                            ;;
1247                  esac                  esac
1248              fi              fi
1249          fi          fi
# Line 936  echo "" >> srclist.inc Line 1260  echo "" >> srclist.inc
1260  echo "" >> csrclist.inc  echo "" >> csrclist.inc
1261  echo "" >> f90srclist.inc  echo "" >> f90srclist.inc
1262  echo "" >> hlist.inc  echo "" >> hlist.inc
1263    echo "" >> ad_flow_files.inc
1264    
1265  if test -e $MAKEFILE ; then  if test -e $MAKEFILE ; then
1266      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
# Line 949  echo "# by the command:" >> $MAKEFILE Line 1274  echo "# by the command:" >> $MAKEFILE
1274  echo "#    $0 $@" >> $MAKEFILE  echo "#    $0 $@" >> $MAKEFILE
1275  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
1276  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE
1277    
1278    EXE_AD=$EXECUTABLE"_ad"
1279    EXE_FTL=$EXECUTABLE"_ftl"
1280    EXE_SVD=$EXECUTABLE"_svd"
1281    
1282  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1283  #  #
1284  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
# Line 977  EXEDIR      = ${EXEDIR} Line 1307  EXEDIR      = ${EXEDIR}
1307  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
1308  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIR}
1309    
1310    #eh3  new defines for the adjoint work
1311    AUTODIFF    = ${ROOTDIR}/pkg/autodiff
1312    EXE_AD      = ${EXE_AD}
1313    EXE_FTL     = ${EXE_FTL}
1314    EXE_SVD     = ${EXE_SVD}
1315    
1316  EOF  EOF
1317    
1318  #  Note: figure out some way to add Hyades JAM libraries here  #  Note: figure out some way to add Hyades JAM libraries here
# Line 1022  MAKEFILE=${MAKEFILE} Line 1358  MAKEFILE=${MAKEFILE}
1358    
1359  EOF  EOF
1360    
1361  cat srclist.inc    >> $MAKEFILE  cat srclist.inc       >> $MAKEFILE
1362  cat csrclist.inc   >> $MAKEFILE  cat csrclist.inc      >> $MAKEFILE
1363  cat f90srclist.inc >> $MAKEFILE  cat f90srclist.inc    >> $MAKEFILE
1364  cat hlist.inc      >> $MAKEFILE  cat hlist.inc         >> $MAKEFILE
1365    cat ad_flow_files.inc >> $MAKEFILE
1366    echo               >> $MAKEFILE
1367  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE
1368  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE
1369  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
1370    
1371  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
1372    rm -f ad_flow_files.inc
1373    
1374  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1375    
# Line 1043  all: \$(EXECUTABLE) Line 1382  all: \$(EXECUTABLE)
1382  depend:  depend:
1383          @make links          @make links
1384          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
1385          ../../../tools/f90mkdepend >> \$(MAKEFILE)          ${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE)
1386    
1387  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES)
1388    
# Line 1054  output.txt: \$(EXECUTABLE) Line 1393  output.txt: \$(EXECUTABLE)
1393          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
1394    
1395  clean:  clean:
1396            -cat AD_CONFIG.template > AD_CONFIG.h
1397          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl}          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl}
1398  Clean:  Clean:
1399          @make clean          @make clean
1400          @make cleanlinks          @make cleanlinks
1401          -rm -f Makefile.bak          -rm -f Makefile.bak genmake_state genmake_*optfile make.log
1402  CLEAN:  CLEAN:
1403          @make Clean          @make Clean
1404          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
1405          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
1406          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1407          -rm -f \$(EXECUTABLE)          -rm -f \$(EXECUTABLE) output.txt
1408    
1409    #eh3 Makefile: makefile
1410  makefile:  makefile:
1411          ${0} $@          ${0} $@
1412  cleanlinks:  cleanlinks:
# Line 1089  cleanlinks: Line 1430  cleanlinks:
1430  .p.f:  .p.f:
1431          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
1432    
1433    #=========================================
1434    #===  Automatic Differentiation Rules  ===
1435    
1436    TAMC           = ${TAMC}
1437    TAF            = ${TAF}
1438    
1439    TAF_EXTRA      = ${TAF_EXTRA}
1440    TAMC_EXTRA     = ${TAMC_EXTRA}
1441    
1442    EOF
1443    
1444    ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS"
1445    ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF_FLAGS"
1446    ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
1447    for i in $ad_vars ; do
1448        name=$i
1449        t1="t2=\$"`echo $i`
1450        eval $t1
1451        printf "%-20s = " $name >> $MAKEFILE
1452        echo $t2 >> $MAKEFILE
1453    done
1454    
1455    echo "  Add the source list for AD code generation"
1456    echo >> $MAKEFILE
1457    echo -n "AD_FILES = " >> $MAKEFILE
1458    AD_FILES=`cat ad_files`
1459    for i in $AD_FILES ; do
1460        echo    " \\" >> $MAKEFILE
1461        echo -n " $i" >> $MAKEFILE
1462    done
1463    echo >> $MAKEFILE
1464    rm -f ad_files
1465    
1466    cat >>$MAKEFILE <<EOF
1467    
1468    # ... AD ...
1469    adall: ad_taf
1470    adtaf: ad_taf_output.f
1471    adtamc: ad_tamc_output.f
1472    
1473    ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1474            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
1475            @make \$(F77FILES)
1476            @make \$(AD_FLOW_FILES)
1477            cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f
1478    
1479    ad_taf_output.f: ad_input_code.f
1480            \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f
1481            cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f
1482    
1483    ad_taf: ad_taf_output.o \$(OBJFILES)
1484            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
1485    
1486    ad_tamc_output.f: ad_input_code.f
1487            \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f
1488            cat ad_input_code_ad.f | sed -f adjoint_sed > ad_tamc_output.f
1489    
1490    ad_tamc: ad_tamc_output.o \$(OBJFILES)
1491            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
1492    
1493    
1494    # ... FTL ...
1495    ftlall: ftl_taf
1496    ftltaf: ftl_taf_output.f
1497    ftltamc: ftl_tamc_output.f
1498    
1499    ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1500            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
1501            @make \$(F77FILES)
1502            @make \$(AD_FLOW_FILES)
1503            cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f
1504    
1505    ftl_taf_output.f: ftl_input_code.f
1506            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f
1507            cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f
1508    
1509    ftl_taf: ftl_taf_output.o \$(OBJFILES)
1510            \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
1511    
1512    ftl_tamc_output.f: ftl_input_code.f
1513            \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f
1514            cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_tamc_output.f
1515    
1516    ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
1517            \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
1518    
1519    
1520    # ... SVD ...
1521    svd: svd_taf
1522    svd_taf_f: svd_taf_output.f
1523    
1524    svd_input_code.f: \$(SRCFILES)
1525            cmp svd_config.template AD_CONFIG.h || cat svd_config.template > AD_CONFIG.h
1526            @make \$(F77FILES)
1527            @make \$(AD_FLOW_FILES)
1528            cat \$(AD_FLOW_FILES) \$(AD_FILES) > svd_input_code.f
1529    
1530    svd_taf_output.f: svd_input_code.f
1531            \$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) svd_input_code.f
1532            cat svd_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f
1533    
1534    svd_taf: svd_taf_output.o \$(OBJFILES)
1535            \$(LINK) -o ${EXE_SVD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS)
1536    
1537    
1538    #=========================================
1539    
1540  EOF  EOF
1541    
1542    if test "x$EXEHOOK" != x ; then
1543        printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
1544    fi
1545    
1546  echo "  Making list of \"exceptions\" that need \".p\" files"  echo "  Making list of \"exceptions\" that need \".p\" files"
1547  for i in $KPPFILES ; do  for i in $KPPFILES ; do
1548      base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`      base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
# Line 1120  echo "  Adding makedepend marker" Line 1572  echo "  Adding makedepend marker"
1572  printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE  printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE
1573    
1574  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
1575    
1576    #  Write the "template" files for the adjoint builds
1577    cat >AD_CONFIG.template <<EOF
1578    C  WARNING: This file is automatically generated by genmake2 and
1579    C    used by the Makefile rules.  Please DO NOT EDIT this file
1580    C    unless you are CERTAIN that you know what you are doing.
1581    
1582    #undef ALLOW_ADJOINT_RUN
1583    #undef ALLOW_TANGENTLINEAR_RUN
1584    #undef ALLOW_ECCO_OPTIMIZATION
1585    EOF
1586    cat >ad_config.template <<EOF
1587    C  WARNING: This file is automatically generated by genmake2 and
1588    C    used by the Makefile rules.  Please DO NOT EDIT this file
1589    C    unless you are CERTAIN that you know what you are doing.
1590    
1591    #define ALLOW_ADJOINT_RUN
1592    #undef ALLOW_TANGENTLINEAR_RUN
1593    #undef ALLOW_ECCO_OPTIMIZATION
1594    EOF
1595    cat >ftl_config.template <<EOF
1596    C  WARNING: This file is automatically generated by genmake2 and
1597    C    used by the Makefile rules.  Please DO NOT EDIT this file
1598    C    unless you are CERTAIN that you know what you are doing.
1599    
1600    #undef ALLOW_ADJOINT_RUN
1601    #define ALLOW_TANGENTLINEAR_RUN
1602    #undef ALLOW_ECCO_OPTIMIZATION
1603    EOF
1604    cat >svd_config.template <<EOF
1605    C  WARNING: This file is automatically generated by genmake2 and
1606    C    used by the Makefile rules.  Please DO NOT EDIT this file
1607    C    unless you are CERTAIN that you know what you are doing.
1608    
1609    #undef ALLOW_ADJOINT_RUN
1610    #undef ALLOW_TANGENTLINEAR_RUN
1611    #undef ALLOW_ECCO_OPTIMIZATION
1612    EOF
1613    cp AD_CONFIG.template AD_CONFIG.h
1614    
1615    
1616    #  Write the "state" for future records
1617    if test "x$DUMPSTATE" != xf ; then
1618        echo -n "" > genmake_state
1619        for i in $gm_state ; do
1620            t1="t2=\$$i"
1621            eval $t1
1622            echo "$i='$t2'" >> genmake_state
1623        done
1624    fi

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.33

  ViewVC Help
Powered by ViewVC 1.1.22