/[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.50 by edhill, Sat Nov 29 19:58:36 2003 UTC revision 1.121 by edhill, Tue Mar 22 19:45:03 2005 UTC
# 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 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 -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"
126        cat <<EOF >> $MAKEFILE
127    .SUFFIXES:
128    .SUFFIXES: .$tfs .F
129    .F.$tfs:
130            $LN \$< \$@
131    EOF
132        $MAKE "genmake_hello."$tfs > /dev/null 2>&1
133        RETVAL=$?
134        if test "x$RETVAL" != x0 -o ! -f "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 -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
153    
154        #  If we make it here, use the extensions
155        FS=$tfs
156        FS90=$tfs9
157        return
158    }
159    
160    
161    look_for_makedepend()  {
162    
163        #  The "original" makedepend is part of the Imake system that is
164        #  most often distributed with XFree86 or with an XFree86 source
165        #  package.  As a result, many machines (eg. generic Linux) do not
166        #  have a system-default "makedepend" available.  For those
167        #  systems, we have two fall-back options:
168        #
169        #    1) a makedepend implementation shipped with the cyrus-imapd
170        #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
171        #
172        #    2) a known-buggy xmakedpend shell script
173        #
174        #  So the choices are, in order:
175        #
176        #    1) use the user-specified program
177        #    2) use a system-wide default
178        #    3) locally build and use the cyrus implementation
179        #    4) fall back to the buggy local xmakedpend script
180        #
181        if test "x${MAKEDEPEND}" = x ; then
182            which makedepend > /dev/null 2>&1
183            RV0=$?
184            test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"
185            #  echo 'MAKEFILE="'$MAKEFILE'"'
186            cat <<EOF >> $MAKEFILE
187    #   THIS IS A TEST MAKEFILE GENERATED BY "genmake2"
188    #
189    #   Some "makedepend" implementations will die if they cannot
190    #   find a Makefile -- so this file is here to gives them an
191    #   empty one to find and parse.
192    EOF
193            cat <<EOF >> genmake_tc.f
194          program test
195          write(*,*) 'test'
196          stop
197          end
198    EOF
199            makedepend genmake_tc.f > /dev/null 2>&1
200            RV1=$?
201            test -f $MAKEFILE  &&  rm -f $MAKEFILE
202            test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
203            if test "x${RV0}${RV1}" = x00 ; then
204                MAKEDEPEND=makedepend
205            else
206                echo "    a system-default makedepend was not found."
207                
208                #  Try to build the cyrus implementation
209                build_cyrus_makedepend
210                RETVAL=$?
211                if test "x$RETVAL" != x0 ; then
212                    MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
213                fi
214                rm -f ./genmake_cy_md
215            fi
216        else
217            #  echo "MAKEDEPEND=${MAKEDEPEND}"
218            echo "${MAKEDEPEND}" | grep -i cyrus > /dev/null 2>&1
219            RETVAL=$?
220            if test x"$RETVAL" = x0 ; then
221                build_cyrus_makedepend
222            fi
223        fi
224    }
225    
226    
227    build_cyrus_makedepend()  {
228        rm -f ./genmake_cy_md
229        (
230            cd $ROOTDIR/tools/cyrus-imapd-makedepend  \
231                &&  ./configure > /dev/null 2>&1  \
232                &&  make > /dev/null 2>&1
233            if test -x ./makedepend.exe ; then
234                $LN ./makedepend.exe ./makedepend
235            fi
236            ./makedepend ifparser.c > /dev/null 2>&1  \
237                &&  echo "true"
238        ) > ./genmake_cy_md
239        grep true ./genmake_cy_md > /dev/null 2>&1
240        RETVAL=$?
241        rm -f ./genmake_cy_md
242        if test "x$RETVAL" = x0 ; then
243            MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'
244            return 0
245        else
246            echo "WARNING: unable to build cyrus-imapd-makedepend"
247            return 1
248        fi
249    }
250    
251  # Guess possible config options for this host  # Guess possible config options for this host
252  find_possible_configs()  {  find_possible_configs()  {
253    
254      tmp1=`uname`"_"`uname -m`      tmp1=`uname`"_"`uname -m`
255      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
256      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
257      PLATFORM=`echo $tmp3 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`      tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`
258        tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
259        tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
260        PLATFORM=$tmp3
261        echo $PLATFORM | grep cygwin > /dev/null 2>&1  &&  PLATFORM=cygwin_ia32
262      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
263      echo "  The platform appears to be:  $PLATFORM"      echo "  The platform appears to be:  $PLATFORM"
264            
# Line 93  find_possible_configs()  { Line 278  find_possible_configs()  {
278          CPP="cpp -traditional -P"          CPP="cpp -traditional -P"
279      fi      fi
280    
281      # makedepend is not always available      look_for_makedepend
282      if test "x${MAKEDEPEND}" = x ; then  
283        which makedepend >& /dev/null      #================================================================
284        RETVAL=$?      #  look for possible C compilers
285        if test "x${RETVAL}" = x1 ; then      tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc"
286           echo "    makedepend was not found. Using xmakedpend instead."      p_CC=
287           MAKEDEPEND='$(TOOLSDIR)/xmakedepend'      for c in $tmp ; do
288        fi          rm -f ./genmake_hello.c  ./genmake_hello
289            cat >> genmake_hello.c << EOF
290    #include <stdio.h>
291    int main(int argc, char **argv) {
292      printf("Hello!\n");
293      return 0;
294    }
295    EOF
296            $c -o genmake_hello genmake_hello.c > /dev/null 2>&1
297            RETVAL=$?
298            if test "x${RETVAL}" = x0 ; then
299                p_CC="$p_CC $c"
300            fi
301        done
302        rm -f ./genmake_hello.c ./genmake_hello
303        if test "x${p_CC}" = x ; then
304            cat 1>&2 <<EOF
305    
306    Error: No C compilers were found in your path.  Please specify one using:
307    
308        1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
309        2) the CC or MITGCM_CC environment variables.
310    
311    EOF
312            exit 1
313        else
314            echo "  The possible C compilers found in your path are:"
315            echo "   "$p_CC
316            if test "x$CC" = x ; then
317                CC=`echo $p_CC | $AWK '{print $1}'`
318                echo "  Setting C compiler to: "$CC
319            fi
320      fi      fi
321    
322      # look for possible fortran compilers      #================================================================
323        #  look for possible FORTRAN compilers
324      tmp="$MITGCM_FC $FC efc 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"
325      p_FC=      p_FC=
326      for c in $tmp ; do      for c in $tmp ; do
# Line 129  Error: No Fortran compilers were found i Line 346  Error: No Fortran compilers were found i
346    
347      1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),      1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
348      2) a command-line option (eg. "-fc NAME"), or      2) a command-line option (eg. "-fc NAME"), or
349      3) the MITGCM_FC environment variable.      3) the FC or MITGCM_FC environment variables.
350    
351  EOF  EOF
352          exit 1          exit 1
# Line 138  EOF Line 355  EOF
355          echo "   "$p_FC          echo "   "$p_FC
356          if test "x$FC" = x ; then          if test "x$FC" = x ; then
357              FC=`echo $p_FC | $AWK '{print $1}'`              FC=`echo $p_FC | $AWK '{print $1}'`
358                echo "  Setting FORTRAN compiler to: "$FC
359          fi          fi
360      fi      fi
361    
362      for i in $p_FC ; do      if test "x$OPTFILE" = x ; then
363          p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i          OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
364          if test -r $p_OF ; then          if test ! -r $OPTFILE ; then
365              OPTFILE=$p_OF               echo "  I looked for the file "$OPTFILE" but did not find it"
366              echo "  The options file:  $p_OF"          fi
367              echo "    appears to match so we'll use it."      fi
368              break  #    echo "  The options file:  $p_OF"
369          fi  #    echo "    appears to match so we'll use it."
370      done  #   for i in $p_FC ; do
371    #p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
372    #if test -r $p_OF ; then
373    #    OPTFILE=$p_OF
374    #    echo "  The options file:  $p_OF"
375    #    echo "    appears to match so we'll use it."
376    #    break
377    #fi
378    #   done
379      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
380          cat 1>&2 <<EOF          cat 1>&2 <<EOF
381    
# Line 208  get_pdepend_list()  { Line 434  get_pdepend_list()  {
434      . ./.pd_tmp      . ./.pd_tmp
435      rm -f ./.pd_tmp      rm -f ./.pd_tmp
436    
437      echo -n "PNAME = "${}      printf "PNAME = "${}
438  }  }
439    
440    
# Line 222  Usage: "$0" [OPTIONS] Line 448  Usage: "$0" [OPTIONS]
448      -help | --help | -h | --h      -help | --help | -h | --h
449            Print this help message and exit.            Print this help message and exit.
450    
451        -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
452          -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
453              Use "NAME" as the adoptfile.  By default, the file at
454              "tools/adjoint_options/adjoint_default" will be used.
455    
456      -nooptfile | --nooptfile      -nooptfile | --nooptfile
457        -optfile NAME | --optfile NAME | -of NAME | --of NAME        -optfile NAME | --optfile NAME | -of NAME | --of NAME
458        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
# Line 246  Usage: "$0" [OPTIONS] Line 477  Usage: "$0" [OPTIONS]
477        --makefile=NAME | -mf=NAME        --makefile=NAME | -mf=NAME
478            Call the makefile "NAME".  The default is "Makefile".            Call the makefile "NAME".  The default is "Makefile".
479    
480        -makedepend NAME | -md NAME
481          --makedepend=NAME | -md=NAME
482              Use "NAME" for the MAKEDEPEND program.
483    
484      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
485        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
486            Specify the location of the MITgcm ROOTDIR as "NAME".            Specify the location of the MITgcm ROOTDIR as "NAME".
# Line 282  Usage: "$0" [OPTIONS] Line 517  Usage: "$0" [OPTIONS]
517            will search for a working compiler by trying a list of            will search for a working compiler by trying a list of
518            "usual suspects" such as g77, f77, etc.            "usual suspects" such as g77, f77, etc.
519    
520        -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
521              Use "NAME" as the C compiler.  By default, genmake
522              will search for a working compiler by trying a list of
523              "usual suspects" such as gcc, c89, cc, etc.
524    
525      -[no]ieee | --[no]ieee      -[no]ieee | --[no]ieee
526            Do or don't use IEEE numerics.  Note that this option            Do or don't use IEEE numerics.  Note that this option
527            *only* works if it is supported by the OPTFILE that            *only* works if it is supported by the OPTFILE that
528            is being used.            is being used.
529    
530        -mpi | --mpi
531              Include MPI header files and link to MPI libraries
532        -mpi=PATH | --mpi=PATH
533              Include MPI header files and link to MPI libraries using MPI_ROOT
534              set to PATH. i.e. Include files from \$PATH/include, link to libraries
535              from \$PATH/lib and use binaries from \$PATH/bin.
536    
537        -bash NAME
538              Explicitly specify the Bourne or BASH shell to use
539    
540    While it is most often a single word, the "NAME" variables specified    While it is most often a single word, the "NAME" variables specified
541    above can in many cases be a space-delimited string such as:    above can in many cases be a space-delimited string such as:
542    
# Line 307  EOF Line 557  EOF
557    
558  #  Build a CPP macro to automate calling C routines from FORTRAN  #  Build a CPP macro to automate calling C routines from FORTRAN
559  get_fortran_c_namemangling()  {  get_fortran_c_namemangling()  {
560    
561        #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
562        if test ! "x$FC_NAMEMANGLE" = x ; then
563            return 0
564        fi
565    
566      default_nm="#define FC_NAMEMANGLE(X) X ## _"      default_nm="#define FC_NAMEMANGLE(X) X ## _"
567            
568      cat > genmake_test.c <<EOF      cat > genmake_test.c <<EOF
# Line 324  WARNING: Please contact <MITgcm-support@ Line 580  WARNING: Please contact <MITgcm-support@
580  EOF  EOF
581          return 1          return 1
582      fi      fi
583      c_tcall=`nm genmake_test.o | grep 'T ' | grep tcall | cut -d ' ' -f 3`      c_tcall=`nm genmake_test.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
584      RETVAL=$?      RETVAL=$?
585      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
586          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 336  WARNING: Please contact <MITgcm-support@ Line 592  WARNING: Please contact <MITgcm-support@
592  EOF  EOF
593          return 1          return 1
594      fi      fi
595      cat > genmake_tcomp.f <<EOF      cat > genmake_tcomp.$FS <<EOF
596        subroutine tcall( string )        subroutine tcall( string )
597        character*(*) string        character*(*) string
598        call tsub( string )        call tsub( string )
599        end        end
600  EOF  EOF
601      $FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1      $FC $FFLAGS $DEFINES -c genmake_tcomp.$FS >> genmake_warnings 2>&1
602      RETVAL=$?      RETVAL=$?
603      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
604          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 354  WARNING: Please contact <MITgcm-support@ Line 610  WARNING: Please contact <MITgcm-support@
610  EOF  EOF
611          return 1          return 1
612      fi      fi
613      f_tcall=`nm genmake_tcomp.o | grep 'T ' | grep tcall | cut -d ' ' -f 3`      f_tcall=`nm genmake_tcomp.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
614      RETVAL=$?      RETVAL=$?
615      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
616          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 408  void FC_NAMEMANGLE(cloc) ( double *curti Line 664  void FC_NAMEMANGLE(cloc) ( double *curti
664   *curtim = *curtim/1.E6;   *curtim = *curtim/1.E6;
665  }  }
666  EOF  EOF
667      make genmake_tc_1.o >> genmake_tc.log 2>&1      make genmake_tc_1.o >> genmake_warnings 2>&1
668      RET_C=$?      RET_C=$?
669      cat <<EOF > genmake_tc_2.f      cat <<EOF > genmake_tc_2.$FS
670        program hello        program hello
671        Real*8 wtime        Real*8 wtime
672        external cloc        external cloc
# Line 418  EOF Line 674  EOF
674        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
675        end program hello        end program hello
676  EOF  EOF
677      $FC $FFLAGS -o genmake_tc genmake_tc_2.f genmake_tc_1.o >> genmake_tc.log 2>&1      $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1
678      RET_F=$?      RET_F=$?
679      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1
680      RETVAL=$?      RETVAL=$?
681      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
682          HAVE_CLOC=t          HAVE_CLOC=t
# Line 430  EOF Line 686  EOF
686  }  }
687    
688    
689    check_HAVE_STAT()  {
690        get_fortran_c_namemangling
691        cat <<EOF > genmake_tc_1.c
692    $FC_NAMEMANGLE
693    #include <stdio.h>
694    #include <stdlib.h>
695    #include <unistd.h>
696    #include <sys/stat.h>
697    #include <sys/types.h>
698    void FC_NAMEMANGLE(tfsize) ( int *nbyte )
699    {
700        char name[512];
701        struct stat astat;
702    
703        name[0] = 'a'; name[1] = '\0';
704        if (! stat(name, &astat))
705            *nbyte = (int)(astat.st_size);
706        else
707            *nbyte = -1;
708    }
709    EOF
710        make genmake_tc_1.o >> genmake_tc.log 2>&1
711        RET_C=$?
712        cat <<EOF > genmake_tc_2.$FS
713          program hello
714          integer nbyte
715          call tfsize(nbyte)
716          print *," HELLO WORLD", nbyte
717          end program hello
718    EOF
719        $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_tc.log 2>&1
720        RET_F=$?
721        test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1
722        RETVAL=$?
723        if test "x$RETVAL" = x0 ; then
724            HAVE_STAT=t
725            DEFINES="$DEFINES -DHAVE_STAT"
726        fi
727        rm -f genmake_tc*
728    }
729    
730    
731    check_netcdf_libs()  {
732        if test ! "x$SKIP_NETCDF_CHECK" = x ; then
733            return
734        fi
735        echo "" > genmake_tnc.log
736        cat <<EOF > genmake_tnc.F
737          program fgennc
738    #include "netcdf.inc"
739    EOF
740        if test ! "x$MPI" = x ; then
741            echo '#include "mpif.h"' >> genmake_tnc.F
742        fi
743        cat <<EOF >> genmake_tnc.F
744          integer iret, ncid, xid
745          iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
746          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
747          iret = nf_def_dim(ncid, 'X', 11, xid)
748          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
749          iret = nf_close(ncid)
750          IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
751          end
752    EOF
753        echo "Executing:" > genmake_tnc.log
754        echo "  $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS" \
755            > genmake_tnc.log
756        RET_CPP=f
757        $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
758            &&  RET_CPP=t
759        if test "x$RET_CPP" = xf ; then
760            echo "  WARNING: CPP failed to pre-process the netcdf test." \
761                > genmake_tnc.log
762            echo "    Please check that \$INCLUDES is properly set." \
763                > genmake_tnc.log
764        fi
765        echo "Executing:" > genmake_tnc.log
766        echo "  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS" > genmake_tnc.log
767        echo "  $LINK -o genmake_tnc.o $LIBS" > genmake_tnc.log
768        $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
769            &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
770        RET_COMPILE=$?
771    
772        #EH3  Remove test program execution for machines that either disallow
773        #EH3  execution or cannot support it (eg. cross-compilers)
774        #EH3
775        #EH3 test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
776        #EH3 RETVAL=$?
777        #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
778    
779        if test "x$RET_COMPILE" = x0 ; then
780            HAVE_NETCDF=t
781        else
782            # try again with "-lnetcdf" added to the libs
783            $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
784                &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
785                &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
786            RET_COMPILE=$?
787            if test "x$RET_COMPILE" = x0 ; then
788                LIBS="$LIBS -lnetcdf"
789                HAVE_NETCDF=t
790            else
791                cat genmake_tnc.log >> genmake_warnings
792            fi
793        fi
794        rm -f genmake_tnc*
795    }
796    
797    
798    
799    ###############################################################################
800    #   Sequential part of script starts here
801    ###############################################################################
802    
803  #  Set defaults here  #  Set defaults here
804  COMMANDL="$0 $@"  COMMANDL="$0 $@"
805    
# Line 437  PLATFORM= Line 807  PLATFORM=
807  LN=  LN=
808  S64=  S64=
809  KPP=  KPP=
810  FC=  #FC=
811    #CC=gcc
812    #CPP=
813  LINK=  LINK=
 # DEFINES="-DWORDLENGTH=4"  
814  DEFINES=  DEFINES=
815  PACKAGES=  PACKAGES=
816  ENABLE=  ENABLE=
817  DISABLE=  DISABLE=
818  MAKEFILE=  # MAKEFILE=
819  MAKEDEPEND=  # MAKEDEPEND=
820  PDEPEND=  PDEPEND=
821  DUMPSTATE=t  DUMPSTATE=t
822  PDEFAULT=  PDEFAULT=
823  OPTFILE=  OPTFILE=
824  INCLUDES="-I."  INCLUDES="-I. $INCLUDES"
825  FFLAGS=  FFLAGS=
826  FOPTIM=  FOPTIM=
827  CFLAGS=  CFLAGS=
828  KFLAGS1=  KFLAGS1=
829  KFLAGS2=  KFLAGS2=
830    #LDADD=
831  LIBS=  LIBS=
832  KPPFILES=  KPPFILES=
833  NOOPTFILES=  NOOPTFILES=
834  NOOPTFLAGS=  NOOPTFLAGS=
835    MPI=
836    MPIPATH=
837    
838  # DEFINES checked by test compilation  # DEFINES checked by test compilation
839  HAVE_SYSTEM=  HAVE_SYSTEM=
840  HAVE_FDATE=  HAVE_FDATE=
841  FC_NAMEMANGLE=  FC_NAMEMANGLE=
842  HAVE_CLOC=  HAVE_CLOC=
843    HAVE_STAT=
844    HAVE_NETCDF=
845    HAVE_ETIME=
846    
847  MODS=  MODS=
848  TOOLSDIR=  TOOLSDIR=
849  SOURCEDIRS=  SOURCEDIRS=
850  INCLUDEDIRS=  INCLUDEDIRS=
851  STANDARDDIRS=  STANDARDDIRS="USE_THE_DEFAULT"
852    
853    G2ARGS=
854    BASH=
855  PWD=`pwd`  PWD=`pwd`
856  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
857  AWK=awk  test "x$AWK" = x   &&  AWK=awk
858  THISHOSTNAME=`hostname`  THISHOST=`hostname`
859  THISCWD=`pwd`  THISCWD=`pwd`
860  THISDATE=`date`  THISDATE=`date`
861    THISUSER=`echo $USER`
862    THISVER=
863  MACHINE=`uname -a`  MACHINE=`uname -a`
864  EXECUTABLE=  EXECUTABLE=
865  EXEHOOK=  EXEHOOK=
# Line 488  IEEE= Line 869  IEEE=
869  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
870      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
871  fi  fi
872    FS=
873    FS90=
874    
875  AUTODIFF_PKG_USED=f  AUTODIFF_PKG_USED=f
876  AD_OPTFILE=  AD_OPTFILE=
# Line 505  TAMC_EXTRA= Line 888  TAMC_EXTRA=
888    
889  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
890  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
891  gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS"
892    
893  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
894  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 "
895  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
896  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
897  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
898  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE"  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
899    
900  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
901  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
# Line 541  for i in . $MODS ; do Line 924  for i in . $MODS ; do
924          break          break
925      fi      fi
926  done  done
927  echo -n "  getting local config information:  "  printf "  getting local config information:  "
928  if test -e $gm_local ; then  if test -f $gm_local ; then
929      echo "using $gm_local"      echo "using $gm_local"
930      . $gm_local      . $gm_local
931      # echo "DISABLE=$DISABLE"      # echo "DISABLE=$DISABLE"
# Line 551  else Line 934  else
934      echo "none found"      echo "none found"
935  fi  fi
936    
937  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
938  #OPTIONS=  #OPTIONS=
939  #n=0  #n=0
940  #for i ; do  #for i ; do
# Line 563  fi Line 946  fi
946  #done  #done
947  #parse_options  #parse_options
948  ac_prev=  ac_prev=
949  for ac_option ; do  for ac_option in "$@" ; do
950    
951        G2ARGS="$G2ARGS \"$ac_option\""
952    
953      # If the previous option needs an argument, assign it.      # If the previous option needs an argument, assign it.
954      if test -n "$ac_prev"; then      if test -n "$ac_prev"; then
# Line 606  for ac_option ; do Line 991  for ac_option ; do
991          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
992              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
993                    
994            -bash | --bash)
995                ac_prev=BASH ;;
996            -bash=* | --bash=*)
997                BASH=$ac_optarg ;;
998            
999            -makedepend | --makedepend | -md | --md)
1000                ac_prev=MAKEDEPEND ;;
1001            -makedepend=* | --makedepend=* | -md=* | --md=*)
1002                MAKEDEPEND=$ac_optarg ;;
1003            
1004          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -ma | --ma)
1005              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
1006          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -ma=* | --ma=*)
# Line 647  for ac_option ; do Line 1042  for ac_option ; do
1042  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1043  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1044  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1045                        
1046            -cc | --cc)
1047                ac_prev=CC ;;
1048            -cc=* | --cc=*)
1049                CC=$ac_optarg ;;
1050            
1051          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1052              ac_prev=FC ;;              ac_prev=FC ;;
1053          -fc=* | --fc=*)          -fc=* | --fc=*)
1054              FC=$ac_optarg ;;              FC=$ac_optarg ;;
1055                    
1056            -fs | --fs)
1057                ac_prev=FS ;;
1058            -fs=* | --fs=*)
1059                FS=$ac_optarg ;;
1060            
1061            -fs90 | --fs90)
1062                ac_prev=FS90 ;;
1063            -fs90=* | --fs90=*)
1064                FS90=$ac_optarg ;;
1065            
1066          -ieee | --ieee)          -ieee | --ieee)
1067              IEEE=true ;;              IEEE=true ;;
1068          -noieee | --noieee)          -noieee | --noieee)
1069              IEEE= ;;              IEEE= ;;
1070    
1071            -mpi | --mpi)
1072                MPI=true ;;
1073            -mpi=* | --mpi=*)
1074                MPIPATH=$ac_optarg
1075                MPI=true ;;
1076                    
1077  #       -jam | --jam)  #       -jam | --jam)
1078  #           JAM=1 ;;  #           JAM=1 ;;
# Line 690  for ac_option ; do Line 1106  for ac_option ; do
1106            
1107  done  done
1108    
1109    
1110  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1111      echo      echo
1112      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
# Line 702  if test -f ./.genmakerc ; then Line 1119  if test -f ./.genmakerc ; then
1119      echo      echo
1120  fi  fi
1121    
1122    #  Find the MITgcm ${ROOTDIR}
1123  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1124      if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1125        if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
1126          ROOTDIR=".."          ROOTDIR=".."
1127      else      else
1128          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
1129              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
1130                  ROOTDIR=$d                  ROOTDIR=$d
1131                  echo -n "Warning:  ROOTDIR was not specified but there appears to be"                  printf "Warning:  ROOTDIR was not specified but there appears to be"
1132                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
1133                  break                  break
1134              fi              fi
# Line 727  if test ! -d ${ROOTDIR} ; then Line 1146  if test ! -d ${ROOTDIR} ; then
1146      exit 1      exit 1
1147  fi  fi
1148    
1149    #  Find the MITgcm ${THISVER}
1150    if test -f "${ROOTDIR}/doc/tag-index" ; then
1151        THISVER=`grep checkpoint ${ROOTDIR}/doc/tag-index | head -1`
1152    fi
1153    
1154    if test "x$MAKEFILE" = x ; then
1155        MAKEFILE="Makefile"
1156    fi
1157    
1158  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
1159  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1160      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
# Line 743  if test "x$OPTFILE" != xNONE ; then Line 1171  if test "x$OPTFILE" != xNONE ; then
1171          . "$OPTFILE"          . "$OPTFILE"
1172          RETVAL=$?          RETVAL=$?
1173          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
1174              echo -n "Error: failed to source OPTFILE \"$OPTFILE\""              printf "Error: failed to source OPTFILE \"$OPTFILE\""
1175              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1176              exit 1              exit 1
1177          fi          fi
# Line 770  if test "x${AD_OPTFILE}" != xNONE ; then Line 1198  if test "x${AD_OPTFILE}" != xNONE ; then
1198          . "$AD_OPTFILE"          . "$AD_OPTFILE"
1199          RETVAL=$?          RETVAL=$?
1200          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
1201              echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""              printf "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
1202              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1203              exit 1              exit 1
1204          fi          fi
# Line 783  if test "x${AD_OPTFILE}" != xNONE ; then Line 1211  if test "x${AD_OPTFILE}" != xNONE ; then
1211      fi      fi
1212  fi  fi
1213    
1214  #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #====================================================================
1215    #  Set default values if not set by the optfile
1216    #
1217    #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1218  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1219    if test ! "x$BASH" = x ; then
1220        # add a trailing space so that it works within the Makefile syntax (see below)
1221        BASH="$BASH "
1222    fi
1223  if test "x$FC" = x ; then  if test "x$FC" = x ; then
1224      cat <<EOF 1>&2      cat <<EOF 1>&2
1225    
# Line 795  Error: no Fortran compiler: please speci Line 1230  Error: no Fortran compiler: please speci
1230  EOF  EOF
1231      exit 1      exit 1
1232  fi  fi
1233    if test "x$CC" = x ; then
1234        CC=cc
1235    #     cat <<EOF 1>&2
1236    # Error: no C compiler: please specify using one of the following:
1237    #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1238    #   2) the "-cc=XXX" command-line option
1239    #   3) the "./genmake_local" file
1240    # EOF
1241    #     exit 1
1242    fi
1243  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1244      LINK=$FC      LINK=$FC
1245  fi  fi
 if test "x$CPP" = x ; then  
     CPP="cpp"  
 fi  
1246  if test "x$MAKE" = x ; then  if test "x$MAKE" = x ; then
1247      MAKE="make"      MAKE="make"
1248  fi  fi
1249    if test "x$CPP" = x ; then
1250        CPP=cpp
1251    fi
1252    #EH3 === UGLY ===
1253    #  The following is an ugly little hack to check for $CPP in /lib/ and
1254    #  it should eventually be replaced with a more general function that
1255    #  searches a combo of the user's path and a list of "usual suspects"
1256    #  to find the correct location for binaries such as $CPP.
1257    for i in " " "/lib/" ; do
1258        echo "#define A a" | $i$CPP > test_cpp 2>&1 && CPP=$i$CPP
1259    done
1260    #EH3 === UGLY ===
1261  echo "#define A a" | $CPP > test_cpp 2>&1  echo "#define A a" | $CPP > test_cpp 2>&1
1262  RETVAL=$?  RETVAL=$?
1263  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
# Line 820  EOF Line 1274  EOF
1274  else  else
1275      rm -f test_cpp      rm -f test_cpp
1276  fi  fi
1277  if test "x$MAKEDEPEND" = x ; then  look_for_makedepend
     MAKEDEPEND=makedepend  
 fi  
1278  if test "x$LN" = x ; then  if test "x$LN" = x ; then
1279      LN="ln -s"      LN="ln -s"
1280  fi  fi
# Line 840  EOF Line 1292  EOF
1292  fi  fi
1293  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
1294    
1295    #  Check for broken *.F/*.f handling and fix if possible
1296    check_for_broken_Ff
1297    
1298    if test ! "x$MPI" = x ; then
1299          echo "  Turning on MPI cpp macros"
1300          DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1301    fi
1302    
1303  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1304  echo -n "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1305  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1306        program hello        program hello
1307        call system('echo hi')        call system('echo hi')
1308        end        end
1309  EOF  EOF
1310  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1311  RETVAL=$?  RETVAL=$?
1312  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1313      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 860  else Line 1319  else
1319  fi  fi
1320  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1321    
1322  echo -n "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1323  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1324        program hello        program hello
1325        CHARACTER(128) string        CHARACTER(128) string
1326        string = ' '        string = ' '
# Line 869  cat > genmake_tcomp.f <<EOF Line 1328  cat > genmake_tcomp.f <<EOF
1328        print *, string        print *, string
1329        end        end
1330  EOF  EOF
1331  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1332  RETVAL=$?  RETVAL=$?
1333  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1334      HAVE_FDATE=t      HAVE_FDATE=t
# Line 881  else Line 1340  else
1340  fi  fi
1341  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1342    
1343  echo -n "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Do we have the etime() command using $FC...  "
1344    cat > genmake_tcomp.$FS <<EOF
1345          program hello
1346          REAL*4 ACTUAL, TARRAY(2)
1347          EXTERNAL ETIME
1348          REAL*4 ETIME
1349          actual = etime( tarray )
1350          print *, tarray
1351          end
1352    EOF
1353    $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1354    RETVAL=$?
1355    if test "x$RETVAL" = x0 ; then
1356        HAVE_ETIME=t
1357        DEFINES="$DEFINES -DHAVE_ETIME"
1358        echo "yes"
1359    else
1360        HAVE_ETIME=
1361        echo "no"
1362    fi
1363    rm -f genmake_tcomp*
1364    
1365    printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1366  check_HAVE_CLOC  check_HAVE_CLOC
1367  if test "x$HAVE_CLOC" != x ; then  if test "x$HAVE_CLOC" != x ; then
1368      echo "yes"      echo "yes"
1369  else  else
1370      echo "no"      echo "no"
1371  fi  fi
1372  echo "$FC_NAMEMANGLE" > FC_NAMEMANGLE.h.template  rm -f genmake_t*
1373  cmp FC_NAMEMANGLE.h FC_NAMEMANGLE.h.template > /dev/null 2>&1  
1374  RETVAL=$?  printf "  Can we use stat() through C calls...  "
1375  if test "x$RETVAL" != x0 ; then  check_HAVE_STAT
1376      mv -f FC_NAMEMANGLE.h.template FC_NAMEMANGLE.h  if test "x$HAVE_STAT" != x ; then
1377        echo "yes"
1378    else
1379        echo "no"
1380  fi  fi
1381  rm -f genmake_t*  rm -f genmake_t*
1382    
1383    printf "  Can we create NetCDF-enabled binaries...  "
1384    check_netcdf_libs
1385    if test "x$HAVE_NETCDF" != x ; then
1386        echo "yes"
1387    else
1388        echo "no"
1389    fi
1390    
1391    
1392  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1393  echo -n "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
1394  for d in $MODS ; do  for d in $MODS ; do
1395      if test ! -d $d ; then      if test ! -d $d ; then
1396          echo          echo
1397          echo "Error: MODS directory \"$d\" not found!"          echo "Error: MODS directory \"$d\" not found!"
1398          exit 1          exit 1
1399      else      else
1400          echo -n " $d"          printf " $d"
1401          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1402          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
1403      fi      fi
1404  done  done
1405  echo  echo
1406    
 if test "x$MAKEFILE" = x ; then  
     MAKEFILE="Makefile"  
 fi  
1407  if test "x${PLATFORM}" = x ; then  if test "x${PLATFORM}" = x ; then
1408      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
1409  fi  fi
1410    
1411  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1412      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1413        if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1414          EXEDIR=../exe          EXEDIR=../exe
1415      else      else
1416          EXEDIR=.          EXEDIR=.
# Line 935  if test "x${TOOLSDIR}" = x ; then Line 1425  if test "x${TOOLSDIR}" = x ; then
1425      TOOLSDIR="$ROOTDIR/tools"      TOOLSDIR="$ROOTDIR/tools"
1426  fi  fi
1427  if test ! -d ${TOOLSDIR} ; then  if test ! -d ${TOOLSDIR} ; then
1428      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"
1429      exit 1      exit 1
1430  fi  fi
1431  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1432      S64='$(TOOLSDIR)/set64bitConst.sh'      echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1433        RETVAL=$?
1434        if test "x${RETVAL}" = x0 ; then
1435            S64='$(TOOLSDIR)/set64bitConst.sh'
1436        else
1437            echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1438            RETVAL=$?
1439            if test "x${RETVAL}" = x0 ; then
1440                S64='$(TOOLSDIR)/set64bitConst.csh'
1441            else
1442                cat <<EOF
1443    
1444    ERROR: neither of the two default scripts:
1445    
1446        ${TOOLSDIR}/set64bitConst.sh
1447        ${TOOLSDIR}/set64bitConst.csh
1448    
1449      are working so please check paths or specify (with \$S64) a
1450      working version of this script.
1451    
1452    EOF
1453                exit 1
1454            fi
1455        fi
1456  fi  fi
1457  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1458    
# Line 956  if test -r $ROOTDIR"/eesupp/src/Makefile Line 1469  if test -r $ROOTDIR"/eesupp/src/Makefile
1469          rm -f make_eesupp.errors          rm -f make_eesupp.errors
1470      else      else
1471          echo "Error: problem encountered while building source files in eesupp:"          echo "Error: problem encountered while building source files in eesupp:"
1472          cat make_eesupp.errors          cat make_eesupp.errors 1>&2
1473          exit 1          exit 1
1474      fi      fi
1475  fi  fi
1476    
1477    #same for exch2
1478    if test -r $ROOTDIR"/pkg/exch2/Makefile" ; then
1479        echo "  Making source files in exch2 from  templates"
1480        ( cd $ROOTDIR"/pkg/exch2/" && $MAKE ) > make_exch2.errors 2>&1
1481        RETVAL=$?
1482        if test "x${RETVAL}" = x0 ; then
1483            rm -f make_exch2.errors
1484        else
1485            echo "Error: problem encountered while building source files in exch2:"
1486            cat make_exch2.errors 1>&2
1487            exit 1
1488        fi
1489    fi
1490    
1491  printf "\n===  Determining package settings  ===\n"  printf "\n===  Determining package settings  ===\n"
1492  if  test "x${PDEPEND}" = x ; then  if  test "x${PDEPEND}" = x ; then
1493      tmp=$ROOTDIR"/pkg/pkg_depend"      tmp=$ROOTDIR"/pkg/pkg_depend"
# Line 1016  else Line 1543  else
1543          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
1544          RETVAL=$?          RETVAL=$?
1545          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
1546              echo -n "Error: can't parse default package list "              printf "Error: can't parse default package list "
1547              echo "-- please check PDEFAULT=\"$PDEFAULT\""              echo "-- please check PDEFAULT=\"$PDEFAULT\""
1548              exit 1              exit 1
1549          fi          fi
# Line 1024  else Line 1551  else
1551              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
1552          done          done
1553          echo "    before group expansion packages are: $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
1554          expand_pkg_groups          RET=1
1555            while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
1556          echo "    after group expansion packages are:  $PACKAGES"          echo "    after group expansion packages are:  $PACKAGES"
1557      fi      fi
1558  fi  fi
1559    
1560  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
1561    for i in $PACKAGES ; do
1562        echo $i >> ./.tmp_pack
1563    done
1564    for i in `grep  "-" ./.tmp_pack` ; do
1565        j=`echo $i | sed 's/[-]//'`
1566        DISABLE="$DISABLE $j"
1567    done
1568  pack=  pack=
1569  for p in $PACKAGES ; do  for p in $PACKAGES ; do
1570      addit="t"      addit="t"
# Line 1046  PACKAGES="$pack" Line 1581  PACKAGES="$pack"
1581  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
1582  echo "" > ./.tmp_pack  echo "" > ./.tmp_pack
1583  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
1584    # Test if each explicitly referenced package exists
1585  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1586      if test ! -d "$ROOTDIR/pkg/$i" ; then      j=`echo $i | sed 's/[-+]//'`
1587        if test ! -d "$ROOTDIR/pkg/$j" ; then
1588          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""
1589          exit 1          exit 1
1590      fi      fi
1591      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
1592  done  done
 pack=`cat ./.tmp_pack | sort | uniq`  
 rm -f ./.tmp_pack  
1593  PACKAGES=  PACKAGES=
1594  for i in $pack ; do  for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do
1595      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
1596  done  done
1597    rm -f ./.tmp_pack
1598  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1599    
1600    #  Check availability of NetCDF and then either build the MNC template
1601    #  files or delete mnc from the list of available packages.
1602    echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1603    RETVAL=$?
1604    if test "x$RETVAL" = x0 ; then
1605        if test "x$HAVE_NETCDF" != xt ; then
1606            cat <<EOF
1607    
1608    *********************************************************************
1609    WARNING: the "mnc" package was enabled but tests failed to compile
1610      NetCDF applications.  Please check that:
1611    
1612      1) NetCDF is correctly installed for this compiler and
1613      2) the LIBS variable (within the "optfile") specifies the correct
1614           NetCDF library to link against.
1615    
1616      Due to this failure, the "mnc" package is now DISABLED.
1617    *********************************************************************
1618    
1619    EOF
1620            PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
1621            DISABLE="$DISABLE mnc"
1622        else
1623            ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
1624            RETVAL=$?
1625            if test "x${RETVAL}" = x0 ; then
1626                rm -f make_mnc.errors
1627            else
1628                echo "Error: problem encountered while building source files in pkg/mnc:"
1629                cat make_mnc.errors 1>&2
1630                exit 1
1631            fi
1632        fi
1633    fi
1634    
1635  echo "  applying package dependency rules"  echo "  applying package dependency rules"
1636  ck=  ck=
1637  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
# Line 1125  while test "x$ck" != xtt ; do Line 1696  while test "x$ck" != xtt ; do
1696              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
1697              exit 1              exit 1
1698          fi          fi
1699          i=$(( $i + 1 ))          i=`echo "$i + 1" | bc -l`
1700            #i=$(( $i + 1 ))
1701      done      done
1702      ck=$ck"t"      ck=$ck"t"
1703  done  done
# Line 1144  for i in $PACKAGES ; do Line 1716  for i in $PACKAGES ; do
1716      fi      fi
1717  done  done
1718    
   
1719  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
1720  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
1721  #  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 1164  for n in $names ; do Line 1735  for n in $names ; do
1735              fi              fi
1736          done          done
1737          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1738              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1739              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
1740          fi          fi
1741      fi      fi
1742  done  done
1743  ENABLED_PACKAGES=  ENABLED_PACKAGES=
1744  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1745      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`      def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1746      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1747  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
1748    
1749  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
1750      case $i in      case $i in
1751          aim_v23)          aim_v23)
             DEFINES="$DEFINES -DALLOW_AIM"  
1752              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"              ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM"
1753              echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"              echo "Warning: ALLOW_AIM is set to enable aim_v23."
1754              ;;              ;;
1755      esac      esac
1756  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
# Line 1189  done Line 1759  done
1759    
1760  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
1761  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
1762  if test "x$STANDARDDIRS" = x ; then  if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then
1763      STANDARDDIRS="eesupp model"      STANDARDDIRS="eesupp model"
1764  fi  fi
1765  for d in $STANDARDDIRS ; do  if test "x$STANDARDDIRS" != x ; then
1766      adr="$ROOTDIR/$d/src"      for d in $STANDARDDIRS ; do
1767      if test ! -d $adr ; then          adr="$ROOTDIR/$d/src"
1768          echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""          if test ! -d $adr ; then
1769          echo "  is correct and that you correctly specified the STANDARDDIRS option"              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1770          exit 1              echo "  is correct and that you correctly specified the STANDARDDIRS option"
1771      else              exit 1
1772          SOURCEDIRS="$SOURCEDIRS $adr"          else
1773      fi              SOURCEDIRS="$SOURCEDIRS $adr"
1774      adr="$ROOTDIR/$d/inc"          fi
1775      if test ! -d $adr ; then          adr="$ROOTDIR/$d/inc"
1776          echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""          if test ! -d $adr ; then
1777          echo "  is correct and that you correctly specified the STANDARDDIRS option"              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
1778          exit 1              echo "  is correct and that you correctly specified the STANDARDDIRS option"
1779      else              exit 1
1780          INCLUDEDIRS="$INCLUDEDIRS $adr"          else
1781      fi              INCLUDEDIRS="$INCLUDEDIRS $adr"
1782  done          fi
1783        done
1784    fi
1785    
1786  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"
1787  echo "    of \"#define ALLOW_PKGNAME\"-type statements:"  echo "    of \"#define \"-type statements that are no longer allowed:"
1788  CPP_OPTIONS=  CPP_OPTIONS=
1789    CPP_EEOPTIONS=
1790  spaths=". $INCLUDEDIRS"  spaths=". $INCLUDEDIRS"
1791    names=`ls -1 "$ROOTDIR/pkg"`
1792  for i in $spaths ; do  for i in $spaths ; do
1793      try="$i/CPP_OPTIONS.h"      try="$i/CPP_OPTIONS.h"
1794      #  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  
1795          echo "    found CPP_OPTIONS=\"$try\""          echo "    found CPP_OPTIONS=\"$try\""
1796          CPP_OPTIONS="$try"          CPP_OPTIONS="$try"
1797          break          # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h
1798            for n in $names ; do
1799                test_for_package_in_cpp_options $CPP_OPTIONS $n
1800            done
1801        fi
1802        try="$i/CPP_EEOPTIONS.h"
1803        if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" = x ; then
1804            echo "    found CPP_EEOPTIONS=\"$try\""
1805            # New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h
1806    #**** not yet enabled ****
1807    #        test_for_mpi_in_cpp_eeoptions $try
1808    #**** not yet enabled ****
1809            CPP_EEOPTIONS="$try"
1810      fi      fi
1811  done  done
1812  if test "x$CPP_OPTIONS" = x ; then  if test "x$CPP_OPTIONS" = x ; then
1813      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"
1814      exit 1      exit 1
1815  fi  fi
 # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h  
 names=`ls -1 "$ROOTDIR/pkg"`  
 for n in $names ; do  
     test_for_package_in_cpp_options $CPP_OPTIONS $n  
 done  
   
1816    
1817  #  Here, we build the list of files to be "run through" the adjoint  #  Here, we build the list of files to be "run through" the adjoint
1818  #  compiler.  #  compiler.
# Line 1247  for i in $SOURCEDIRS ; do Line 1826  for i in $SOURCEDIRS ; do
1826          cat $i/$j >> ad_files          cat $i/$j >> ad_files
1827      done      done
1828  done  done
1829    if test ! "x"$FS = "x.f" ; then
1830        cat ad_files | sed -e "s/\.f/$FS/g" > ad_files_f
1831        mv -f ad_files_f ad_files
1832    fi
1833    
1834  echo  echo
1835  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
1836  echo "  setting INCLUDES"  echo "  setting INCLUDES"
1837  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
1838      if ! test -d $i ; then      if test ! -d $i ; then
 #       INCLUDES="$INCLUDES -I$i"  
 #   else  
1839          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
1840      fi      fi
1841  done  done
# Line 1264  rm -rf .links.tmp Line 1845  rm -rf .links.tmp
1845  mkdir .links.tmp  mkdir .links.tmp
1846  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
1847  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
1848  echo -n 'SRCFILES = '    > srclist.inc  printf 'SRCFILES = '    > srclist.inc
1849  echo -n 'CSRCFILES = '   > csrclist.inc  printf 'CSRCFILES = '   > csrclist.inc
1850  echo -n 'F90SRCFILES = ' > f90srclist.inc  printf 'F90SRCFILES = ' > f90srclist.inc
1851  echo -n 'HEADERFILES = ' > hlist.inc  printf 'HEADERFILES = ' > hlist.inc
1852  echo -n 'AD_FLOW_FILES = ' > ad_flow_files.inc  printf 'AD_FLOW_FILES = ' > ad_flow_files.inc
1853  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
1854  for d in $alldirs ; do  for d in $alldirs ; do
1855      deplist=      deplist=
# Line 1284  for d in $alldirs ; do Line 1865  for d in $alldirs ; do
1865                          ;;                          ;;
1866                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
1867                          ;;                          ;;
1868                      ./BUILD_INFO.h)
1869                            ;;
1870                    *)                    *)
1871                          touch .links.tmp/$sf                          touch .links.tmp/$sf
1872                          deplist="$deplist $sf"                          deplist="$deplist $sf"
1873                          ;;                          ;;
1874                  esac                  esac
1875                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`                  extn=`echo $sf | $AWK -F. '{print $NF}'`
1876                  case $extn in                  case $extn in
1877                      F)                      F)
1878                          echo    " \\"  >> srclist.inc                          echo    " \\"  >> srclist.inc
1879                          echo -n " $sf" >> srclist.inc                          printf " $sf" >> srclist.inc
1880                          ;;                          ;;
1881                      F90)                      F90)
1882                          echo    " \\"  >> f90srclist.inc                          echo    " \\"  >> f90srclist.inc
1883                          echo -n " $sf" >> f90srclist.inc                          printf " $sf" >> f90srclist.inc
1884                          ;;                          ;;
1885                      c)                      c)
1886                          echo    " \\"  >> csrclist.inc                          echo    " \\"  >> csrclist.inc
1887                          echo -n " $sf" >> csrclist.inc                          printf " $sf" >> csrclist.inc
1888                          ;;                          ;;
1889                      h)                      h)
1890                          echo    " \\"  >> hlist.inc                          echo    " \\"  >> hlist.inc
1891                          echo -n " $sf" >> hlist.inc                          printf " $sf" >> hlist.inc
1892                          ;;                          ;;
1893                      flow)                      flow)
1894                          echo    " \\"  >> ad_flow_files.inc                          echo    " \\"  >> ad_flow_files.inc
1895                          echo -n " $sf" >> ad_flow_files.inc                          printf " $sf" >> ad_flow_files.inc
1896                          ;;                          ;;
1897                  esac                  esac
1898              fi              fi
# Line 1329  echo "" >> f90srclist.inc Line 1912  echo "" >> f90srclist.inc
1912  echo "" >> hlist.inc  echo "" >> hlist.inc
1913  echo "" >> ad_flow_files.inc  echo "" >> ad_flow_files.inc
1914    
1915  if test -e $MAKEFILE ; then  if test -f $MAKEFILE ; then
1916      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
1917  fi  fi
1918  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
# Line 1338  echo "#    $MACHINE" >> $MAKEFILE Line 1921  echo "#    $MACHINE" >> $MAKEFILE
1921  echo "# This makefile was generated automatically on" >> $MAKEFILE  echo "# This makefile was generated automatically on" >> $MAKEFILE
1922  echo "#    $THISDATE" >> $MAKEFILE  echo "#    $THISDATE" >> $MAKEFILE
1923  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
1924  echo "#    $0 $@" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
1925  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
1926  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
1927    
1928  EXE_AD=$EXECUTABLE"_ad"  EXE_AD=$EXECUTABLE"_ad"
1929  EXE_FTL=$EXECUTABLE"_ftl"  EXE_FTL=$EXECUTABLE"_ftl"
1930  EXE_SVD=$EXECUTABLE"_svd"  EXE_SVD=$EXECUTABLE"_svd"
1931    
1932  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1933    #
1934    # OPTFILE="$OPTFILE"
1935  #  #
1936  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
1937  # SOURCEDIRS   : Directories containing the source (.F) files  # SOURCEDIRS   : Directories containing the source (.F) files
# Line 1383  EXE_SVD     = ${EXE_SVD} Line 1968  EXE_SVD     = ${EXE_SVD}
1968  ENABLED_PACKAGES = ${ENABLED_PACKAGES}  ENABLED_PACKAGES = ${ENABLED_PACKAGES}
1969  DISABLED_PACKAGES = ${DISABLED_PACKAGES}  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
1970    
1971    # These files are created by Makefile
1972    SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h
1973    
1974  EOF  EOF
1975    
1976  #  Note: figure out some way to add Hyades JAM libraries here  #  Note: figure out some way to add Hyades JAM libraries here
# Line 1400  KPP = ${KPP} Line 1988  KPP = ${KPP}
1988  FC = ${FC}  FC = ${FC}
1989  # Fortran compiler  # Fortran compiler
1990  F90C = ${F90C}  F90C = ${F90C}
1991    # C compiler
1992    CC = ${CC}
1993  # Link editor  # Link editor
1994  LINK = ${LINK}  LINK = ${LINK} ${LDADD}
1995    
1996  # Defines for CPP  # Defines for CPP
1997  DEFINES = ${DEFINES}  DEFINES = ${DEFINES}
# Line 1422  CFLAGS = ${CFLAGS} Line 2012  CFLAGS = ${CFLAGS}
2012  NOOPTFILES = ${NOOPTFILES}  NOOPTFILES = ${NOOPTFILES}
2013  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2014  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2015  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS}
2016  # Name of the Mekfile  # Name of the Mekfile
2017  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2018    
# Line 1433  cat csrclist.inc      >> $MAKEFILE Line 2023  cat csrclist.inc      >> $MAKEFILE
2023  cat f90srclist.inc    >> $MAKEFILE  cat f90srclist.inc    >> $MAKEFILE
2024  cat hlist.inc         >> $MAKEFILE  cat hlist.inc         >> $MAKEFILE
2025  cat ad_flow_files.inc >> $MAKEFILE  cat ad_flow_files.inc >> $MAKEFILE
2026  echo               >> $MAKEFILE  echo >> $MAKEFILE
2027  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE
2028  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F=.'$FS90')' >> $MAKEFILE
2029  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
2030    echo >> $MAKEFILE
2031    echo '.SUFFIXES:' >> $MAKEFILE
2032    echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE
2033  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
2034  rm -f ad_flow_files.inc  rm -f ad_flow_files.inc
2035    
2036  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2037    
 .SUFFIXES:  
 .SUFFIXES: .o .f .p .F .c .F90 .f90  
   
2038  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
2039  \$(EXECUTABLE): links \$(OBJFILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)
2040          @echo Creating \$@ ...          @echo Creating \$@ ...
2041          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2042  depend:  depend:
2043          @make links          @make links
2044          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
2045          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2046            -rm -f makedepend.out
2047    
2048  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) ${PACKAGES_DOT_H} AD_CONFIG.h  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
2049    
2050  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77FILES) \$(F90FILES)
2051    
# Line 1464  output.txt: \$(EXECUTABLE) Line 2054  output.txt: \$(EXECUTABLE)
2054          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
2055    
2056  clean:  clean:
2057          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2058  Clean:  Clean:
2059          @make clean          @make clean
2060          @make cleanlinks          @make cleanlinks
2061          -rm -f ${PACKAGES_DOT_H} AD_CONFIG.h          -rm -f \$(SPECIAL_FILES)
2062          -rm -f Makefile.bak genmake_state genmake_*optfile genmake_warnings make.log          -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak
2063  CLEAN:  CLEAN:
2064          @make Clean          @make Clean
2065          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2066          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2067          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2068          -rm -f \$(EXECUTABLE) output.txt          -rm -f \$(EXECUTABLE) output.txt STD*
2069    
2070  #eh3 Makefile: makefile  #eh3 Makefile: makefile
2071  makefile:  makefile:
2072          $THIS_SCRIPT $@          $THIS_SCRIPT $G2ARGS
2073  cleanlinks:  cleanlinks:
2074          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2075    
2076  # Special targets  # Special targets (SPECIAL_FILES) which are create by make
2077  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2078          @echo Creating \$@ ...          @echo Creating \$@ ...
2079          @\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@          @$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) > \$@
2080  AD_CONFIG.h:  AD_CONFIG.h:
2081          @echo Creating \$@ ...          @echo Creating \$@ ...
2082          @\$(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 > \$@          @$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 > \$@
2083    FC_NAMEMANGLE.h:
2084            @echo Creating \$@ ...
2085            echo "$FC_NAMEMANGLE" > \$@
2086    
2087    BUILD_INFO.h:
2088            @echo Creating \$@ ...
2089    EOF
2090    
2091  # The normal chain of rules is (  .F - .f - .o  )  test ! "x$THISVER" = x  && echo "       -echo \"#define THISVER '$THISVER'\" > \$@"   >> $MAKEFILE
2092  .F.f:  test ! "x$THISUSER" = x && echo "       -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2093    test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2094    test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2095    
2096    cat >>$MAKEFILE <<EOF
2097    
2098    # The normal chain of rules is (  .F - .$FS - .o  )
2099    
2100    ## This nullifies any default implicit rules concerning these two file types:
2101    ## %.o : %.F
2102    
2103    .F.$FS:
2104          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2105  .f.o:  .$FS.o:
2106          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2107  .F90.f90:  .F90.$FS90:
2108          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2109  .f90.o:  .$FS90.o:
2110          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2111  .c.o:  .c.o:
2112          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) -c \$<
2113    
2114  # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2115  .F.p:  .F.p:
2116          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2117  .p.f:  .p.$FS:
2118          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
2119    
2120  #=========================================  #=========================================
# Line 1533  done Line 2141  done
2141    
2142  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
2143  echo >> $MAKEFILE  echo >> $MAKEFILE
2144  echo -n "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
2145  AD_FILES=`cat ad_files`  AD_FILES=`cat ad_files`
2146  for i in $AD_FILES ; do  for i in $AD_FILES ; do
2147      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
2148      echo -n " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
2149  done  done
2150  echo >> $MAKEFILE  echo >> $MAKEFILE
2151  rm -f ad_files  rm -f ad_files
# Line 1546  cat >>$MAKEFILE <<EOF Line 2154  cat >>$MAKEFILE <<EOF
2154    
2155  # ... AD ...  # ... AD ...
2156  adall: ad_taf  adall: ad_taf
2157  adtaf: ad_taf_output.f  adtaf: ad_taf_output.$FS
2158  adtamc: ad_tamc_output.f  adtamc: ad_tamc_output.$FS
2159    
2160  ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2161          @\$(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          @$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
2162          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2163          -rm -f ad_config.template          -rm -f ad_config.template
2164          @make \$(F77FILES)          @make \$(F77FILES)
2165          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2166          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS
2167    
2168  ad_taf_output.f: ad_input_code.f  ad_taf_output.$FS: ad_input_code.$FS
2169          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2170          cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2171    
2172  adtafonly:  adtafonly:
2173          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2174          cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2175    
2176  ad_taf: ad_taf_output.o \$(OBJFILES)  ad_taf: ad_taf_output.o \$(OBJFILES)
2177          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2178    
2179  ad_tamc_output.f: ad_input_code.f  ad_tamc_output.$FS: ad_input_code.$FS
2180          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2181          cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.f          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
2182    
2183  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2184          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2185    
2186    adonlyfwd:
2187            patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2188    
2189    adtrick:
2190            patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2191    
2192  # ... FTL ...  # ... FTL ...
2193  ftlall: ftl_taf  ftlall: ftl_taf
2194  ftltaf: ftl_taf_output.f  ftltaf: ftl_taf_output.$FS
2195  ftltamc: ftl_tamc_output.f  ftltamc: ftl_tamc_output.$FS
2196    
2197  ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2198          @\$(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          @$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
2199          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2200          -rm -f ftl_config.template          -rm -f ftl_config.template
2201          @make \$(F77FILES)          @make \$(F77FILES)
2202          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2203          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2204    
2205  ftl_taf_output.f: ftl_input_code.f  ftl_taf_output.$FS: ftl_input_code.$FS
2206          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2207          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2208    
2209  ftltafonly:  ftltafonly:
2210          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2211          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2212    
2213  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
2214          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2215    
2216  ftl_tamc_output.f: ftl_input_code.f  ftl_tamc_output.$FS: ftl_input_code.$FS
2217          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2218          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.f          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS
2219    
2220  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2221          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2222    
2223    
2224  # ... SVD ...  # ... SVD ...
2225  svdtaf: ad_taf_output.f ftl_taf_output.f  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
2226  svdall: svd_taf          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"
2227            @echo "--->>> Do make svdall afterwards to compile. <<<---"
2228    svdall: svd_touch svd_taf
2229    
2230  svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES)  svd_taf: \$(OBJFILES)
2231          \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS)          \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS)
2232    
2233            @echo "--->>> Only COMPILE svd code! <<<---"
2234            @echo "--->>> Assumes you previously <<<---"
2235            @echo "--->>> did make svdtaf        <<<---"
2236    
2237    svd_touch:
2238            @echo "--->>> Only COMPILE svd code! <<<---"
2239            @echo "--->>> Assumes you previously <<<---"
2240            @echo "--->>> did make svdtaf        <<<---"
2241            touch ad_taf_output.$FS ftl_taf_output.$FS
2242            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
2243            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
2244            @$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
2245            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2246            -rm -f ftl_config.template
2247    
2248  #=========================================  #=========================================
2249    
# Line 1631  for i in $KPPFILES ; do Line 2260  for i in $KPPFILES ; do
2260      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
2261          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
2262      fi      fi
2263      echo "$base.f: $base.p" >> $MAKEFILE      echo "$base.$FS: $base.p" >> $MAKEFILE
2264  done  done
2265    
2266  echo "  Making list of NOOPTFILES"  echo "  Making list of NOOPTFILES"
# Line 1641  for i in $NOOPTFILES ; do Line 2270  for i in $NOOPTFILES ; do
2270      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
2271          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
2272      fi      fi
2273      echo "$base.o: $base.f" >> $MAKEFILE      echo "$base.o: $base.$FS" >> $MAKEFILE
2274      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
2275  done  done
2276    
# Line 1655  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 2284  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
2284  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
2285    
2286  # Create special header files  # Create special header files
2287  $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"  $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"
2288  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
2289      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
2290  else  else
2291      cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H > /dev/null 2>&1
2292      RETVAL=$?      RETVAL=$?
2293      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
2294          rm -f $PACKAGES_DOT_H".tmp"          rm -f $PACKAGES_DOT_H".tmp"
# Line 1669  else Line 2298  else
2298      fi      fi
2299  fi  fi
2300  if test ! -f AD_CONFIG.h ; then  if test ! -f AD_CONFIG.h ; then
2301      $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      $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
2302  fi  fi
2303    
2304    
2305  #  Write the "state" for future records  #  Write the "state" for future records
2306  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" != xf ; then
2307      echo -n "" > genmake_state      printf "" > genmake_state
2308      for i in $gm_state ; do      for i in $gm_state ; do
2309          t1="t2=\$$i"          t1="t2=\$$i"
2310          eval $t1          eval $t1

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.121

  ViewVC Help
Powered by ViewVC 1.1.22