/[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.74 by adcroft, Wed Mar 24 17:12:51 2004 UTC revision 1.136 by edhill, Thu Nov 24 17:52:15 2005 UTC
# Line 73  expand_pkg_groups() { Line 73  expand_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 83  find_possible_configs()  { Line 258  find_possible_configs()  {
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      tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`      tmp3=`echo $tmp2 | sed -e 's/cray sv1/craysv1/'`
260      PLATFORM=$tmp3      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 102  find_possible_configs()  { Line 278  find_possible_configs()  {
278          CPP="cpp -traditional -P"          CPP="cpp -traditional -P"
279      fi      fi
280    
281      #  The "original" makedepend is part of the Imake system that is      look_for_makedepend
282      #  most often distributed with XFree86 or with an XFree86 source  
283      #  package.  As a result, many machines (eg. generic Linux) do not      #================================================================
284      #  have a system-default "makedepend" available.  For those      #  look for possible C compilers
285      #  systems, we have two fall-back options:      tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc"
286      #      p_CC=
287      #    1) a makedepend implementation shipped with the cyrus-imapd      for c in $tmp ; do
288      #       package:  ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/          rm -f ./genmake_hello.c  ./genmake_hello
289      #          cat >> genmake_hello.c << EOF
290      #    2) a known-buggy xmakedpend shell script  #include <stdio.h>
291      #  int main(int argc, char **argv) {
292      #  So the choices are, in order:    printf("Hello!\n");
293      #    return 0;
294      #    1) use the user-specified program  }
295      #    2) use a system-wide default  EOF
296      #    3) locally build and use the cyrus implementation          $c -o genmake_hello genmake_hello.c > /dev/null 2>&1
297      #    4) fall back to the buggy local xmakedpend script          RETVAL=$?
298      #          if test "x${RETVAL}" = x0 ; then
299      if test "x${MAKEDEPEND}" = x ; then              p_CC="$p_CC $c"
300        which makedepend > /dev/null 2>&1          fi
301        RETVAL=$?      done
302        if test ! "x${RETVAL}" = x0 ; then      rm -f ./genmake_hello.c ./genmake_hello
303           echo "    a system-default makedepend was not found."      if test "x${p_CC}" = x ; then
304            cat 1>&2 <<EOF
305           #  Try to build the cyrus impl  
306           rm -f ./genmake_cy_md  Error: No C compilers were found in your path.  Please specify one using:
307           (  
308               cd $ROOTDIR/tools/cyrus-imapd-makedepend  \      1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
309                   &&  ./configure > /dev/null 2>&1  \      2) the CC or MITGCM_CC environment variables.
310                   &&  make > /dev/null 2>&1  \  
311                   &&  ./makedepend ifparser.c > /dev/null 2>&1  \  EOF
312                   &&  echo "true"          exit 1
313           ) > ./genmake_cy_md      else
314           grep true ./genmake_cy_md > /dev/null 2>&1          echo "  The possible C compilers found in your path are:"
315           RETVAL=$?          echo "   "$p_CC
316           if test "x$RETVAL" = x0 ; then          if test "x$CC" = x ; then
317               MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'              CC=`echo $p_CC | $AWK '{print $1}'`
318           else              echo "  Setting C compiler to: "$CC
319               MAKEDEPEND='$(TOOLSDIR)/xmakedepend'          fi
          fi  
          rm -f ./genmake_cy_md  
       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 172  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
356          if test "x$FC" = x ; then      fi
357              FC=`echo $p_FC | $AWK '{print $1}'`  
358              echo "  Setting FORTRAN compiler to: "$FC      #  Use the first of the compilers found in the current PATH
359          fi      #  that has a correctly-named optfile
360        if test "x$OPTFILE" = x  -a  "x$FC" = x ; then
361            for i in $p_FC ; do
362                OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
363                if test -r $OPTFILE ; then
364                    echo "  Setting OPTFILE to: "$OPTFILE
365                    break
366                fi
367            done
368      fi      fi
369    
370      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
# Line 274  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 338  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      -mpi | --mpi
542            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
543      -mpi=PATH | --mpi=PATH      -mpi=PATH | --mpi=PATH
544            Include MPI header files and link to MPI libraries using MPI_ROOT            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            set to PATH. i.e. Include files from \$PATH/include, link to libraries
546            from $PATH/lib and use binaries from $PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
547    
548      -bash NAME      -bash NAME
549            Explicitly specify the Bourne or BASH shell to use            Explicitly specify the Bourne or BASH shell to use
# Line 373  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 390  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 402  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 420  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 474  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 496  EOF Line 697  EOF
697  }  }
698    
699    
700    check_HAVE_SETRLSTK()  {
701        get_fortran_c_namemangling
702        cat <<EOF > genmake_tc_1.c
703    $FC_NAMEMANGLE
704    #include <sys/time.h>
705    #include <sys/resource.h>
706    #include <unistd.h>
707    void FC_NAMEMANGLE(setrlstk) ()
708    {
709        struct rlimit rls;
710        rls.rlim_cur = RLIM_INFINITY;
711        rls.rlim_max = RLIM_INFINITY;
712        setrlimit(RLIMIT_STACK, &rls);
713        return;
714    }
715    EOF
716        make genmake_tc_1.o >> genmake_warnings 2>&1
717        RET_C=$?
718        cat <<EOF > genmake_tc_2.$FS
719          program hello
720          external setrlstk
721          call setrlstk()
722          end
723    EOF
724        echo >> genmake_warnings
725        echo "running: check_HAVE_SETRLSTK()" >> genmake_warnings
726        cat genmake_tc_2.$FS >> genmake_warnings
727        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
728        echo $COMM >> genmake_warnings
729        $COMM >> genmake_warnings 2>&1
730        RETVAL=$?
731        if test "x$RETVAL" = x0 ; then
732            HAVE_SETRLSTK=t
733            DEFINES="$DEFINES -DHAVE_SETRLSTK"
734        fi
735        rm -f genmake_tc*
736    }
737    
738    
739    check_HAVE_STAT()  {
740        get_fortran_c_namemangling
741        cat <<EOF > genmake_tc_1.c
742    $FC_NAMEMANGLE
743    #include <stdio.h>
744    #include <stdlib.h>
745    #include <unistd.h>
746    #include <sys/stat.h>
747    #include <sys/types.h>
748    void FC_NAMEMANGLE(tfsize) ( int *nbyte )
749    {
750        char name[512];
751        struct stat astat;
752    
753        name[0] = 'a'; name[1] = '\0';
754        if (! stat(name, &astat))
755            *nbyte = (int)(astat.st_size);
756        else
757            *nbyte = -1;
758    }
759    EOF
760        make genmake_tc_1.o >> genmake_tc.log 2>&1
761        RET_C=$?
762        cat <<EOF > genmake_tc_2.$FS
763          program hello
764          integer nbyte
765          call tfsize(nbyte)
766          print *," HELLO WORLD", nbyte
767          end
768    EOF
769        echo >> genmake_warnings
770        echo "running: check_HAVE_STAT()" >> genmake_warnings
771        cat genmake_tc_2.$FS >> genmake_warnings
772        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
773        echo $COMM >> genmake_warnings
774        $COMM >> genmake_tc.log 2>&1
775        RETVAL=$?
776        if test "x$RETVAL" = x0 ; then
777            HAVE_STAT=t
778            DEFINES="$DEFINES -DHAVE_STAT"
779        fi
780        rm -f genmake_tc*
781    }
782    
783    
784  check_netcdf_libs()  {  check_netcdf_libs()  {
785        if test ! "x$SKIP_NETCDF_CHECK" = x ; then
786            return
787        fi
788        echo >> genmake_warnings
789        echo "running: check_netcdf_libs()" >> genmake_warnings
790      cat <<EOF > genmake_tnc.F      cat <<EOF > genmake_tnc.F
791        program fgennc        program fgennc
792  #include "netcdf.inc"  #include "netcdf.inc"
793    EOF
794        if test ! "x$MPI" = x ; then
795            echo '#include "mpif.h"' >> genmake_tnc.F
796        fi
797        cat <<EOF >> genmake_tnc.F
798        integer iret, ncid, xid        integer iret, ncid, xid
799        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
800        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
# Line 509  check_netcdf_libs()  { Line 804  check_netcdf_libs()  {
804        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
805        end        end
806  EOF  EOF
807      $CPP genmake_tnc.F > genmake_tnc.f  \      echo "===  genmake_tnc.F  ===" > genmake_tnc.log
808          &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1      cat genmake_tnc.F >> genmake_tnc.log
809        echo "===  genmake_tnc.F  ===" >> genmake_tnc.log
810        RET_CPP=f
811        COMM="$CPP $DEFINES $INCLUDES genmake_tnc.F"
812        echo "$COMM" >> genmake_tnc.log
813        $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t
814        if test "x$RET_CPP" = xf ; then
815            echo "  WARNING: CPP failed to pre-process the netcdf test." \
816                >> genmake_tnc.log
817            echo "    Please check that \$INCLUDES is properly set." \
818                >> genmake_tnc.log
819        fi
820        echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log
821        echo "  &&  $LINK -o genmake_tnc.o $LIBS" >> genmake_tnc.log
822        $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
823            &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
824      RET_COMPILE=$?      RET_COMPILE=$?
825      test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1      cat genmake_tnc.log >> genmake_warnings
826      RETVAL=$?  
827      if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then      #EH3  Remove test program execution for machines that either disallow
828        #EH3  execution or cannot support it (eg. cross-compilers)
829        #EH3
830        #EH3 test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
831        #EH3 RETVAL=$?
832        #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
833    
834        if test "x$RET_COMPILE" = x0 ; then
835          HAVE_NETCDF=t          HAVE_NETCDF=t
836      else      else
837          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
838          $CPP genmake_tnc.F > genmake_tnc.f  \          echo "try again with added '-lnetcdf'" > genmake_tnc.log
839              &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \          echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log
840              $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
841            echo " &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
842            $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
843                &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
844                &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
845          RET_COMPILE=$?          RET_COMPILE=$?
846          test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1          cat genmake_tnc.log >> genmake_warnings
847          RETVAL=$?          if test "x$RET_COMPILE" = x0 ; then
         if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then  
848              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
849              HAVE_NETCDF=t              HAVE_NETCDF=t
         else  
             cat genmake_tnc.log >> genmake_warnings  
850          fi          fi
851      fi      fi
852      rm -f genmake_tnc*      rm -f genmake_tnc*
# Line 547  PLATFORM= Line 865  PLATFORM=
865  LN=  LN=
866  S64=  S64=
867  KPP=  KPP=
868  FC=  #FC=
869  CPP=  #CC=gcc
870    #CPP=
871  LINK=  LINK=
872  DEFINES=  DEFINES=
873  PACKAGES=  PACKAGES=
874  ENABLE=  ENABLE=
875  DISABLE=  DISABLE=
876  MAKEFILE=  # MAKEFILE=
877  MAKEDEPEND=  # MAKEDEPEND=
878  PDEPEND=  PDEPEND=
879  DUMPSTATE=t  DUMPSTATE=t
880  PDEFAULT=  PDEFAULT=
881  OPTFILE=  OPTFILE=
882  INCLUDES="-I."  INCLUDES="-I. $INCLUDES"
883  FFLAGS=  FFLAGS=
884  FOPTIM=  FOPTIM=
885  CFLAGS=  CFLAGS=
# Line 573  NOOPTFILES= Line 892  NOOPTFILES=
892  NOOPTFLAGS=  NOOPTFLAGS=
893  MPI=  MPI=
894  MPIPATH=  MPIPATH=
895    TS=
896    HAVE_TEST_L=
897    
898  # DEFINES checked by test compilation  # DEFINES checked by test compilation or command-line
899  HAVE_SYSTEM=  HAVE_SYSTEM=
900  HAVE_FDATE=  HAVE_FDATE=
901  FC_NAMEMANGLE=  FC_NAMEMANGLE=
902  HAVE_CLOC=  HAVE_CLOC=
903    HAVE_SETRLSTK=
904    HAVE_STAT=
905  HAVE_NETCDF=  HAVE_NETCDF=
906    HAVE_ETIME=
907    IGNORE_TIME=
908    
909  MODS=  MODS=
910  TOOLSDIR=  TOOLSDIR=
# Line 590  STANDARDDIRS="USE_THE_DEFAULT" Line 915  STANDARDDIRS="USE_THE_DEFAULT"
915  G2ARGS=  G2ARGS=
916  BASH=  BASH=
917  PWD=`pwd`  PWD=`pwd`
918  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
919  AWK=awk  test "x$AWK" = x   &&  AWK=awk
920  THISHOSTNAME=`hostname`  THISHOST=`hostname`
921  THISCWD=`pwd`  THISCWD=`pwd`
922  THISDATE=`date`  THISDATE=`date`
923    THISUSER=`echo $USER`
924    THISVER=
925  MACHINE=`uname -a`  MACHINE=`uname -a`
926  EXECUTABLE=  EXECUTABLE=
927  EXEHOOK=  EXEHOOK=
# Line 604  IEEE= Line 931  IEEE=
931  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
932      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
933  fi  fi
934    FS=
935    FS90=
936    
937  AUTODIFF_PKG_USED=f  AUTODIFF_PKG_USED=f
938  AD_OPTFILE=  AD_OPTFILE=
# Line 621  TAMC_EXTRA= Line 950  TAMC_EXTRA=
950    
951  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
952  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
953  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE TS MPI JAM DUMPSTATE STANDARDDIRS"
954    
955  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
956  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 "
957  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
958  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
959  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
960  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE"  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
961    
962  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
963  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 658  for i in . $MODS ; do Line 987  for i in . $MODS ; do
987      fi      fi
988  done  done
989  printf "  getting local config information:  "  printf "  getting local config information:  "
990  if test -e $gm_local ; then  if test -f $gm_local ; then
991      echo "using $gm_local"      echo "using $gm_local"
992      . $gm_local      . $gm_local
993      # echo "DISABLE=$DISABLE"      # echo "DISABLE=$DISABLE"
# Line 667  else Line 996  else
996      echo "none found"      echo "none found"
997  fi  fi
998    
999  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
1000  #OPTIONS=  #OPTIONS=
1001  #n=0  #n=0
1002  #for i ; do  #for i ; do
# Line 679  fi Line 1008  fi
1008  #done  #done
1009  #parse_options  #parse_options
1010  ac_prev=  ac_prev=
1011  for ac_option ; do  for ac_option in "$@" ; do
1012    
1013      G2ARGS="$G2ARGS \"$ac_option\""      G2ARGS="$G2ARGS \"$ac_option\""
1014    
# Line 775  for ac_option ; do Line 1104  for ac_option ; do
1104  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1105  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1106  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1107                        
1108            -cc | --cc)
1109                ac_prev=CC ;;
1110            -cc=* | --cc=*)
1111                CC=$ac_optarg ;;
1112            
1113          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1114              ac_prev=FC ;;              ac_prev=FC ;;
1115          -fc=* | --fc=*)          -fc=* | --fc=*)
1116              FC=$ac_optarg ;;              FC=$ac_optarg ;;
1117                    
1118            -fs | --fs)
1119                ac_prev=FS ;;
1120            -fs=* | --fs=*)
1121                FS=$ac_optarg ;;
1122            
1123            -fs90 | --fs90)
1124                ac_prev=FS90 ;;
1125            -fs90=* | --fs90=*)
1126                FS90=$ac_optarg ;;
1127            
1128          -ieee | --ieee)          -ieee | --ieee)
1129              IEEE=true ;;              IEEE=true ;;
1130          -noieee | --noieee)          -noieee | --noieee)
1131              IEEE= ;;              IEEE= ;;
1132    
1133            -ts | --ts)
1134                TS=true ;;
1135    
1136          -mpi | --mpi)          -mpi | --mpi)
1137              MPI=true ;;              MPI=true ;;
1138          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
# Line 809  for ac_option ; do Line 1156  for ac_option ; do
1156              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1157          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1158              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1159            
1160            -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1161                IGNORE_TIME="-DIGNORE_TIME" ;;
1162    
1163          -*)          -*)
1164              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
# Line 824  for ac_option ; do Line 1174  for ac_option ; do
1174            
1175  done  done
1176    
1177    
1178  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1179      echo      echo
1180      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 836  if test -f ./.genmakerc ; then Line 1187  if test -f ./.genmakerc ; then
1187      echo      echo
1188  fi  fi
1189    
1190    #  Find the MITgcm ${ROOTDIR}
1191  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1192      if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1193        if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
1194          ROOTDIR=".."          ROOTDIR=".."
1195      else      else
1196          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
# Line 861  if test ! -d ${ROOTDIR} ; then Line 1214  if test ! -d ${ROOTDIR} ; then
1214      exit 1      exit 1
1215  fi  fi
1216    
1217    #  Find the MITgcm ${THISVER}
1218    if test -f "${ROOTDIR}/doc/tag-index" ; then
1219        THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`
1220    fi
1221    
1222    if test "x$MAKEFILE" = x ; then
1223        MAKEFILE="Makefile"
1224    fi
1225    
1226  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
1227  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1228      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
# Line 917  if test "x${AD_OPTFILE}" != xNONE ; then Line 1279  if test "x${AD_OPTFILE}" != xNONE ; then
1279      fi      fi
1280  fi  fi
1281    
1282  #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #====================================================================
1283    #  Set default values if not set by the optfile
1284    #
1285    #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1286  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1287  if test ! "x$BASH" = x ; then  if test ! "x$BASH" = x ; then
1288      # add a trailing space so that it works within the Makefile syntax (see below)      # add a trailing space so that it works within the Makefile syntax (see below)
# Line 933  Error: no Fortran compiler: please speci Line 1298  Error: no Fortran compiler: please speci
1298  EOF  EOF
1299      exit 1      exit 1
1300  fi  fi
1301    if test "x$CC" = x ; then
1302        CC=cc
1303    #     cat <<EOF 1>&2
1304    # Error: no C compiler: please specify using one of the following:
1305    #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1306    #   2) the "-cc=XXX" command-line option
1307    #   3) the "./genmake_local" file
1308    # EOF
1309    #     exit 1
1310    fi
1311  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1312      LINK=$FC      LINK=$FC
1313  fi  fi
# Line 943  if test "x$CPP" = x ; then Line 1318  if test "x$CPP" = x ; then
1318      CPP=cpp      CPP=cpp
1319  fi  fi
1320  #EH3 === UGLY ===  #EH3 === UGLY ===
1321  #  The following an ugly little hack to check for $CPP in /lib/ and it  #  The following is an ugly little hack to check for $CPP in /lib/ and
1322  #  should eventually be replaced with a more general function that  #  it should eventually be replaced with a more general function that
1323  #  searches a combo of the user's path and a list of "usual suspects"  #  searches a combo of the user's path and a list of "usual suspects"
1324  #  to find the correct location for binaries such as $CPP.  #  to find the correct location for binaries such as $CPP.
1325  for i in " " "/lib/" ; do  for i in " " "/lib/" ; do
# Line 967  EOF Line 1342  EOF
1342  else  else
1343      rm -f test_cpp      rm -f test_cpp
1344  fi  fi
1345  if test "x$MAKEDEPEND" = x ; then  look_for_makedepend
     MAKEDEPEND=makedepend  
 fi  
1346  if test "x$LN" = x ; then  if test "x$LN" = x ; then
1347      LN="ln -s"      LN="ln -s"
1348  fi  fi
# Line 985  Error: The command "ln -s" failed -- ple Line 1358  Error: The command "ln -s" failed -- ple
1358  EOF  EOF
1359      exit 1      exit 1
1360  fi  fi
1361    test -L genmake_tlink > /dev/null 2>&1
1362    RETVAL=$?
1363    if test "x$RETVAL" = x0 ; then
1364        HAVE_TEST_L=t
1365    fi
1366  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
1367    
1368    #  Check for broken *.F/*.f handling and fix if possible
1369    check_for_broken_Ff
1370    
1371  if test ! "x$MPI" = x ; then  if test ! "x$MPI" = x ; then
1372        echo "  Turning on MPI cpp macros"        echo "  Turning on MPI cpp macros"
1373        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1374  fi  fi
1375    
1376    if test ! "x$TS" = x ; then
1377          echo "  Turning on timing per timestep"
1378          DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1379    fi
1380    
1381  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1382  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1383  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1384        program hello        program hello
1385        call system('echo hi')        call system('echo hi')
1386        end        end
1387  EOF  EOF
1388  $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
1389  RETVAL=$?  RETVAL=$?
1390  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1391      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 1012  fi Line 1398  fi
1398  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1399    
1400  printf "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1401  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1402        program hello        program hello
1403        CHARACTER(128) string        CHARACTER*(128) string
1404        string = ' '        string = ' '
1405        call fdate( string )        call fdate( string )
1406        print *, string        print *, string
1407        end        end
1408  EOF  EOF
1409  $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
1410  RETVAL=$?  RETVAL=$?
1411  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1412      HAVE_FDATE=t      HAVE_FDATE=t
# Line 1032  else Line 1418  else
1418  fi  fi
1419  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1420    
1421    printf "  Do we have the etime() command using $FC...  "
1422    cat > genmake_tcomp.$FS <<EOF
1423          program hello
1424          REAL*4 ACTUAL, TARRAY(2)
1425          EXTERNAL ETIME
1426          REAL*4 ETIME
1427          actual = etime( tarray )
1428          print *, tarray
1429          end
1430    EOF
1431    $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1432    RETVAL=$?
1433    if test "x$RETVAL" = x0 ; then
1434        HAVE_ETIME=t
1435        DEFINES="$DEFINES -DHAVE_ETIME"
1436        echo "yes"
1437    else
1438        HAVE_ETIME=
1439        echo "no"
1440    fi
1441    rm -f genmake_tcomp*
1442    
1443  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1444  check_HAVE_CLOC  check_HAVE_CLOC
1445  if test "x$HAVE_CLOC" != x ; then  if test "x$HAVE_CLOC" != x ; then
# Line 1041  else Line 1449  else
1449  fi  fi
1450  rm -f genmake_t*  rm -f genmake_t*
1451    
1452    printf "  Can we unlimit the stack size using $FC...  "
1453    check_HAVE_SETRLSTK
1454    if test "x$HAVE_SETRLSTK" != x ; then
1455        echo "yes"
1456    else
1457        echo "no"
1458    fi
1459    rm -f genmake_t*
1460    
1461    printf "  Can we use stat() through C calls...  "
1462    check_HAVE_STAT
1463    if test "x$HAVE_STAT" != x ; then
1464        echo "yes"
1465    else
1466        echo "no"
1467    fi
1468    rm -f genmake_t*
1469    
1470  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1471  check_netcdf_libs  check_netcdf_libs
1472  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
# Line 1048  if test "x$HAVE_NETCDF" != x ; then Line 1474  if test "x$HAVE_NETCDF" != x ; then
1474  else  else
1475      echo "no"      echo "no"
1476  fi  fi
1477    DEFINES="$DEFINES $IGNORE_TIME"
1478    
1479  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1480  printf "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
# Line 1065  for d in $MODS ; do Line 1491  for d in $MODS ; do
1491  done  done
1492  echo  echo
1493    
 if test "x$MAKEFILE" = x ; then  
     MAKEFILE="Makefile"  
 fi  
1494  if test "x${PLATFORM}" = x ; then  if test "x${PLATFORM}" = x ; then
1495      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
1496  fi  fi
1497    
1498  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1499      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1500        if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1501          EXEDIR=../exe          EXEDIR=../exe
1502      else      else
1503          EXEDIR=.          EXEDIR=.
# Line 1092  if test ! -d ${TOOLSDIR} ; then Line 1516  if test ! -d ${TOOLSDIR} ; then
1516      exit 1      exit 1
1517  fi  fi
1518  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1519      S64='$(TOOLSDIR)/set64bitConst.sh'      echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1520        RETVAL=$?
1521        if test "x${RETVAL}" = x0 ; then
1522            S64='$(TOOLSDIR)/set64bitConst.sh'
1523        else
1524            echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1525            RETVAL=$?
1526            if test "x${RETVAL}" = x0 ; then
1527                S64='$(TOOLSDIR)/set64bitConst.csh'
1528            else
1529                cat <<EOF
1530    
1531    ERROR: neither of the two default scripts:
1532    
1533        ${TOOLSDIR}/set64bitConst.sh
1534        ${TOOLSDIR}/set64bitConst.csh
1535    
1536      are working so please check paths or specify (with \$S64) a
1537      working version of this script.
1538    
1539    EOF
1540                exit 1
1541            fi
1542        fi
1543  fi  fi
1544  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1545    
# Line 1191  else Line 1638  else
1638              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
1639          done          done
1640          echo "    before group expansion packages are: $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
1641          while ! expand_pkg_groups; do echo > /dev/null; done          RET=1
1642            while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
1643          echo "    after group expansion packages are:  $PACKAGES"          echo "    after group expansion packages are:  $PACKAGES"
1644      fi      fi
1645  fi  fi
# Line 1236  done Line 1684  done
1684  rm -f ./.tmp_pack  rm -f ./.tmp_pack
1685  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1686    
1687    #  Check availability of NetCDF and then either build the MNC template
1688    #  files or delete mnc from the list of available packages.
1689    echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1690    RETVAL=$?
1691    if test "x$RETVAL" = x0 ; then
1692        if test "x$HAVE_NETCDF" != xt ; then
1693            cat <<EOF
1694    
1695    *********************************************************************
1696    WARNING: the "mnc" package was enabled but tests failed to compile
1697      NetCDF applications.  Please check that:
1698    
1699      1) NetCDF is correctly installed for this compiler and
1700      2) the LIBS variable (within the "optfile") specifies the correct
1701           NetCDF library to link against.
1702    
1703      Due to this failure, the "mnc" package is now DISABLED.
1704    *********************************************************************
1705    
1706    EOF
1707            PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
1708            DISABLE="$DISABLE mnc"
1709        else
1710            ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
1711            RETVAL=$?
1712            if test "x${RETVAL}" = x0 ; then
1713                rm -f make_mnc.errors
1714            else
1715                echo "Error: problem encountered while building source files in pkg/mnc:"
1716                cat make_mnc.errors 1>&2
1717                exit 1
1718            fi
1719        fi
1720    fi
1721    
1722  echo "  applying package dependency rules"  echo "  applying package dependency rules"
1723  ck=  ck=
1724  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
# Line 1300  while test "x$ck" != xtt ; do Line 1783  while test "x$ck" != xtt ; do
1783              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
1784              exit 1              exit 1
1785          fi          fi
1786          i=$(( $i + 1 ))          i=`echo "$i + 1" | bc -l`
1787            #i=$(( $i + 1 ))
1788      done      done
1789      ck=$ck"t"      ck=$ck"t"
1790  done  done
# Line 1319  for i in $PACKAGES ; do Line 1803  for i in $PACKAGES ; do
1803      fi      fi
1804  done  done
1805    
 #  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 "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  
   
1806  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
1807  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
1808  #  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 1365  for n in $names ; do Line 1822  for n in $names ; do
1822              fi              fi
1823          done          done
1824          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1825              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1826              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
1827          fi          fi
1828      fi      fi
1829  done  done
1830  ENABLED_PACKAGES=  ENABLED_PACKAGES=
1831  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1832      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`      def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1833      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1834  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
1835    
# Line 1456  for i in $SOURCEDIRS ; do Line 1913  for i in $SOURCEDIRS ; do
1913          cat $i/$j >> ad_files          cat $i/$j >> ad_files
1914      done      done
1915  done  done
1916    if test ! "x"$FS = "x.f" ; then
1917        cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f
1918        mv -f ad_files_f ad_files
1919    fi
1920    
1921  echo  echo
1922  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
1923  echo "  setting INCLUDES"  echo "  setting INCLUDES"
1924  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
1925      if ! test -d $i ; then      if test ! -d $i ; then
 #       INCLUDES="$INCLUDES -I$i"  
 #   else  
1926          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
1927      fi      fi
1928  done  done
# Line 1487  for d in $alldirs ; do Line 1945  for d in $alldirs ; do
1945      for sf in $sfiles ; do      for sf in $sfiles ; do
1946          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
1947              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
1948                    ignore_f=f
1949                  case $d/$sf in                  case $d/$sf in
1950                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
1951                          ;;                          ;;
# Line 1494  for d in $alldirs ; do Line 1953  for d in $alldirs ; do
1953                          ;;                          ;;
1954                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
1955                          ;;                          ;;
1956                      ./BUILD_INFO.h)
1957                            ;;
1958                    *)                    *)
1959                          touch .links.tmp/$sf                          #  For the local directory *ONLY*,
1960                          deplist="$deplist $sf"                          #  ignore all soft-links
1961                            if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
1962                                ignore_f=t
1963                            else
1964                                touch .links.tmp/$sf
1965                                deplist="$deplist $sf"
1966                            fi
1967                          ;;                          ;;
1968                  esac                  esac
1969                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`                  if test "x$ignore_f" = xf ; then
1970                  case $extn in                      extn=`echo $sf | $AWK -F. '{print $NF}'`
1971                      F)                      case $extn in
1972                          echo    " \\"  >> srclist.inc                          F)
1973                          printf " $sf" >> srclist.inc                              echo    " \\"  >> srclist.inc
1974                          ;;                              printf " $sf" >> srclist.inc
1975                      F90)                              ;;
1976                          echo    " \\"  >> f90srclist.inc                          F90)
1977                          printf " $sf" >> f90srclist.inc                              echo    " \\"  >> f90srclist.inc
1978                          ;;                              printf " $sf" >> f90srclist.inc
1979                      c)                              ;;
1980                          echo    " \\"  >> csrclist.inc                          c)
1981                          printf " $sf" >> csrclist.inc                              echo    " \\"  >> csrclist.inc
1982                          ;;                              printf " $sf" >> csrclist.inc
1983                      h)                              ;;
1984                          echo    " \\"  >> hlist.inc                          h)
1985                          printf " $sf" >> hlist.inc                              echo    " \\"  >> hlist.inc
1986                          ;;                              printf " $sf" >> hlist.inc
1987                      flow)                              ;;
1988                          echo    " \\"  >> ad_flow_files.inc                          flow)
1989                          printf " $sf" >> ad_flow_files.inc                              echo    " \\"  >> ad_flow_files.inc
1990                          ;;                              printf " $sf" >> ad_flow_files.inc
1991                  esac                              ;;
1992                        esac
1993                    fi
1994              fi              fi
1995          fi          fi
1996      done      done
# Line 1539  echo "" >> f90srclist.inc Line 2008  echo "" >> f90srclist.inc
2008  echo "" >> hlist.inc  echo "" >> hlist.inc
2009  echo "" >> ad_flow_files.inc  echo "" >> ad_flow_files.inc
2010    
2011  if test -e $MAKEFILE ; then  if test -f $MAKEFILE ; then
2012      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
2013  fi  fi
2014  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
# Line 1550  echo "#    $THISDATE" >> $MAKEFILE Line 2019  echo "#    $THISDATE" >> $MAKEFILE
2019  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2020  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
2021  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2022  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2023    
2024  EXE_AD=$EXECUTABLE"_ad"  EXE_AD=$EXECUTABLE"_ad"
2025  EXE_FTL=$EXECUTABLE"_ftl"  EXE_FTL=$EXECUTABLE"_ftl"
# Line 1596  ENABLED_PACKAGES = ${ENABLED_PACKAGES} Line 2065  ENABLED_PACKAGES = ${ENABLED_PACKAGES}
2065  DISABLED_PACKAGES = ${DISABLED_PACKAGES}  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
2066    
2067  # These files are created by Makefile  # These files are created by Makefile
2068  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
2069    
2070  EOF  EOF
2071    
# Line 1615  KPP = ${KPP} Line 2084  KPP = ${KPP}
2084  FC = ${FC}  FC = ${FC}
2085  # Fortran compiler  # Fortran compiler
2086  F90C = ${F90C}  F90C = ${F90C}
2087    # C compiler
2088    CC = ${CC}
2089  # Link editor  # Link editor
2090  LINK = ${LINK} ${LDADD}  LINK = ${LINK} ${LDADD}
2091    
# Line 1637  CFLAGS = ${CFLAGS} Line 2108  CFLAGS = ${CFLAGS}
2108  NOOPTFILES = ${NOOPTFILES}  NOOPTFILES = ${NOOPTFILES}
2109  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2110  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2111  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS}
2112  # Name of the Mekfile  # Name of the Mekfile
2113  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2114    
# Line 1648  cat csrclist.inc      >> $MAKEFILE Line 2119  cat csrclist.inc      >> $MAKEFILE
2119  cat f90srclist.inc    >> $MAKEFILE  cat f90srclist.inc    >> $MAKEFILE
2120  cat hlist.inc         >> $MAKEFILE  cat hlist.inc         >> $MAKEFILE
2121  cat ad_flow_files.inc >> $MAKEFILE  cat ad_flow_files.inc >> $MAKEFILE
2122  echo               >> $MAKEFILE  echo >> $MAKEFILE
2123  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE
2124  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE
2125  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
2126    echo >> $MAKEFILE
2127    echo '.SUFFIXES:' >> $MAKEFILE
2128    echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE
2129  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
2130  rm -f ad_flow_files.inc  rm -f ad_flow_files.inc
2131    
2132  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2133    
 .SUFFIXES:  
 .SUFFIXES: .o .f .p .F .c .F90 .f90  
   
2134  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
2135  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)
2136          @echo Creating \$@ ...          @echo Creating \$@ ...
2137          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2138  depend:  depend:
2139          @make links          @make links
2140          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
2141          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2142          -rm -f makedepend.out          -rm -f makedepend.out
2143    
2144    lib: libmitgcmuv.a
2145    
2146    libmitgcmuv.a: \$(OBJFILES)
2147            ar rcv libmitgcmuv.a \$(OBJFILES)
2148    
2149  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
2150    
2151  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77FILES) \$(F90FILES)
# Line 1680  output.txt: \$(EXECUTABLE) Line 2155  output.txt: \$(EXECUTABLE)
2155          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
2156    
2157  clean:  clean:
2158          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2159  Clean:  Clean:
2160          @make clean          @make clean
2161          @make cleanlinks          @make cleanlinks
# Line 1691  CLEAN: Line 2166  CLEAN:
2166          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2167          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2168          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2169          -rm -f \$(EXECUTABLE) output.txt          -rm -f \$(EXECUTABLE) output.txt STD*
2170    
2171  #eh3 Makefile: makefile  #eh3 Makefile: makefile
2172  makefile:  makefile:
# Line 1699  makefile: Line 2174  makefile:
2174  cleanlinks:  cleanlinks:
2175          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2176    
2177  # Special targets ($SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are create by make
2178  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2179          @echo Creating \$@ ...          @echo Creating \$@ ...
2180          @$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) > \$@          @$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) > \$@
# Line 1710  FC_NAMEMANGLE.h: Line 2185  FC_NAMEMANGLE.h:
2185          @echo Creating \$@ ...          @echo Creating \$@ ...
2186          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
2187    
2188  # The normal chain of rules is (  .F - .f - .o  )  BUILD_INFO.h:
2189  .F.f:          @echo Creating \$@ ...
2190    EOF
2191    
2192    test ! "x$THISVER" = x  && echo "       -echo \"#define THISVER '$THISVER'\" > \$@"   >> $MAKEFILE
2193    test ! "x$THISUSER" = x && echo "       -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2194    test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2195    test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2196    
2197    cat >>$MAKEFILE <<EOF
2198    
2199    # The normal chain of rules is (  .F - .$FS - .o  )
2200    
2201    ## This nullifies any default implicit rules concerning these two file types:
2202    ## %.o : %.F
2203    
2204    .F.$FS:
2205          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2206  .f.o:  .$FS.o:
2207          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2208  .F90.f90:  .F90.$FS90:
2209          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2210  .f90.o:  .$FS90.o:
2211          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2212  .c.o:  .c.o:
2213          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) -c \$<
2214    
2215  # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2216  .F.p:  .F.p:
2217          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2218  .p.f:  .p.$FS:
2219          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
2220    
2221  #=========================================  #=========================================
# Line 1765  cat >>$MAKEFILE <<EOF Line 2255  cat >>$MAKEFILE <<EOF
2255    
2256  # ... AD ...  # ... AD ...
2257  adall: ad_taf  adall: ad_taf
2258  adtaf: ad_taf_output.f  adtaf: ad_taf_output.$FS
2259  adtamc: ad_tamc_output.f  adtamc: ad_tamc_output.$FS
2260    
2261  ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2262          @$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          @$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
2263          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
2264          -rm -f ad_config.template          -rm -f ad_config.template
2265          @make \$(F77FILES)          @make \$(F77FILES)
2266          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2267          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS
2268    
2269  ad_taf_output.f: ad_input_code.f  ad_taf_output.$FS: ad_input_code.$FS
2270          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2271          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
2272    
2273  adtafonly:  adtafonly:
2274          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2275          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
2276    
2277  ad_taf: ad_taf_output.o \$(OBJFILES)  ad_taf: ad_taf_output.o \$(OBJFILES)
2278          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2279    
2280  ad_tamc_output.f: ad_input_code.f  ad_tamc_output.$FS: ad_input_code.$FS
2281          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2282          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
2283    
2284  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2285          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2286    
2287    adonlyfwd:
2288            patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2289    
2290    adtrick:
2291            patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2292    
2293  # ... FTL ...  # ... FTL ...
2294  ftlall: ftl_taf  ftlall: ftl_taf
2295  ftltaf: ftl_taf_output.f  ftltaf: ftl_taf_output.$FS
2296  ftltamc: ftl_tamc_output.f  ftltamc: ftl_tamc_output.$FS
2297    
2298  ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2299          @$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          @$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
2300          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
2301          -rm -f ftl_config.template          -rm -f ftl_config.template
2302          @make \$(F77FILES)          @make \$(F77FILES)
2303          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2304          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2305    
2306  ftl_taf_output.f: ftl_input_code.f  ftl_taf_output.$FS: ftl_input_code.$FS
2307          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2308          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
2309    
2310  ftltafonly:  ftltafonly:
2311          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2312          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
2313    
2314  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
2315          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2316    
2317  ftl_tamc_output.f: ftl_input_code.f  ftl_tamc_output.$FS: ftl_input_code.$FS
2318          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2319          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
2320    
2321  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2322          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2323    
2324    
2325  # ... SVD ...  # ... SVD ...
2326  svdtaf: ad_taf_output.f ftl_taf_output.f  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
2327  svdall: svd_taf          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"
2328            @echo "--->>> Do make svdall afterwards to compile. <<<---"
2329    svdall: svd_touch svd_taf
2330    
2331  svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES)  svd_taf: \$(OBJFILES)
2332          \$(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)
2333    
2334            @echo "--->>> Only COMPILE svd code! <<<---"
2335            @echo "--->>> Assumes you previously <<<---"
2336            @echo "--->>> did make svdtaf        <<<---"
2337    
2338    svd_touch:
2339            @echo "--->>> Only COMPILE svd code! <<<---"
2340            @echo "--->>> Assumes you previously <<<---"
2341            @echo "--->>> did make svdtaf        <<<---"
2342            touch ad_taf_output.$FS ftl_taf_output.$FS
2343            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
2344            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
2345            @$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
2346            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2347            -rm -f ftl_config.template
2348    
2349  #=========================================  #=========================================
2350    
# Line 1850  for i in $KPPFILES ; do Line 2361  for i in $KPPFILES ; do
2361      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
2362          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
2363      fi      fi
2364      echo "$base.f: $base.p" >> $MAKEFILE      echo "$base.$FS: $base.p" >> $MAKEFILE
2365  done  done
2366    
2367  echo "  Making list of NOOPTFILES"  echo "  Making list of NOOPTFILES"
# Line 1860  for i in $NOOPTFILES ; do Line 2371  for i in $NOOPTFILES ; do
2371      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
2372          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
2373      fi      fi
2374      echo "$base.o: $base.f" >> $MAKEFILE      echo "$base.o: $base.$FS" >> $MAKEFILE
2375      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
2376  done  done
2377    

Legend:
Removed from v.1.74  
changed lines
  Added in v.1.136

  ViewVC Help
Powered by ViewVC 1.1.22