/[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.13 by edhill, Fri Oct 10 18:38:57 2003 UTC revision 1.78 by adcroft, Tue May 4 16:30:21 2004 UTC
# Line 1  Line 1 
1  #!/bin/bash  #! /usr/bin/env bash
2  #  #
3  # $Header$  # $Header$
4  #  #
# Line 13  Line 13 
13  test_for_package_in_cpp_options() {  test_for_package_in_cpp_options() {
14      cpp_options=$1      cpp_options=$1
15      pkg=$2      pkg=$2
16      grep -i "#define.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg" || exit 99
17      RETVAL=$?      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg" || exit 99
18      if test "x${RETVAL}" = x0 ; then      test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg" || exit 99
19          echo "Error: In $cpp_options there is an illegal line: #define ALLOW_$pkg"      test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg" || exit 99
20          exit 99  }
21      fi  
22      grep -i "#undef.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1  # Search for particular CPP #cmds associated with MPI
23      RETVAL=$?  # usage: test_for_mpi_in_cpp_eeoptions CPP_file
24      if test "x${RETVAL}" = x0 ; then  test_for_mpi_in_cpp_eeoptions() {
25          echo "Error: In $cpp_options there is an illegal line: #undef ALLOW_$pkg"      cpp_options=$1
26          exit 99      test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI" || exit 99
27      fi      test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI" || exit 99
28      grep -i "#define.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1      test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI" || exit 99
29        test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI" || exit 99
30    }
31    
32    # Search for particular string in a file. Return 1 if detected, 0 if not
33    # usage: test_for_string_in_file file string
34    test_for_string_in_file() {
35        file=$1
36        strng=$2
37        grep -i "$strng" $file > /dev/null 2>&1
38      RETVAL=$?      RETVAL=$?
39      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
40          echo "Error: In $cpp_options there is an illegal line: #define DISABLE_$pkg"          printf "Error: In $file there is an illegal line: "
41          exit 99          grep -i "$strng" $file
42            return 1
43      fi      fi
44      grep -i "#undef.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1      return 0
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         echo "Error: In $cpp_options there is an illegal line: #undef DISABLE_$pkg"  
         exit 99  
    fi  
45  }  }
46    
47  # Read the $ROOTDIR/pkg/pkg_groups file and expand any references to  # Read the $ROOTDIR/pkg/pkg_groups file and expand any references to
# Line 46  expand_pkg_groups() { Line 51  expand_pkg_groups() {
51      PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"      PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"
52      if test -r $PKG_GROUPS ; then      if test -r $PKG_GROUPS ; then
53          cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp          cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp
54          cat ./p1.tmp | awk '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp
55          matched=0          matched=0
56          for i in $PACKAGES ; do          for i in $PACKAGES ; do
57              line=`grep "^ *$i" ./p2.tmp`              line=`grep "^ *$i" ./p2.tmp`
58              RETVAL=$?              RETVAL=$?
59              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
60                  matched=1                  matched=1
61                  replace=`echo $line | awk '{ $1=""; $2=""; print $0 }'`                  replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
62                  echo "    replacing \"$i\" with: $replace"                  echo "    replacing \"$i\" with: $replace"
63                  new_packages="$new_packages $replace"                  new_packages="$new_packages $replace"
64              else              else
# Line 62  expand_pkg_groups() { Line 67  expand_pkg_groups() {
67          done          done
68          PACKAGES=$new_packages          PACKAGES=$new_packages
69          rm -f ./p[1,2].tmp          rm -f ./p[1,2].tmp
70            return $matched
71      else      else
72          echo "Warning: can't read package groups definition file: $PKG_GROUPS"          echo "Warning: can't read package groups definition file: $PKG_GROUPS"
73      fi      fi
74  }  }
75    
76    #  Check for broken environments (eg. cygwin, MacOSX w/HFS+) that
77    #  cannot distinguish [*.F/*.F90] from [*.f/*.f90] files.
78    check_for_broken_Ff()  {
79        #  Do we have defaults for $FS and/or $FS90 ?
80        tfs=f
81        tfs9=f90
82        if test "x$FS" != x ; then
83            tfs="$FS"
84        fi
85        if test "x$FS90" != x ; then
86            tfs9="$FS90"
87        fi
88    
89        #  First check the ability to create a *.F/.f pair.
90        cat <<EOF >> genmake_hello.F
91          program hello
92          write(*,*) 'hi'
93          stop
94          end
95    EOF
96        cp genmake_hello.F "genmake_hello."$tfs > /dev/null 2>&1
97        RETVAL=$?
98        if test "x$RETVAL" != x0 ; then
99            if test "x$FS" = x ; then
100                FS='for'
101                FS90='fr9'
102                check_for_broken_Ff
103            else
104                cat <<EOF 2>&1
105    ERROR: Your file system cannot distinguish between *.F and *.f files
106      (fails the "cp" test) and this program cannot find a suitable
107      replacement extension.  Please try a different build environment or
108      contact the <MITgcm-support@mitgcm.org> list for help.
109    
110    EOF
111                exit -1
112            fi
113            return
114        fi
115        rm -f genmake_hello.*
116    
117        #  Check the ability of ${MAKE} and ${LN} to use the current set
118        #  of extensions.
119        cat <<EOF >> genmake_hello.F
120          program hello
121          write(*,*) 'hi'
122          stop
123          end
124    EOF
125        test -e Makefile  &&  mv -f Makefile Makefile.bak
126        cat <<EOF >> Makefile
127    %.$tfs : %.F
128    .SUFFIXES:
129    genmake_hello.$tfs: genmake_hello.F
130            $LN genmake_hello.F genmake_hello.$tfs
131    EOF
132        $MAKE "genmake_hello."$tfs > /dev/null 2>&1
133        RETVAL=$?
134        if test "x$RETVAL" != x0 -o ! -e "genmake_hello."$tfs ; then
135            if test "x$FS" = x ; then
136                FS='for'
137                FS90='fr9'
138                check_for_broken_Ff
139            else
140                cat <<EOF 2>&1
141    ERROR: Your file system cannot distinguish between *.F and *.f files
142      (fails the "make/ln" test) and this program cannot find a suitable
143      replacement extension.  Please try a different build environment or
144      contact the <MITgcm-support@mitgcm.org> list for help.
145    
146    EOF
147                exit -1
148                return
149            fi
150        fi
151        rm -f genmake_hello.* Makefile
152        test -e Makefile  &&  mv -f Makefile.bak Makefile
153    
154        #  If we make it here, use the extensions
155        FS=$tfs
156        FS90=$tfs9
157        return
158    }
159    
160    
161  # Guess possible config options for this host  # Guess possible config options for this host
162  find_possible_configs()  {  find_possible_configs()  {
163    
164      tmp1=`uname`"_"`uname -m`      tmp1=`uname`"_"`uname -m`
165      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
166      PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
167        tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
168        tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
169        tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
170        PLATFORM=$tmp3
171        echo $PLATFORM | grep cygwin > /dev/null 2>&1  &&  PLATFORM=cygwin_ia32
172      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
173      echo "  The platform appears to be:  $PLATFORM"      echo "  The platform appears to be:  $PLATFORM"
 #     if test "x$OFLIST" = x ; then  
 #       echo "  No pre-defined options files were found matching this platform"  
 #       echo "  but examples for other platforms can be found in:"  
 #       echo "    $ROOTDIR/tools/build_options"  
 #     else  
 #       echo "  Options files (located in $ROOTDIR/tools/build_options) that"  
 #       echo "  may work with this machine are:"  
 #       for i in $OFLIST ; do  
 #           echo "    $i"  
 #       done  
 #     fi  
174            
175      echo "test" > test      echo "test" > test
176      ln -s ./test link      ln -s ./test link
# Line 103  find_possible_configs()  { Line 188  find_possible_configs()  {
188          CPP="cpp -traditional -P"          CPP="cpp -traditional -P"
189      fi      fi
190    
191        #  The "original" makedepend is part of the Imake system that is
192        #  most often distributed with XFree86 or with an XFree86 source
193        #  package.  As a result, many machines (eg. generic Linux) do not
194        #  have a system-default "makedepend" available.  For those
195        #  systems, we have two fall-back options:
196        #
197        #    1) a makedepend implementation shipped with the cyrus-imapd
198        #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
199        #
200        #    2) a known-buggy xmakedpend shell script
201        #
202        #  So the choices are, in order:
203        #
204        #    1) use the user-specified program
205        #    2) use a system-wide default
206        #    3) locally build and use the cyrus implementation
207        #    4) fall back to the buggy local xmakedpend script
208        #
209        if test "x${MAKEDEPEND}" = x ; then
210          which makedepend > /dev/null 2>&1
211          RV0=$?
212          cat <<EOF >> genmake_tc.f
213          program test
214          write(*,*) 'test'
215          stop
216          end
217    EOF
218          makedepend genmake_tc.f > /dev/null 2>&1
219          RV1=$?
220          if test ! "x${RV0}${RV1}" = x00 ; then
221             echo "    a system-default makedepend was not found."
222    
223             #  Try to build the cyrus impl
224             rm -f ./genmake_cy_md
225             (
226                 cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
227                     &&  ./configure > /dev/null 2>&1  \
228                     &&  make > /dev/null 2>&1
229                 if test -x ./makedepend.exe ; then
230                     $LN ./makedepend.exe ./makedepend
231                 fi
232                 ./makedepend ifparser.c > /dev/null 2>&1  \
233                     &&  echo "true"
234             ) > ./genmake_cy_md
235             grep true ./genmake_cy_md > /dev/null 2>&1
236             RETVAL=$?
237             if test "x$RETVAL" = x0 ; then
238                 MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
239             else
240                 MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
241             fi
242             rm -f ./genmake_cy_md
243          fi
244        fi
245    
246      # look for possible fortran compilers      # look for possible fortran compilers
247      tmp="$MITGCM_FC $FC g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
248      p_FC=      p_FC=
249      for c in $tmp ; do      for c in $tmp ; do
250          rm -f ./hello.f ./hello          rm -f ./hello.f ./hello
# Line 121  EOF Line 261  EOF
261              p_FC="$p_FC $c"              p_FC="$p_FC $c"
262          fi          fi
263      done      done
264        rm -f ./hello.f ./hello
265      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
266          cat 1>&2 <<EOF          cat 1>&2 <<EOF
267    
# Line 136  EOF Line 277  EOF
277          echo "  The possible FORTRAN compilers found in your path are:"          echo "  The possible FORTRAN compilers found in your path are:"
278          echo "   "$p_FC          echo "   "$p_FC
279          if test "x$FC" = x ; then          if test "x$FC" = x ; then
280              FC=`echo $p_FC | awk '{print $1}'`              FC=`echo $p_FC | $AWK '{print $1}'`
281                echo "  Setting FORTRAN compiler to: "$FC
282          fi          fi
283      fi      fi
284    
285      for i in $p_FC ; do      if test "x$OPTFILE" = x ; then
286          p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
287          if test -r $p_OF ; then          if test ! -r $OPTFILE ; then
288              OPTFILE=$p_OF               echo "  I looked for the file "$OPTFILE" but did not find it"
289              echo "  The options file:  $p_OF"          fi
290              echo "    appears to match so we'll use it."      fi
291              break  #    echo "  The options file:  $p_OF"
292          fi  #    echo "    appears to match so we'll use it."
293      done  #   for i in $p_FC ; do
294    #p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
295    #if test -r $p_OF ; then
296    #    OPTFILE=$p_OF
297    #    echo "  The options file:  $p_OF"
298    #    echo "    appears to match so we'll use it."
299    #    break
300    #fi
301    #   done
302      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
303          cat 1>&2 <<EOF          cat 1>&2 <<EOF
304    
# Line 202  get_pdepend_list()  { Line 352  get_pdepend_list()  {
352      #  strip the comments and then convert the dependency file into      #  strip the comments and then convert the dependency file into
353      #  two arrays: PNAME, DNAME      #  two arrays: PNAME, DNAME
354      cat $1 | sed -e 's/#.*$//g' \      cat $1 | sed -e 's/#.*$//g' \
355          | 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} }' \
356          > ./.pd_tmp          > ./.pd_tmp
357      source ./.pd_tmp      . ./.pd_tmp
358      rm -f ./.pd_tmp      rm -f ./.pd_tmp
359    
360      echo -n "PNAME = "${}      printf "PNAME = "${}
361  }  }
362    
363    
364  #  Explain usage  #  Explain usage
365  usage()  {  usage()  {
366      echo  cat <<EOF
367      echo "Usage: "$0" [OPTIONS]"  
368      echo "  where [OPTIONS] can be:"  Usage: "$0" [OPTIONS]
369      echo    where [OPTIONS] can be:
370      echo "    -help | --help | -h | --h"  
371      echo "    -nooptfile | --nooptfile"      -help | --help | -h | --h
372      echo "      -optfile NAME | --optfile NAME | -of NAME | --of NAME"            Print this help message and exit.
373      echo "      -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME"  
374      echo "    -pdepend NAME | --pdepend NAME"      -nooptfile | --nooptfile
375      echo "      -pdepend=NAME | --pdepend=NAME"        -optfile NAME | --optfile NAME | -of NAME | --of NAME
376      echo "    -pdefault NAME | --pdefault NAME"        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
377      echo "      -pdefault=NAME | --pdefault=NAME"            Use "NAME" as the optfile.  By default, an attempt will be
378      echo "    -make NAME | -m NAME"            made to find an appropriate "standard" optfile in the
379      echo "      --make=NAME | -m=NAME"            tools/build_options/ directory.
380      echo "    -makefile NAME | -mf NAME"  
381      echo "      --makefile=NAME | -mf=NAME"      -pdepend NAME | --pdepend NAME
382      echo "    -platform NAME | --platform NAME | -pl NAME | --pl NAME"        -pdepend=NAME | --pdepend=NAME
383      echo "      -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME"            Get package dependency information from "NAME".
384      echo "    -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME"  
385      echo "      -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME"      -pdefault NAME | --pdefault NAME
386      echo "    -mods NAME | --mods NAME | -mo NAME | --mo NAME"        -pdefault=NAME | --pdefault=NAME
387      echo "      -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME"            Get the default package list from "NAME".
388      echo "    -disable NAME | --disable NAME"  
389      echo "      -disable=NAME | --disable=NAME"      -make NAME | -m NAME
390      echo "    -enable NAME | --enable NAME"        --make=NAME | -m=NAME
391      echo "      -enable=NAME | --enable=NAME"            Use "NAME" for the MAKE program. The default is "make" but
392      echo "    -standarddirs NAME | --standarddirs NAME"            many platforms, "gmake" is the preferred choice.
393      echo "      -standarddirs=NAME | --standarddirs=NAME"  
394      echo "    -noopt NAME | --noopt NAME"      -makefile NAME | -mf NAME
395      echo "      -noopt=NAME | --noopt=NAME"        --makefile=NAME | -mf=NAME
396  #    echo "    -cpp NAME | --cpp NAME"            Call the makefile "NAME".  The default is "Makefile".
397  #    echo "      -cpp=NAME | --cpp=NAME"  
398      echo "    -fortran NAME | --fortran NAME | -fc NAME | --fc NAME"      -makedepend NAME | -md NAME
399      echo "      -fc=NAME | --fc=NAME"        --makedepend=NAME | -md=NAME
400      echo "    -[no]ieee | --[no]ieee"            Use "NAME" for the MAKEDEPEND program.
401      echo "    -[no]mpi | --[no]mpi"  
402      echo "    -[no]jam | --[no]jam"      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
403      echo        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
404      echo "  and NAME is a string such as:"            Specify the location of the MITgcm ROOTDIR as "NAME".
405      echo            By default, genamke will try to find the location by
406      echo "    --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'"            looking in parent directories (up to the 5th parent).
407      echo "    -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'"  
408      echo "    -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'"      -mods NAME | --mods NAME | -mo NAME | --mo NAME
409      echo        -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME
410      echo "  which, depending upon your shell, may need to be single-quoted"            Here, "NAME" specifies a list of directories that are
411      echo "  if it contains spaces, dashes, or other special characters."            used for additional source code.  Files found in the
412              "mods list" are given preference over files of the same
413              name found elsewhere.
414    
415        -disable NAME | --disable NAME
416          -disable=NAME | --disable=NAME
417              Here "NAME" specifies a list of packages that we don't
418              want to use.  If this violates package dependencies,
419              genamke will exit with an error message.
420    
421        -enable NAME | --enable NAME
422          -enable=NAME | --enable=NAME
423              Here "NAME" specifies a list of packages that we wish
424              to specifically enable.  If this violates package
425              dependencies, genamke will exit with an error message.
426    
427        -standarddirs NAME | --standarddirs NAME
428          -standarddirs=NAME | --standarddirs=NAME
429              Here, "NAME" specifies a list of directories to be
430              used as the "standard" code.
431    
432        -fortran NAME | --fortran NAME | -fc NAME | --fc NAME
433          -fc=NAME | --fc=NAME
434              Use "NAME" as the fortran compiler.  By default, genmake
435              will search for a working compiler by trying a list of
436              "usual suspects" such as g77, f77, etc.
437    
438        -[no]ieee | --[no]ieee
439              Do or don't use IEEE numerics.  Note that this option
440              *only* works if it is supported by the OPTFILE that
441              is being used.
442    
443        -mpi | --mpi
444              Include MPI header files and link to MPI libraries
445        -mpi=PATH | --mpi=PATH
446              Include MPI header files and link to MPI libraries using MPI_ROOT
447              set to PATH. i.e. Include files from $PATH/include, link to libraries
448              from $PATH/lib and use binaries from $PATH/bin.
449    
450        -bash NAME
451              Explicitly specify the Bourne or BASH shell to use
452    
453      While it is most often a single word, the "NAME" variables specified
454      above can in many cases be a space-delimited string such as:
455    
456        --enable pkg1   --enable 'pkg1 pkg2'   --enable 'pkg1 pkg2 pkg3'
457        -mods=dir1   -mods='dir1'   -mods='dir1 dir2 dir3'
458        -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'
459    
460      which, depending upon your shell, may need to be single-quoted.
461    
462      For more detailed genmake documentation, please see:
463    
464        http://mitgcm.org/devel_HOWTO/
465    
466    EOF
467    
468      exit 1      exit 1
469  }  }
470    
471  #eh3 # This is the generic configuration.  #  Build a CPP macro to automate calling C routines from FORTRAN
472  #eh3 set LN         = ( 'ln -s' )  get_fortran_c_namemangling()  {
473  #eh3 set CPP        = ( '/lib/cpp -P' )      default_nm="#define FC_NAMEMANGLE(X) X ## _"
474  #eh3 set S64        = ( '$(TOOLSDIR)/set64bitConst.sh' )      
475  #eh3 set KPP        = (  )      cat > genmake_test.c <<EOF
476  #eh3 set FC         = ( 'f77' )  void tcall( char * string ) { tsub( string ); }
477  #eh3 set LINK       = $FC  EOF
478  #eh3 set MAKEDEPEND = ( 'makedepend' )      $MAKE genmake_test.o >> genmake_warnings 2>&1
479  #eh3 set INCLUDES   = ( -I. )      RETVAL=$?
480  #eh3 set FFLAGS     = (  )      if test "x$RETVAL" != x0 ; then
481  #eh3 set FOPTIM     = (  )          FC_NAMEMANGLE=$default_nm
482  #eh3 set CFLAGS     = (  )          cat <<EOF>> genmake_errors
483  #eh3 set KFLAGS1    = (  )  
484  #eh3 set KFLAGS2    = (  )  WARNING: C test compile fails
485  #eh3 set LIBS       = (  )  WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
486  #eh3 set KPPFILES   = (  )  WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
487  #eh3 if (! $?NOOPTFILES ) set NOOPTFILES = (  )  EOF
488  #eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = (  )          return 1
489        fi
490        c_tcall=`nm genmake_test.o | grep 'T ' | grep tcall | cut -d ' ' -f 3`
491        RETVAL=$?
492        if test "x$RETVAL" != x0 ; then
493            FC_NAMEMANGLE=$default_nm
494            cat <<EOF>> genmake_warnings
495    
496    WARNING: The "nm" command failed.
497    WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
498    WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here
499    EOF
500            return 1
501        fi
502        cat > genmake_tcomp.f <<EOF
503          subroutine tcall( string )
504          character*(*) string
505          call tsub( string )
506          end
507    EOF
508        $FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1
509        RETVAL=$?
510        if test "x$RETVAL" != x0 ; then
511            FC_NAMEMANGLE=$default_nm
512            cat <<EOF>> genmake_warnings
513    
514    WARNING: FORTRAN test compile fails -- please see "genmake_errors"
515    WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
516    WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
517    EOF
518            return 1
519        fi
520        f_tcall=`nm genmake_tcomp.o | grep 'T ' | grep tcall | cut -d ' ' -f 3`
521        RETVAL=$?
522        if test "x$RETVAL" != x0 ; then
523            FC_NAMEMANGLE=$default_nm
524            cat <<EOF>> genmake_warnings
525    
526    WARNING: The "nm" command failed.
527    WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'
528    WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here.
529    EOF
530            return 1
531        fi
532    
533        c_a=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
534        f_a=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
535        c_b=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
536        f_b=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
537    
538        nmangle="X"
539        if test "x$c_a" != "x$f_a" ; then
540            comm="echo x$f_a | sed -e 's|x$c_a||'"
541            a=`eval $comm`
542            nmangle="$a ## $nmangle"
543        fi
544        if test "x$c_b" != "x$f_b" ; then
545            comm="echo x$f_b | sed -e 's|x$c_b||'"
546            b=`eval $comm`
547            nmangle="$nmangle ## $b"
548        fi
549    
550        FC_NAMEMANGLE="#define FC_NAMEMANGLE(X)  $nmangle"
551    
552        #  cleanup the testing files
553        rm -f genmake_tcomp.* genmake_test.*
554    }
555    
556    
557    check_HAVE_CLOC()  {
558        get_fortran_c_namemangling
559        cat <<EOF > genmake_tc_1.c
560    $FC_NAMEMANGLE
561    #include <stdio.h>
562    #include <stdlib.h>
563    #include <unistd.h>
564    #include <assert.h>
565    #include <sys/time.h>
566    void FC_NAMEMANGLE(cloc) ( double *curtim )
567    {
568     struct timeval tv1;
569     gettimeofday(&tv1 , (void *)NULL );
570     *curtim =  (double)((tv1.tv_usec)+(tv1.tv_sec)*1.E6);
571     *curtim = *curtim/1.E6;
572    }
573    EOF
574        make genmake_tc_1.o >> genmake_tc.log 2>&1
575        RET_C=$?
576        cat <<EOF > genmake_tc_2.f
577          program hello
578          Real*8 wtime
579          external cloc
580          call cloc(wtime)
581          print *," HELLO WORLD", wtime
582          end program hello
583    EOF
584        $FC $FFLAGS -o genmake_tc genmake_tc_2.f genmake_tc_1.o >> genmake_tc.log 2>&1
585        RET_F=$?
586        test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1
587        RETVAL=$?
588        if test "x$RETVAL" = x0 ; then
589            HAVE_CLOC=t
590            DEFINES="$DEFINES -DHAVE_CLOC"
591        fi
592        rm -f genmake_tc*
593    }
594    
595    
596    check_netcdf_libs()  {
597        cat <<EOF > genmake_tnc.for
598          program fgennc
599    #include "netcdf.inc"
600          integer iret, ncid, xid
601          iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
602          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
603          iret = nf_def_dim(ncid, 'X', 11, xid)
604          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
605          iret = nf_close(ncid)
606          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
607          end
608    EOF
609        $CPP genmake_tnc.for > genmake_tnc.f  \
610            &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1
611        RET_COMPILE=$?
612        test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
613        RETVAL=$?
614        if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
615            HAVE_NETCDF=t
616        else
617            # try again with "-lnetcdf" added to the libs
618            $CPP genmake_tnc.for > genmake_tnc.f  \
619                &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \
620                $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1
621            RET_COMPILE=$?
622            test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
623            RETVAL=$?
624            if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
625                LIBS="$LIBS -lnetcdf"
626                HAVE_NETCDF=t
627            else
628                cat genmake_tnc.log >> genmake_warnings
629            fi
630        fi
631        rm -f genmake_tnc*
632    }
633    
634    
635    
636    ###############################################################################
637    #   Sequential part of script starts here
638    ###############################################################################
639    
640  #  Set defaults here  #  Set defaults here
641  COMMANDL="$0 $@"  COMMANDL="$0 $@"
# Line 289  LN= Line 645  LN=
645  S64=  S64=
646  KPP=  KPP=
647  FC=  FC=
648    CPP=
649  LINK=  LINK=
650  DEFINES="-DWORDLENGTH=4"  DEFINES=
651  PACKAGES=  PACKAGES=
652  ENABLE=  ENABLE=
653  DISABLE=  DISABLE=
# Line 306  FOPTIM= Line 663  FOPTIM=
663  CFLAGS=  CFLAGS=
664  KFLAGS1=  KFLAGS1=
665  KFLAGS2=  KFLAGS2=
666    #LDADD=
667  LIBS=  LIBS=
668  KPPFILES=  KPPFILES=
669  NOOPTFILES=  NOOPTFILES=
670  NOOPTFLAGS=  NOOPTFLAGS=
671    MPI=
672    MPIPATH=
673    
674    # DEFINES checked by test compilation
675    HAVE_SYSTEM=
676    HAVE_FDATE=
677    FC_NAMEMANGLE=
678    HAVE_CLOC=
679    HAVE_NETCDF=
680    
681  MODS=  MODS=
682  TOOLSDIR=  TOOLSDIR=
683  SOURCEDIRS=  SOURCEDIRS=
684  INCLUDEDIRS=  INCLUDEDIRS=
685  STANDARDDIRS=  STANDARDDIRS="USE_THE_DEFAULT"
686    
687    G2ARGS=
688    BASH=
689  PWD=`pwd`  PWD=`pwd`
690  MAKE=make  MAKE=make
691    AWK=awk
692  THISHOSTNAME=`hostname`  THISHOSTNAME=`hostname`
693  THISCWD=`pwd`  THISCWD=`pwd`
694  THISDATE=`date`  THISDATE=`date`
# Line 331  IEEE= Line 701  IEEE=
701  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
702      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
703  fi  fi
704    FS=
705    FS90=
706    
707    AUTODIFF_PKG_USED=f
708    AD_OPTFILE=
709    TAF=
710    AD_TAF_FLAGS=
711    FTL_TAF_FLAGS=
712    SVD_TAF_FLAGS=
713    TAF_EXTRA=
714    TAMC=
715    AD_TAMC_FLAGS=
716    FTL_TAF_FLAGS=
717    SVD_TAMC_FLAGS=
718    TAMC_EXTRA=
719    
720    
721  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
722  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
723  gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS"
724    
725  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
726  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "
727  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
728  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"
729  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
730    gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE"
731    
732  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6"  #  The following are all related to adjoint/tangent-linear stuff
733    gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
734    gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
735    gm_s12="TAF_EXTRA TAMC_EXTRA"
736    
737    gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7"
738    gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
739    
740    cat <<EOF
741    
742    GENMAKE :
743    
744    A program for GENerating MAKEfiles for the MITgcm project.  For a
745    quick list of options, use "genmake -h" or for more detail see:
746    
747      http://mitgcm.org/devel_HOWTO/
748    
749    EOF
750    
 echo  
751  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
752  gm_local="genmake_local"  gm_local="genmake_local"
753  for i in . $MODS ; do  for i in . $MODS ; do
754      if test -r $i/$gm_local ; then      if test -r $i/$gm_local ; then
755          source $i/$gm_local          . $i/$gm_local
756          break          break
757      fi      fi
758  done  done
759  echo -n "  getting local config information:  "  printf "  getting local config information:  "
760  if test -e $gm_local ; then  if test -e $gm_local ; then
761      echo "using $gm_local"      echo "using $gm_local"
762      source $gm_local      . $gm_local
763      # echo "DISABLE=$DISABLE"      # echo "DISABLE=$DISABLE"
764      # echo "ENABLE=$ENABLE"      # echo "ENABLE=$ENABLE"
765  else  else
# Line 375  fi Line 777  fi
777  #   n=$(( $n + 1 ))  #   n=$(( $n + 1 ))
778  #done  #done
779  #parse_options  #parse_options
   
780  ac_prev=  ac_prev=
781  for ac_option ; do  for ac_option ; do
782    
783        G2ARGS="$G2ARGS \"$ac_option\""
784    
785      # If the previous option needs an argument, assign it.      # If the previous option needs an argument, assign it.
786      if test -n "$ac_prev"; then      if test -n "$ac_prev"; then
787          eval "$ac_prev=\$ac_option"          eval "$ac_prev=\$ac_option"
# Line 400  for ac_option ; do Line 803  for ac_option ; do
803          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
804              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
805                    
806            -adoptfile | --adoptfile | -adof | --adof)
807                ac_prev=AD_OPTFILE ;;
808            -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
809                AD_OPTFILE=$ac_optarg ;;
810            
811          -pdepend | --pdepend)          -pdepend | --pdepend)
812              ac_prev=PDEPEND ;;              ac_prev=PDEPEND ;;
813          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
# Line 415  for ac_option ; do Line 823  for ac_option ; do
823          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
824              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
825                    
826            -bash | --bash)
827                ac_prev=BASH ;;
828            -bash=* | --bash=*)
829                BASH=$ac_optarg ;;
830            
831            -makedepend | --makedepend | -md | --md)
832                ac_prev=MAKEDEPEND ;;
833            -makedepend=* | --makedepend=* | -md=* | --md=*)
834                MAKEDEPEND=$ac_optarg ;;
835            
836          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -ma | --ma)
837              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
838          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -ma=* | --ma=*)
839              MAKEFILE=$ac_optarg ;;              MAKEFILE=$ac_optarg ;;
840                    
841          -platform | --platform | -pl | --pl)          -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*)
842              ac_prev=PLATFORM ;;              echo "ERROR: The platform option has been removed.  Please specify"
843          -platform=* | --platform=* | -pl=* | --pl=*)              echo "  the build options using the \"optfile\" mechanism."
844              PLATFORM=$ac_optarg ;;              echo
845                usage
846                ;;
847                    
848          -rootdir | --rootdir | -rd | --rd)          -rootdir | --rootdir | -rd | --rd)
849              ac_prev=ROOTDIR ;;              ac_prev=ROOTDIR ;;
# Line 450  for ac_option ; do Line 870  for ac_option ; do
870          -standarddirs=* | --standarddirs=*)          -standarddirs=* | --standarddirs=*)
871              STANDARDDIRS=$ac_optarg ;;              STANDARDDIRS=$ac_optarg ;;
872    
         -noopt | --noopt)  
             ac_prev=NOOPT ;;  
         -noopt=* | --noopt=*)  
             NOOPT=$ac_optarg ;;  
           
873  #           -cpp | --cpp)  #           -cpp | --cpp)
874  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
875  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
# Line 465  for ac_option ; do Line 880  for ac_option ; do
880          -fc=* | --fc=*)          -fc=* | --fc=*)
881              FC=$ac_optarg ;;              FC=$ac_optarg ;;
882                    
883            -fs | --fs)
884                ac_prev=FS ;;
885            -fs=* | --fs=*)
886                FS=$ac_optarg ;;
887            
888            -fs90 | --fs90)
889                ac_prev=FS90 ;;
890            -fs90=* | --fs90=*)
891                FS90=$ac_optarg ;;
892            
893          -ieee | --ieee)          -ieee | --ieee)
894              IEEE=true ;;              IEEE=true ;;
895          -noieee | --noieee)          -noieee | --noieee)
896              IEEE= ;;              IEEE= ;;
897            
898          -mpi | --mpi)          -mpi | --mpi)
899              MPI=true ;;              MPI=true ;;
900          -nompi | --nompi)          -mpi=* | --mpi=*)
901              MPI= ;;              MPIPATH=$ac_optarg
902                MPI=true ;;
903                    
904          -jam | --jam)  #       -jam | --jam)
905              JAM=1 ;;  #           JAM=1 ;;
906          -nojam | --nojam)  #       -nojam | --nojam)
907              JAM=0 ;;  #           JAM=0 ;;
908                    
909          -ds | --ds)          -ds | --ds)
910              DUMPSTATE=t ;;              DUMPSTATE=t ;;
911                    
912            -taf_extra | --taf_extra)
913                ac_prev=TAF_EXTRA ;;
914            -taf_extra=* | --taf_extra=*)
915                TAF_EXTRA=$ac_optarg ;;
916    
917            -tamc_extra | --tamc_extra)
918                ac_prev=TAMC_EXTRA ;;
919            -tamc_extra=* | --tamc_extra=*)
920                TAMC_EXTRA=$ac_optarg ;;
921    
922          -*)          -*)
923              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
924              usage              usage
# Line 516  if test "x${ROOTDIR}" = x ; then Line 952  if test "x${ROOTDIR}" = x ; then
952          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
953              if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then              if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then
954                  ROOTDIR=$d                  ROOTDIR=$d
955                  echo -n "Warning:  ROOTDIR was not specified but there appears to be"                  printf "Warning:  ROOTDIR was not specified but there appears to be"
956                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
957                  break                  break
958              fi              fi
# Line 547  fi Line 983  fi
983  if test "x$OPTFILE" != xNONE ; then  if test "x$OPTFILE" != xNONE ; then
984      if test -f "$OPTFILE" -a -r "$OPTFILE" ; then      if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
985          echo "    using OPTFILE=\"$OPTFILE\""          echo "    using OPTFILE=\"$OPTFILE\""
986          source "$OPTFILE"          . "$OPTFILE"
987          RETVAL=$?          RETVAL=$?
988          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
989              echo -n "Error: failed to source OPTFILE \"$OPTFILE\""              printf "Error: failed to source OPTFILE \"$OPTFILE\""
990              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
991              exit 1              exit 1
992          fi          fi
# Line 563  if test "x$OPTFILE" != xNONE ; then Line 999  if test "x$OPTFILE" != xNONE ; then
999      fi      fi
1000  fi  fi
1001    
1002  #  Check that FC, LINK, CPP, and S64 are defined.  If not, complain  #  Check for broken systems that cannot correctly distinguish *.F and *.f files
1003  #  and abort!  # check_for_broken_Ff
1004    
1005    echo "  getting AD_OPTFILE information:  "
1006    if test "x${AD_OPTFILE}" = x ; then
1007        if test "x$MITGCM_AD_OF" = x ; then
1008            AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
1009        else
1010            AD_OPTFILE=$MITGCM_AD_OF
1011        fi
1012    fi
1013    if test "x${AD_OPTFILE}" != xNONE ; then
1014        if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then
1015            echo "    using AD_OPTFILE=\"$AD_OPTFILE\""
1016            . "$AD_OPTFILE"
1017            RETVAL=$?
1018            if test "x$RETVAL" != x0 ; then
1019                printf "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
1020                echo "--please check that variable syntax is bash-compatible"
1021                exit 1
1022            fi
1023            if test "x$DUMPSTATE" != xf ; then
1024                cp -f $AD_OPTFILE "genmake_ad_optfile"
1025            fi
1026        else
1027            echo "Error: can't read AD_OPTFILE=\"$AD_OPTFILE\""
1028            exit 1
1029        fi
1030    fi
1031    
1032    #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1033    #  either set defaults or complain and abort!
1034    if test ! "x$BASH" = x ; then
1035        # add a trailing space so that it works within the Makefile syntax (see below)
1036        BASH="$BASH "
1037    fi
1038  if test "x$FC" = x ; then  if test "x$FC" = x ; then
1039      cat <<EOF 1>&2      cat <<EOF 1>&2
1040    
# Line 578  fi Line 1048  fi
1048  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1049      LINK=$FC      LINK=$FC
1050  fi  fi
1051    if test "x$MAKE" = x ; then
1052        MAKE="make"
1053    fi
1054  if test "x$CPP" = x ; then  if test "x$CPP" = x ; then
1055      CPP="cpp"      CPP=cpp
1056  fi  fi
1057    #EH3 === UGLY ===
1058    #  The following is an ugly little hack to check for $CPP in /lib/ and
1059    #  it should eventually be replaced with a more general function that
1060    #  searches a combo of the user's path and a list of "usual suspects"
1061    #  to find the correct location for binaries such as $CPP.
1062    for i in " " "/lib/" ; do
1063        echo "#define A a" | $i$CPP > test_cpp 2>&1 && CPP=$i$CPP
1064    done
1065    #EH3 === UGLY ===
1066  echo "#define A a" | $CPP > test_cpp 2>&1  echo "#define A a" | $CPP > test_cpp 2>&1
1067  RETVAL=$?  RETVAL=$?
1068  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
# Line 590  Error: C pre-processor "$CPP" failed the Line 1072  Error: C pre-processor "$CPP" failed the
1072    
1073    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
1074    2) the "./genmake_local" file    2) the "./genmake_local" file
1075      3) with the CPP environment variable
1076    
1077  EOF  EOF
1078      exit 1      exit 1
# Line 599  fi Line 1082  fi
1082  if test "x$MAKEDEPEND" = x ; then  if test "x$MAKEDEPEND" = x ; then
1083      MAKEDEPEND=makedepend      MAKEDEPEND=makedepend
1084  fi  fi
1085    if test "x$LN" = x ; then
1086        LN="ln -s"
1087    fi
1088    echo "test" > genmake_test_ln
1089    $LN genmake_test_ln genmake_tlink
1090    RETVAL=$?
1091    if test "x$RETVAL" != x0 ; then
1092        cat <<EOF 1>&2
1093    
1094    Error: The command "ln -s" failed -- please specify a working soft-link
1095      command in the optfile.
1096    
1097    EOF
1098        exit 1
1099    fi
1100    rm -f genmake_test_ln genmake_tlink
1101    
1102    #  Check for broken *.F/*.f handling and fix if possible
1103    check_for_broken_Ff
1104    
1105    if test ! "x$MPI" = x ; then
1106          echo "  Turning on MPI cpp macros"
1107          DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1108    fi
1109    
1110    printf "\n===  Checking system libraries  ===\n"
1111    printf "  Do we have the system() command using $FC...  "
1112    cat > genmake_tcomp.f <<EOF
1113          program hello
1114          call system('echo hi')
1115          end
1116    EOF
1117    $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1
1118    RETVAL=$?
1119    if test "x$RETVAL" = x0 ; then
1120        HAVE_SYSTEM=t
1121        DEFINES="$DEFINES -DHAVE_SYSTEM"
1122        echo "yes"
1123    else
1124        HAVE_SYSTEM=
1125        echo "no"
1126    fi
1127    rm -f genmake_tcomp*
1128    
1129    printf "  Do we have the fdate() command using $FC...  "
1130    cat > genmake_tcomp.f <<EOF
1131          program hello
1132          CHARACTER(128) string
1133          string = ' '
1134          call fdate( string )
1135          print *, string
1136          end
1137    EOF
1138    $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1
1139    RETVAL=$?
1140    if test "x$RETVAL" = x0 ; then
1141        HAVE_FDATE=t
1142        DEFINES="$DEFINES -DHAVE_FDATE"
1143        echo "yes"
1144    else
1145        HAVE_FDATE=
1146        echo "no"
1147    fi
1148    rm -f genmake_tcomp*
1149    
1150    printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1151    check_HAVE_CLOC
1152    if test "x$HAVE_CLOC" != x ; then
1153        echo "yes"
1154    else
1155        echo "no"
1156    fi
1157    rm -f genmake_t*
1158    
1159    printf "  Can we create NetCDF-enabled binaries...  "
1160    check_netcdf_libs
1161    if test "x$HAVE_NETCDF" != x ; then
1162        echo "yes"
1163    else
1164        echo "no"
1165    fi
1166    
1167    
1168  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1169  echo -n "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
1170  for d in $MODS ; do  for d in $MODS ; do
1171      if test ! -d $d ; then      if test ! -d $d ; then
1172          echo          echo
1173          echo "Error: MODS directory \"$d\" not found!"          echo "Error: MODS directory \"$d\" not found!"
1174          exit 1          exit 1
1175      else      else
1176          echo -n " $d"          printf " $d"
1177          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1178          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
1179      fi      fi
# Line 638  if test "x${TOOLSDIR}" = x ; then Line 1203  if test "x${TOOLSDIR}" = x ; then
1203      TOOLSDIR="$ROOTDIR/tools"      TOOLSDIR="$ROOTDIR/tools"
1204  fi  fi
1205  if test ! -d ${TOOLSDIR} ; then  if test ! -d ${TOOLSDIR} ; then
1206      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"
1207      exit 1      exit 1
1208  fi  fi
1209  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1210      S64='$(TOOLSDIR)/set64bitConst.sh'      S64='$(TOOLSDIR)/set64bitConst.sh'
1211  fi  fi
1212    THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1213    
1214  EXECUTABLE=${EXECUTABLE:-mitgcmuv}  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
1215    
# Line 652  EXECUTABLE=${EXECUTABLE:-mitgcmuv} Line 1218  EXECUTABLE=${EXECUTABLE:-mitgcmuv}
1218  #  they appear as regular source code  #  they appear as regular source code
1219  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then  if test -r $ROOTDIR"/eesupp/src/Makefile" ; then
1220      echo "  Making source files in eesupp from templates"      echo "  Making source files in eesupp from templates"
1221      $MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1      ( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1
1222      RETVAL=$?      RETVAL=$?
1223      if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
1224          rm -f make_eesupp.errors          rm -f make_eesupp.errors
1225      else      else
1226          echo "Error: problem encountered while building source files in eesupp:"          echo "Error: problem encountered while building source files in eesupp:"
1227          cat make_eesupp.errors          cat make_eesupp.errors 1>&2
1228          exit 1          exit 1
1229      fi      fi
1230  fi  fi
1231    
1232    #same for exch2
1233    if test -r $ROOTDIR"/pkg/exch2/Makefile" ; then
1234        echo "  Making source files in exch2 from  templates"
1235        ( cd $ROOTDIR"/pkg/exch2/" && $MAKE ) > make_exch2.errors 2>&1
1236        RETVAL=$?
1237        if test "x${RETVAL}" = x0 ; then
1238            rm -f make_exch2.errors
1239        else
1240            echo "Error: problem encountered while building source files in exch2:"
1241            cat make_exch2.errors 1>&2
1242            exit 1
1243        fi
1244    fi
1245    
1246  printf "\n===  Determining package settings  ===\n"  printf "\n===  Determining package settings  ===\n"
1247  if  test "x${PDEPEND}" = x ; then  if  test "x${PDEPEND}" = x ; then
1248      tmp=$ROOTDIR"/pkg/pkg_depend"      tmp=$ROOTDIR"/pkg/pkg_depend"
# Line 682  echo "  getting package dependency info Line 1262  echo "  getting package dependency info
1262  #  Strip the comments and then convert the dependency file into  #  Strip the comments and then convert the dependency file into
1263  #  two arrays: PNAME, DNAME  #  two arrays: PNAME, DNAME
1264  cat $PDEPEND | sed -e 's/#.*$//g' \  cat $PDEPEND | sed -e 's/#.*$//g' \
1265      | awk 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \      | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
1266      > ./.pd_tmp      > ./.pd_tmp
1267  RETVAL=$?  RETVAL=$?
1268  if test ! "x${RETVAL}" = x0 ; then  if test ! "x${RETVAL}" = x0 ; then
1269      echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""      echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""
1270      exit 1      exit 1
1271  fi  fi
1272  source ./.pd_tmp  . ./.pd_tmp
1273  rm -f ./.pd_tmp  rm -f ./.pd_tmp
1274    
1275  #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"  #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"
1276  #  file should eventually be added so that, for convenience, one can  #  file should eventually be added so that, for convenience, one can
1277  #  specify groups of packages using names like "ocean" and "atmosphere".  #  specify groups of packages using names like "ocean" and "atmosphere".
1278  echo  -n "  checking default package list:  "  echo "  checking default package list:  "
1279  if test "x${PDEFAULT}" = x ; then  if test "x${PDEFAULT}" = x ; then
1280      for i in "." $MODS ; do      for i in "." $MODS ; do
1281          if test -r $i"/packages.conf" ; then          if test -r $i"/packages.conf" ; then
# Line 708  if test "x${PDEFAULT}" = x ; then Line 1288  if test "x${PDEFAULT}" = x ; then
1288      PDEFAULT="$ROOTDIR/pkg/pkg_default"      PDEFAULT="$ROOTDIR/pkg/pkg_default"
1289  fi  fi
1290  if test "x${PDEFAULT}" = xNONE ; then  if test "x${PDEFAULT}" = xNONE ; then
1291      echo "default packages file disabled"      echo "    default packages file disabled"
1292  else  else
1293      if test ! -r $PDEFAULT ; then      if test ! -r $PDEFAULT ; then
         echo ""  
1294          echo "Warning:  can't read default packages from PDEFAULT=\"$PDEFAULT\""          echo "Warning:  can't read default packages from PDEFAULT=\"$PDEFAULT\""
1295      else      else
1296          echo "  using PDEFAULT=\"$PDEFAULT\""          echo "    using PDEFAULT=\"$PDEFAULT\""
1297          #  Strip the comments and add all the names          #  Strip the comments and add all the names
1298          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | awk '(NF>0){print $0}'`          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
1299          RETVAL=$?          RETVAL=$?
1300          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
1301              echo -n "Error: can't parse default package list "              printf "Error: can't parse default package list "
1302              echo "-- please check PDEFAULT=\"$PDEFAULT\""              echo "-- please check PDEFAULT=\"$PDEFAULT\""
1303              exit 1              exit 1
1304          fi          fi
# Line 727  else Line 1306  else
1306              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
1307          done          done
1308          echo "    before group expansion packages are: $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
1309          expand_pkg_groups          while ! expand_pkg_groups; do echo > /dev/null; done
1310          echo "    after group expansion packages are:  $PACKAGES"          echo "    after group expansion packages are:  $PACKAGES"
1311      fi      fi
1312  fi  fi
1313    
1314  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
1315    for i in $PACKAGES ; do
1316        echo $i >> ./.tmp_pack
1317    done
1318    for i in `grep  "-" ./.tmp_pack` ; do
1319        j=`echo $i | sed 's/[-]//'`
1320        DISABLE="$DISABLE $j"
1321    done
1322  pack=  pack=
1323  for p in $PACKAGES ; do  for p in $PACKAGES ; do
1324      addit="t"      addit="t"
# Line 749  PACKAGES="$pack" Line 1335  PACKAGES="$pack"
1335  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
1336  echo "" > ./.tmp_pack  echo "" > ./.tmp_pack
1337  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
1338    # Test if each explicitly referenced package exists
1339  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1340      if test ! -d "$ROOTDIR/pkg/$i" ; then      j=`echo $i | sed 's/[-+]//'`
1341        if test ! -d "$ROOTDIR/pkg/$j" ; then
1342          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""
1343          exit 1          exit 1
1344      fi      fi
1345      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
1346  done  done
 pack=`cat ./.tmp_pack | sort | uniq`  
 rm -f ./.tmp_pack  
1347  PACKAGES=  PACKAGES=
1348  for i in $pack ; do  for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do
1349      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
1350  done  done
1351    rm -f ./.tmp_pack
1352  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1353    
1354  echo "  applying package dependency rules"  echo "  applying package dependency rules"
# Line 838  for i in $PACKAGES ; do Line 1425  for i in $PACKAGES ; do
1425      if test -d $adr ; then      if test -d $adr ; then
1426          SOURCEDIRS="$SOURCEDIRS $adr"          SOURCEDIRS="$SOURCEDIRS $adr"
1427          INCLUDEDIRS="$INCLUDEDIRS $adr"          INCLUDEDIRS="$INCLUDEDIRS $adr"
1428            if test "x$i" = xautodiff ; then
1429                AUTODIFF_PKG_USED=t
1430            fi
1431      else      else
1432          echo "Error: the directory \"$adr\" for package $i doesn't exist"          echo "Error: the directory \"$adr\" for package $i doesn't exist"
1433          exit 1          exit 1
1434      fi      fi
1435  done  done
1436    
1437  #  This is compatible with the old genmake.  The "DISABLE_*" flags  #  Build MNC templates and check for ability to build and use NetCDF
1438  #  need to be replaced by the "ALLOW_*" flags set below.  echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1439  #  RETVAL=$?
1440  # echo -n "  Setting package-specific CPP flags:  "  if test "x$RETVAL" = x0 ; then
1441  # pkrm=( mom_fluxform mom_vecinv generic_advdiff )      ( cd $ROOTDIR"/pkg/mnc" && $MAKE templates ) > make_mnc.errors 2>&1
1442  # pkrmdef=( -DDISABLE_MOM_FLUXFORM -DDISABLE_MOM_VECINV -DDISABLE_GENERIC_ADVDIFF -DDISABLE_DEBUGMODE )      RETVAL=$?
1443  # echo -n "  "      if test "x${RETVAL}" = x0 ; then
1444  # i=0          rm -f make_mnc.errors
1445  # while test $i -lt "${#pkrm[@]}" ; do      else
1446  #     echo "$PACKAGES" | grep "${pk[$i]}" > /dev/null 2>&1          echo "Error: problem encountered while building source files in pkg/mnc:"
1447  #     RETVAL=$?          cat make_mnc.errors 1>&2
1448  #     if test "x$RETVAL" = x1 ; then          exit 1
1449  #       DEFINES="$DEFINES ${pkdef[$i]}"      fi
1450  #       echo -n " ${pkdef[$i]}"      if test "x$HAVE_NETCDF" != xt ; then
1451  #     fi          cat <<EOF
 #     i=$(( $i + 1 ))  
 # done  
 # echo  
   
 # Create a list of #define and #undef to enable/disable packages  
 PACKAGES_DOT_H=PACKAGES_CONFIG.h  
 cat <<EOF >$PACKAGES_DOT_H".tmp"  
 C=== GENMAKE v2 ===  
 C  The following defines have been set by GENMAKE, so please do not  
 C  edit anything below these comments.  In general, you should  
 C  add or remove packages by re-running genmake with different  
 C  "-enable" and/or "-disable" options.  
1452    
1453  #ifndef PACKAGES_H  WARNING: the "mnc" package has been enabled but tests failed to
1454  #define PACKAGES_H    compile and/or execute NetCDF applications.  Please check that:
1455    
1456  C  Packages disabled by genmake:    1) NetCDF is installed for your compiler and
1457      2) the LIBS variable (within the 'optfile") specifies the correct
1458           NetCDF library to link against.
1459      
1460  EOF  EOF
1461        fi
1462    fi
1463    
1464    # Create a list of #define and #undef to enable/disable packages
1465    PACKAGES_DOT_H=PACKAGES_CONFIG.h
1466  #  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
1467  #  away.  On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h  #  away.  On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h
1468  #  file would eventually be split up so that all package-related #define  #  file would eventually be split up so that all package-related #define
1469  #  statements could be separated and handled only by genmake.  #  statements could be separated and handled only by genmake.
1470  names=`ls -1 "$ROOTDIR/pkg"`  names=`ls -1 "$ROOTDIR/pkg"`
1471  all_pack=  all_pack=
1472    DISABLED_PACKAGES=
1473  for n in $names ; do  for n in $names ; do
1474      if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then      if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then
1475          has_pack="f"          has_pack="f"
# Line 893  for n in $names ; do Line 1480  for n in $names ; do
1480              fi              fi
1481          done          done
1482          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1483              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`
1484              echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
 #           DEFINES="$DEFINES -U$undef"  
   
 #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  
             case $n in  
                 mom_fluxform)  
                     DEFINES="$DEFINES -DDISABLE_MOM_FLUXFORM"  
                     ;;  
                 mom_vecinv)  
                     DEFINES="$DEFINES -DDISABLE_MOM_VECINV"  
                     ;;  
                 debug)  
                     DEFINES="$DEFINES -DDISABLE_DEBUGMODE"  
                     ;;  
             esac  
 #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  
   
1485          fi          fi
1486      fi      fi
1487  done  done
1488  cat <<EOF >>$PACKAGES_DOT_H".tmp"  ENABLED_PACKAGES=
   
 C  Packages enabled by genmake:  
 EOF  
1489  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1490      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`
1491      echo "#define $def" >> $PACKAGES_DOT_H".tmp"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1492  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
1493    
1494  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
1495      case $i in      case $i in
1496          aim_v23)          aim_v23)
1497              echo "#define   ALLOW_AIM" >> $PACKAGES_DOT_H".tmp"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
1498              DEFINES="$DEFINES -DALLOW_AIM"              echo "Warning: ALLOW_AIM is set to enable aim_v23."
             echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"  
1499              ;;              ;;
1500      esac      esac
1501  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
1502    
1503  done  done
 cat <<EOF >>$PACKAGES_DOT_H".tmp"  
   
 #endif /* PACKAGES_H */  
 EOF  
   
 if test ! -f $PACKAGES_DOT_H ; then  
     mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H  
 else  
     cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H  
     RETVAL=$?  
     if test "x$RETVAL" = x0 ; then  
         rm -f $PACKAGES_DOT_H".tmp"  
     else  
         mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"  
         mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H  
     fi  
 fi  
1504    
1505  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
1506  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
1507  if test "x$STANDARDDIRS" = x ; then  if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
1508      STANDARDDIRS="eesupp model"      STANDARDDIRS="eesupp model"
1509  fi  fi
1510  for d in $STANDARDDIRS ; do  if test "x$STANDARDDIRS" != x ; then
1511      adr="$ROOTDIR/$d/src"      for d in $STANDARDDIRS ; do
1512      if test ! -d $adr ; then          adr="$ROOTDIR/$d/src"
1513          echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""          if test ! -d $adr ; then
1514          echo "  is correct and that you correctly specified the STANDARDDIRS option"              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1515          exit 1              echo "  is correct and that you correctly specified the STANDARDDIRS option"
1516      else              exit 1
1517          SOURCEDIRS="$SOURCEDIRS $adr"          else
1518      fi              SOURCEDIRS="$SOURCEDIRS $adr"
1519      adr="$ROOTDIR/$d/inc"          fi
1520      if test ! -d $adr ; then          adr="$ROOTDIR/$d/inc"
1521          echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""          if test ! -d $adr ; then
1522          echo "  is correct and that you correctly specified the STANDARDDIRS option"              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1523          exit 1              echo "  is correct and that you correctly specified the STANDARDDIRS option"
1524      else              exit 1
1525          INCLUDEDIRS="$INCLUDEDIRS $adr"          else
1526      fi              INCLUDEDIRS="$INCLUDEDIRS $adr"
1527  done          fi
1528        done
1529    fi
1530    
1531  echo " Searching for CPP_OPTIONS.h in order to warn about the presence"  echo "  Searching for *OPTIONS.h files in order to warn about the presence"
1532  echo " of \"#define ALLOW_PKGNAME\"-type statements:"  echo "    of \"#define \"-type statements that are no longer allowed:"
1533  CPP_OPTIONS=  CPP_OPTIONS=
1534    CPP_EEOPTIONS=
1535  spaths=". $INCLUDEDIRS"  spaths=". $INCLUDEDIRS"
1536    names=`ls -1 "$ROOTDIR/pkg"`
1537  for i in $spaths ; do  for i in $spaths ; do
1538      try="$i/CPP_OPTIONS.h"      try="$i/CPP_OPTIONS.h"
1539      #  echo -n "    trying $try : "      if test -f $try -a -r $try -a "x$CPP_OPTIONS" = x ; then
     if test -f $try -a -r $try ; then  
1540          echo "    found CPP_OPTIONS=\"$try\""          echo "    found CPP_OPTIONS=\"$try\""
1541          CPP_OPTIONS="$try"          CPP_OPTIONS="$try"
1542          break          # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
1543            for n in $names ; do
1544                test_for_package_in_cpp_options $CPP_OPTIONS $n
1545            done
1546        fi
1547        try="$i/CPP_EEOPTIONS.h"
1548        if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" = x ; then
1549            echo "    found CPP_EEOPTIONS=\"$try\""
1550            # New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h
1551    #**** not yet enabled ****
1552    #        test_for_mpi_in_cpp_eeoptions $try
1553    #**** not yet enabled ****
1554            CPP_EEOPTIONS="$try"
1555      fi      fi
1556  done  done
1557  if test "x$CPP_OPTIONS" = x ; then  if test "x$CPP_OPTIONS" = x ; then
1558      echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"      echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths"
1559      exit 1      exit 1
1560  fi  fi
1561  # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h  
1562  names=`ls -1 "$ROOTDIR/pkg"`  #  Here, we build the list of files to be "run through" the adjoint
1563  for n in $names ; do  #  compiler.
1564      test_for_package_in_cpp_options $CPP_OPTIONS $n  if test -f ./ad_files ; then
1565        rm -f ./ad_files
1566    fi
1567    echo "  Creating the list of files for the adjoint compiler."
1568    for i in $SOURCEDIRS ; do
1569        list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
1570        for j in $list_files ; do
1571            cat $i/$j >> ad_files
1572        done
1573  done  done
1574    
1575    
# Line 1016  rm -rf .links.tmp Line 1589  rm -rf .links.tmp
1589  mkdir .links.tmp  mkdir .links.tmp
1590  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
1591  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
1592  echo -n 'SRCFILES = '    > srclist.inc  printf 'SRCFILES = '    > srclist.inc
1593  echo -n 'CSRCFILES = '   > csrclist.inc  printf 'CSRCFILES = '   > csrclist.inc
1594  echo -n 'F90SRCFILES = ' > f90srclist.inc  printf 'F90SRCFILES = ' > f90srclist.inc
1595  echo -n 'HEADERFILES = ' > hlist.inc  printf 'HEADERFILES = ' > hlist.inc
1596    printf 'AD_FLOW_FILES = ' > ad_flow_files.inc
1597  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
1598  for d in $alldirs ; do  for d in $alldirs ; do
1599      deplist=      deplist=
1600      sfiles=`( cd $d; echo *.[h,c,F] )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
1601      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
1602      for sf in $sfiles ; do      for sf in $sfiles ; do
1603          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
1604              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
1605                  extn=`echo $sf | awk -F '.' '{print $NF}'`                  case $d/$sf in
1606                  touch .links.tmp/$sf                    ./$PACKAGES_DOT_H)
1607                  deplist="$deplist $sf"                          ;;
1608                      ./AD_CONFIG.h)
1609                            ;;
1610                      ./FC_NAMEMANGLE.h)
1611                            ;;
1612                      *)
1613                            touch .links.tmp/$sf
1614                            deplist="$deplist $sf"
1615                            ;;
1616                    esac
1617                    extn=`echo $sf | $AWK -F '.' '{print $NF}'`
1618                  case $extn in                  case $extn in
1619                      F)                      F)
1620                          echo    " \\"  >> srclist.inc                          echo    " \\"  >> srclist.inc
1621                          echo -n " $sf" >> srclist.inc                          printf " $sf" >> srclist.inc
1622                          ;;                          ;;
1623                      F90)                      F90)
1624                          echo    " \\"  >> f90srclist.inc                          echo    " \\"  >> f90srclist.inc
1625                          echo -n " $sf" >> f90srclist.inc                          printf " $sf" >> f90srclist.inc
1626                          ;;                          ;;
1627                      c)                      c)
1628                          echo    " \\"  >> csrclist.inc                          echo    " \\"  >> csrclist.inc
1629                          echo -n " $sf" >> csrclist.inc                          printf " $sf" >> csrclist.inc
1630                          ;;                          ;;
1631                      h)                      h)
1632                          echo    " \\"  >> hlist.inc                          echo    " \\"  >> hlist.inc
1633                          echo -n " $sf" >> hlist.inc                          printf " $sf" >> hlist.inc
1634                            ;;
1635                        flow)
1636                            echo    " \\"  >> ad_flow_files.inc
1637                            printf " $sf" >> ad_flow_files.inc
1638                          ;;                          ;;
1639                  esac                  esac
1640              fi              fi
# Line 1064  echo "" >> srclist.inc Line 1652  echo "" >> srclist.inc
1652  echo "" >> csrclist.inc  echo "" >> csrclist.inc
1653  echo "" >> f90srclist.inc  echo "" >> f90srclist.inc
1654  echo "" >> hlist.inc  echo "" >> hlist.inc
1655    echo "" >> ad_flow_files.inc
1656    
1657  if test -e $MAKEFILE ; then  if test -e $MAKEFILE ; then
1658      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
# Line 1074  echo "#    $MACHINE" >> $MAKEFILE Line 1663  echo "#    $MACHINE" >> $MAKEFILE
1663  echo "# This makefile was generated automatically on" >> $MAKEFILE  echo "# This makefile was generated automatically on" >> $MAKEFILE
1664  echo "#    $THISDATE" >> $MAKEFILE  echo "#    $THISDATE" >> $MAKEFILE
1665  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
1666  echo "#    $0 $@" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
1667  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
1668  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE
1669    
1670    EXE_AD=$EXECUTABLE"_ad"
1671    EXE_FTL=$EXECUTABLE"_ftl"
1672    EXE_SVD=$EXECUTABLE"_svd"
1673    
1674  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1675    #
1676    # OPTFILE="$OPTFILE"
1677  #  #
1678  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
1679  # SOURCEDIRS   : Directories containing the source (.F) files  # SOURCEDIRS   : Directories containing the source (.F) files
# Line 1105  EXEDIR      = ${EXEDIR} Line 1701  EXEDIR      = ${EXEDIR}
1701  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
1702  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIR}
1703    
1704    #eh3  new defines for the adjoint work
1705    AUTODIFF    = ${ROOTDIR}/pkg/autodiff
1706    EXE_AD      = ${EXE_AD}
1707    EXE_FTL     = ${EXE_FTL}
1708    EXE_SVD     = ${EXE_SVD}
1709    
1710    ENABLED_PACKAGES = ${ENABLED_PACKAGES}
1711    DISABLED_PACKAGES = ${DISABLED_PACKAGES}
1712    
1713    # These files are created by Makefile
1714    SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h
1715    
1716  EOF  EOF
1717    
1718  #  Note: figure out some way to add Hyades JAM libraries here  #  Note: figure out some way to add Hyades JAM libraries here
# Line 1123  FC = ${FC} Line 1731  FC = ${FC}
1731  # Fortran compiler  # Fortran compiler
1732  F90C = ${F90C}  F90C = ${F90C}
1733  # Link editor  # Link editor
1734  LINK = ${LINK}  LINK = ${LINK} ${LDADD}
1735    
1736  # Defines for CPP  # Defines for CPP
1737  DEFINES = ${DEFINES}  DEFINES = ${DEFINES}
# Line 1150  MAKEFILE=${MAKEFILE} Line 1758  MAKEFILE=${MAKEFILE}
1758    
1759  EOF  EOF
1760    
1761  cat srclist.inc    >> $MAKEFILE  cat srclist.inc       >> $MAKEFILE
1762  cat csrclist.inc   >> $MAKEFILE  cat csrclist.inc      >> $MAKEFILE
1763  cat f90srclist.inc >> $MAKEFILE  cat f90srclist.inc    >> $MAKEFILE
1764  cat hlist.inc      >> $MAKEFILE  cat hlist.inc         >> $MAKEFILE
1765  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE  cat ad_flow_files.inc >> $MAKEFILE
1766  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE  echo >> $MAKEFILE
1767    echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE
1768    echo 'F90FILES =  $(F90SRCFILES:.F=.'$FS90')' >> $MAKEFILE
1769  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
1770    echo >> $MAKEFILE
1771    echo '.SUFFIXES:' >> $MAKEFILE
1772    echo '.SUFFIXES: .o .F .p .'$FS' .c .F90 .'$FS90 >> $MAKEFILE
1773  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc
1774    rm -f ad_flow_files.inc
1775    
1776  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1777    
 .SUFFIXES:  
 .SUFFIXES: .o .f .p .F .c .F90 .f90  
   
1778  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
1779  \$(EXECUTABLE): \$(OBJFILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)
1780            @echo Creating \$@ ...
1781          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
1782  depend:  depend:
1783          @make links          @make links
1784          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
1785          ${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
1786            -rm -f makedepend.out
1787    
1788  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
1789    
1790  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77FILES) \$(F90FILES)
1791    
# Line 1182  output.txt: \$(EXECUTABLE) Line 1794  output.txt: \$(EXECUTABLE)
1794          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
1795    
1796  clean:  clean:
1797          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl}          -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
1798  Clean:  Clean:
1799          @make clean          @make clean
1800          @make cleanlinks          @make cleanlinks
1801          -rm -f Makefile.bak genmake_state genmake_optfile make.log          -rm -f \$(SPECIAL_FILES)
1802            -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak
1803  CLEAN:  CLEAN:
1804          @make Clean          @make Clean
1805          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
1806          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
1807          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1808          -rm -f \$(EXECUTABLE) output.txt          -rm -f \$(EXECUTABLE) output.txt STD*
1809    
1810    #eh3 Makefile: makefile
1811  makefile:  makefile:
1812          ${0} $@          $THIS_SCRIPT $G2ARGS
1813  cleanlinks:  cleanlinks:
1814          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
1815    
1816  # The normal chain of rules is (  .F - .f - .o  )  # Special targets ($SPECIAL_FILES) which are create by make
1817  .F.f:  ${PACKAGES_DOT_H}:
1818            @echo Creating \$@ ...
1819            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@
1820    AD_CONFIG.h:
1821            @echo Creating \$@ ...
1822            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > \$@
1823    FC_NAMEMANGLE.h:
1824            @echo Creating \$@ ...
1825            echo "$FC_NAMEMANGLE" > \$@
1826    
1827    # The normal chain of rules is (  .F - .$FS - .o  )
1828    
1829    %.o : %.F
1830    
1831    .F.$FS:
1832          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1833  .f.o:  .$FS.o:
1834          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
1835  .F90.f90:  .F90.$FS90:
1836          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1837  .f90.o:  .$FS90.o:
1838          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
1839  .c.o:  .c.o:
1840          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) -c \$<
1841    
1842  # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
1843  .F.p:  .F.p:
1844          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
1845  .p.f:  .p.$FS:
1846          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
1847    
1848    #=========================================
1849    #===  Automatic Differentiation Rules  ===
1850    
1851    TAMC           = ${TAMC}
1852    TAF            = ${TAF}
1853    
1854    TAF_EXTRA      = ${TAF_EXTRA}
1855    TAMC_EXTRA     = ${TAMC_EXTRA}
1856    
1857    EOF
1858    
1859    ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS"
1860    ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF_FLAGS"
1861    ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
1862    for i in $ad_vars ; do
1863        name=$i
1864        t1="t2=\$"`echo $i`
1865        eval $t1
1866        printf "%-20s = " $name >> $MAKEFILE
1867        echo $t2 >> $MAKEFILE
1868    done
1869    
1870    echo "  Add the source list for AD code generation"
1871    echo >> $MAKEFILE
1872    printf "AD_FILES = " >> $MAKEFILE
1873    AD_FILES=`cat ad_files`
1874    for i in $AD_FILES ; do
1875        echo    " \\" >> $MAKEFILE
1876        printf " $i" >> $MAKEFILE
1877    done
1878    echo >> $MAKEFILE
1879    rm -f ad_files
1880    
1881    cat >>$MAKEFILE <<EOF
1882    
1883    # ... AD ...
1884    adall: ad_taf
1885    adtaf: ad_taf_output.f
1886    adtamc: ad_tamc_output.f
1887    
1888    ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1889            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template
1890            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
1891            -rm -f ad_config.template
1892            @make \$(F77FILES)
1893            @make \$(AD_FLOW_FILES)
1894            cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f
1895    
1896    ad_taf_output.f: ad_input_code.f
1897            \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f
1898            cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f
1899    
1900    adtafonly:
1901            \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f
1902            cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f
1903    
1904    ad_taf: ad_taf_output.o \$(OBJFILES)
1905            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
1906    
1907    ad_tamc_output.f: ad_input_code.f
1908            \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f
1909            cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.f
1910    
1911    ad_tamc: ad_tamc_output.o \$(OBJFILES)
1912            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
1913    
1914    
1915    # ... FTL ...
1916    ftlall: ftl_taf
1917    ftltaf: ftl_taf_output.f
1918    ftltamc: ftl_tamc_output.f
1919    
1920    ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1921            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template
1922            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
1923            -rm -f ftl_config.template
1924            @make \$(F77FILES)
1925            @make \$(AD_FLOW_FILES)
1926            cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f
1927    
1928    ftl_taf_output.f: ftl_input_code.f
1929            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f
1930            cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f
1931    
1932    ftltafonly:
1933            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f
1934            cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f
1935    
1936    ftl_taf: ftl_taf_output.o \$(OBJFILES)
1937            \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
1938    
1939    ftl_tamc_output.f: ftl_input_code.f
1940            \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f
1941            cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.f
1942    
1943    ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
1944            \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
1945    
1946    
1947    # ... SVD ...
1948    svdtaf: ad_taf_output.f ftl_taf_output.f
1949    svdall: svd_taf
1950    
1951    svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES)
1952            \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS)
1953    
1954    
1955    #=========================================
1956    
1957  EOF  EOF
1958    
1959  if test "x$EXEHOOK" != x ; then  if test "x$EXEHOOK" != x ; then
# Line 1230  for i in $KPPFILES ; do Line 1967  for i in $KPPFILES ; do
1967      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
1968          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
1969      fi      fi
1970      echo "$base.f: $base.p" >> $MAKEFILE      echo "$base.$FS: $base.p" >> $MAKEFILE
1971  done  done
1972    
1973  echo "  Making list of NOOPTFILES"  echo "  Making list of NOOPTFILES"
# Line 1240  for i in $NOOPTFILES ; do Line 1977  for i in $NOOPTFILES ; do
1977      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
1978          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
1979      fi      fi
1980      echo "$base.o: $base.f" >> $MAKEFILE      echo "$base.o: $base.$FS" >> $MAKEFILE
1981      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
1982  done  done
1983    
# Line 1253  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 1990  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
1990    
1991  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
1992    
1993    # Create special header files
1994    $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" $DISABLED_PACKAGES " " "Enabled packages:" $ENABLED_PACKAGES > $PACKAGES_DOT_H".tmp"
1995    if test ! -f $PACKAGES_DOT_H ; then
1996        mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1997    else
1998        cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H > /dev/null 2>&1
1999        RETVAL=$?
2000        if test "x$RETVAL" = x0 ; then
2001            rm -f $PACKAGES_DOT_H".tmp"
2002        else
2003            mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"
2004            mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
2005        fi
2006    fi
2007    if test ! -f AD_CONFIG.h ; then
2008        $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > AD_CONFIG.h
2009    fi
2010    
2011    
2012  #  Write the "state" for future records  #  Write the "state" for future records
2013  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" != xf ; then
2014      echo -n "" > genmake_state      printf "" > genmake_state
2015      for i in $gm_state ; do      for i in $gm_state ; do
2016          t1="t2=\$$i"          t1="t2=\$$i"
2017          eval $t1          eval $t1

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.78

  ViewVC Help
Powered by ViewVC 1.1.22