/[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.62 by edhill, Thu Jan 15 19:19:59 2004 UTC revision 1.138 by edhill, Sun Dec 4 13:57:08 2005 UTC
# Line 37  test_for_string_in_file() { Line 37  test_for_string_in_file() {
37      grep -i "$strng" $file > /dev/null 2>&1      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 -n "Error: In $file there is an illegal line: "          printf "Error: In $file there is an illegal line: "
41          grep -i "$strng" $file          grep -i "$strng" $file
42          return 1          return 1
43      fi      fi
# Line 67  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    
# Line 80  find_possible_configs()  { Line 256  find_possible_configs()  {
256      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
257      tmp1=`echo $tmp3 | sed -e 's|x86_64|amd64|'`      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/'`      tmp2=`echo $tmp1 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
259      PLATFORM=$tmp2      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 100  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      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"      #  look for possible FORTRAN compilers
324        tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 gfortran"
325      p_FC=      p_FC=
326      for c in $tmp ; do      for c in $tmp ; do
327          rm -f ./hello.f ./hello          rm -f ./hello.f ./hello
# Line 136  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
353      else      else
354          echo "  The possible FORTRAN compilers found in your path are:"          echo "  The possible FORTRAN compilers found in your path are:"
355          echo "   "$p_FC          echo "   "$p_FC
         if test "x$FC" = x ; then  
             FC=`echo $p_FC | $AWK '{print $1}'`  
         fi  
356      fi      fi
357    
358      for i in $p_FC ; do      #  Use the first of the compilers found in the current PATH
359          p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i      #  that has a correctly-named optfile
360          if test -r $p_OF ; then      if test "x$OPTFILE" = x  -a  "x$FC" = x ; then
361              OPTFILE=$p_OF          for i in $p_FC ; do
362              echo "  The options file:  $p_OF"              OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
363              echo "    appears to match so we'll use it."              if test -r $OPTFILE ; then
364              break                  echo "  Setting OPTFILE to: "$OPTFILE
365          fi                  break
366      done              fi
367            done
368        fi
369    
370        if test "x$OPTFILE" = x ; then
371            OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC
372            if test ! -r $OPTFILE ; then
373                 echo "  I looked for the file "$OPTFILE" but did not find it"
374            fi
375        fi
376    #    echo "  The options file:  $p_OF"
377    #    echo "    appears to match so we'll use it."
378    #   for i in $p_FC ; do
379    #p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
380    #if test -r $p_OF ; then
381    #    OPTFILE=$p_OF
382    #    echo "  The options file:  $p_OF"
383    #    echo "    appears to match so we'll use it."
384    #    break
385    #fi
386    #   done
387      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
388          cat 1>&2 <<EOF          cat 1>&2 <<EOF
389    
# Line 215  get_pdepend_list()  { Line 442  get_pdepend_list()  {
442      . ./.pd_tmp      . ./.pd_tmp
443      rm -f ./.pd_tmp      rm -f ./.pd_tmp
444    
445      echo -n "PNAME = "${}      printf "PNAME = "${}
446  }  }
447    
448    
# Line 229  Usage: "$0" [OPTIONS] Line 456  Usage: "$0" [OPTIONS]
456      -help | --help | -h | --h      -help | --help | -h | --h
457            Print this help message and exit.            Print this help message and exit.
458    
459        -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
460          -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
461              Use "NAME" as the adoptfile.  By default, the file at
462              "tools/adjoint_options/adjoint_default" will be used.
463    
464      -nooptfile | --nooptfile      -nooptfile | --nooptfile
465        -optfile NAME | --optfile NAME | -of NAME | --of NAME        -optfile NAME | --optfile NAME | -of NAME | --of NAME
466        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
# Line 253  Usage: "$0" [OPTIONS] Line 485  Usage: "$0" [OPTIONS]
485        --makefile=NAME | -mf=NAME        --makefile=NAME | -mf=NAME
486            Call the makefile "NAME".  The default is "Makefile".            Call the makefile "NAME".  The default is "Makefile".
487    
488        -makedepend NAME | -md NAME
489          --makedepend=NAME | -md=NAME
490              Use "NAME" for the MAKEDEPEND program.
491    
492      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME      -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME
493        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME        -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME
494            Specify the location of the MITgcm ROOTDIR as "NAME".            Specify the location of the MITgcm ROOTDIR as "NAME".
# Line 289  Usage: "$0" [OPTIONS] Line 525  Usage: "$0" [OPTIONS]
525            will search for a working compiler by trying a list of            will search for a working compiler by trying a list of
526            "usual suspects" such as g77, f77, etc.            "usual suspects" such as g77, f77, etc.
527    
528        -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
529              Use "NAME" as the C compiler.  By default, genmake
530              will search for a working compiler by trying a list of
531              "usual suspects" such as gcc, c89, cc, etc.
532    
533      -[no]ieee | --[no]ieee      -[no]ieee | --[no]ieee
534            Do or don't use IEEE numerics.  Note that this option            Do or don't use IEEE numerics.  Note that this option
535            *only* works if it is supported by the OPTFILE that            *only* works if it is supported by the OPTFILE that
536            is being used.            is being used.
537    
538        -ts | --ts
539              Produce timing information per timestep
540    
541        -mpi | --mpi
542              Include MPI header files and link to MPI libraries
543        -mpi=PATH | --mpi=PATH
544              Include MPI header files and link to MPI libraries using MPI_ROOT
545              set to PATH. i.e. Include files from \$PATH/include, link to libraries
546              from \$PATH/lib and use binaries from \$PATH/bin.
547    
548        -bash NAME
549              Explicitly specify the Bourne or BASH shell to use
550    
551    While it is most often a single word, the "NAME" variables specified    While it is most often a single word, the "NAME" variables specified
552    above can in many cases be a space-delimited string such as:    above can in many cases be a space-delimited string such as:
553    
# Line 314  EOF Line 568  EOF
568    
569  #  Build a CPP macro to automate calling C routines from FORTRAN  #  Build a CPP macro to automate calling C routines from FORTRAN
570  get_fortran_c_namemangling()  {  get_fortran_c_namemangling()  {
571    
572        #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
573        if test ! "x$FC_NAMEMANGLE" = x ; then
574            return 0
575        fi
576    
577      default_nm="#define FC_NAMEMANGLE(X) X ## _"      default_nm="#define FC_NAMEMANGLE(X) X ## _"
578            
579      cat > genmake_test.c <<EOF      cat > genmake_test.c <<EOF
# Line 331  WARNING: Please contact <MITgcm-support@ Line 591  WARNING: Please contact <MITgcm-support@
591  EOF  EOF
592          return 1          return 1
593      fi      fi
594      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`
595      RETVAL=$?      RETVAL=$?
596      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
597          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 343  WARNING: Please contact <MITgcm-support@ Line 603  WARNING: Please contact <MITgcm-support@
603  EOF  EOF
604          return 1          return 1
605      fi      fi
606      cat > genmake_tcomp.f <<EOF      cat > genmake_tcomp.$FS <<EOF
607        subroutine tcall( string )        subroutine tcall( string )
608        character*(*) string        character*(*) string
609        call tsub( string )        call tsub( string )
610        end        end
611  EOF  EOF
612      $FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1      $FC $FFLAGS -c genmake_tcomp.$FS >> genmake_warnings 2>&1
613      RETVAL=$?      RETVAL=$?
614      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
615          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 361  WARNING: Please contact <MITgcm-support@ Line 621  WARNING: Please contact <MITgcm-support@
621  EOF  EOF
622          return 1          return 1
623      fi      fi
624      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`
625      RETVAL=$?      RETVAL=$?
626      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
627          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 415  void FC_NAMEMANGLE(cloc) ( double *curti Line 675  void FC_NAMEMANGLE(cloc) ( double *curti
675   *curtim = *curtim/1.E6;   *curtim = *curtim/1.E6;
676  }  }
677  EOF  EOF
678      make genmake_tc_1.o >> genmake_tc.log 2>&1      make genmake_tc_1.o >> genmake_warnings 2>&1
679      RET_C=$?      RET_C=$?
680      cat <<EOF > genmake_tc_2.f      cat <<EOF > genmake_tc_2.$FS
681        program hello        program hello
682        Real*8 wtime        REAL*8 wtime
683        external cloc        external cloc
684        call cloc(wtime)        call cloc(wtime)
685        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
686        end program hello        end
687  EOF  EOF
688      $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
689      RET_F=$?      RET_F=$?
690      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1
691      RETVAL=$?      RETVAL=$?
692      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
693          HAVE_CLOC=t          HAVE_CLOC=t
# Line 437  EOF Line 697  EOF
697  }  }
698    
699    
700    check_HAVE_SIGREG()  {
701        get_fortran_c_namemangling
702        cat <<EOF > genmake_tc_1.c
703    $FC_NAMEMANGLE
704    #include <stdlib.h>
705    #include <stdio.h>
706    #include <signal.h>
707    #include <errno.h>
708    #include <ucontext.h>
709    
710    int * ip;
711    
712    static void killhandler(
713        unsigned int sn, siginfo_t  si, struct ucontext *sc )
714    {
715        *ip = *ip + 1;
716        return;
717    }
718    
719    void FC_NAMEMANGLE(sigreg) (int * aip)
720    {
721        struct sigaction s;
722        ip = aip;
723        s.sa_flags = SA_SIGINFO;
724        s.sa_sigaction = (void *)killhandler;
725        if(sigaction (SIGTERM,&s,(struct sigaction *)NULL)) {
726            printf("Sigaction returned error = %d\n", errno);
727            exit(0);
728        }
729        return;
730    }
731    EOF
732        make genmake_tc_1.o >> genmake_warnings 2>&1
733        RET_C=$?
734        cat <<EOF > genmake_tc_2.$FS
735          program hello
736          integer anint
737          common /iv/ anint
738          external sigreg
739          call sigreg(anint)
740          end
741    EOF
742        echo >> genmake_warnings
743        echo "running: check_HAVE_SIGREG()" >> genmake_warnings
744        cat genmake_tc_2.$FS >> genmake_warnings
745        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
746        echo $COMM >> genmake_warnings
747        $COMM >> genmake_warnings 2>&1
748        RETVAL=$?
749        if test "x$RETVAL" = x0 ; then
750            HAVE_SIGREG=t
751            DEFINES="$DEFINES -DHAVE_SIGREG"
752        fi
753        rm -f genmake_tc*
754    }
755    
756    
757    check_HAVE_SETRLSTK()  {
758        get_fortran_c_namemangling
759        cat <<EOF > genmake_tc_1.c
760    $FC_NAMEMANGLE
761    #include <sys/time.h>
762    #include <sys/resource.h>
763    #include <unistd.h>
764    void FC_NAMEMANGLE(setrlstk) ()
765    {
766        struct rlimit rls;
767        rls.rlim_cur = RLIM_INFINITY;
768        rls.rlim_max = RLIM_INFINITY;
769        setrlimit(RLIMIT_STACK, &rls);
770        return;
771    }
772    EOF
773        make genmake_tc_1.o >> genmake_warnings 2>&1
774        RET_C=$?
775        cat <<EOF > genmake_tc_2.$FS
776          program hello
777          external setrlstk
778          call setrlstk()
779          end
780    EOF
781        echo >> genmake_warnings
782        echo "running: check_HAVE_SETRLSTK()" >> genmake_warnings
783        cat genmake_tc_2.$FS >> genmake_warnings
784        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
785        echo $COMM >> genmake_warnings
786        $COMM >> genmake_warnings 2>&1
787        RETVAL=$?
788        if test "x$RETVAL" = x0 ; then
789            HAVE_SETRLSTK=t
790            DEFINES="$DEFINES -DHAVE_SETRLSTK"
791        fi
792        rm -f genmake_tc*
793    }
794    
795    
796    check_HAVE_STAT()  {
797        get_fortran_c_namemangling
798        cat <<EOF > genmake_tc_1.c
799    $FC_NAMEMANGLE
800    #include <stdio.h>
801    #include <stdlib.h>
802    #include <unistd.h>
803    #include <sys/stat.h>
804    #include <sys/types.h>
805    void FC_NAMEMANGLE(tfsize) ( int *nbyte )
806    {
807        char name[512];
808        struct stat astat;
809    
810        name[0] = 'a'; name[1] = '\0';
811        if (! stat(name, &astat))
812            *nbyte = (int)(astat.st_size);
813        else
814            *nbyte = -1;
815    }
816    EOF
817        make genmake_tc_1.o >> genmake_tc.log 2>&1
818        RET_C=$?
819        cat <<EOF > genmake_tc_2.$FS
820          program hello
821          integer nbyte
822          call tfsize(nbyte)
823          print *," HELLO WORLD", nbyte
824          end
825    EOF
826        echo >> genmake_warnings
827        echo "running: check_HAVE_STAT()" >> genmake_warnings
828        cat genmake_tc_2.$FS >> genmake_warnings
829        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
830        echo $COMM >> genmake_warnings
831        $COMM >> genmake_tc.log 2>&1
832        RETVAL=$?
833        if test "x$RETVAL" = x0 ; then
834            HAVE_STAT=t
835            DEFINES="$DEFINES -DHAVE_STAT"
836        fi
837        rm -f genmake_tc*
838    }
839    
840    
841  check_netcdf_libs()  {  check_netcdf_libs()  {
842        if test ! "x$SKIP_NETCDF_CHECK" = x ; then
843            return
844        fi
845        echo >> genmake_warnings
846        echo "running: check_netcdf_libs()" >> genmake_warnings
847      cat <<EOF > genmake_tnc.F      cat <<EOF > genmake_tnc.F
848        program fgennc        program fgennc
849  #include "netcdf.inc"  #include "netcdf.inc"
850    EOF
851        if test ! "x$MPI" = x ; then
852            echo '#include "mpif.h"' >> genmake_tnc.F
853        fi
854        cat <<EOF >> genmake_tnc.F
855        integer iret, ncid, xid        integer iret, ncid, xid
856        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
857        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
# Line 450  check_netcdf_libs()  { Line 861  check_netcdf_libs()  {
861        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
862        end        end
863  EOF  EOF
864      $CPP genmake_tnc.F > genmake_tnc.f  \      echo "===  genmake_tnc.F  ===" > genmake_tnc.log
865          &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1      cat genmake_tnc.F >> genmake_tnc.log
866        echo "===  genmake_tnc.F  ===" >> genmake_tnc.log
867        RET_CPP=f
868        COMM="$CPP $DEFINES $INCLUDES genmake_tnc.F"
869        echo "$COMM" >> genmake_tnc.log
870        $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t
871        if test "x$RET_CPP" = xf ; then
872            echo "  WARNING: CPP failed to pre-process the netcdf test." \
873                >> genmake_tnc.log
874            echo "    Please check that \$INCLUDES is properly set." \
875                >> genmake_tnc.log
876        fi
877        echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log
878        echo "  &&  $LINK -o genmake_tnc.o $LIBS" >> genmake_tnc.log
879        $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
880            &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
881      RET_COMPILE=$?      RET_COMPILE=$?
882      test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1      cat genmake_tnc.log >> genmake_warnings
883      RETVAL=$?  
884      if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then      #EH3  Remove test program execution for machines that either disallow
885        #EH3  execution or cannot support it (eg. cross-compilers)
886        #EH3
887        #EH3 test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
888        #EH3 RETVAL=$?
889        #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
890    
891        if test "x$RET_COMPILE" = x0 ; then
892          HAVE_NETCDF=t          HAVE_NETCDF=t
893      else      else
894            # try again with "-lnetcdf" added to the libs
895            echo "try again with added '-lnetcdf'" > genmake_tnc.log
896            echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log
897            echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
898            echo " &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
899            $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
900                &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
901                &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
902            RET_COMPILE=$?
903          cat genmake_tnc.log >> genmake_warnings          cat genmake_tnc.log >> genmake_warnings
904            if test "x$RET_COMPILE" = x0 ; then
905                LIBS="$LIBS -lnetcdf"
906                HAVE_NETCDF=t
907            fi
908      fi      fi
909      rm -f genmake_tnc*      rm -f genmake_tnc*
910  }  }
911    
912    
913    
914    ###############################################################################
915    #   Sequential part of script starts here
916    ###############################################################################
917    
918  #  Set defaults here  #  Set defaults here
919  COMMANDL="$0 $@"  COMMANDL="$0 $@"
920    
# Line 471  PLATFORM= Line 922  PLATFORM=
922  LN=  LN=
923  S64=  S64=
924  KPP=  KPP=
925  FC=  #FC=
926  CPP=  #CC=gcc
927    #CPP=
928  LINK=  LINK=
 # DEFINES="-DWORDLENGTH=4"  
929  DEFINES=  DEFINES=
930  PACKAGES=  PACKAGES=
931  ENABLE=  ENABLE=
932  DISABLE=  DISABLE=
933  MAKEFILE=  # MAKEFILE=
934  MAKEDEPEND=  # MAKEDEPEND=
935  PDEPEND=  PDEPEND=
936  DUMPSTATE=t  DUMPSTATE=t
937  PDEFAULT=  PDEFAULT=
938  OPTFILE=  OPTFILE=
939  INCLUDES="-I."  INCLUDES="-I. $INCLUDES"
940  FFLAGS=  FFLAGS=
941  FOPTIM=  FOPTIM=
942  CFLAGS=  CFLAGS=
943  KFLAGS1=  KFLAGS1=
944  KFLAGS2=  KFLAGS2=
945    #LDADD=
946  LIBS=  LIBS=
947  KPPFILES=  KPPFILES=
948  NOOPTFILES=  NOOPTFILES=
949  NOOPTFLAGS=  NOOPTFLAGS=
950    MPI=
951    MPIPATH=
952    TS=
953    HAVE_TEST_L=
954    
955  # DEFINES checked by test compilation  # DEFINES checked by test compilation or command-line
956  HAVE_SYSTEM=  HAVE_SYSTEM=
957  HAVE_FDATE=  HAVE_FDATE=
958  FC_NAMEMANGLE=  FC_NAMEMANGLE=
959  HAVE_CLOC=  HAVE_CLOC=
960    HAVE_SETRLSTK=
961    HAVE_STAT=
962  HAVE_NETCDF=  HAVE_NETCDF=
963    HAVE_ETIME=
964    IGNORE_TIME=
965    
966  MODS=  MODS=
967  TOOLSDIR=  TOOLSDIR=
# Line 509  SOURCEDIRS= Line 969  SOURCEDIRS=
969  INCLUDEDIRS=  INCLUDEDIRS=
970  STANDARDDIRS="USE_THE_DEFAULT"  STANDARDDIRS="USE_THE_DEFAULT"
971    
972    G2ARGS=
973    BASH=
974  PWD=`pwd`  PWD=`pwd`
975  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
976  AWK=awk  test "x$AWK" = x   &&  AWK=awk
977  THISHOSTNAME=`hostname`  THISHOST=`hostname`
978  THISCWD=`pwd`  THISCWD=`pwd`
979  THISDATE=`date`  THISDATE=`date`
980    THISUSER=`echo $USER`
981    THISVER=
982  MACHINE=`uname -a`  MACHINE=`uname -a`
983  EXECUTABLE=  EXECUTABLE=
984  EXEHOOK=  EXEHOOK=
# Line 524  IEEE= Line 988  IEEE=
988  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
989      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
990  fi  fi
991    FS=
992    FS90=
993    
994  AUTODIFF_PKG_USED=f  AUTODIFF_PKG_USED=f
995  AD_OPTFILE=  AD_OPTFILE=
# Line 541  TAMC_EXTRA= Line 1007  TAMC_EXTRA=
1007    
1008  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1009  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
1010  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE TS MPI JAM DUMPSTATE STANDARDDIRS"
1011    
1012  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1013  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 "
1014  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
1015  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
1016  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
1017  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE"  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
1018    
1019  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1020  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 577  for i in . $MODS ; do Line 1043  for i in . $MODS ; do
1043          break          break
1044      fi      fi
1045  done  done
1046  echo -n "  getting local config information:  "  printf "  getting local config information:  "
1047  if test -e $gm_local ; then  if test -f $gm_local ; then
1048      echo "using $gm_local"      echo "using $gm_local"
1049      . $gm_local      . $gm_local
1050      # echo "DISABLE=$DISABLE"      # echo "DISABLE=$DISABLE"
# Line 587  else Line 1053  else
1053      echo "none found"      echo "none found"
1054  fi  fi
1055    
1056  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
1057  #OPTIONS=  #OPTIONS=
1058  #n=0  #n=0
1059  #for i ; do  #for i ; do
# Line 599  fi Line 1065  fi
1065  #done  #done
1066  #parse_options  #parse_options
1067  ac_prev=  ac_prev=
1068  for ac_option ; do  for ac_option in "$@" ; do
1069    
1070        G2ARGS="$G2ARGS \"$ac_option\""
1071    
1072      # If the previous option needs an argument, assign it.      # If the previous option needs an argument, assign it.
1073      if test -n "$ac_prev"; then      if test -n "$ac_prev"; then
# Line 642  for ac_option ; do Line 1110  for ac_option ; do
1110          -make=* | --make=* | -m=* | --m=*)          -make=* | --make=* | -m=* | --m=*)
1111              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
1112                    
1113            -bash | --bash)
1114                ac_prev=BASH ;;
1115            -bash=* | --bash=*)
1116                BASH=$ac_optarg ;;
1117            
1118            -makedepend | --makedepend | -md | --md)
1119                ac_prev=MAKEDEPEND ;;
1120            -makedepend=* | --makedepend=* | -md=* | --md=*)
1121                MAKEDEPEND=$ac_optarg ;;
1122            
1123          -makefile | --makefile | -ma | --ma)          -makefile | --makefile | -ma | --ma)
1124              ac_prev=MAKEFILE ;;              ac_prev=MAKEFILE ;;
1125          -makefile=* | --makefile=* | -ma=* | --ma=*)          -makefile=* | --makefile=* | -ma=* | --ma=*)
# Line 683  for ac_option ; do Line 1161  for ac_option ; do
1161  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1162  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1163  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1164                        
1165            -cc | --cc)
1166                ac_prev=CC ;;
1167            -cc=* | --cc=*)
1168                CC=$ac_optarg ;;
1169            
1170          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1171              ac_prev=FC ;;              ac_prev=FC ;;
1172          -fc=* | --fc=*)          -fc=* | --fc=*)
1173              FC=$ac_optarg ;;              FC=$ac_optarg ;;
1174                    
1175            -fs | --fs)
1176                ac_prev=FS ;;
1177            -fs=* | --fs=*)
1178                FS=$ac_optarg ;;
1179            
1180            -fs90 | --fs90)
1181                ac_prev=FS90 ;;
1182            -fs90=* | --fs90=*)
1183                FS90=$ac_optarg ;;
1184            
1185          -ieee | --ieee)          -ieee | --ieee)
1186              IEEE=true ;;              IEEE=true ;;
1187          -noieee | --noieee)          -noieee | --noieee)
1188              IEEE= ;;              IEEE= ;;
1189    
1190            -ts | --ts)
1191                TS=true ;;
1192    
1193            -mpi | --mpi)
1194                MPI=true ;;
1195            -mpi=* | --mpi=*)
1196                MPIPATH=$ac_optarg
1197                MPI=true ;;
1198                    
1199  #       -jam | --jam)  #       -jam | --jam)
1200  #           JAM=1 ;;  #           JAM=1 ;;
# Line 711  for ac_option ; do Line 1213  for ac_option ; do
1213              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1214          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1215              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1216            
1217            -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1218                IGNORE_TIME="-DIGNORE_TIME" ;;
1219    
1220          -*)          -*)
1221              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
# Line 726  for ac_option ; do Line 1231  for ac_option ; do
1231            
1232  done  done
1233    
1234    
1235  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1236      echo      echo
1237      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 738  if test -f ./.genmakerc ; then Line 1244  if test -f ./.genmakerc ; then
1244      echo      echo
1245  fi  fi
1246    
1247    #  Find the MITgcm ${ROOTDIR}
1248  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1249      if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1250        if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
1251          ROOTDIR=".."          ROOTDIR=".."
1252      else      else
1253          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
1254              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
1255                  ROOTDIR=$d                  ROOTDIR=$d
1256                  echo -n "Warning:  ROOTDIR was not specified but there appears to be"                  printf "Warning:  ROOTDIR was not specified but there appears to be"
1257                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."                  echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it."
1258                  break                  break
1259              fi              fi
# Line 763  if test ! -d ${ROOTDIR} ; then Line 1271  if test ! -d ${ROOTDIR} ; then
1271      exit 1      exit 1
1272  fi  fi
1273    
1274    #  Find the MITgcm ${THISVER}
1275    if test -f "${ROOTDIR}/doc/tag-index" ; then
1276        THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`
1277    fi
1278    
1279    if test "x$MAKEFILE" = x ; then
1280        MAKEFILE="Makefile"
1281    fi
1282    
1283  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
1284  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1285      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
# Line 779  if test "x$OPTFILE" != xNONE ; then Line 1296  if test "x$OPTFILE" != xNONE ; then
1296          . "$OPTFILE"          . "$OPTFILE"
1297          RETVAL=$?          RETVAL=$?
1298          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
1299              echo -n "Error: failed to source OPTFILE \"$OPTFILE\""              printf "Error: failed to source OPTFILE \"$OPTFILE\""
1300              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1301              exit 1              exit 1
1302          fi          fi
# Line 806  if test "x${AD_OPTFILE}" != xNONE ; then Line 1323  if test "x${AD_OPTFILE}" != xNONE ; then
1323          . "$AD_OPTFILE"          . "$AD_OPTFILE"
1324          RETVAL=$?          RETVAL=$?
1325          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
1326              echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""              printf "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
1327              echo "--please check that variable syntax is bash-compatible"              echo "--please check that variable syntax is bash-compatible"
1328              exit 1              exit 1
1329          fi          fi
# Line 819  if test "x${AD_OPTFILE}" != xNONE ; then Line 1336  if test "x${AD_OPTFILE}" != xNONE ; then
1336      fi      fi
1337  fi  fi
1338    
1339  #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #====================================================================
1340    #  Set default values if not set by the optfile
1341    #
1342    #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1343  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1344    if test ! "x$BASH" = x ; then
1345        # add a trailing space so that it works within the Makefile syntax (see below)
1346        BASH="$BASH "
1347    fi
1348  if test "x$FC" = x ; then  if test "x$FC" = x ; then
1349      cat <<EOF 1>&2      cat <<EOF 1>&2
1350    
# Line 831  Error: no Fortran compiler: please speci Line 1355  Error: no Fortran compiler: please speci
1355  EOF  EOF
1356      exit 1      exit 1
1357  fi  fi
1358    if test "x$CC" = x ; then
1359        CC=cc
1360    #     cat <<EOF 1>&2
1361    # Error: no C compiler: please specify using one of the following:
1362    #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1363    #   2) the "-cc=XXX" command-line option
1364    #   3) the "./genmake_local" file
1365    # EOF
1366    #     exit 1
1367    fi
1368  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1369      LINK=$FC      LINK=$FC
1370  fi  fi
 if test "x$CPP" = x ; then  
     CPP="cpp"  
 fi  
1371  if test "x$MAKE" = x ; then  if test "x$MAKE" = x ; then
1372      MAKE="make"      MAKE="make"
1373  fi  fi
1374    if test "x$CPP" = x ; then
1375        CPP=cpp
1376    fi
1377    #EH3 === UGLY ===
1378    #  The following is an ugly little hack to check for $CPP in /lib/ and
1379    #  it should eventually be replaced with a more general function that
1380    #  searches a combo of the user's path and a list of "usual suspects"
1381    #  to find the correct location for binaries such as $CPP.
1382    for i in " " "/lib/" ; do
1383        echo "#define A a" | $i$CPP > test_cpp 2>&1 && CPP=$i$CPP
1384    done
1385    #EH3 === UGLY ===
1386  echo "#define A a" | $CPP > test_cpp 2>&1  echo "#define A a" | $CPP > test_cpp 2>&1
1387  RETVAL=$?  RETVAL=$?
1388  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
# Line 856  EOF Line 1399  EOF
1399  else  else
1400      rm -f test_cpp      rm -f test_cpp
1401  fi  fi
1402  if test "x$MAKEDEPEND" = x ; then  look_for_makedepend
     MAKEDEPEND=makedepend  
 fi  
1403  if test "x$LN" = x ; then  if test "x$LN" = x ; then
1404      LN="ln -s"      LN="ln -s"
1405  fi  fi
# Line 874  Error: The command "ln -s" failed -- ple Line 1415  Error: The command "ln -s" failed -- ple
1415  EOF  EOF
1416      exit 1      exit 1
1417  fi  fi
1418    test -L genmake_tlink > /dev/null 2>&1
1419    RETVAL=$?
1420    if test "x$RETVAL" = x0 ; then
1421        HAVE_TEST_L=t
1422    fi
1423  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
1424    
1425    #  Check for broken *.F/*.f handling and fix if possible
1426    check_for_broken_Ff
1427    
1428    if test ! "x$MPI" = x ; then
1429          echo "  Turning on MPI cpp macros"
1430          DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1431    fi
1432    
1433    if test ! "x$TS" = x ; then
1434          echo "  Turning on timing per timestep"
1435          DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1436    fi
1437    
1438  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1439  echo -n "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1440  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1441        program hello        program hello
1442        call system('echo hi')        call system('echo hi')
1443        end        end
1444  EOF  EOF
1445  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1446  RETVAL=$?  RETVAL=$?
1447  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1448      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 896  else Line 1454  else
1454  fi  fi
1455  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1456    
1457  echo -n "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1458  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1459        program hello        program hello
1460        CHARACTER(128) string        CHARACTER*(128) string
1461        string = ' '        string = ' '
1462        call fdate( string )        call fdate( string )
1463        print *, string        print *, string
1464        end        end
1465  EOF  EOF
1466  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1467  RETVAL=$?  RETVAL=$?
1468  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1469      HAVE_FDATE=t      HAVE_FDATE=t
# Line 917  else Line 1475  else
1475  fi  fi
1476  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1477    
1478  echo -n "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Do we have the etime() command using $FC...  "
1479    cat > genmake_tcomp.$FS <<EOF
1480          program hello
1481          REAL*4 ACTUAL, TARRAY(2)
1482          EXTERNAL ETIME
1483          REAL*4 ETIME
1484          actual = etime( tarray )
1485          print *, tarray
1486          end
1487    EOF
1488    $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1489    RETVAL=$?
1490    if test "x$RETVAL" = x0 ; then
1491        HAVE_ETIME=t
1492        DEFINES="$DEFINES -DHAVE_ETIME"
1493        echo "yes"
1494    else
1495        HAVE_ETIME=
1496        echo "no"
1497    fi
1498    rm -f genmake_tcomp*
1499    
1500    printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1501  check_HAVE_CLOC  check_HAVE_CLOC
1502  if test "x$HAVE_CLOC" != x ; then  if test "x$HAVE_CLOC" != x ; then
1503      echo "yes"      echo "yes"
# Line 926  else Line 1506  else
1506  fi  fi
1507  rm -f genmake_t*  rm -f genmake_t*
1508    
1509  echo -n "  Can we create NetCDF-enabled binaries...  "  printf "  Can we unlimit the stack size using $FC...  "
1510    check_HAVE_SETRLSTK
1511    if test "x$HAVE_SETRLSTK" != x ; then
1512        echo "yes"
1513    else
1514        echo "no"
1515    fi
1516    rm -f genmake_t*
1517    
1518    printf "  Can we register a signal handler using $FC...  "
1519    check_HAVE_SIGREG
1520    if test "x$HAVE_SIGREG" != x ; then
1521        echo "yes"
1522    else
1523        echo "no"
1524    fi
1525    rm -f genmake_t*
1526    
1527    printf "  Can we use stat() through C calls...  "
1528    check_HAVE_STAT
1529    if test "x$HAVE_STAT" != x ; then
1530        echo "yes"
1531    else
1532        echo "no"
1533    fi
1534    rm -f genmake_t*
1535    
1536    printf "  Can we create NetCDF-enabled binaries...  "
1537  check_netcdf_libs  check_netcdf_libs
1538  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
1539      echo "yes"      echo "yes"
1540  else  else
1541      echo "no"      echo "no"
1542  fi  fi
1543    DEFINES="$DEFINES $IGNORE_TIME"
1544    
1545  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1546  echo -n "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
1547  for d in $MODS ; do  for d in $MODS ; do
1548      if test ! -d $d ; then      if test ! -d $d ; then
1549          echo          echo
1550          echo "Error: MODS directory \"$d\" not found!"          echo "Error: MODS directory \"$d\" not found!"
1551          exit 1          exit 1
1552      else      else
1553          echo -n " $d"          printf " $d"
1554          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1555          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
1556      fi      fi
1557  done  done
1558  echo  echo
1559    
 if test "x$MAKEFILE" = x ; then  
     MAKEFILE="Makefile"  
 fi  
1560  if test "x${PLATFORM}" = x ; then  if test "x${PLATFORM}" = x ; then
1561      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
1562  fi  fi
1563    
1564  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1565      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1566        if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1567          EXEDIR=../exe          EXEDIR=../exe
1568      else      else
1569          EXEDIR=.          EXEDIR=.
# Line 973  if test "x${TOOLSDIR}" = x ; then Line 1578  if test "x${TOOLSDIR}" = x ; then
1578      TOOLSDIR="$ROOTDIR/tools"      TOOLSDIR="$ROOTDIR/tools"
1579  fi  fi
1580  if test ! -d ${TOOLSDIR} ; then  if test ! -d ${TOOLSDIR} ; then
1581      echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"
1582      exit 1      exit 1
1583  fi  fi
1584  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1585      S64='$(TOOLSDIR)/set64bitConst.sh'      echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1586        RETVAL=$?
1587        if test "x${RETVAL}" = x0 ; then
1588            S64='$(TOOLSDIR)/set64bitConst.sh'
1589        else
1590            echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1591            RETVAL=$?
1592            if test "x${RETVAL}" = x0 ; then
1593                S64='$(TOOLSDIR)/set64bitConst.csh'
1594            else
1595                cat <<EOF
1596    
1597    ERROR: neither of the two default scripts:
1598    
1599        ${TOOLSDIR}/set64bitConst.sh
1600        ${TOOLSDIR}/set64bitConst.csh
1601    
1602      are working so please check paths or specify (with \$S64) a
1603      working version of this script.
1604    
1605    EOF
1606                exit 1
1607            fi
1608        fi
1609  fi  fi
1610  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1611    
# Line 1068  else Line 1696  else
1696          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
1697          RETVAL=$?          RETVAL=$?
1698          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
1699              echo -n "Error: can't parse default package list "              printf "Error: can't parse default package list "
1700              echo "-- please check PDEFAULT=\"$PDEFAULT\""              echo "-- please check PDEFAULT=\"$PDEFAULT\""
1701              exit 1              exit 1
1702          fi          fi
# Line 1076  else Line 1704  else
1704              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
1705          done          done
1706          echo "    before group expansion packages are: $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
1707          expand_pkg_groups          RET=1
1708            while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
1709          echo "    after group expansion packages are:  $PACKAGES"          echo "    after group expansion packages are:  $PACKAGES"
1710      fi      fi
1711  fi  fi
1712    
1713  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
1714    for i in $PACKAGES ; do
1715        echo $i >> ./.tmp_pack
1716    done
1717    for i in `grep  "-" ./.tmp_pack` ; do
1718        j=`echo $i | sed 's/[-]//'`
1719        DISABLE="$DISABLE $j"
1720    done
1721  pack=  pack=
1722  for p in $PACKAGES ; do  for p in $PACKAGES ; do
1723      addit="t"      addit="t"
# Line 1098  PACKAGES="$pack" Line 1734  PACKAGES="$pack"
1734  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
1735  echo "" > ./.tmp_pack  echo "" > ./.tmp_pack
1736  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
1737    # Test if each explicitly referenced package exists
1738  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1739      if test ! -d "$ROOTDIR/pkg/$i" ; then      j=`echo $i | sed 's/[-+]//'`
1740        if test ! -d "$ROOTDIR/pkg/$j" ; then
1741          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""          echo "Error: can't find package $i at \"$ROOTDIR/pkg/$i\""
1742          exit 1          exit 1
1743      fi      fi
1744      echo $i >> ./.tmp_pack      echo $i >> ./.tmp_pack
1745  done  done
 pack=`cat ./.tmp_pack | sort | uniq`  
 rm -f ./.tmp_pack  
1746  PACKAGES=  PACKAGES=
1747  for i in $pack ; do  for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do
1748      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
1749  done  done
1750    rm -f ./.tmp_pack
1751  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1752    
1753    #  Check availability of NetCDF and then either build the MNC template
1754    #  files or delete mnc from the list of available packages.
1755    echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1756    RETVAL=$?
1757    if test "x$RETVAL" = x0 ; then
1758        if test "x$HAVE_NETCDF" != xt ; then
1759            cat <<EOF
1760    
1761    *********************************************************************
1762    WARNING: the "mnc" package was enabled but tests failed to compile
1763      NetCDF applications.  Please check that:
1764    
1765      1) NetCDF is correctly installed for this compiler and
1766      2) the LIBS variable (within the "optfile") specifies the correct
1767           NetCDF library to link against.
1768    
1769      Due to this failure, the "mnc" package is now DISABLED.
1770    *********************************************************************
1771    
1772    EOF
1773            PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
1774            DISABLE="$DISABLE mnc"
1775        else
1776            ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
1777            RETVAL=$?
1778            if test "x${RETVAL}" = x0 ; then
1779                rm -f make_mnc.errors
1780            else
1781                echo "Error: problem encountered while building source files in pkg/mnc:"
1782                cat make_mnc.errors 1>&2
1783                exit 1
1784            fi
1785        fi
1786    fi
1787    
1788  echo "  applying package dependency rules"  echo "  applying package dependency rules"
1789  ck=  ck=
1790  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
# Line 1177  while test "x$ck" != xtt ; do Line 1849  while test "x$ck" != xtt ; do
1849              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
1850              exit 1              exit 1
1851          fi          fi
1852          i=$(( $i + 1 ))          i=`echo "$i + 1" | bc -l`
1853            #i=$(( $i + 1 ))
1854      done      done
1855      ck=$ck"t"      ck=$ck"t"
1856  done  done
# Line 1196  for i in $PACKAGES ; do Line 1869  for i in $PACKAGES ; do
1869      fi      fi
1870  done  done
1871    
 #  Build MNC templates and check for ability to build and use NetCDF  
 echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1  
 RETVAL=$?  
 if test "x$RETVAL" = x0 ; then  
     ( cd $ROOTDIR"/pkg/mnc" && $MAKE templates ) > make_mnc.errors 2>&1  
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         rm -f make_mnc.errors  
     else  
         echo "Error: problem encountered while building source files in pkg/mnc:"  
         cat make_mnc.errors 1>&2  
         exit 1  
     fi  
     if test -a "x$HAVE_NETCDF" != xt ; then  
         cat <<EOF  
   
 WARNING: the "mnc" package has been enabled but tests failed to  
   compile and/or execute NetCDF applications.  Please check that:  
   
   1) NetCDF is installed for your compiler and  
   2) the LIBS variable (within the 'optfile") specifies the correct  
        NetCDF library to link against.  
     
 EOF  
     fi  
 fi  
   
1872  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
1873  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
1874  #  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 1242  for n in $names ; do Line 1888  for n in $names ; do
1888              fi              fi
1889          done          done
1890          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1891              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1892              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
1893          fi          fi
1894      fi      fi
1895  done  done
1896  ENABLED_PACKAGES=  ENABLED_PACKAGES=
1897  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1898      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`      def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1899      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1900  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
1901    
# Line 1333  for i in $SOURCEDIRS ; do Line 1979  for i in $SOURCEDIRS ; do
1979          cat $i/$j >> ad_files          cat $i/$j >> ad_files
1980      done      done
1981  done  done
1982    if test ! "x"$FS = "x.f" ; then
1983        cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f
1984        mv -f ad_files_f ad_files
1985    fi
1986    
1987  echo  echo
1988  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
1989  echo "  setting INCLUDES"  echo "  setting INCLUDES"
1990  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
1991      if ! test -d $i ; then      if test ! -d $i ; then
 #       INCLUDES="$INCLUDES -I$i"  
 #   else  
1992          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
1993      fi      fi
1994  done  done
# Line 1351  rm -rf .links.tmp Line 1998  rm -rf .links.tmp
1998  mkdir .links.tmp  mkdir .links.tmp
1999  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
2000  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
2001  echo -n 'SRCFILES = '    > srclist.inc  printf 'SRCFILES = '    > srclist.inc
2002  echo -n 'CSRCFILES = '   > csrclist.inc  printf 'CSRCFILES = '   > csrclist.inc
2003  echo -n 'F90SRCFILES = ' > f90srclist.inc  printf 'F90SRCFILES = ' > f90srclist.inc
2004  echo -n 'HEADERFILES = ' > hlist.inc  printf 'HEADERFILES = ' > hlist.inc
2005  echo -n 'AD_FLOW_FILES = ' > ad_flow_files.inc  printf 'AD_FLOW_FILES = ' > ad_flow_files.inc
2006  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2007  for d in $alldirs ; do  for d in $alldirs ; do
2008      deplist=      deplist=
# Line 1364  for d in $alldirs ; do Line 2011  for d in $alldirs ; do
2011      for sf in $sfiles ; do      for sf in $sfiles ; do
2012          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
2013              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2014                    ignore_f=f
2015                  case $d/$sf in                  case $d/$sf in
2016                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
2017                          ;;                          ;;
# Line 1371  for d in $alldirs ; do Line 2019  for d in $alldirs ; do
2019                          ;;                          ;;
2020                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
2021                          ;;                          ;;
2022                      ./BUILD_INFO.h)
2023                            ;;
2024                    *)                    *)
2025                          touch .links.tmp/$sf                          #  For the local directory *ONLY*,
2026                          deplist="$deplist $sf"                          #  ignore all soft-links
2027                            if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
2028                                ignore_f=t
2029                            else
2030                                touch .links.tmp/$sf
2031                                deplist="$deplist $sf"
2032                            fi
2033                          ;;                          ;;
2034                  esac                  esac
2035                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`                  if test "x$ignore_f" = xf ; then
2036                  case $extn in                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2037                      F)                      case $extn in
2038                          echo    " \\"  >> srclist.inc                          F)
2039                          echo -n " $sf" >> srclist.inc                              echo    " \\"  >> srclist.inc
2040                          ;;                              printf " $sf" >> srclist.inc
2041                      F90)                              ;;
2042                          echo    " \\"  >> f90srclist.inc                          F90)
2043                          echo -n " $sf" >> f90srclist.inc                              echo    " \\"  >> f90srclist.inc
2044                          ;;                              printf " $sf" >> f90srclist.inc
2045                      c)                              ;;
2046                          echo    " \\"  >> csrclist.inc                          c)
2047                          echo -n " $sf" >> csrclist.inc                              echo    " \\"  >> csrclist.inc
2048                          ;;                              printf " $sf" >> csrclist.inc
2049                      h)                              ;;
2050                          echo    " \\"  >> hlist.inc                          h)
2051                          echo -n " $sf" >> hlist.inc                              echo    " \\"  >> hlist.inc
2052                          ;;                              printf " $sf" >> hlist.inc
2053                      flow)                              ;;
2054                          echo    " \\"  >> ad_flow_files.inc                          flow)
2055                          echo -n " $sf" >> ad_flow_files.inc                              echo    " \\"  >> ad_flow_files.inc
2056                          ;;                              printf " $sf" >> ad_flow_files.inc
2057                  esac                              ;;
2058                        esac
2059                    fi
2060              fi              fi
2061          fi          fi
2062      done      done
# Line 1416  echo "" >> f90srclist.inc Line 2074  echo "" >> f90srclist.inc
2074  echo "" >> hlist.inc  echo "" >> hlist.inc
2075  echo "" >> ad_flow_files.inc  echo "" >> ad_flow_files.inc
2076    
2077  if test -e $MAKEFILE ; then  if test -f $MAKEFILE ; then
2078      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
2079  fi  fi
2080  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
# Line 1425  echo "#    $MACHINE" >> $MAKEFILE Line 2083  echo "#    $MACHINE" >> $MAKEFILE
2083  echo "# This makefile was generated automatically on" >> $MAKEFILE  echo "# This makefile was generated automatically on" >> $MAKEFILE
2084  echo "#    $THISDATE" >> $MAKEFILE  echo "#    $THISDATE" >> $MAKEFILE
2085  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2086  echo "#    $0 $@" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
2087  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2088  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2089    
2090  EXE_AD=$EXECUTABLE"_ad"  EXE_AD=$EXECUTABLE"_ad"
2091  EXE_FTL=$EXECUTABLE"_ftl"  EXE_FTL=$EXECUTABLE"_ftl"
# Line 1473  ENABLED_PACKAGES = ${ENABLED_PACKAGES} Line 2131  ENABLED_PACKAGES = ${ENABLED_PACKAGES}
2131  DISABLED_PACKAGES = ${DISABLED_PACKAGES}  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
2132    
2133  # These files are created by Makefile  # These files are created by Makefile
2134  SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h  SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h
2135    
2136  EOF  EOF
2137    
# Line 1492  KPP = ${KPP} Line 2150  KPP = ${KPP}
2150  FC = ${FC}  FC = ${FC}
2151  # Fortran compiler  # Fortran compiler
2152  F90C = ${F90C}  F90C = ${F90C}
2153    # C compiler
2154    CC = ${CC}
2155  # Link editor  # Link editor
2156  LINK = ${LINK}  LINK = ${LINK} ${LDADD}
2157    
2158  # Defines for CPP  # Defines for CPP
2159  DEFINES = ${DEFINES}  DEFINES = ${DEFINES}
# Line 1514  CFLAGS = ${CFLAGS} Line 2174  CFLAGS = ${CFLAGS}
2174  NOOPTFILES = ${NOOPTFILES}  NOOPTFILES = ${NOOPTFILES}
2175  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2176  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2177  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS}
2178  # Name of the Mekfile  # Name of the Mekfile
2179  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2180    
# Line 1525  cat csrclist.inc      >> $MAKEFILE Line 2185  cat csrclist.inc      >> $MAKEFILE
2185  cat f90srclist.inc    >> $MAKEFILE  cat f90srclist.inc    >> $MAKEFILE
2186  cat hlist.inc         >> $MAKEFILE  cat hlist.inc         >> $MAKEFILE
2187  cat ad_flow_files.inc >> $MAKEFILE  cat ad_flow_files.inc >> $MAKEFILE
2188  echo               >> $MAKEFILE  echo >> $MAKEFILE
2189  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE
2190  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE
2191  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
2192    echo >> $MAKEFILE
2193    echo '.SUFFIXES:' >> $MAKEFILE
2194    echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE
2195  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
2196  rm -f ad_flow_files.inc  rm -f ad_flow_files.inc
2197    
2198  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2199    
 .SUFFIXES:  
 .SUFFIXES: .o .f .p .F .c .F90 .f90  
   
2200  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
2201  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)
2202          @echo Creating \$@ ...          @echo Creating \$@ ...
2203          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2204  depend:  depend:
2205          @make links          @make links
2206          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
2207          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2208            -rm -f makedepend.out
2209    
2210    lib: libmitgcmuv.a
2211    
2212    libmitgcmuv.a: \$(OBJFILES)
2213            ar rcv libmitgcmuv.a \$(OBJFILES)
2214    
2215  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
2216    
# Line 1556  output.txt: \$(EXECUTABLE) Line 2221  output.txt: \$(EXECUTABLE)
2221          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
2222    
2223  clean:  clean:
2224          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2225  Clean:  Clean:
2226          @make clean          @make clean
2227          @make cleanlinks          @make cleanlinks
# Line 1567  CLEAN: Line 2232  CLEAN:
2232          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2233          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2234          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2235          -rm -f \$(EXECUTABLE) output.txt          -rm -f \$(EXECUTABLE) output.txt STD*
2236    
2237  #eh3 Makefile: makefile  #eh3 Makefile: makefile
2238  makefile:  makefile:
2239          $THIS_SCRIPT $@          $THIS_SCRIPT $G2ARGS
2240  cleanlinks:  cleanlinks:
2241          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2242    
2243  # Special targets ($SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are create by make
2244  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2245          @echo Creating \$@ ...          @echo Creating \$@ ...
2246          @\$(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) > \$@
2247  AD_CONFIG.h:  AD_CONFIG.h:
2248          @echo Creating \$@ ...          @echo Creating \$@ ...
2249          @\$(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 > \$@
2250  FC_NAMEMANGLE.h:  FC_NAMEMANGLE.h:
2251          @echo Creating \$@ ...          @echo Creating \$@ ...
2252          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
2253    
2254  # The normal chain of rules is (  .F - .f - .o  )  BUILD_INFO.h:
2255  .F.f:          @echo Creating \$@ ...
2256    EOF
2257    
2258    test ! "x$THISVER" = x  && echo "       -echo \"#define THISVER '$THISVER'\" > \$@"   >> $MAKEFILE
2259    test ! "x$THISUSER" = x && echo "       -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2260    test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2261    test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2262    
2263    cat >>$MAKEFILE <<EOF
2264    
2265    # The normal chain of rules is (  .F - .$FS - .o  )
2266    
2267    ## This nullifies any default implicit rules concerning these two file types:
2268    ## %.o : %.F
2269    
2270    .F.$FS:
2271          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2272  .f.o:  .$FS.o:
2273          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2274  .F90.f90:  .F90.$FS90:
2275          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2276  .f90.o:  .$FS90.o:
2277          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2278  .c.o:  .c.o:
2279          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) -c \$<
2280    
2281  # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2282  .F.p:  .F.p:
2283          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2284  .p.f:  .p.$FS:
2285          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
2286    
2287  #=========================================  #=========================================
# Line 1628  done Line 2308  done
2308    
2309  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
2310  echo >> $MAKEFILE  echo >> $MAKEFILE
2311  echo -n "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
2312  AD_FILES=`cat ad_files`  AD_FILES=`cat ad_files`
2313  for i in $AD_FILES ; do  for i in $AD_FILES ; do
2314      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
2315      echo -n " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
2316  done  done
2317  echo >> $MAKEFILE  echo >> $MAKEFILE
2318  rm -f ad_files  rm -f ad_files
# Line 1641  cat >>$MAKEFILE <<EOF Line 2321  cat >>$MAKEFILE <<EOF
2321    
2322  # ... AD ...  # ... AD ...
2323  adall: ad_taf  adall: ad_taf
2324  adtaf: ad_taf_output.f  adtaf: ad_taf_output.$FS
2325  adtamc: ad_tamc_output.f  adtamc: ad_tamc_output.$FS
2326    
2327  ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2328          @\$(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
2329          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
2330          -rm -f ad_config.template          -rm -f ad_config.template
2331          @make \$(F77FILES)          @make \$(F77FILES)
2332          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2333          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS
2334    
2335  ad_taf_output.f: ad_input_code.f  ad_taf_output.$FS: ad_input_code.$FS
2336          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2337          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
2338    
2339  adtafonly:  adtafonly:
2340          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2341          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
2342    
2343  ad_taf: ad_taf_output.o \$(OBJFILES)  ad_taf: ad_taf_output.o \$(OBJFILES)
2344          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2345    
2346  ad_tamc_output.f: ad_input_code.f  ad_tamc_output.$FS: ad_input_code.$FS
2347          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2348          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
2349    
2350  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2351          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2352    
2353    adonlyfwd:
2354            patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2355    
2356    adtrick:
2357            patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2358    
2359  # ... FTL ...  # ... FTL ...
2360  ftlall: ftl_taf  ftlall: ftl_taf
2361  ftltaf: ftl_taf_output.f  ftltaf: ftl_taf_output.$FS
2362  ftltamc: ftl_tamc_output.f  ftltamc: ftl_tamc_output.$FS
2363    
2364  ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2365          @\$(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
2366          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
2367          -rm -f ftl_config.template          -rm -f ftl_config.template
2368          @make \$(F77FILES)          @make \$(F77FILES)
2369          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2370          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2371    
2372  ftl_taf_output.f: ftl_input_code.f  ftl_taf_output.$FS: ftl_input_code.$FS
2373          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2374          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
2375    
2376  ftltafonly:  ftltafonly:
2377          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2378          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
2379    
2380  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
2381          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2382    
2383  ftl_tamc_output.f: ftl_input_code.f  ftl_tamc_output.$FS: ftl_input_code.$FS
2384          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2385          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
2386    
2387  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2388          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2389    
2390    
2391  # ... SVD ...  # ... SVD ...
2392  svdtaf: ad_taf_output.f ftl_taf_output.f  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
2393  svdall: svd_taf          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"
2394            @echo "--->>> Do make svdall afterwards to compile. <<<---"
2395    svdall: svd_touch svd_taf
2396    
2397  svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES)  svd_taf: \$(OBJFILES)
2398          \$(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)
2399    
2400            @echo "--->>> Only COMPILE svd code! <<<---"
2401            @echo "--->>> Assumes you previously <<<---"
2402            @echo "--->>> did make svdtaf        <<<---"
2403    
2404    svd_touch:
2405            @echo "--->>> Only COMPILE svd code! <<<---"
2406            @echo "--->>> Assumes you previously <<<---"
2407            @echo "--->>> did make svdtaf        <<<---"
2408            touch ad_taf_output.$FS ftl_taf_output.$FS
2409            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
2410            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
2411            @$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
2412            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2413            -rm -f ftl_config.template
2414    
2415  #=========================================  #=========================================
2416    
# Line 1726  for i in $KPPFILES ; do Line 2427  for i in $KPPFILES ; do
2427      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
2428          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
2429      fi      fi
2430      echo "$base.f: $base.p" >> $MAKEFILE      echo "$base.$FS: $base.p" >> $MAKEFILE
2431  done  done
2432    
2433  echo "  Making list of NOOPTFILES"  echo "  Making list of NOOPTFILES"
# Line 1736  for i in $NOOPTFILES ; do Line 2437  for i in $NOOPTFILES ; do
2437      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
2438          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
2439      fi      fi
2440      echo "$base.o: $base.f" >> $MAKEFILE      echo "$base.o: $base.$FS" >> $MAKEFILE
2441      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
2442  done  done
2443    
# Line 1750  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 2451  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
2451  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
2452    
2453  # Create special header files  # Create special header files
2454  $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"
2455  if test ! -f $PACKAGES_DOT_H ; then  if test ! -f $PACKAGES_DOT_H ; then
2456      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H      mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
2457  else  else
# Line 1764  else Line 2465  else
2465      fi      fi
2466  fi  fi
2467  if test ! -f AD_CONFIG.h ; then  if test ! -f AD_CONFIG.h ; then
2468      $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
2469  fi  fi
2470    
2471    
2472  #  Write the "state" for future records  #  Write the "state" for future records
2473  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" != xf ; then
2474      echo -n "" > genmake_state      printf "" > genmake_state
2475      for i in $gm_state ; do      for i in $gm_state ; do
2476          t1="t2=\$$i"          t1="t2=\$$i"
2477          eval $t1          eval $t1

Legend:
Removed from v.1.62  
changed lines
  Added in v.1.138

  ViewVC Help
Powered by ViewVC 1.1.22