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

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

  ViewVC Help
Powered by ViewVC 1.1.22