/[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.132 by cnh, Fri Sep 16 00:50:49 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
# Line 274  Usage: "$0" [OPTIONS] Line 448  Usage: "$0" [OPTIONS]
448      -help | --help | -h | --h      -help | --help | -h | --h
449            Print this help message and exit.            Print this help message and exit.
450    
451        -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
452          -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
453              Use "NAME" as the adoptfile.  By default, the file at
454              "tools/adjoint_options/adjoint_default" will be used.
455    
456      -nooptfile | --nooptfile      -nooptfile | --nooptfile
457        -optfile NAME | --optfile NAME | -of NAME | --of NAME        -optfile NAME | --optfile NAME | -of NAME | --of NAME
458        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
# Line 338  Usage: "$0" [OPTIONS] Line 517  Usage: "$0" [OPTIONS]
517            will search for a working compiler by trying a list of            will search for a working compiler by trying a list of
518            "usual suspects" such as g77, f77, etc.            "usual suspects" such as g77, f77, etc.
519    
520        -cc NAME | --cc NAME | -cc=NAME | --cc=NAME
521              Use "NAME" as the C compiler.  By default, genmake
522              will search for a working compiler by trying a list of
523              "usual suspects" such as gcc, c89, cc, etc.
524    
525      -[no]ieee | --[no]ieee      -[no]ieee | --[no]ieee
526            Do or don't use IEEE numerics.  Note that this option            Do or don't use IEEE numerics.  Note that this option
527            *only* works if it is supported by the OPTFILE that            *only* works if it is supported by the OPTFILE that
528            is being used.            is being used.
529    
530        -ts | --ts
531              Produce timing information per timestep
532    
533      -mpi | --mpi      -mpi | --mpi
534            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
535      -mpi=PATH | --mpi=PATH      -mpi=PATH | --mpi=PATH
536            Include MPI header files and link to MPI libraries using MPI_ROOT            Include MPI header files and link to MPI libraries using MPI_ROOT
537            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
538            from $PATH/lib and use binaries from $PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
539    
540      -bash NAME      -bash NAME
541            Explicitly specify the Bourne or BASH shell to use            Explicitly specify the Bourne or BASH shell to use
# Line 373  EOF Line 560  EOF
560    
561  #  Build a CPP macro to automate calling C routines from FORTRAN  #  Build a CPP macro to automate calling C routines from FORTRAN
562  get_fortran_c_namemangling()  {  get_fortran_c_namemangling()  {
563    
564        #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
565        if test ! "x$FC_NAMEMANGLE" = x ; then
566            return 0
567        fi
568    
569      default_nm="#define FC_NAMEMANGLE(X) X ## _"      default_nm="#define FC_NAMEMANGLE(X) X ## _"
570            
571      cat > genmake_test.c <<EOF      cat > genmake_test.c <<EOF
# Line 390  WARNING: Please contact <MITgcm-support@ Line 583  WARNING: Please contact <MITgcm-support@
583  EOF  EOF
584          return 1          return 1
585      fi      fi
586      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`
587      RETVAL=$?      RETVAL=$?
588      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
589          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 402  WARNING: Please contact <MITgcm-support@ Line 595  WARNING: Please contact <MITgcm-support@
595  EOF  EOF
596          return 1          return 1
597      fi      fi
598      cat > genmake_tcomp.f <<EOF      cat > genmake_tcomp.$FS <<EOF
599        subroutine tcall( string )        subroutine tcall( string )
600        character*(*) string        character*(*) string
601        call tsub( string )        call tsub( string )
602        end        end
603  EOF  EOF
604      $FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1      $FC $FFLAGS $DEFINES -c genmake_tcomp.$FS >> genmake_warnings 2>&1
605      RETVAL=$?      RETVAL=$?
606      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
607          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 420  WARNING: Please contact <MITgcm-support@ Line 613  WARNING: Please contact <MITgcm-support@
613  EOF  EOF
614          return 1          return 1
615      fi      fi
616      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`
617      RETVAL=$?      RETVAL=$?
618      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
619          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 474  void FC_NAMEMANGLE(cloc) ( double *curti Line 667  void FC_NAMEMANGLE(cloc) ( double *curti
667   *curtim = *curtim/1.E6;   *curtim = *curtim/1.E6;
668  }  }
669  EOF  EOF
670      make genmake_tc_1.o >> genmake_tc.log 2>&1      make genmake_tc_1.o >> genmake_warnings 2>&1
671      RET_C=$?      RET_C=$?
672      cat <<EOF > genmake_tc_2.f      cat <<EOF > genmake_tc_2.$FS
673        program hello        program hello
674        Real*8 wtime        REAL*8 wtime
675        external cloc        external cloc
676        call cloc(wtime)        call cloc(wtime)
677        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
678        end program hello        end
679  EOF  EOF
680      $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
681      RET_F=$?      RET_F=$?
682      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1
683      RETVAL=$?      RETVAL=$?
684      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
685          HAVE_CLOC=t          HAVE_CLOC=t
# Line 496  EOF Line 689  EOF
689  }  }
690    
691    
692    check_HAVE_SETRLSTK()  {
693        get_fortran_c_namemangling
694        cat <<EOF > genmake_tc_1.c
695    $FC_NAMEMANGLE
696    #include <sys/time.h>
697    #include <sys/resource.h>
698    #include <unistd.h>
699    void FC_NAMEMANGLE(setrlstk) ()
700    {
701        struct rlimit rls;
702        rls.rlim_cur = RLIM_INFINITY;
703        rls.rlim_max = RLIM_INFINITY;
704        setrlimit(RLIMIT_STACK, &rls);
705        return;
706    }
707    EOF
708        make genmake_tc_1.o >> genmake_warnings 2>&1
709        RET_C=$?
710        cat <<EOF > genmake_tc_2.$FS
711          program hello
712          external setrlstk
713          call setrlstk()
714          end
715    EOF
716        $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1
717        RET_F=$?
718        test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1
719        RETVAL=$?
720        if test "x$RETVAL" = x0 ; then
721            HAVE_SETRLSTK=t
722            DEFINES="$DEFINES -DHAVE_SETRLSTK"
723        fi
724        rm -f genmake_tc*
725    }
726    
727    
728    check_HAVE_STAT()  {
729        get_fortran_c_namemangling
730        cat <<EOF > genmake_tc_1.c
731    $FC_NAMEMANGLE
732    #include <stdio.h>
733    #include <stdlib.h>
734    #include <unistd.h>
735    #include <sys/stat.h>
736    #include <sys/types.h>
737    void FC_NAMEMANGLE(tfsize) ( int *nbyte )
738    {
739        char name[512];
740        struct stat astat;
741    
742        name[0] = 'a'; name[1] = '\0';
743        if (! stat(name, &astat))
744            *nbyte = (int)(astat.st_size);
745        else
746            *nbyte = -1;
747    }
748    EOF
749        make genmake_tc_1.o >> genmake_tc.log 2>&1
750        RET_C=$?
751        cat <<EOF > genmake_tc_2.$FS
752          program hello
753          integer nbyte
754          call tfsize(nbyte)
755          print *," HELLO WORLD", nbyte
756          end
757    EOF
758        $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_tc.log 2>&1
759        RET_F=$?
760        test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1
761        RETVAL=$?
762        if test "x$RETVAL" = x0 ; then
763            HAVE_STAT=t
764            DEFINES="$DEFINES -DHAVE_STAT"
765        fi
766        rm -f genmake_tc*
767    }
768    
769    
770  check_netcdf_libs()  {  check_netcdf_libs()  {
771        if test ! "x$SKIP_NETCDF_CHECK" = x ; then
772            return
773        fi
774        echo "" > genmake_tnc.log
775      cat <<EOF > genmake_tnc.F      cat <<EOF > genmake_tnc.F
776        program fgennc        program fgennc
777  #include "netcdf.inc"  #include "netcdf.inc"
778    EOF
779        if test ! "x$MPI" = x ; then
780            echo '#include "mpif.h"' >> genmake_tnc.F
781        fi
782        cat <<EOF >> genmake_tnc.F
783        integer iret, ncid, xid        integer iret, ncid, xid
784        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
785        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
# Line 509  check_netcdf_libs()  { Line 789  check_netcdf_libs()  {
789        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
790        end        end
791  EOF  EOF
792      $CPP genmake_tnc.F > genmake_tnc.f  \      echo "Executing:" > genmake_tnc.log
793          &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1      echo "  $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS" \
794            > genmake_tnc.log
795        RET_CPP=f
796        $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
797            &&  RET_CPP=t
798        if test "x$RET_CPP" = xf ; then
799            echo "  WARNING: CPP failed to pre-process the netcdf test." \
800                > genmake_tnc.log
801            echo "    Please check that \$INCLUDES is properly set." \
802                > genmake_tnc.log
803        fi
804        echo "Executing:" > genmake_tnc.log
805        echo "  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS" > genmake_tnc.log
806        echo "  $LINK -o genmake_tnc.o $LIBS" > genmake_tnc.log
807        $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
808            &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
809      RET_COMPILE=$?      RET_COMPILE=$?
810      test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1  
811      RETVAL=$?      #EH3  Remove test program execution for machines that either disallow
812      if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then      #EH3  execution or cannot support it (eg. cross-compilers)
813        #EH3
814        #EH3 test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
815        #EH3 RETVAL=$?
816        #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
817    
818        if test "x$RET_COMPILE" = x0 ; then
819          HAVE_NETCDF=t          HAVE_NETCDF=t
820      else      else
821          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
822          $CPP genmake_tnc.F > genmake_tnc.f  \          $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
823              &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
824              $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1              &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
825          RET_COMPILE=$?          RET_COMPILE=$?
826          test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1          if test "x$RET_COMPILE" = x0 ; then
         RETVAL=$?  
         if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then  
827              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
828              HAVE_NETCDF=t              HAVE_NETCDF=t
829          else          else
# Line 547  PLATFORM= Line 846  PLATFORM=
846  LN=  LN=
847  S64=  S64=
848  KPP=  KPP=
849  FC=  #FC=
850  CPP=  #CC=gcc
851    #CPP=
852  LINK=  LINK=
853  DEFINES=  DEFINES=
854  PACKAGES=  PACKAGES=
855  ENABLE=  ENABLE=
856  DISABLE=  DISABLE=
857  MAKEFILE=  # MAKEFILE=
858  MAKEDEPEND=  # MAKEDEPEND=
859  PDEPEND=  PDEPEND=
860  DUMPSTATE=t  DUMPSTATE=t
861  PDEFAULT=  PDEFAULT=
862  OPTFILE=  OPTFILE=
863  INCLUDES="-I."  INCLUDES="-I. $INCLUDES"
864  FFLAGS=  FFLAGS=
865  FOPTIM=  FOPTIM=
866  CFLAGS=  CFLAGS=
# Line 573  NOOPTFILES= Line 873  NOOPTFILES=
873  NOOPTFLAGS=  NOOPTFLAGS=
874  MPI=  MPI=
875  MPIPATH=  MPIPATH=
876    TS=
877    HAVE_TEST_L=
878    
879  # DEFINES checked by test compilation  # DEFINES checked by test compilation or command-line
880  HAVE_SYSTEM=  HAVE_SYSTEM=
881  HAVE_FDATE=  HAVE_FDATE=
882  FC_NAMEMANGLE=  FC_NAMEMANGLE=
883  HAVE_CLOC=  HAVE_CLOC=
884    HAVE_SETRLSTK=
885    HAVE_STAT=
886  HAVE_NETCDF=  HAVE_NETCDF=
887    HAVE_ETIME=
888    IGNORE_TIME=
889    
890  MODS=  MODS=
891  TOOLSDIR=  TOOLSDIR=
# Line 590  STANDARDDIRS="USE_THE_DEFAULT" Line 896  STANDARDDIRS="USE_THE_DEFAULT"
896  G2ARGS=  G2ARGS=
897  BASH=  BASH=
898  PWD=`pwd`  PWD=`pwd`
899  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
900  AWK=awk  test "x$AWK" = x   &&  AWK=awk
901  THISHOSTNAME=`hostname`  THISHOST=`hostname`
902  THISCWD=`pwd`  THISCWD=`pwd`
903  THISDATE=`date`  THISDATE=`date`
904    THISUSER=`echo $USER`
905    THISVER=
906  MACHINE=`uname -a`  MACHINE=`uname -a`
907  EXECUTABLE=  EXECUTABLE=
908  EXEHOOK=  EXEHOOK=
# Line 604  IEEE= Line 912  IEEE=
912  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
913      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
914  fi  fi
915    FS=
916    FS90=
917    
918  AUTODIFF_PKG_USED=f  AUTODIFF_PKG_USED=f
919  AD_OPTFILE=  AD_OPTFILE=
# Line 621  TAMC_EXTRA= Line 931  TAMC_EXTRA=
931    
932  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
933  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
934  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE TS MPI JAM DUMPSTATE STANDARDDIRS"
935    
936  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
937  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 "
938  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
939  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
940  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
941  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE"  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
942    
943  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
944  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 968  for i in . $MODS ; do
968      fi      fi
969  done  done
970  printf "  getting local config information:  "  printf "  getting local config information:  "
971  if test -e $gm_local ; then  if test -f $gm_local ; then
972      echo "using $gm_local"      echo "using $gm_local"
973      . $gm_local      . $gm_local
974      # echo "DISABLE=$DISABLE"      # echo "DISABLE=$DISABLE"
# Line 667  else Line 977  else
977      echo "none found"      echo "none found"
978  fi  fi
979    
980  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
981  #OPTIONS=  #OPTIONS=
982  #n=0  #n=0
983  #for i ; do  #for i ; do
# Line 679  fi Line 989  fi
989  #done  #done
990  #parse_options  #parse_options
991  ac_prev=  ac_prev=
992  for ac_option ; do  for ac_option in "$@" ; do
993    
994      G2ARGS="$G2ARGS \"$ac_option\""      G2ARGS="$G2ARGS \"$ac_option\""
995    
# Line 775  for ac_option ; do Line 1085  for ac_option ; do
1085  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1086  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1087  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1088                        
1089            -cc | --cc)
1090                ac_prev=CC ;;
1091            -cc=* | --cc=*)
1092                CC=$ac_optarg ;;
1093            
1094          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1095              ac_prev=FC ;;              ac_prev=FC ;;
1096          -fc=* | --fc=*)          -fc=* | --fc=*)
1097              FC=$ac_optarg ;;              FC=$ac_optarg ;;
1098                    
1099            -fs | --fs)
1100                ac_prev=FS ;;
1101            -fs=* | --fs=*)
1102                FS=$ac_optarg ;;
1103            
1104            -fs90 | --fs90)
1105                ac_prev=FS90 ;;
1106            -fs90=* | --fs90=*)
1107                FS90=$ac_optarg ;;
1108            
1109          -ieee | --ieee)          -ieee | --ieee)
1110              IEEE=true ;;              IEEE=true ;;
1111          -noieee | --noieee)          -noieee | --noieee)
1112              IEEE= ;;              IEEE= ;;
1113    
1114            -ts | --ts)
1115                TS=true ;;
1116    
1117          -mpi | --mpi)          -mpi | --mpi)
1118              MPI=true ;;              MPI=true ;;
1119          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
# Line 809  for ac_option ; do Line 1137  for ac_option ; do
1137              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1138          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1139              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1140            
1141            -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1142                IGNORE_TIME="-DIGNORE_TIME" ;;
1143    
1144          -*)          -*)
1145              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
# Line 824  for ac_option ; do Line 1155  for ac_option ; do
1155            
1156  done  done
1157    
1158    
1159  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1160      echo      echo
1161      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 1168  if test -f ./.genmakerc ; then
1168      echo      echo
1169  fi  fi
1170    
1171    #  Find the MITgcm ${ROOTDIR}
1172  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1173      if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1174        if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
1175          ROOTDIR=".."          ROOTDIR=".."
1176      else      else
1177          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do          for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do
# Line 861  if test ! -d ${ROOTDIR} ; then Line 1195  if test ! -d ${ROOTDIR} ; then
1195      exit 1      exit 1
1196  fi  fi
1197    
1198    #  Find the MITgcm ${THISVER}
1199    if test -f "${ROOTDIR}/doc/tag-index" ; then
1200        THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`
1201    fi
1202    
1203    if test "x$MAKEFILE" = x ; then
1204        MAKEFILE="Makefile"
1205    fi
1206    
1207  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
1208  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1209      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
# Line 917  if test "x${AD_OPTFILE}" != xNONE ; then Line 1260  if test "x${AD_OPTFILE}" != xNONE ; then
1260      fi      fi
1261  fi  fi
1262    
1263  #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #====================================================================
1264    #  Set default values if not set by the optfile
1265    #
1266    #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1267  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1268  if test ! "x$BASH" = x ; then  if test ! "x$BASH" = x ; then
1269      # 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 1279  Error: no Fortran compiler: please speci
1279  EOF  EOF
1280      exit 1      exit 1
1281  fi  fi
1282    if test "x$CC" = x ; then
1283        CC=cc
1284    #     cat <<EOF 1>&2
1285    # Error: no C compiler: please specify using one of the following:
1286    #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1287    #   2) the "-cc=XXX" command-line option
1288    #   3) the "./genmake_local" file
1289    # EOF
1290    #     exit 1
1291    fi
1292  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1293      LINK=$FC      LINK=$FC
1294  fi  fi
# Line 943  if test "x$CPP" = x ; then Line 1299  if test "x$CPP" = x ; then
1299      CPP=cpp      CPP=cpp
1300  fi  fi
1301  #EH3 === UGLY ===  #EH3 === UGLY ===
1302  #  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
1303  #  should eventually be replaced with a more general function that  #  it should eventually be replaced with a more general function that
1304  #  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"
1305  #  to find the correct location for binaries such as $CPP.  #  to find the correct location for binaries such as $CPP.
1306  for i in " " "/lib/" ; do  for i in " " "/lib/" ; do
# Line 967  EOF Line 1323  EOF
1323  else  else
1324      rm -f test_cpp      rm -f test_cpp
1325  fi  fi
1326  if test "x$MAKEDEPEND" = x ; then  look_for_makedepend
     MAKEDEPEND=makedepend  
 fi  
1327  if test "x$LN" = x ; then  if test "x$LN" = x ; then
1328      LN="ln -s"      LN="ln -s"
1329  fi  fi
# Line 985  Error: The command "ln -s" failed -- ple Line 1339  Error: The command "ln -s" failed -- ple
1339  EOF  EOF
1340      exit 1      exit 1
1341  fi  fi
1342    test -L genmake_tlink > /dev/null 2>&1
1343    RETVAL=$?
1344    if test "x$RETVAL" = x0 ; then
1345        HAVE_TEST_L=t
1346    fi
1347  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
1348    
1349    #  Check for broken *.F/*.f handling and fix if possible
1350    check_for_broken_Ff
1351    
1352  if test ! "x$MPI" = x ; then  if test ! "x$MPI" = x ; then
1353        echo "  Turning on MPI cpp macros"        echo "  Turning on MPI cpp macros"
1354        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1355  fi  fi
1356    
1357    if test ! "x$TS" = x ; then
1358          echo "  Turning on timing per timestep"
1359          DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1360    fi
1361    
1362  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1363  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1364  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1365        program hello        program hello
1366        call system('echo hi')        call system('echo hi')
1367        end        end
1368  EOF  EOF
1369  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1370  RETVAL=$?  RETVAL=$?
1371  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1372      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 1012  fi Line 1379  fi
1379  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1380    
1381  printf "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1382  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1383        program hello        program hello
1384        CHARACTER(128) string        CHARACTER*(128) string
1385        string = ' '        string = ' '
1386        call fdate( string )        call fdate( string )
1387        print *, string        print *, string
1388        end        end
1389  EOF  EOF
1390  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1391  RETVAL=$?  RETVAL=$?
1392  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1393      HAVE_FDATE=t      HAVE_FDATE=t
# Line 1032  else Line 1399  else
1399  fi  fi
1400  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1401    
1402    printf "  Do we have the etime() command using $FC...  "
1403    cat > genmake_tcomp.$FS <<EOF
1404          program hello
1405          REAL*4 ACTUAL, TARRAY(2)
1406          EXTERNAL ETIME
1407          REAL*4 ETIME
1408          actual = etime( tarray )
1409          print *, tarray
1410          end
1411    EOF
1412    $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1413    RETVAL=$?
1414    if test "x$RETVAL" = x0 ; then
1415        HAVE_ETIME=t
1416        DEFINES="$DEFINES -DHAVE_ETIME"
1417        echo "yes"
1418    else
1419        HAVE_ETIME=
1420        echo "no"
1421    fi
1422    rm -f genmake_tcomp*
1423    
1424  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
1425  check_HAVE_CLOC  check_HAVE_CLOC
1426  if test "x$HAVE_CLOC" != x ; then  if test "x$HAVE_CLOC" != x ; then
# Line 1041  else Line 1430  else
1430  fi  fi
1431  rm -f genmake_t*  rm -f genmake_t*
1432    
1433    printf "  Can we unlimit the stack size using $FC...  "
1434    check_HAVE_SETRLSTK
1435    if test "x$HAVE_SETRLSTK" != x ; then
1436        echo "yes"
1437    else
1438        echo "no"
1439    fi
1440    rm -f genmake_t*
1441    
1442    printf "  Can we use stat() through C calls...  "
1443    check_HAVE_STAT
1444    if test "x$HAVE_STAT" != x ; then
1445        echo "yes"
1446    else
1447        echo "no"
1448    fi
1449    rm -f genmake_t*
1450    
1451  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1452  check_netcdf_libs  check_netcdf_libs
1453  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
# Line 1048  if test "x$HAVE_NETCDF" != x ; then Line 1455  if test "x$HAVE_NETCDF" != x ; then
1455  else  else
1456      echo "no"      echo "no"
1457  fi  fi
1458    DEFINES="$DEFINES $IGNORE_TIME"
1459    
1460  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1461  printf "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
# Line 1065  for d in $MODS ; do Line 1472  for d in $MODS ; do
1472  done  done
1473  echo  echo
1474    
 if test "x$MAKEFILE" = x ; then  
     MAKEFILE="Makefile"  
 fi  
1475  if test "x${PLATFORM}" = x ; then  if test "x${PLATFORM}" = x ; then
1476      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
1477  fi  fi
1478    
1479  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1480      if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1481        if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1482          EXEDIR=../exe          EXEDIR=../exe
1483      else      else
1484          EXEDIR=.          EXEDIR=.
# Line 1092  if test ! -d ${TOOLSDIR} ; then Line 1497  if test ! -d ${TOOLSDIR} ; then
1497      exit 1      exit 1
1498  fi  fi
1499  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1500      S64='$(TOOLSDIR)/set64bitConst.sh'      echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1501        RETVAL=$?
1502        if test "x${RETVAL}" = x0 ; then
1503            S64='$(TOOLSDIR)/set64bitConst.sh'
1504        else
1505            echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1506            RETVAL=$?
1507            if test "x${RETVAL}" = x0 ; then
1508                S64='$(TOOLSDIR)/set64bitConst.csh'
1509            else
1510                cat <<EOF
1511    
1512    ERROR: neither of the two default scripts:
1513    
1514        ${TOOLSDIR}/set64bitConst.sh
1515        ${TOOLSDIR}/set64bitConst.csh
1516    
1517      are working so please check paths or specify (with \$S64) a
1518      working version of this script.
1519    
1520    EOF
1521                exit 1
1522            fi
1523        fi
1524  fi  fi
1525  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1526    
# Line 1191  else Line 1619  else
1619              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
1620          done          done
1621          echo "    before group expansion packages are: $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
1622          while ! expand_pkg_groups; do echo > /dev/null; done          RET=1
1623            while test $RET = 1 ; do expand_pkg_groups; RET=$?; done
1624          echo "    after group expansion packages are:  $PACKAGES"          echo "    after group expansion packages are:  $PACKAGES"
1625      fi      fi
1626  fi  fi
# Line 1236  done Line 1665  done
1665  rm -f ./.tmp_pack  rm -f ./.tmp_pack
1666  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1667    
1668    #  Check availability of NetCDF and then either build the MNC template
1669    #  files or delete mnc from the list of available packages.
1670    echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1671    RETVAL=$?
1672    if test "x$RETVAL" = x0 ; then
1673        if test "x$HAVE_NETCDF" != xt ; then
1674            cat <<EOF
1675    
1676    *********************************************************************
1677    WARNING: the "mnc" package was enabled but tests failed to compile
1678      NetCDF applications.  Please check that:
1679    
1680      1) NetCDF is correctly installed for this compiler and
1681      2) the LIBS variable (within the "optfile") specifies the correct
1682           NetCDF library to link against.
1683    
1684      Due to this failure, the "mnc" package is now DISABLED.
1685    *********************************************************************
1686    
1687    EOF
1688            PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
1689            DISABLE="$DISABLE mnc"
1690        else
1691            ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
1692            RETVAL=$?
1693            if test "x${RETVAL}" = x0 ; then
1694                rm -f make_mnc.errors
1695            else
1696                echo "Error: problem encountered while building source files in pkg/mnc:"
1697                cat make_mnc.errors 1>&2
1698                exit 1
1699            fi
1700        fi
1701    fi
1702    
1703  echo "  applying package dependency rules"  echo "  applying package dependency rules"
1704  ck=  ck=
1705  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
# Line 1300  while test "x$ck" != xtt ; do Line 1764  while test "x$ck" != xtt ; do
1764              echo "  the dependency rules for \"$dname\""              echo "  the dependency rules for \"$dname\""
1765              exit 1              exit 1
1766          fi          fi
1767          i=$(( $i + 1 ))          i=`echo "$i + 1" | bc -l`
1768            #i=$(( $i + 1 ))
1769      done      done
1770      ck=$ck"t"      ck=$ck"t"
1771  done  done
# Line 1319  for i in $PACKAGES ; do Line 1784  for i in $PACKAGES ; do
1784      fi      fi
1785  done  done
1786    
 #  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  
   
1787  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
1788  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
1789  #  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 1803  for n in $names ; do
1803              fi              fi
1804          done          done
1805          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1806              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1807              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
1808          fi          fi
1809      fi      fi
1810  done  done
1811  ENABLED_PACKAGES=  ENABLED_PACKAGES=
1812  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1813      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`      def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1814      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1815  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
1816    
# Line 1456  for i in $SOURCEDIRS ; do Line 1894  for i in $SOURCEDIRS ; do
1894          cat $i/$j >> ad_files          cat $i/$j >> ad_files
1895      done      done
1896  done  done
1897    if test ! "x"$FS = "x.f" ; then
1898        cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f
1899        mv -f ad_files_f ad_files
1900    fi
1901    
1902  echo  echo
1903  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
1904  echo "  setting INCLUDES"  echo "  setting INCLUDES"
1905  for i in $INCLUDEDIRS ; do  for i in $INCLUDEDIRS ; do
1906      if ! test -d $i ; then      if test ! -d $i ; then
 #       INCLUDES="$INCLUDES -I$i"  
 #   else  
1907          echo "Warning: can't find INCLUDEDIRS=\"$i\""          echo "Warning: can't find INCLUDEDIRS=\"$i\""
1908      fi      fi
1909  done  done
# Line 1487  for d in $alldirs ; do Line 1926  for d in $alldirs ; do
1926      for sf in $sfiles ; do      for sf in $sfiles ; do
1927          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
1928              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
1929                    ignore_f=f
1930                  case $d/$sf in                  case $d/$sf in
1931                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
1932                          ;;                          ;;
# Line 1494  for d in $alldirs ; do Line 1934  for d in $alldirs ; do
1934                          ;;                          ;;
1935                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
1936                          ;;                          ;;
1937                      ./BUILD_INFO.h)
1938                            ;;
1939                    *)                    *)
1940                          touch .links.tmp/$sf                          #  For the local directory *ONLY*,
1941                          deplist="$deplist $sf"                          #  ignore all soft-links
1942                            if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
1943                                ignore_f=t
1944                            else
1945                                touch .links.tmp/$sf
1946                                deplist="$deplist $sf"
1947                            fi
1948                          ;;                          ;;
1949                  esac                  esac
1950                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`                  if test "x$ignore_f" = xf ; then
1951                  case $extn in                      extn=`echo $sf | $AWK -F. '{print $NF}'`
1952                      F)                      case $extn in
1953                          echo    " \\"  >> srclist.inc                          F)
1954                          printf " $sf" >> srclist.inc                              echo    " \\"  >> srclist.inc
1955                          ;;                              printf " $sf" >> srclist.inc
1956                      F90)                              ;;
1957                          echo    " \\"  >> f90srclist.inc                          F90)
1958                          printf " $sf" >> f90srclist.inc                              echo    " \\"  >> f90srclist.inc
1959                          ;;                              printf " $sf" >> f90srclist.inc
1960                      c)                              ;;
1961                          echo    " \\"  >> csrclist.inc                          c)
1962                          printf " $sf" >> csrclist.inc                              echo    " \\"  >> csrclist.inc
1963                          ;;                              printf " $sf" >> csrclist.inc
1964                      h)                              ;;
1965                          echo    " \\"  >> hlist.inc                          h)
1966                          printf " $sf" >> hlist.inc                              echo    " \\"  >> hlist.inc
1967                          ;;                              printf " $sf" >> hlist.inc
1968                      flow)                              ;;
1969                          echo    " \\"  >> ad_flow_files.inc                          flow)
1970                          printf " $sf" >> ad_flow_files.inc                              echo    " \\"  >> ad_flow_files.inc
1971                          ;;                              printf " $sf" >> ad_flow_files.inc
1972                  esac                              ;;
1973                        esac
1974                    fi
1975              fi              fi
1976          fi          fi
1977      done      done
# Line 1539  echo "" >> f90srclist.inc Line 1989  echo "" >> f90srclist.inc
1989  echo "" >> hlist.inc  echo "" >> hlist.inc
1990  echo "" >> ad_flow_files.inc  echo "" >> ad_flow_files.inc
1991    
1992  if test -e $MAKEFILE ; then  if test -f $MAKEFILE ; then
1993      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
1994  fi  fi
1995  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
# Line 1550  echo "#    $THISDATE" >> $MAKEFILE Line 2000  echo "#    $THISDATE" >> $MAKEFILE
2000  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2001  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
2002  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2003  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2004    
2005  EXE_AD=$EXECUTABLE"_ad"  EXE_AD=$EXECUTABLE"_ad"
2006  EXE_FTL=$EXECUTABLE"_ftl"  EXE_FTL=$EXECUTABLE"_ftl"
# Line 1596  ENABLED_PACKAGES = ${ENABLED_PACKAGES} Line 2046  ENABLED_PACKAGES = ${ENABLED_PACKAGES}
2046  DISABLED_PACKAGES = ${DISABLED_PACKAGES}  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
2047    
2048  # These files are created by Makefile  # These files are created by Makefile
2049  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
2050    
2051  EOF  EOF
2052    
# Line 1615  KPP = ${KPP} Line 2065  KPP = ${KPP}
2065  FC = ${FC}  FC = ${FC}
2066  # Fortran compiler  # Fortran compiler
2067  F90C = ${F90C}  F90C = ${F90C}
2068    # C compiler
2069    CC = ${CC}
2070  # Link editor  # Link editor
2071  LINK = ${LINK} ${LDADD}  LINK = ${LINK} ${LDADD}
2072    
# Line 1637  CFLAGS = ${CFLAGS} Line 2089  CFLAGS = ${CFLAGS}
2089  NOOPTFILES = ${NOOPTFILES}  NOOPTFILES = ${NOOPTFILES}
2090  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2091  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2092  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS}
2093  # Name of the Mekfile  # Name of the Mekfile
2094  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2095    
# Line 1648  cat csrclist.inc      >> $MAKEFILE Line 2100  cat csrclist.inc      >> $MAKEFILE
2100  cat f90srclist.inc    >> $MAKEFILE  cat f90srclist.inc    >> $MAKEFILE
2101  cat hlist.inc         >> $MAKEFILE  cat hlist.inc         >> $MAKEFILE
2102  cat ad_flow_files.inc >> $MAKEFILE  cat ad_flow_files.inc >> $MAKEFILE
2103  echo               >> $MAKEFILE  echo >> $MAKEFILE
2104  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE
2105  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE
2106  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
2107    echo >> $MAKEFILE
2108    echo '.SUFFIXES:' >> $MAKEFILE
2109    echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE
2110  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
2111  rm -f ad_flow_files.inc  rm -f ad_flow_files.inc
2112    
2113  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2114    
 .SUFFIXES:  
 .SUFFIXES: .o .f .p .F .c .F90 .f90  
   
2115  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
2116  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)
2117          @echo Creating \$@ ...          @echo Creating \$@ ...
2118          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2119  depend:  depend:
2120          @make links          @make links
2121          \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)
2122          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2123          -rm -f makedepend.out          -rm -f makedepend.out
2124    
2125    lib: libmitgcmuv.a
2126    
2127    libmitgcmuv.a: \$(OBJFILES)
2128            ar rcv libmitgcmuv.a \$(OBJFILES)
2129    
2130  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
2131    
2132  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77FILES) \$(F90FILES)
# Line 1680  output.txt: \$(EXECUTABLE) Line 2136  output.txt: \$(EXECUTABLE)
2136          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
2137    
2138  clean:  clean:
2139          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2140  Clean:  Clean:
2141          @make clean          @make clean
2142          @make cleanlinks          @make cleanlinks
# Line 1691  CLEAN: Line 2147  CLEAN:
2147          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2148          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2149          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2150          -rm -f \$(EXECUTABLE) output.txt          -rm -f \$(EXECUTABLE) output.txt STD*
2151    
2152  #eh3 Makefile: makefile  #eh3 Makefile: makefile
2153  makefile:  makefile:
# Line 1699  makefile: Line 2155  makefile:
2155  cleanlinks:  cleanlinks:
2156          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2157    
2158  # Special targets ($SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are create by make
2159  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2160          @echo Creating \$@ ...          @echo Creating \$@ ...
2161          @$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 2166  FC_NAMEMANGLE.h:
2166          @echo Creating \$@ ...          @echo Creating \$@ ...
2167          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
2168    
2169  # The normal chain of rules is (  .F - .f - .o  )  BUILD_INFO.h:
2170  .F.f:          @echo Creating \$@ ...
2171    EOF
2172    
2173    test ! "x$THISVER" = x  && echo "       -echo \"#define THISVER '$THISVER'\" > \$@"   >> $MAKEFILE
2174    test ! "x$THISUSER" = x && echo "       -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2175    test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2176    test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2177    
2178    cat >>$MAKEFILE <<EOF
2179    
2180    # The normal chain of rules is (  .F - .$FS - .o  )
2181    
2182    ## This nullifies any default implicit rules concerning these two file types:
2183    ## %.o : %.F
2184    
2185    .F.$FS:
2186          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2187  .f.o:  .$FS.o:
2188          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2189  .F90.f90:  .F90.$FS90:
2190          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2191  .f90.o:  .$FS90.o:
2192          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2193  .c.o:  .c.o:
2194          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) -c \$<
2195    
2196  # Special exceptions that use the ( .F - .p - .f - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2197  .F.p:  .F.p:
2198          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2199  .p.f:  .p.$FS:
2200          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
2201    
2202  #=========================================  #=========================================
# Line 1765  cat >>$MAKEFILE <<EOF Line 2236  cat >>$MAKEFILE <<EOF
2236    
2237  # ... AD ...  # ... AD ...
2238  adall: ad_taf  adall: ad_taf
2239  adtaf: ad_taf_output.f  adtaf: ad_taf_output.$FS
2240  adtamc: ad_tamc_output.f  adtamc: ad_tamc_output.$FS
2241    
2242  ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2243          @$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
2244          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
2245          -rm -f ad_config.template          -rm -f ad_config.template
2246          @make \$(F77FILES)          @make \$(F77FILES)
2247          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2248          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS
2249    
2250  ad_taf_output.f: ad_input_code.f  ad_taf_output.$FS: ad_input_code.$FS
2251          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2252          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
2253    
2254  adtafonly:  adtafonly:
2255          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2256          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
2257    
2258  ad_taf: ad_taf_output.o \$(OBJFILES)  ad_taf: ad_taf_output.o \$(OBJFILES)
2259          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2260    
2261  ad_tamc_output.f: ad_input_code.f  ad_tamc_output.$FS: ad_input_code.$FS
2262          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2263          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
2264    
2265  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2266          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2267    
2268    adonlyfwd:
2269            patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2270    
2271    adtrick:
2272            patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2273    
2274  # ... FTL ...  # ... FTL ...
2275  ftlall: ftl_taf  ftlall: ftl_taf
2276  ftltaf: ftl_taf_output.f  ftltaf: ftl_taf_output.$FS
2277  ftltamc: ftl_tamc_output.f  ftltamc: ftl_tamc_output.$FS
2278    
2279  ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2280          @$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
2281          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
2282          -rm -f ftl_config.template          -rm -f ftl_config.template
2283          @make \$(F77FILES)          @make \$(F77FILES)
2284          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2285          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2286    
2287  ftl_taf_output.f: ftl_input_code.f  ftl_taf_output.$FS: ftl_input_code.$FS
2288          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2289          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
2290    
2291  ftltafonly:  ftltafonly:
2292          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2293          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
2294    
2295  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
2296          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2297    
2298  ftl_tamc_output.f: ftl_input_code.f  ftl_tamc_output.$FS: ftl_input_code.$FS
2299          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2300          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
2301    
2302  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2303          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2304    
2305    
2306  # ... SVD ...  # ... SVD ...
2307  svdtaf: ad_taf_output.f ftl_taf_output.f  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
2308  svdall: svd_taf          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"
2309            @echo "--->>> Do make svdall afterwards to compile. <<<---"
2310    svdall: svd_touch svd_taf
2311    
2312  svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES)  svd_taf: \$(OBJFILES)
2313          \$(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)
2314    
2315            @echo "--->>> Only COMPILE svd code! <<<---"
2316            @echo "--->>> Assumes you previously <<<---"
2317            @echo "--->>> did make svdtaf        <<<---"
2318    
2319    svd_touch:
2320            @echo "--->>> Only COMPILE svd code! <<<---"
2321            @echo "--->>> Assumes you previously <<<---"
2322            @echo "--->>> did make svdtaf        <<<---"
2323            touch ad_taf_output.$FS ftl_taf_output.$FS
2324            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
2325            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
2326            @$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
2327            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2328            -rm -f ftl_config.template
2329    
2330  #=========================================  #=========================================
2331    
# Line 1850  for i in $KPPFILES ; do Line 2342  for i in $KPPFILES ; do
2342      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
2343          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
2344      fi      fi
2345      echo "$base.f: $base.p" >> $MAKEFILE      echo "$base.$FS: $base.p" >> $MAKEFILE
2346  done  done
2347    
2348  echo "  Making list of NOOPTFILES"  echo "  Making list of NOOPTFILES"
# Line 1860  for i in $NOOPTFILES ; do Line 2352  for i in $NOOPTFILES ; do
2352      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
2353          echo "Error: unable to add file \"$i\" to the exceptions list"          echo "Error: unable to add file \"$i\" to the exceptions list"
2354      fi      fi
2355      echo "$base.o: $base.f" >> $MAKEFILE      echo "$base.o: $base.$FS" >> $MAKEFILE
2356      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE      printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE
2357  done  done
2358    

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

  ViewVC Help
Powered by ViewVC 1.1.22