/[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.1 by edhill, Sat Aug 16 14:01:08 2003 UTC revision 1.27 by edhill, Tue Nov 4 18:40:58 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"
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         p_LN="ln -s"  
105      fi      fi
     rm -f test link  
106    
107      # look for possible fortran compilers      # look for possible fortran compilers
108        tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
109      p_FC=      p_FC=
110      for c in f77 g77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 ; do      for c in $tmp ; do
111          which $c > /dev/null 2>&1          rm -f ./hello.f ./hello
112            cat >> hello.f <<EOF
113          program hello
114          do i=1,3
115            print *, 'hello world : ', i
116          enddo
117          end
118    EOF
119            $c -o hello hello.f > /dev/null 2>&1
120          RETVAL=$?          RETVAL=$?
121          if test "x${RETVAL}" = x0 ; then          if test "x${RETVAL}" = x0 ; then
122              p_FC="$p_FC $c"              p_FC="$p_FC $c"
123          fi          fi
124      done      done
125      echo "Possible FORTRAN compilers appear to be:  "      rm -f ./hello.f ./hello
126      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
127          echo "  None found!!!"          cat 1>&2 <<EOF
128      else  
129          echo "  "$p_FC  Error: No Fortran compilers were found in your path.  Please specify one using:
130      fi  
131        1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
132        2) a command-line option (eg. "-fc NAME"), or
133        3) the MITGCM_FC environment variable.
134    
     # 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  
135  EOF  EOF
136          eval "$mpi_fort -showme test.f > out"          exit 1
137          RETVAL=$?      else
138          if test "x${RETVAL}" = x0 ; then          echo "  The possible FORTRAN compilers found in your path are:"
139              a=`cat out`          echo "   "$p_FC
140              for i in $a ; do          if test "x$FC" = x ; then
141                  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  
142          fi          fi
         rm -f test.f out  
143      fi      fi
144    
145  }      for i in $p_FC ; do
146            p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
147            if test -r $p_OF ; then
148                OPTFILE=$p_OF
149                echo "  The options file:  $p_OF"
150                echo "    appears to match so we'll use it."
151                break
152            fi
153        done
154        if test "x$OPTFILE" = x ; then
155            cat 1>&2 <<EOF
156    
157  parse_options()  {  Error: No options file was found in:  $ROOTDIR/tools/build_options/
158      that matches this platform ("$PLATFORM") and the compilers found in
159      your path.  Please specify an "optfile" using:
160    
161      ac_prev=      1) the command line (eg. "-optfile=path/to/OPTFILE"), or
162      for ac_option in "${OPTIONS[@]}" ; do      2) the MITGCM_OF environment variable.
163    
164      If you need help, please contact the developers at <MITgcm-support@mitgcm.org>.
165    
166    EOF
167            exit 1
168        fi
169        
170    #     # look for possible MPI libraries
171    #     mpi_libs=
172    #     mpi_fort=`which mpif77 2>/dev/null`
173    #     RETVAL=$?
174    #     if test "x${RETVAL}" = x0 ; then
175    #       cat >>test.f <<EOF
176    #       PROGRAM HELLO
177    #       DO 10, I=1,10
178    #       PRINT *,'Hello World'
179    #    10 CONTINUE
180    #       STOP
181    #       END
182    # EOF
183    #       eval "$mpi_fort -showme test.f > out"
184    #       RETVAL=$?
185    #       if test "x${RETVAL}" = x0 ; then
186    #           a=`cat out`
187    #           for i in $a ; do
188    #               case $i in
189    #                   -*)
190    #                       mpi_libs="$mpi_libs $i" ;;
191    #               esac
192    #           done
193    #           echo "The MPI libs appear to be:"
194    #           echo "  "$mpi_libs
195    #       fi
196    #       rm -f test.f out
197    #     fi
198    
         # 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  
199  }  }
200    
201  #  Parse the package dependency information  #  Parse the package dependency information
# Line 199  get_pdepend_list()  { Line 204  get_pdepend_list()  {
204      #  strip the comments and then convert the dependency file into      #  strip the comments and then convert the dependency file into
205      #  two arrays: PNAME, DNAME      #  two arrays: PNAME, DNAME
206      cat $1 | sed -e 's/#.*$//g' \      cat $1 | sed -e 's/#.*$//g' \
207          | 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} }' \
208          > ./.pd_tmp          > ./.pd_tmp
209      source ./.pd_tmp      source ./.pd_tmp
210      rm -f ./.pd_tmp      rm -f ./.pd_tmp
# Line 210  get_pdepend_list()  { Line 215  get_pdepend_list()  {
215    
216  #  Explain usage  #  Explain usage
217  usage()  {  usage()  {
218      echo ""      echo
219      echo "Usage: "$0" [OPTIONS]"      echo "Usage: "$0" [OPTIONS]"
220      echo "  where [OPTIONS] can be:"$'\n'      echo "  where [OPTIONS] can be:"
221        echo
222      echo "    -help | --help | -h | --h"      echo "    -help | --help | -h | --h"
223      echo "    -nooptfile | --nooptfile"      echo "    -nooptfile | --nooptfile"
224      echo "      -optfile NAME | --optfile NAME | -of NAME | --of NAME"      echo "      -optfile NAME | --optfile NAME | -of NAME | --of NAME"
# Line 221  usage()  { Line 227  usage()  {
227      echo "      -pdepend=NAME | --pdepend=NAME"      echo "      -pdepend=NAME | --pdepend=NAME"
228      echo "    -pdefault NAME | --pdefault NAME"      echo "    -pdefault NAME | --pdefault NAME"
229      echo "      -pdefault=NAME | --pdefault=NAME"      echo "      -pdefault=NAME | --pdefault=NAME"
230      echo "    -makefile NAME | -ma NAME"      echo "    -make NAME | -m NAME"
231      echo "      --makefile=NAME | -ma=NAME"      echo "      --make=NAME | -m=NAME"
232        echo "    -makefile NAME | -mf NAME"
233        echo "      --makefile=NAME | -mf=NAME"
234      echo "    -platform NAME | --platform NAME | -pl NAME | --pl NAME"      echo "    -platform NAME | --platform NAME | -pl NAME | --pl NAME"
235      echo "      -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME"      echo "      -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME"
236      echo "    -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME"      echo "    -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME"
# Line 233  usage()  { Line 241  usage()  {
241      echo "      -disable=NAME | --disable=NAME"      echo "      -disable=NAME | --disable=NAME"
242      echo "    -enable NAME | --enable NAME"      echo "    -enable NAME | --enable NAME"
243      echo "      -enable=NAME | --enable=NAME"      echo "      -enable=NAME | --enable=NAME"
244        echo "    -standarddirs NAME | --standarddirs NAME"
245        echo "      -standarddirs=NAME | --standarddirs=NAME"
246      echo "    -noopt NAME | --noopt NAME"      echo "    -noopt NAME | --noopt NAME"
247      echo "      -noopt=NAME | --noopt=NAME"      echo "      -noopt=NAME | --noopt=NAME"
248  #    echo "    -cpp NAME | --cpp NAME"  #    echo "    -cpp NAME | --cpp NAME"
# Line 241  usage()  { Line 251  usage()  {
251      echo "      -fc=NAME | --fc=NAME"      echo "      -fc=NAME | --fc=NAME"
252      echo "    -[no]ieee | --[no]ieee"      echo "    -[no]ieee | --[no]ieee"
253      echo "    -[no]mpi | --[no]mpi"      echo "    -[no]mpi | --[no]mpi"
254      echo "    -[no]jam | --[no]jam"$'\n'      echo "    -[no]jam | --[no]jam"
255      echo "  and NAME is a string such as:"$'\n'      echo
256        echo "  and NAME is a string such as:"
257        echo
258      echo "    --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'"      echo "    --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'"
259      echo "    -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'"      echo "    -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'"
260      echo "    -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'"$'\n'      echo "    -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'"
261        echo
262      echo "  which, depending upon your shell, may need to be single-quoted"      echo "  which, depending upon your shell, may need to be single-quoted"
263      echo "  if it contains spaces, dashes, or other special characters."      echo "  if it contains spaces, dashes, or other special characters."
264      exit 1      exit 1
265  }  }
266    
 # Dump all important state  
 dump_state()  {  
     fname=$1  
     echo " " > $fname  
     RETVAL=$?  
     if test "x${RETVAL}" = x ; then  
         echo "Error: cannot write to $fname"  
         exit 1  
     fi  
     echo "makefile "$makefile > $fname  
 }  
   
   
267  #eh3 # This is the generic configuration.  #eh3 # This is the generic configuration.
268  #eh3 set LN         = ( 'ln -s' )  #eh3 set LN         = ( 'ln -s' )
269  #eh3 set CPP        = ( '/lib/cpp -P' )  #eh3 set CPP        = ( '/lib/cpp -P' )
# Line 284  dump_state()  { Line 284  dump_state()  {
284  #eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = (  )  #eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = (  )
285    
286  #  Set defaults here  #  Set defaults here
287    COMMANDL="$0 $@"
288    
289  PLATFORM=  PLATFORM=
290  LN=  LN=
291  S64=  S64=
292  KPP=  KPP=
293  FC=  FC=
294  LINK=  LINK=
295    DEFINES="-DWORDLENGTH=4"
296  PACKAGES=  PACKAGES=
297  ENABLE=  ENABLE=
298  DISABLE=  DISABLE=
299  MAKEFILE=  MAKEFILE=
300  MAKEDEPEND=  MAKEDEPEND=
301  PDEPEND=  PDEPEND=
302    DUMPSTATE=t
303  PDEFAULT=  PDEFAULT=
304  OPTFILE=  OPTFILE=
305  INCLUDES=-I.  INCLUDES="-I."
306  FFLAGS=  FFLAGS=
307  FOPTIM=  FOPTIM=
308  CFLAGS=  CFLAGS=
# Line 313  MODS= Line 317  MODS=
317  TOOLSDIR=  TOOLSDIR=
318  SOURCEDIRS=  SOURCEDIRS=
319  INCLUDEDIRS=  INCLUDEDIRS=
320    STANDARDDIRS=
321    
322  PWD=`pwd`  PWD=`pwd`
323  MAKE=make  MAKE=make
324    AWK=awk
325  THISHOSTNAME=`hostname`  THISHOSTNAME=`hostname`
326  THISCWD=`pwd`  THISCWD=`pwd`
327  THISDATE=`date`  THISDATE=`date`
328  MACHINE=`uname -a`  MACHINE=`uname -a`
329    EXECUTABLE=
330    EXEHOOK=
331    EXEDIR=
332    PACKAGES_CONF=
333    IEEE=
334    if test "x$MITGCM_IEEE" != x ; then
335        IEEE=$MITGCM_IEEE
336    fi
337    
338    AUTODIFF_PKG_USED=f
339    AD_OPTFILE=
340    TAF=
341    AD_TAF_FLAGS=
342    FTL_TAF_FLAGS=
343    SVD_TAF_FLAGS=
344    TAF_EXTRA=
345    TAMC=
346    AD_TAMC_FLAGS=
347    FTL_TAF_FLAGS=
348    SVD_TAMC_FLAGS=
349    TAMC_EXTRA=
350    
351    
352    #  The following state can be set directly by command-line switches
353    gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"
354    gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS"
355    
356    #  The following state is not directly set by command-line switches
357    gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "
358    gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
359    gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"
360    gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
361    
362    #  The following are all related to adjoint/tangent-linear stuff
363    gm_s7="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
364    gm_s8="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
365    gm_s9="TAF_EXTRA TAMC_EXTRA"
366    
367  echo $'\n'"===  Processing options files and arguments  ==="  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8 $gm_s9"
368  gm_local="./gm_local"  
369    
370    echo
371    echo "===  Processing options files and arguments  ==="
372    gm_local="genmake_local"
373    for i in . $MODS ; do
374        if test -r $i/$gm_local ; then
375            source $i/$gm_local
376            break
377        fi
378    done
379  echo -n "  getting local config information:  "  echo -n "  getting local config information:  "
380  if test -e $gm_local ; then  if test -e $gm_local ; then
381      echo "using $gm_local"      echo "using $gm_local"
382      source $gm_local      source $gm_local
383      echo "DISABLE=$DISABLE"$'\n'"ENABLE=$ENABLE"      # echo "DISABLE=$DISABLE"
384        # echo "ENABLE=$ENABLE"
385  else  else
386      echo "none found"      echo "none found"
387  fi  fi
388    
389  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"
390  OPTIONS=()  #OPTIONS=
391  n=0  #n=0
392  for i ; do  #for i ; do
393     setvar="OPTIONS[$n]='$i'"  #   echo "$i  $n"
394     #  echo "  $setvar"  #   setvar="OPTIONS[$n]='$i'"
395     eval "$setvar"  #   #  echo "  $setvar"
396     n=$(( $n + 1 ))  #   eval "$setvar"
397  done  #   n=$(( $n + 1 ))
398  parse_options  #done
399    #parse_options
400  echo "  getting OPTFILE information:  "  ac_prev=
401  if test "x${OPTFILE}" = x ; then  for ac_option ; do
402      echo "Warning: no OPTFILE specified so we'll look for possible settings"  
403      echo $'\n'"===  Searching for possible settings for OPTFILE  ==="      # If the previous option needs an argument, assign it.
404      find_possible_configs      if test -n "$ac_prev"; then
405  else          eval "$ac_prev=\$ac_option"
406      if test "x$OPTFILE" = xNONE ; then          ac_prev=
407          echo "    OPTFILE=NONE so we'll try to use default settings"          continue
     else  
         if test -f "$OPTFILE" -a -r "$OPTFILE" ; then  
             echo "    using OPTFILE=\"$OPTFILE\""  
             source "$OPTFILE"  
             RETVAL=$?  
             if test "x$RETVAL" != x0 ; then  
                 echo -n "Error: failed to source OPTFILE \"$OPTFILE\""  
                 echo "--please check that variable syntax is bash-compatible"  
                 exit 1  
             fi  
         else  
             echo "Error: can't read OPTFILE=\"$OPTFILE\""  
             exit 1  
         fi  
     fi  
 fi  
   
 echo $'\n'"===  Setting defaults  ==="  
 echo -n "  Adding MODS directories:  "  
 for d in $MODS ; do  
     if test ! -d $d ; then  
         echo $'\n\n'"Error: MODS directory \"$d\" not found!"  
         exit 1  
     else  
         echo -n " $d"  
         SOURCEDIRS="$SOURCEDIRS $d"  
         INCLUDEDIRS="$INCLUDEDIRS $d"  
408      fi      fi
409        
410        ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
411        
412        case $ac_option in
413            
414            -help | --help | -h | --h)
415                usage ;;
416            
417            -nooptfile | --nooptfile)
418                OPTFILE="NONE" ;;
419            -optfile | --optfile | -of | --of)
420                ac_prev=OPTFILE ;;
421            -optfile=* | --optfile=* | -of=* | --of=*)
422                OPTFILE=$ac_optarg ;;
423            
424            -adoptfile | --adoptfile | -ad | --ad)
425                ac_prev=AD_OPTFILE ;;
426            -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
427                AD_OPTFILE=$ac_optarg ;;
428            
429            -pdepend | --pdepend)
430                ac_prev=PDEPEND ;;
431            -pdepend=* | --pdepend=*)
432                PDEPEND=$ac_optarg ;;
433            
434            -pdefault | --pdefault)
435                ac_prev=PDEFAULT ;;
436            -pdefault=* | --pdefault=*)
437                PDEFAULT=$ac_optarg ;;
438            
439            -make | --make | -m | --m)
440                ac_prev=MAKE ;;
441            -make=* | --make=* | -m=* | --m=*)
442                MAKE=$ac_optarg ;;
443            
444            -makefile | --makefile | -ma | --ma)
445                ac_prev=MAKEFILE ;;
446            -makefile=* | --makefile=* | -ma=* | --ma=*)
447                MAKEFILE=$ac_optarg ;;
448            
449            -platform | --platform | -pl | --pl)
450                ac_prev=PLATFORM ;;
451            -platform=* | --platform=* | -pl=* | --pl=*)
452                PLATFORM=$ac_optarg ;;
453            
454            -rootdir | --rootdir | -rd | --rd)
455                ac_prev=ROOTDIR ;;
456            -rootdir=* | --rootdir=* | -rd=* | --rd=*)
457                ROOTDIR=$ac_optarg ;;
458            
459            -mods | --mods | -mo | --mo)
460                ac_prev=MODS ;;
461            -mods=* | --mods=* | -mo=* | --mo=*)
462                MODS=$ac_optarg ;;
463            
464            -disable | --disable)
465                ac_prev=DISABLE ;;
466            -disable=* | --disable=*)
467                DISABLE=$ac_optarg ;;
468            
469            -enable | --enable)
470                ac_prev=ENABLE ;;
471            -enable=* | --enable=*)
472                ENABLE=$ac_optarg ;;
473            
474            -standarddirs | --standarddirs)
475                ac_prev=STANDARDDIRS ;;
476            -standarddirs=* | --standarddirs=*)
477                STANDARDDIRS=$ac_optarg ;;
478    
479            -noopt | --noopt)
480                ac_prev=NOOPT ;;
481            -noopt=* | --noopt=*)
482                NOOPT=$ac_optarg ;;
483            
484    #           -cpp | --cpp)
485    #               ac_prev=cpp ;;
486    #           -cpp=* | --cpp=*)
487    #               CPP=$ac_optarg ;;
488                
489            -fortran | --fortran | -fc | --fc)
490                ac_prev=FC ;;
491            -fc=* | --fc=*)
492                FC=$ac_optarg ;;
493            
494            -ieee | --ieee)
495                IEEE=true ;;
496            -noieee | --noieee)
497                IEEE= ;;
498            
499            -mpi | --mpi)
500                MPI=true ;;
501            -nompi | --nompi)
502                MPI= ;;
503            
504            -jam | --jam)
505                JAM=1 ;;
506            -nojam | --nojam)
507                JAM=0 ;;
508            
509            -ds | --ds)
510                DUMPSTATE=t ;;
511            
512            -taf_extra | --taf_extra)
513                ac_prev=TAF_EXTRA ;;
514            -taf_extra=* | --taf_extra=*)
515                TAF_EXTRA=$ac_optarg ;;
516    
517            -tamc_extra | --tamc_extra)
518                ac_prev=TAMC_EXTRA ;;
519            -tamc_extra=* | --tamc_extra=*)
520                TAMC_EXTRA=$ac_optarg ;;
521    
522            -*)
523                echo "Error: unrecognized option: "$ac_option
524                usage
525                ;;
526            
527            *)
528                echo "Error: unrecognized argument: "$ac_option
529                usage
530                ;;
531            
532        esac
533        
534  done  done
 echo  
535    
536  if test "x$MAKEFILE" = x ; then  if test -f ./.genmakerc ; then
537      MAKEFILE="Makefile"      echo
538  fi      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
539  if test "x${PLATFORM}" = x ; then      echo "  file.  This file format is no longer supported.  Please see:"
540      PLATFORM=$p_PLATFORM      echo
541        echo "    http://mitgcm.org/devel_HOWTO/"
542        echo
543        echo "  for directions on how to setup and use the new \"genmake2\" input"
544        echo "  files and send an email to MITgcm-support@mitgcm.org if you want help."
545        echo
546  fi  fi
547    
548  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
# Line 414  if test ! -d ${ROOTDIR} ; then Line 570  if test ! -d ${ROOTDIR} ; then
570      exit 1      exit 1
571  fi  fi
572    
573    echo "  getting OPTFILE information:  "
574    if test "x${OPTFILE}" = x ; then
575        if test "x$MITGCM_OF" = x ; then
576            echo "Warning: no OPTFILE specified so we'll look for possible settings"
577            printf "\n===  Searching for possible settings for OPTFILE  ===\n"
578            find_possible_configs
579        else
580            OPTFILE=$MITGCM_OF
581        fi
582    fi
583    if test "x$OPTFILE" != xNONE ; then
584        if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
585            echo "    using OPTFILE=\"$OPTFILE\""
586            source "$OPTFILE"
587            RETVAL=$?
588            if test "x$RETVAL" != x0 ; then
589                echo -n "Error: failed to source OPTFILE \"$OPTFILE\""
590                echo "--please check that variable syntax is bash-compatible"
591                exit 1
592            fi
593            if test "x$DUMPSTATE" != xf ; then
594                cp -f $OPTFILE "genmake_optfile"
595            fi
596        else
597            echo "Error: can't read OPTFILE=\"$OPTFILE\""
598            exit 1
599        fi
600    fi
601    
602    echo "  getting AD_OPTFILE information:  "
603    if test "x${AD_OPTFILE}" = x ; then
604        if test "x$MITGCM_AD_OF" = x ; then
605            AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
606        else
607            AD_OPTFILE=$MITGCM_AD_OF
608        fi
609    fi
610    if test "x${AD_OPTFILE}" != xNONE ; then
611        if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then
612            echo "    using AD_OPTFILE=\"$AD_OPTFILE\""
613            source "$AD_OPTFILE"
614            RETVAL=$?
615            if test "x$RETVAL" != x0 ; then
616                echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
617                echo "--please check that variable syntax is bash-compatible"
618                exit 1
619            fi
620            if test "x$DUMPSTATE" != xf ; then
621                cp -f $AD_OPTFILE "genmake_ad_optfile"
622            fi
623        else
624            echo "Error: can't read AD_OPTFILE=\"$AD_OPTFILE\""
625            exit 1
626        fi
627    fi
628    
629    #  Check that FC, LINK, CPP, and S64 are defined.  If not, complain
630    #  and abort!
631    if test "x$FC" = x ; then
632        cat <<EOF 1>&2
633    
634    Error: no Fortran compiler: please specify using one of the following:
635      1) within the options file ("FC=...") as specified by "-of=OPTFILE"
636      2) the "-fc=XXX" command-line option
637      3) the "./genmake_local" file
638    EOF
639        exit 1
640    fi
641    if test "x$LINK" = x ; then
642        LINK=$FC
643    fi
644    if test "x$CPP" = x ; then
645        CPP="cpp"
646    fi
647    echo "#define A a" | $CPP > test_cpp 2>&1
648    RETVAL=$?
649    if test "x$RETVAL" != x0 ; then
650        cat <<EOF 1>&2
651    
652    Error: C pre-processor "$CPP" failed the test case: please specify using:
653    
654      1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
655      2) the "./genmake_local" file
656    
657    EOF
658        exit 1
659    else
660        rm -f test_cpp
661    fi
662    if test "x$MAKEDEPEND" = x ; then
663        MAKEDEPEND=makedepend
664    fi
665    
666    printf "\n===  Setting defaults  ===\n"
667    echo -n "  Adding MODS directories:  "
668    for d in $MODS ; do
669        if test ! -d $d ; then
670            echo
671            echo "Error: MODS directory \"$d\" not found!"
672            exit 1
673        else
674            echo -n " $d"
675            SOURCEDIRS="$SOURCEDIRS $d"
676            INCLUDEDIRS="$INCLUDEDIRS $d"
677        fi
678    done
679    echo
680    
681    if test "x$MAKEFILE" = x ; then
682        MAKEFILE="Makefile"
683    fi
684    if test "x${PLATFORM}" = x ; then
685        PLATFORM=$p_PLATFORM
686    fi
687    
688  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
689      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then
690          EXEDIR=../exe          EXEDIR=../exe
# Line 433  if test ! -d ${TOOLSDIR} ; then Line 704  if test ! -d ${TOOLSDIR} ; then
704      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"
705      exit 1      exit 1
706  fi  fi
707    if test "x$S64" = x ; then
708        S64='$(TOOLSDIR)/set64bitConst.sh'
709    fi
710    
711  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
712    
# Line 443  if test -r $ROOTDIR"/eesupp/src/Makefile Line 717  if test -r $ROOTDIR"/eesupp/src/Makefile
717      echo "  Making source files in eesupp from templates"      echo "  Making source files in eesupp from templates"
718      $MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1      $MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1
719      RETVAL=$?      RETVAL=$?
720      if test "x${RETVAL}" == "x0" ; then      if test "x${RETVAL}" = x0 ; then
721          rm -f make_eesupp.errors          rm -f make_eesupp.errors
722      else      else
723          echo "Error: problem encountered while building source files in eesupp:"          echo "Error: problem encountered while building source files in eesupp:"
# Line 452  if test -r $ROOTDIR"/eesupp/src/Makefile Line 726  if test -r $ROOTDIR"/eesupp/src/Makefile
726      fi      fi
727  fi  fi
728    
729  echo $'\n'"===  Determining package settings  ==="  printf "\n===  Determining package settings  ===\n"
730  if  test "x${PDEPEND}" = x ; then  if  test "x${PDEPEND}" = x ; then
731      tmp=$ROOTDIR"/pkg/pkg_depend"      tmp=$ROOTDIR"/pkg/pkg_depend"
732      if test -r $tmp ; then      if test -r $tmp ; then
# Line 471  echo "  getting package dependency info Line 745  echo "  getting package dependency info
745  #  Strip the comments and then convert the dependency file into  #  Strip the comments and then convert the dependency file into
746  #  two arrays: PNAME, DNAME  #  two arrays: PNAME, DNAME
747  cat $PDEPEND | sed -e 's/#.*$//g' \  cat $PDEPEND | sed -e 's/#.*$//g' \
748      | awk 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \      | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
749      > ./.pd_tmp      > ./.pd_tmp
750  RETVAL=$?  RETVAL=$?
751  if test ! "x${RETVAL}" = x0 ; then  if test ! "x${RETVAL}" = x0 ; then
# Line 481  fi Line 755  fi
755  source ./.pd_tmp  source ./.pd_tmp
756  rm -f ./.pd_tmp  rm -f ./.pd_tmp
757    
758    #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"
759    #  file should eventually be added so that, for convenience, one can
760    #  specify groups of packages using names like "ocean" and "atmosphere".
761  echo  -n "  checking default package list:  "  echo  -n "  checking default package list:  "
762  if test "x${PDEFAULT}" = x ; then  if test "x${PDEFAULT}" = x ; then
763        for i in "." $MODS ; do
764            if test -r $i"/packages.conf" ; then
765                    PDEFAULT=$i"/packages.conf"
766                    break
767            fi
768        done
769    fi
770    if test "x${PDEFAULT}" = x ; then
771      PDEFAULT="$ROOTDIR/pkg/pkg_default"      PDEFAULT="$ROOTDIR/pkg/pkg_default"
772  fi  fi
773  if test "x${PDEFAULT}" = xNONE ; then  if test "x${PDEFAULT}" = xNONE ; then
# Line 494  else Line 779  else
779      else      else
780          echo "  using PDEFAULT=\"$PDEFAULT\""          echo "  using PDEFAULT=\"$PDEFAULT\""
781          #  Strip the comments and add all the names          #  Strip the comments and add all the names
782          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | awk '(NF>0){print $0}'`          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
783          RETVAL=$?          RETVAL=$?
784          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
785              echo -n "Error: can't parse default package list "              echo -n "Error: can't parse default package list "
# Line 504  else Line 789  else
789          for i in $def ; do          for i in $def ; do
790              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
791          done          done
792          echo "    packages are:  $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
793            expand_pkg_groups
794            echo "    after group expansion packages are:  $PACKAGES"
795      fi      fi
796  fi  fi
797    
# Line 523  for p in $PACKAGES ; do Line 810  for p in $PACKAGES ; do
810  done  done
811  PACKAGES="$pack"  PACKAGES="$pack"
812  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
813  rm -f ./.tmp_pack  echo "" > ./.tmp_pack
814  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
815  for i in $PACKAGES ; do  for i in $PACKAGES ; do
816      if test ! -d "$ROOTDIR/pkg/$i" ; then      if test ! -d "$ROOTDIR/pkg/$i" ; then
# Line 544  echo "  applying package dependency rule Line 831  echo "  applying package dependency rule
831  ck=  ck=
832  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
833      i=0      i=0
834      rtot=${#PNAME[@]}      # rtot=${#PNAME[@]}
835        rtot=$nname
836      while test $i -lt $rtot ; do      while test $i -lt $rtot ; do
837    
838          #  Is $pname in the current $PACKAGES list?          #  Is $pname in the current $PACKAGES list?
839          pname=${PNAME[$i]}          #  pname=${PNAME[$i]}
840            tmp="pname=\"\$PNAME_$i\""
841            eval $tmp
842          pin="f"          pin="f"
843          for p in $PACKAGES ; do          for p in $PACKAGES ; do
844              if test "x$p" = "x$pname" ; then              if test "x$p" = "x$pname" ; then
# Line 557  while test "x$ck" != xtt ; do Line 847  while test "x$ck" != xtt ; do
847          done          done
848    
849          #  Is the DNAME entry a (+) or (-) rule ?          #  Is the DNAME entry a (+) or (-) rule ?
850            tmp="dname=\"\$DNAME_$i\""
851            eval $tmp
852          plus="-"          plus="-"
853          echo "${DNAME[$i]}" | grep '^+' > /dev/null 2>&1          echo $dname | grep '^+' > /dev/null 2>&1
854          RETVAL=$?          RETVAL=$?
855          if test "x$RETVAL" = x0 ; then          if test "x$RETVAL" = x0 ; then
856              plus="+"              plus="+"
857          fi          fi
858    
859          #  Is $dname in the current $PACKAGES list?          #  Is $dname in the current $PACKAGES list?
860          dname=`echo ${DNAME[$i]} | sed -e 's/^[+-]//'`          dname=`echo $dname | sed -e 's/^[+-]//'`
861          din="f"          din="f"
862          for p in $PACKAGES ; do          for p in $PACKAGES ; do
863              if test "x$p" = "x$dname" ; then              if test "x$p" = "x$dname" ; then
# Line 609  for i in $PACKAGES ; do Line 901  for i in $PACKAGES ; do
901      if test -d $adr ; then      if test -d $adr ; then
902          SOURCEDIRS="$SOURCEDIRS $adr"          SOURCEDIRS="$SOURCEDIRS $adr"
903          INCLUDEDIRS="$INCLUDEDIRS $adr"          INCLUDEDIRS="$INCLUDEDIRS $adr"
904            if test "x$i" = xautodiff ; then
905                AUTODIFF_PKG_USED=t
906            fi
907      else      else
908          echo "Error: the directory \"$adr\" for package $i doesn't exist"          echo "Error: the directory \"$adr\" for package $i doesn't exist"
909          exit 1          exit 1
910      fi      fi
911  done  done
912    
 #  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  
913    
914  echo "  Setting package-specific CPP flags in CPP_OPTIONS.h:"  # Create a list of #define and #undef to enable/disable packages
915  CPP_OPTIONS=  PACKAGES_DOT_H=PACKAGES_CONFIG.h
916  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  
917  C=== GENMAKE v2 ===  C=== GENMAKE v2 ===
918  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
919  C  them only if you know what you're doing.  In general, you should  C  edit anything below these comments.  In general, you should
920  C  add or remove packages by re-running genmake with different  C  add or remove packages by re-running genmake with different
921  C  "-enable" and/or "-disable" options.  C  "-enable" and/or "-disable" options.
922    
923    #ifndef PACKAGES_H
924    #define PACKAGES_H
925    
926  C  Packages disabled by genmake:  C  Packages disabled by genmake:
927  EOF  EOF
928  #  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 686  for n in $names ; do Line 941  for n in $names ; do
941              fi              fi
942          done          done
943          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
944              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`
945              echo "#undef $undef" >> CPP_OPTIONS.h.tmp              echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"
946    #           DEFINES="$DEFINES -U$undef"
947    
948  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
949              case $n in              case $n in
# Line 697  for n in $names ; do Line 953  for n in $names ; do
953                  mom_vecinv)                  mom_vecinv)
954                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"
955                      ;;                      ;;
                 generic_advdiff)  
                     DEFINES="$DEFINES -DDISABLE_GENERIC_ADVDIFF"  
                     ;;  
                 debug)  
                     DEFINES="$DEFINES -DDISABLE_DEBUGMODE"  
                     ;;  
956              esac              esac
957  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
958    
959          fi          fi
960      fi      fi
961  done  done
962  cat <<EOF >>CPP_OPTIONS.h.tmp  cat <<EOF >>$PACKAGES_DOT_H".tmp"
963    
964  C  Packages enabled by genmake:  C  Packages enabled by genmake:
965  EOF  EOF
966  for i in $PACKAGES ; do  for i in $PACKAGES ; do
967      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`
968      echo "#define $def" >> CPP_OPTIONS.h.tmp      echo "#define $def" >> $PACKAGES_DOT_H".tmp"
969    #eh3 DEFINES="$DEFINES -D$def"
970    
971  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
972      case $i in      case $i in
973          aim_v23)          aim_v23)
974              echo "#define   ALLOW_AIM" >> CPP_OPTIONS.h.tmp              echo "#define   ALLOW_AIM" >> $PACKAGES_DOT_H".tmp"
975                DEFINES="$DEFINES -DALLOW_AIM"
976                echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"
977              ;;              ;;
978      esac      esac
979  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
980    
981  done  done
982  mv -f CPP_OPTIONS.h.tmp CPP_OPTIONS.h  cat <<EOF >>$PACKAGES_DOT_H".tmp"
983    
984    #endif /* PACKAGES_H */
985    EOF
986    
987    if test ! -f $PACKAGES_DOT_H ; then
988        mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
989    else
990        cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
991        RETVAL=$?
992        if test "x$RETVAL" = x0 ; then
993            rm -f $PACKAGES_DOT_H".tmp"
994        else
995            mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"
996            mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
997        fi
998    fi
999    
1000  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
1001  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
1002  STANDARDDIRS=${STANDARDDIRS:-"eesupp model"}  if test "x$STANDARDDIRS" = x ; then
1003        STANDARDDIRS="eesupp model"
1004    fi
1005  for d in $STANDARDDIRS ; do  for d in $STANDARDDIRS ; do
1006      adr="$ROOTDIR/$d/src"      adr="$ROOTDIR/$d/src"
1007      if test ! -d $adr ; then      if test ! -d $adr ; then
# Line 750  for d in $STANDARDDIRS ; do Line 1021  for d in $STANDARDDIRS ; do
1021      fi      fi
1022  done  done
1023    
1024    echo "  Searching for CPP_OPTIONS.h in order to warn about the presence"
1025    echo "    of \"#define ALLOW_PKGNAME\"-type statements:"
1026    CPP_OPTIONS=
1027    spaths=". $INCLUDEDIRS"
1028    for i in $spaths ; do
1029        try="$i/CPP_OPTIONS.h"
1030        #  echo -n "    trying $try : "
1031        if test -f $try -a -r $try ; then
1032            echo "    found CPP_OPTIONS=\"$try\""
1033            CPP_OPTIONS="$try"
1034            break
1035        fi
1036    done
1037    if test "x$CPP_OPTIONS" = x ; then
1038        echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"
1039        exit 1
1040    fi
1041    # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
1042    names=`ls -1 "$ROOTDIR/pkg"`
1043    for n in $names ; do
1044        test_for_package_in_cpp_options $CPP_OPTIONS $n
1045    done
1046    
1047    
1048  echo $'\n'"===  Creating the Makefile  ==="  #  Here, we build the list of files to be "run through" the adjoint
1049    #  compiler.
1050    if test -f ./ad_files ; then
1051        rm -f ./ad_files
1052    fi
1053    echo "  Creating the list of files for the adjoint compiler."
1054    for i in $SOURCEDIRS ; do
1055        list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
1056        for j in $list_files ; do
1057            cat $i/$j >> ad_files
1058        done
1059    done
1060    
1061    cat <<EOF > adjoint_sed
1062    s/call adopen(/call adopen ( mythid,\\
1063         \&           /g
1064    s/call adclose(/call adclose( mythid,\\
1065         \&           /g
1066    s/call adread(/call adread ( mythid,\\
1067         \&           /g
1068    s/call adwrite(/call adwrite( mythid,\\
1069         \&           /g
1070    
1071    EOF
1072    
1073    echo
1074    echo "===  Creating the Makefile  ==="
1075  echo "  setting INCLUDES"  echo "  setting INCLUDES"
1076  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
1077      if test -d $i ; then      if ! test -d $i ; then
1078          INCLUDES="$INCLUDES -I$i"  #       INCLUDES="$INCLUDES -I$i"
1079      else  #   else
1080          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
1081      fi      fi
1082  done  done
# Line 766  rm -rf .links.tmp Line 1086  rm -rf .links.tmp
1086  mkdir .links.tmp  mkdir .links.tmp
1087  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
1088  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
1089  echo -n 'SRCFILES = ' > srclist.inc  echo -n 'SRCFILES = '    > srclist.inc
1090  echo -n 'CSRCFILES = ' > csrclist.inc  echo -n 'CSRCFILES = '   > csrclist.inc
1091    echo -n 'F90SRCFILES = ' > f90srclist.inc
1092  echo -n 'HEADERFILES = ' > hlist.inc  echo -n 'HEADERFILES = ' > hlist.inc
1093  alldirs=". $SOURCEDIRS $INCLUDEDIRS"  echo -n 'AD_FLOW_FILES = ' > ad_flow_files.inc
1094    alldirs="$SOURCEDIRS $INCLUDEDIRS ."
1095  for d in $alldirs ; do  for d in $alldirs ; do
1096      deplist=      deplist=
1097      sfiles=`( cd $d; echo *.[h,c,F] )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
1098        sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
1099      for sf in $sfiles ; do      for sf in $sfiles ; do
1100          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
1101              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
1102                  extn=`echo $sf | awk -F '.' '{print $NF}'`                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`
1103                  touch .links.tmp/$sf                  touch .links.tmp/$sf
1104                  deplist="$deplist $sf"                  deplist="$deplist $sf"
1105                  case $extn in                  case $extn in
# Line 784  for d in $alldirs ; do Line 1107  for d in $alldirs ; do
1107                          echo    " \\"  >> srclist.inc                          echo    " \\"  >> srclist.inc
1108                          echo -n " $sf" >> srclist.inc                          echo -n " $sf" >> srclist.inc
1109                          ;;                          ;;
1110                        F90)
1111                            echo    " \\"  >> f90srclist.inc
1112                            echo -n " $sf" >> f90srclist.inc
1113                            ;;
1114                      c)                      c)
1115                          echo    " \\"  >> csrclist.inc                          echo    " \\"  >> csrclist.inc
1116                          echo -n " $sf" >> csrclist.inc                          echo -n " $sf" >> csrclist.inc
# Line 792  for d in $alldirs ; do Line 1119  for d in $alldirs ; do
1119                          echo    " \\"  >> hlist.inc                          echo    " \\"  >> hlist.inc
1120                          echo -n " $sf" >> hlist.inc                          echo -n " $sf" >> hlist.inc
1121                          ;;                          ;;
1122                        flow)
1123                            echo    " \\"  >> ad_flow_files.inc
1124                            echo -n " $sf" >> ad_flow_files.inc
1125                            ;;
1126                  esac                  esac
1127              fi              fi
1128          fi          fi
1129      done      done
1130      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
1131          echo $'\n'"#  These files are linked from $d" >> srclinks.tmp          echo "" >> srclinks.tmp
1132            echo "#  These files are linked from $d" >> srclinks.tmp
1133          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> srclinks.tmp
1134          echo $'\t$(LN) '$d'/$@ $@' >> srclinks.tmp          printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp
1135      fi      fi
1136  done  done
1137  rm -rf .links.tmp  rm -rf .links.tmp
1138  echo "" >> srclist.inc  echo "" >> srclist.inc
1139  echo "" >> csrclist.inc  echo "" >> csrclist.inc
1140    echo "" >> f90srclist.inc
1141  echo "" >> hlist.inc  echo "" >> hlist.inc
1142    echo "" >> ad_flow_files.inc
1143    
1144  if test -e $MAKEFILE ; then  if test -e $MAKEFILE ; then
1145      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
# Line 819  echo "# by the command:" >> $MAKEFILE Line 1153  echo "# by the command:" >> $MAKEFILE
1153  echo "#    $0 $@" >> $MAKEFILE  echo "#    $0 $@" >> $MAKEFILE
1154  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
1155  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE
1156    
1157    EXE_AD=$EXECUTABLE"_ad"
1158    EXE_FTL=$EXECUTABLE"_ftl"
1159    EXE_SVD=$EXECUTABLE"_svd"
1160    
1161  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1162  #  #
1163  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
# Line 847  EXEDIR      = ${EXEDIR} Line 1186  EXEDIR      = ${EXEDIR}
1186  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
1187  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIR}
1188    
1189    #eh3  new defines for the adjoint work
1190    AUTODIFF    = ${ROOTDIR}/pkg/autodiff
1191    EXE_AD      = ${EXE_AD}
1192    EXE_FTL     = ${EXE_FTL}
1193    EXE_SVD     = ${EXE_SVD}
1194    
1195  EOF  EOF
1196    
1197  #  Note: figure out some way to add Hyades JAM libraries here  #  Note: figure out some way to add Hyades JAM libraries here
# Line 862  MAKEDEPEND = ${MAKEDEPEND} Line 1207  MAKEDEPEND = ${MAKEDEPEND}
1207  KPP = ${KPP}  KPP = ${KPP}
1208  # Fortran compiler  # Fortran compiler
1209  FC = ${FC}  FC = ${FC}
1210    # Fortran compiler
1211    F90C = ${F90C}
1212  # Link editor  # Link editor
1213  LINK = ${LINK}  LINK = ${LINK}
1214    
# Line 875  KFLAGS2 = ${KFLAGS2} Line 1222  KFLAGS2 = ${KFLAGS2}
1222  # Optim./debug for FC  # Optim./debug for FC
1223  FFLAGS = ${FFLAGS}  FFLAGS = ${FFLAGS}
1224  FOPTIM = ${FOPTIM}  FOPTIM = ${FOPTIM}
1225    # Optim./debug for FC
1226    F90FLAGS = ${F90FLAGS}
1227    F90OPTIM = ${F90OPTIM}
1228  # Flags for CC  # Flags for CC
1229  CFLAGS = ${CFLAGS}  CFLAGS = ${CFLAGS}
1230  # Files that should not be optimized  # Files that should not be optimized
# Line 882  NOOPTFILES = ${NOOPTFILES} Line 1232  NOOPTFILES = ${NOOPTFILES}
1232  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
1233  # Flags and libraries needed for linking  # Flags and libraries needed for linking
1234  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS} \$(XLIBS)
1235    # Name of the Mekfile
1236    MAKEFILE=${MAKEFILE}
1237    
1238  EOF  EOF
1239    
1240  cat srclist.inc  >> $MAKEFILE  cat srclist.inc       >> $MAKEFILE
1241  cat csrclist.inc >> $MAKEFILE  cat csrclist.inc      >> $MAKEFILE
1242  cat hlist.inc >> $MAKEFILE  cat f90srclist.inc    >> $MAKEFILE
1243  echo 'F77FILES =  $(SRCFILES:.F=.f)'                    >> $MAKEFILE  cat hlist.inc         >> $MAKEFILE
1244  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o)' >> $MAKEFILE  cat ad_flow_files.inc >> $MAKEFILE
1245    echo               >> $MAKEFILE
1246    echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE
1247    echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE
1248    echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
1249    
1250  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc
1251    rm -f ad_flow_files.inc
1252    
1253  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1254    
1255  .SUFFIXES:  .SUFFIXES:
1256  .SUFFIXES: .o .f .p .F .c  .SUFFIXES: .o .f .p .F .c .F90 .f90
1257    
1258  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
1259  \$(EXECUTABLE): \$(OBJFILES)  \$(EXECUTABLE): \$(OBJFILES)
# Line 904  all: \$(EXECUTABLE) Line 1261  all: \$(EXECUTABLE)
1261  depend:  depend:
1262          @make links          @make links
1263          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
1264            ${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE)
1265    
1266  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES)
1267    
1268  small_f: \$(F77FILES)  small_f: \$(F77FILES) \$(F90FILES)
1269    
1270  output.txt: \$(EXECUTABLE)  output.txt: \$(EXECUTABLE)
1271          @printf 'running ... '          @printf 'running ... '
1272          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
1273    
1274  clean:  clean:
1275          -rm -rf *.o *.f *.p ${RMFILES} work.{pc,pcl}          -cat AD_CONFIG.template > AD_CONFIG.h
1276            -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl}
1277  Clean:  Clean:
1278          @make clean          @make clean
1279          @make cleanlinks          @make cleanlinks
1280          -rm -f Makefile.bak          -rm -f Makefile.bak genmake_state genmake_*optfile make.log
1281  CLEAN:  CLEAN:
1282          @make Clean          @make Clean
1283          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
1284          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
1285          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1286          -rm -f \$(EXECUTABLE)          -rm -f \$(EXECUTABLE) output.txt
1287    
1288    #eh3 Makefile: makefile
1289  makefile:  makefile:
1290          ${0} $@          ${0} $@
1291  cleanlinks:  cleanlinks:
# Line 936  cleanlinks: Line 1296  cleanlinks:
1296          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1297  .f.o:  .f.o:
1298          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
1299    .F90.f90:
1300            \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1301    .f90.o:
1302            \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
1303  .c.o:  .c.o:
1304          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) -c \$<
1305    
# Line 945  cleanlinks: Line 1309  cleanlinks:
1309  .p.f:  .p.f:
1310          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
1311    
1312    #=========================================
1313    #===  Automatic Differentiation Rules  ===
1314    
1315    TAMC           = ${TAMC}
1316    TAF            = ${TAF}
1317    
1318    TAF_EXTRA      = ${TAF_EXTRA}
1319    TAMC_EXTRA     = ${TAMC_EXTRA}
1320    
1321  EOF  EOF
1322    
1323    ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS"
1324    ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF_FLAGS"
1325    ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
1326    for i in $ad_vars ; do
1327        name=$i
1328        t1="t2=\$"`echo $i`
1329        eval $t1
1330        printf "%-20s = " $name >> $MAKEFILE
1331        echo $t2 >> $MAKEFILE
1332    done
1333    
1334    echo "  Add the source list for AD code generation"
1335    echo >> $MAKEFILE
1336    echo -n "AD_FILES = " >> $MAKEFILE
1337    AD_FILES=`cat ad_files`
1338    for i in $AD_FILES ; do
1339        echo    " \\" >> $MAKEFILE
1340        echo -n " $i" >> $MAKEFILE
1341    done
1342    echo >> $MAKEFILE
1343    rm -f ad_files
1344    
1345    cat >>$MAKEFILE <<EOF
1346    
1347    # ... AD ...
1348    adall: ad_taf
1349    adtaf: ad_taf_output.f
1350    adtamc: ad_tamc_output.f
1351    
1352    ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1353            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
1354            @make \$(F77FILES)
1355            @make \$(AD_FLOW_FILES)
1356            cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f
1357    
1358    ad_taf_output.f: ad_input_code.f
1359            \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f
1360            cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f
1361    
1362    ad_taf: ad_taf_output.o \$(OBJFILES)
1363            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
1364    
1365    ad_tamc_output.f: ad_input_code.f
1366            \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f
1367            cat ad_input_code_ad.f | sed -f adjoint_sed > ad_tamc_output.f
1368    
1369    ad_tamc: ad_tamc_output.o \$(OBJFILES)
1370            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
1371    
1372    
1373    # ... FTL ...
1374    ftlall: ftl_taf
1375    ftltaf: ftl_taf_output.f
1376    ftltamc: ftl_tamc_output.f
1377    
1378    ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1379            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
1380            @make \$(F77FILES)
1381            @make \$(AD_FLOW_FILES)
1382            cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f
1383    
1384    ftl_taf_output.f: ftl_input_code.f
1385            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f
1386            cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f
1387    
1388    ftl_taf: ftl_taf_output.o \$(OBJFILES)
1389            \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
1390    
1391    ftl_tamc_output.f: ftl_input_code.f
1392            \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f
1393            cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_tamc_output.f
1394    
1395    ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
1396            \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
1397    
1398    
1399    # ... SVD ...
1400    svd: svd_taf
1401    svd_taf_f: svd_taf_output.f
1402    
1403    svd_input_code.f: \$(SRCFILES)
1404            cmp svd_config.template AD_CONFIG.h || cat svd_config.template > AD_CONFIG.h
1405            @make \$(F77FILES)
1406            @make \$(AD_FLOW_FILES)
1407            cat \$(AD_FLOW_FILES) \$(AD_FILES) > svd_input_code.f
1408    
1409    svd_taf_output.f: svd_input_code.f
1410            \$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) svd_input_code.f
1411            cat svd_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f
1412    
1413    svd_taf: svd_taf_output.o \$(OBJFILES)
1414            \$(LINK) -o ${EXE_SVD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS)
1415    
1416    
1417    #=========================================
1418    
1419    EOF
1420    
1421    if test "x$EXEHOOK" != x ; then
1422        printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
1423    fi
1424    
1425  echo "  Making list of \"exceptions\" that need \".p\" files"  echo "  Making list of \"exceptions\" that need \".p\" files"
1426  for i in $KPPFILES ; do  for i in $KPPFILES ; do
1427      base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`      base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`
# Line 965  for i in $NOOPTFILES ; do Line 1440  for i in $NOOPTFILES ; do
1440          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
1441      fi      fi
1442      echo "$base.o: $base.f" >> $MAKEFILE      echo "$base.o: $base.f" >> $MAKEFILE
1443      echo $'\t$(FC) $(FFLAGS) $(NOOPTFLAGS) -c $<' >> $MAKEFILE      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
1444  done  done
1445    
1446  echo "  Add rules for links"  echo "  Add rules for links"
# Line 973  cat srclinks.tmp >> $MAKEFILE Line 1448  cat srclinks.tmp >> $MAKEFILE
1448  rm -f srclinks.tmp  rm -f srclinks.tmp
1449    
1450  echo "  Adding makedepend marker"  echo "  Adding makedepend marker"
1451  echo $'\n\n'"# DO NOT DELETE" >> $MAKEFILE  printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE
1452    
1453    printf "\n===  Done  ===\n"
1454    
1455    #  Write the "template" files for the adjoint builds
1456    cat >AD_CONFIG.template <<EOF
1457    C  WARNING: This file is automatically generated by genmake2 and
1458    C    used by the Makefile rules.  Please DO NOT EDIT this file
1459    C    unless you are CERTAIN that you know what you are doing.
1460    
1461    #undef ALLOW_ADJOINT_RUN
1462    #undef ALLOW_TANGENTLINEAR_RUN
1463    #undef ALLOW_ECCO_OPTIMIZATION
1464    EOF
1465    cat >ad_config.template <<EOF
1466    C  WARNING: This file is automatically generated by genmake2 and
1467    C    used by the Makefile rules.  Please DO NOT EDIT this file
1468    C    unless you are CERTAIN that you know what you are doing.
1469    
1470    #define ALLOW_ADJOINT_RUN
1471    #undef ALLOW_TANGENTLINEAR_RUN
1472    #undef ALLOW_ECCO_OPTIMIZATION
1473    EOF
1474    cat >ftl_config.template <<EOF
1475    C  WARNING: This file is automatically generated by genmake2 and
1476    C    used by the Makefile rules.  Please DO NOT EDIT this file
1477    C    unless you are CERTAIN that you know what you are doing.
1478    
1479    #undef ALLOW_ADJOINT_RUN
1480    #define ALLOW_TANGENTLINEAR_RUN
1481    #undef ALLOW_ECCO_OPTIMIZATION
1482    EOF
1483    cat >svd_config.template <<EOF
1484    C  WARNING: This file is automatically generated by genmake2 and
1485    C    used by the Makefile rules.  Please DO NOT EDIT this file
1486    C    unless you are CERTAIN that you know what you are doing.
1487    
1488    #undef ALLOW_ADJOINT_RUN
1489    #undef ALLOW_TANGENTLINEAR_RUN
1490    #undef ALLOW_ECCO_OPTIMIZATION
1491    EOF
1492    cp AD_CONFIG.template AD_CONFIG.h
1493    
1494    
1495  echo $'\n'"===  Done  ==="  #  Write the "state" for future records
1496    if test "x$DUMPSTATE" != xf ; then
1497        echo -n "" > genmake_state
1498        for i in $gm_state ; do
1499            t1="t2=\$$i"
1500            eval $t1
1501            echo "$i='$t2'" >> genmake_state
1502        done
1503    fi

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.27

  ViewVC Help
Powered by ViewVC 1.1.22