/[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.87 by edhill, Sat Jul 17 03:29:08 2004 UTC revision 1.125 by edhill, Sun Jul 10 00:15:49 2005 UTC
# Line 122  EOF Line 122  EOF
122        stop        stop
123        end        end
124  EOF  EOF
125      test -e Makefile  &&  mv -f Makefile Makefile.bak      test -f $MAKEFILE  &&  mv -f $MAKEFILE $MAKEFILE".tst"
126      cat <<EOF >> Makefile      cat <<EOF >> $MAKEFILE
 %.$tfs : %.F  
127  .SUFFIXES:  .SUFFIXES:
128  genmake_hello.$tfs: genmake_hello.F  .SUFFIXES: .$tfs .F
129          $LN genmake_hello.F genmake_hello.$tfs  .F.$tfs:
130            $LN \$< \$@
131  EOF  EOF
132      $MAKE "genmake_hello."$tfs > /dev/null 2>&1      $MAKE "genmake_hello."$tfs > /dev/null 2>&1
133      RETVAL=$?      RETVAL=$?
134      if test "x$RETVAL" != x0 -o ! -e "genmake_hello."$tfs ; then      if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then
135          if test "x$FS" = x ; then          if test "x$FS" = x ; then
136              FS='for'              FS='for'
137              FS90='fr9'              FS90='fr9'
# Line 148  EOF Line 148  EOF
148              return              return
149          fi          fi
150      fi      fi
151      rm -f genmake_hello.* Makefile      rm -f genmake_hello.* $MAKEFILE
152      test -e Makefile  &&  mv -f Makefile.bak Makefile      test -f $MAKEFILE".tst"  &&  mv -f $MAKEFILE".tst" $MAKEFILE
153    
154      #  If we make it here, use the extensions      #  If we make it here, use the extensions
155      FS=$tfs      FS=$tfs
# Line 181  look_for_makedepend()  { Line 181  look_for_makedepend()  {
181      if test "x${MAKEDEPEND}" = x ; then      if test "x${MAKEDEPEND}" = x ; then
182          which makedepend > /dev/null 2>&1          which makedepend > /dev/null 2>&1
183          RV0=$?          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          cat <<EOF >> genmake_tc.f
194        program test        program test
195        write(*,*) 'test'        write(*,*) 'test'
# Line 189  look_for_makedepend()  { Line 198  look_for_makedepend()  {
198  EOF  EOF
199          makedepend genmake_tc.f > /dev/null 2>&1          makedepend genmake_tc.f > /dev/null 2>&1
200          RV1=$?          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          if test "x${RV0}${RV1}" = x00 ; then
204              MAKEDEPEND=makedepend              MAKEDEPEND=makedepend
205          else          else
206              echo "    a system-default makedepend was not found."              echo "    a system-default makedepend was not found."
207                            
208              #  Try to build the cyrus implementation              #  Try to build the cyrus implementation
209              rm -f ./genmake_cy_md              build_cyrus_makedepend
             (  
                 cd $ROOTDIR/tools/cyrus-imapd-makedepend  \  
                     &&  ./configure > /dev/null 2>&1  \  
                     &&  make > /dev/null 2>&1  
                 if test -x ./makedepend.exe ; then  
                     $LN ./makedepend.exe ./makedepend  
                 fi  
                 ./makedepend ifparser.c > /dev/null 2>&1  \  
                     &&  echo "true"  
             ) > ./genmake_cy_md  
             grep true ./genmake_cy_md > /dev/null 2>&1  
210              RETVAL=$?              RETVAL=$?
211              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" != x0 ; then
                 MAKEDEPEND='$(TOOLSDIR)/cyrus-imapd-makedepend/makedepend'  
             else  
212                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'                  MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
213              fi              fi
214              rm -f ./genmake_cy_md              rm -f ./genmake_cy_md
215          fi          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      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 251  find_possible_configs()  { Line 280  find_possible_configs()  {
280    
281      look_for_makedepend      look_for_makedepend
282    
283      # look for possible fortran compilers      #================================================================
284      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"      #  look for possible C compilers
285        tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc"
286        p_CC=
287        for c in $tmp ; do
288            rm -f ./genmake_hello.c  ./genmake_hello
289            cat >> genmake_hello.c << EOF
290    #include <stdio.h>
291    int main(int argc, char **argv) {
292      printf("Hello!\n");
293      return 0;
294    }
295    EOF
296            $c -o genmake_hello genmake_hello.c > /dev/null 2>&1
297            RETVAL=$?
298            if test "x${RETVAL}" = x0 ; then
299                p_CC="$p_CC $c"
300            fi
301        done
302        rm -f ./genmake_hello.c ./genmake_hello
303        if test "x${p_CC}" = x ; then
304            cat 1>&2 <<EOF
305    
306    Error: No C compilers were found in your path.  Please specify one using:
307    
308        1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"),
309        2) the CC or MITGCM_CC environment variables.
310    
311    EOF
312            exit 1
313        else
314            echo "  The possible C compilers found in your path are:"
315            echo "   "$p_CC
316            if test "x$CC" = x ; then
317                CC=`echo $p_CC | $AWK '{print $1}'`
318                echo "  Setting C compiler to: "$CC
319            fi
320        fi
321    
322        #================================================================
323        #  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 277  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 448  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
# Line 457  Usage: "$0" [OPTIONS] Line 531  Usage: "$0" [OPTIONS]
531            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
532      -mpi=PATH | --mpi=PATH      -mpi=PATH | --mpi=PATH
533            Include MPI header files and link to MPI libraries using MPI_ROOT            Include MPI header files and link to MPI libraries using MPI_ROOT
534            set to PATH. i.e. Include files from $PATH/include, link to libraries            set to PATH. i.e. Include files from \$PATH/include, link to libraries
535            from $PATH/lib and use binaries from $PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
536    
537      -bash NAME      -bash NAME
538            Explicitly specify the Bourne or BASH shell to use            Explicitly specify the Bourne or BASH shell to use
# Line 483  EOF Line 557  EOF
557    
558  #  Build a CPP macro to automate calling C routines from FORTRAN  #  Build a CPP macro to automate calling C routines from FORTRAN
559  get_fortran_c_namemangling()  {  get_fortran_c_namemangling()  {
560    
561        #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\""
562        if test ! "x$FC_NAMEMANGLE" = x ; then
563            return 0
564        fi
565    
566      default_nm="#define FC_NAMEMANGLE(X) X ## _"      default_nm="#define FC_NAMEMANGLE(X) X ## _"
567            
568      cat > genmake_test.c <<EOF      cat > genmake_test.c <<EOF
# Line 500  WARNING: Please contact <MITgcm-support@ Line 580  WARNING: Please contact <MITgcm-support@
580  EOF  EOF
581          return 1          return 1
582      fi      fi
583      c_tcall=`nm genmake_test.o | grep 'T ' | grep tcall | cut -d ' ' -f 3`      c_tcall=`nm genmake_test.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
584      RETVAL=$?      RETVAL=$?
585      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
586          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 512  WARNING: Please contact <MITgcm-support@ Line 592  WARNING: Please contact <MITgcm-support@
592  EOF  EOF
593          return 1          return 1
594      fi      fi
595      cat > genmake_tcomp.f <<EOF      cat > genmake_tcomp.$FS <<EOF
596        subroutine tcall( string )        subroutine tcall( string )
597        character*(*) string        character*(*) string
598        call tsub( string )        call tsub( string )
599        end        end
600  EOF  EOF
601      $FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1      $FC $FFLAGS $DEFINES -c genmake_tcomp.$FS >> genmake_warnings 2>&1
602      RETVAL=$?      RETVAL=$?
603      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
604          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 530  WARNING: Please contact <MITgcm-support@ Line 610  WARNING: Please contact <MITgcm-support@
610  EOF  EOF
611          return 1          return 1
612      fi      fi
613      f_tcall=`nm genmake_tcomp.o | grep 'T ' | grep tcall | cut -d ' ' -f 3`      f_tcall=`nm genmake_tcomp.o 2>/dev/null | grep 'T ' | grep tcall | cut -d ' ' -f 3`
614      RETVAL=$?      RETVAL=$?
615      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
616          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 584  void FC_NAMEMANGLE(cloc) ( double *curti Line 664  void FC_NAMEMANGLE(cloc) ( double *curti
664   *curtim = *curtim/1.E6;   *curtim = *curtim/1.E6;
665  }  }
666  EOF  EOF
667      make genmake_tc_1.o >> genmake_tc.log 2>&1      make genmake_tc_1.o >> genmake_warnings 2>&1
668      RET_C=$?      RET_C=$?
669      cat <<EOF > genmake_tc_2.f      cat <<EOF > genmake_tc_2.$FS
670        program hello        program hello
671        Real*8 wtime        Real*8 wtime
672        external cloc        external cloc
# Line 594  EOF Line 674  EOF
674        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
675        end program hello        end program hello
676  EOF  EOF
677      $FC $FFLAGS -o genmake_tc genmake_tc_2.f genmake_tc_1.o >> genmake_tc.log 2>&1      $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1
678      RET_F=$?      RET_F=$?
679      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1
680      RETVAL=$?      RETVAL=$?
681      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
682          HAVE_CLOC=t          HAVE_CLOC=t
# Line 606  EOF Line 686  EOF
686  }  }
687    
688    
689    check_HAVE_STAT()  {
690        get_fortran_c_namemangling
691        cat <<EOF > genmake_tc_1.c
692    $FC_NAMEMANGLE
693    #include <stdio.h>
694    #include <stdlib.h>
695    #include <unistd.h>
696    #include <sys/stat.h>
697    #include <sys/types.h>
698    void FC_NAMEMANGLE(tfsize) ( int *nbyte )
699    {
700        char name[512];
701        struct stat astat;
702    
703        name[0] = 'a'; name[1] = '\0';
704        if (! stat(name, &astat))
705            *nbyte = (int)(astat.st_size);
706        else
707            *nbyte = -1;
708    }
709    EOF
710        make genmake_tc_1.o >> genmake_tc.log 2>&1
711        RET_C=$?
712        cat <<EOF > genmake_tc_2.$FS
713          program hello
714          integer nbyte
715          call tfsize(nbyte)
716          print *," HELLO WORLD", nbyte
717          end program hello
718    EOF
719        $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_tc.log 2>&1
720        RET_F=$?
721        test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1
722        RETVAL=$?
723        if test "x$RETVAL" = x0 ; then
724            HAVE_STAT=t
725            DEFINES="$DEFINES -DHAVE_STAT"
726        fi
727        rm -f genmake_tc*
728    }
729    
730    
731  check_netcdf_libs()  {  check_netcdf_libs()  {
732      cat <<EOF > genmake_tnc.for      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
733            return
734        fi
735        echo "" > genmake_tnc.log
736        cat <<EOF > genmake_tnc.F
737        program fgennc        program fgennc
738  #include "netcdf.inc"  #include "netcdf.inc"
739    EOF
740        if test ! "x$MPI" = x ; then
741            echo '#include "mpif.h"' >> genmake_tnc.F
742        fi
743        cat <<EOF >> genmake_tnc.F
744        integer iret, ncid, xid        integer iret, ncid, xid
745        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
746        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
# Line 619  check_netcdf_libs()  { Line 750  check_netcdf_libs()  {
750        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
751        end        end
752  EOF  EOF
753      $CPP genmake_tnc.for > genmake_tnc.f  \      echo "Executing:" > genmake_tnc.log
754          &&  $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" \
755            > genmake_tnc.log
756        RET_CPP=f
757        $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
758            &&  RET_CPP=t
759        if test "x$RET_CPP" = xf ; then
760            echo "  WARNING: CPP failed to pre-process the netcdf test." \
761                > genmake_tnc.log
762            echo "    Please check that \$INCLUDES is properly set." \
763                > genmake_tnc.log
764        fi
765        echo "Executing:" > genmake_tnc.log
766        echo "  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS" > genmake_tnc.log
767        echo "  $LINK -o genmake_tnc.o $LIBS" > genmake_tnc.log
768        $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
769            &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
770      RET_COMPILE=$?      RET_COMPILE=$?
771      test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1  
772      RETVAL=$?      #EH3  Remove test program execution for machines that either disallow
773      if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then      #EH3  execution or cannot support it (eg. cross-compilers)
774        #EH3
775        #EH3 test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
776        #EH3 RETVAL=$?
777        #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
778    
779        if test "x$RET_COMPILE" = x0 ; then
780          HAVE_NETCDF=t          HAVE_NETCDF=t
781      else      else
782          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
783          $CPP genmake_tnc.for > genmake_tnc.f  \          $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
784              &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
785              $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1              &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
786          RET_COMPILE=$?          RET_COMPILE=$?
787          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  
788              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
789              HAVE_NETCDF=t              HAVE_NETCDF=t
790          else          else
# Line 657  PLATFORM= Line 807  PLATFORM=
807  LN=  LN=
808  S64=  S64=
809  KPP=  KPP=
810  FC=  #FC=
811  CPP=  #CC=gcc
812    #CPP=
813  LINK=  LINK=
814  DEFINES=  DEFINES=
815  PACKAGES=  PACKAGES=
816  ENABLE=  ENABLE=
817  DISABLE=  DISABLE=
818  MAKEFILE=  # MAKEFILE=
819  MAKEDEPEND=  # MAKEDEPEND=
820  PDEPEND=  PDEPEND=
821  DUMPSTATE=t  DUMPSTATE=t
822  PDEFAULT=  PDEFAULT=
823  OPTFILE=  OPTFILE=
824  INCLUDES="-I."  INCLUDES="-I. $INCLUDES"
825  FFLAGS=  FFLAGS=
826  FOPTIM=  FOPTIM=
827  CFLAGS=  CFLAGS=
# Line 684  NOOPTFLAGS= Line 835  NOOPTFLAGS=
835  MPI=  MPI=
836  MPIPATH=  MPIPATH=
837    
838  # DEFINES checked by test compilation  # DEFINES checked by test compilation or command-line
839  HAVE_SYSTEM=  HAVE_SYSTEM=
840  HAVE_FDATE=  HAVE_FDATE=
841  FC_NAMEMANGLE=  FC_NAMEMANGLE=
842  HAVE_CLOC=  HAVE_CLOC=
843    HAVE_STAT=
844  HAVE_NETCDF=  HAVE_NETCDF=
845  HAVE_ETIME=  HAVE_ETIME=
846    IGNORE_TIME=
847    
848  MODS=  MODS=
849  TOOLSDIR=  TOOLSDIR=
# Line 701  STANDARDDIRS="USE_THE_DEFAULT" Line 854  STANDARDDIRS="USE_THE_DEFAULT"
854  G2ARGS=  G2ARGS=
855  BASH=  BASH=
856  PWD=`pwd`  PWD=`pwd`
857  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
858  AWK=awk  test "x$AWK" = x   &&  AWK=awk
859  THISHOSTNAME=`hostname`  THISHOST=`hostname`
860  THISCWD=`pwd`  THISCWD=`pwd`
861  THISDATE=`date`  THISDATE=`date`
862    THISUSER=`echo $USER`
863    THISVER=
864  MACHINE=`uname -a`  MACHINE=`uname -a`
865  EXECUTABLE=  EXECUTABLE=
866  EXEHOOK=  EXEHOOK=
# Line 739  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STA Line 894  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STA
894  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
895  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 "
896  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
897  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
898  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
899  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
900    
# Line 771  for i in . $MODS ; do Line 926  for i in . $MODS ; do
926      fi      fi
927  done  done
928  printf "  getting local config information:  "  printf "  getting local config information:  "
929  if test -e $gm_local ; then  if test -f $gm_local ; then
930      echo "using $gm_local"      echo "using $gm_local"
931      . $gm_local      . $gm_local
932      # echo "DISABLE=$DISABLE"      # echo "DISABLE=$DISABLE"
# Line 780  else Line 935  else
935      echo "none found"      echo "none found"
936  fi  fi
937    
938  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
939  #OPTIONS=  #OPTIONS=
940  #n=0  #n=0
941  #for i ; do  #for i ; do
# Line 792  fi Line 947  fi
947  #done  #done
948  #parse_options  #parse_options
949  ac_prev=  ac_prev=
950  for ac_option in $@ ; do  for ac_option in "$@" ; do
951    
952      G2ARGS="$G2ARGS \"$ac_option\""      G2ARGS="$G2ARGS \"$ac_option\""
953    
# Line 888  for ac_option in $@ ; do Line 1043  for ac_option in $@ ; do
1043  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1044  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1045  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1046                        
1047            -cc | --cc)
1048                ac_prev=CC ;;
1049            -cc=* | --cc=*)
1050                CC=$ac_optarg ;;
1051            
1052          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1053              ac_prev=FC ;;              ac_prev=FC ;;
1054          -fc=* | --fc=*)          -fc=* | --fc=*)
# Line 932  for ac_option in $@ ; do Line 1092  for ac_option in $@ ; do
1092              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1093          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1094              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1095            
1096            -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1097                IGNORE_TIME="-DIGNORE_TIME" ;;
1098    
1099          -*)          -*)
1100              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
# Line 947  for ac_option in $@ ; do Line 1110  for ac_option in $@ ; do
1110            
1111  done  done
1112    
1113    
1114  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1115      echo      echo
1116      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 959  if test -f ./.genmakerc ; then Line 1123  if test -f ./.genmakerc ; then
1123      echo      echo
1124  fi  fi
1125    
1126    #  Find the MITgcm ${ROOTDIR}
1127  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1128      tmp=`echo $PWD | sed -e 's/\// /g' | awk '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1129      if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
1130          ROOTDIR=".."          ROOTDIR=".."
1131      else      else
# Line 985  if test ! -d ${ROOTDIR} ; then Line 1150  if test ! -d ${ROOTDIR} ; then
1150      exit 1      exit 1
1151  fi  fi
1152    
1153    #  Find the MITgcm ${THISVER}
1154    if test -f "${ROOTDIR}/doc/tag-index" ; then
1155        THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`
1156    fi
1157    
1158    if test "x$MAKEFILE" = x ; then
1159        MAKEFILE="Makefile"
1160    fi
1161    
1162  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
1163  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1164      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
# Line 1014  if test "x$OPTFILE" != xNONE ; then Line 1188  if test "x$OPTFILE" != xNONE ; then
1188      fi      fi
1189  fi  fi
1190    
 #  Check for broken systems that cannot correctly distinguish *.F and *.f files  
 # check_for_broken_Ff  
   
1191  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:  "
1192  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1193      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" = x ; then
# Line 1044  if test "x${AD_OPTFILE}" != xNONE ; then Line 1215  if test "x${AD_OPTFILE}" != xNONE ; then
1215      fi      fi
1216  fi  fi
1217    
1218  #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #====================================================================
1219    #  Set default values if not set by the optfile
1220    #
1221    #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1222  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1223  if test ! "x$BASH" = x ; then  if test ! "x$BASH" = x ; then
1224      # 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 1060  Error: no Fortran compiler: please speci Line 1234  Error: no Fortran compiler: please speci
1234  EOF  EOF
1235      exit 1      exit 1
1236  fi  fi
1237    if test "x$CC" = x ; then
1238        CC=cc
1239    #     cat <<EOF 1>&2
1240    # Error: no C compiler: please specify using one of the following:
1241    #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1242    #   2) the "-cc=XXX" command-line option
1243    #   3) the "./genmake_local" file
1244    # EOF
1245    #     exit 1
1246    fi
1247  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1248      LINK=$FC      LINK=$FC
1249  fi  fi
# Line 1122  fi Line 1306  fi
1306    
1307  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1308  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1309  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1310        program hello        program hello
1311        call system('echo hi')        call system('echo hi')
1312        end        end
1313  EOF  EOF
1314  $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
1315  RETVAL=$?  RETVAL=$?
1316  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1317      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 1140  fi Line 1324  fi
1324  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1325    
1326  printf "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1327  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1328        program hello        program hello
1329        CHARACTER(128) string        CHARACTER(128) string
1330        string = ' '        string = ' '
# Line 1148  cat > genmake_tcomp.f <<EOF Line 1332  cat > genmake_tcomp.f <<EOF
1332        print *, string        print *, string
1333        end        end
1334  EOF  EOF
1335  $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
1336  RETVAL=$?  RETVAL=$?
1337  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1338      HAVE_FDATE=t      HAVE_FDATE=t
# Line 1161  fi Line 1345  fi
1345  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1346    
1347  printf "  Do we have the etime() command using $FC...  "  printf "  Do we have the etime() command using $FC...  "
1348  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1349        program hello        program hello
1350        REAL*4 ACTUAL, TARRAY(2)        REAL*4 ACTUAL, TARRAY(2)
1351        EXTERNAL ETIME        EXTERNAL ETIME
# Line 1170  cat > genmake_tcomp.f <<EOF Line 1354  cat > genmake_tcomp.f <<EOF
1354        print *, tarray        print *, tarray
1355        end        end
1356  EOF  EOF
1357  $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
1358  RETVAL=$?  RETVAL=$?
1359  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1360      HAVE_ETIME=t      HAVE_ETIME=t
# Line 1191  else Line 1375  else
1375  fi  fi
1376  rm -f genmake_t*  rm -f genmake_t*
1377    
1378    printf "  Can we use stat() through C calls...  "
1379    check_HAVE_STAT
1380    if test "x$HAVE_STAT" != x ; then
1381        echo "yes"
1382    else
1383        echo "no"
1384    fi
1385    rm -f genmake_t*
1386    
1387  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1388  check_netcdf_libs  check_netcdf_libs
1389  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
# Line 1198  if test "x$HAVE_NETCDF" != x ; then Line 1391  if test "x$HAVE_NETCDF" != x ; then
1391  else  else
1392      echo "no"      echo "no"
1393  fi  fi
1394    DEFINES="$DEFINES $IGNORE_TIME"
1395    
1396  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1397  printf "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
# Line 1215  for d in $MODS ; do Line 1408  for d in $MODS ; do
1408  done  done
1409  echo  echo
1410    
 if test "x$MAKEFILE" = x ; then  
     MAKEFILE="Makefile"  
 fi  
1411  if test "x${PLATFORM}" = x ; then  if test "x${PLATFORM}" = x ; then
1412      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
1413  fi  fi
1414    
1415  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1416      tmp=`echo $PWD | sed -e 's/\// /g' | awk '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1417      if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then      if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1418          EXEDIR=../exe          EXEDIR=../exe
1419      else      else
# Line 1243  if test ! -d ${TOOLSDIR} ; then Line 1433  if test ! -d ${TOOLSDIR} ; then
1433      exit 1      exit 1
1434  fi  fi
1435  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1436      S64='$(TOOLSDIR)/set64bitConst.sh'      echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1437        RETVAL=$?
1438        if test "x${RETVAL}" = x0 ; then
1439            S64='$(TOOLSDIR)/set64bitConst.sh'
1440        else
1441            echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1442            RETVAL=$?
1443            if test "x${RETVAL}" = x0 ; then
1444                S64='$(TOOLSDIR)/set64bitConst.csh'
1445            else
1446                cat <<EOF
1447    
1448    ERROR: neither of the two default scripts:
1449    
1450        ${TOOLSDIR}/set64bitConst.sh
1451        ${TOOLSDIR}/set64bitConst.csh
1452    
1453      are working so please check paths or specify (with \$S64) a
1454      working version of this script.
1455    
1456    EOF
1457                exit 1
1458            fi
1459        fi
1460  fi  fi
1461  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1462    
# Line 1388  done Line 1601  done
1601  rm -f ./.tmp_pack  rm -f ./.tmp_pack
1602  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1603    
1604    #  Check availability of NetCDF and then either build the MNC template
1605    #  files or delete mnc from the list of available packages.
1606    echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1607    RETVAL=$?
1608    if test "x$RETVAL" = x0 ; then
1609        if test "x$HAVE_NETCDF" != xt ; then
1610            cat <<EOF
1611    
1612    *********************************************************************
1613    WARNING: the "mnc" package was enabled but tests failed to compile
1614      NetCDF applications.  Please check that:
1615    
1616      1) NetCDF is correctly installed for this compiler and
1617      2) the LIBS variable (within the "optfile") specifies the correct
1618           NetCDF library to link against.
1619    
1620      Due to this failure, the "mnc" package is now DISABLED.
1621    *********************************************************************
1622    
1623    EOF
1624            PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
1625            DISABLE="$DISABLE mnc"
1626        else
1627            ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
1628            RETVAL=$?
1629            if test "x${RETVAL}" = x0 ; then
1630                rm -f make_mnc.errors
1631            else
1632                echo "Error: problem encountered while building source files in pkg/mnc:"
1633                cat make_mnc.errors 1>&2
1634                exit 1
1635            fi
1636        fi
1637    fi
1638    
1639  echo "  applying package dependency rules"  echo "  applying package dependency rules"
1640  ck=  ck=
1641  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
# Line 1472  for i in $PACKAGES ; do Line 1720  for i in $PACKAGES ; do
1720      fi      fi
1721  done  done
1722    
 #  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  
   
1723  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
1724  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
1725  #  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 1518  for n in $names ; do Line 1739  for n in $names ; do
1739              fi              fi
1740          done          done
1741          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1742              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1743              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
1744          fi          fi
1745      fi      fi
1746  done  done
1747  ENABLED_PACKAGES=  ENABLED_PACKAGES=
1748  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1749      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`      def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1750      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1751  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
1752    
# Line 1609  for i in $SOURCEDIRS ; do Line 1830  for i in $SOURCEDIRS ; do
1830          cat $i/$j >> ad_files          cat $i/$j >> ad_files
1831      done      done
1832  done  done
1833    if test ! "x"$FS = "x.f" ; then
1834        cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f
1835        mv -f ad_files_f ad_files
1836    fi
1837    
1838  echo  echo
1839  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
# Line 1645  for d in $alldirs ; do Line 1869  for d in $alldirs ; do
1869                          ;;                          ;;
1870                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
1871                          ;;                          ;;
1872                      ./BUILD_INFO.h)
1873                            ;;
1874                    *)                    *)
1875                          touch .links.tmp/$sf                          touch .links.tmp/$sf
1876                          deplist="$deplist $sf"                          deplist="$deplist $sf"
1877                          ;;                          ;;
1878                  esac                  esac
1879                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`                  extn=`echo $sf | $AWK -F. '{print $NF}'`
1880                  case $extn in                  case $extn in
1881                      F)                      F)
1882                          echo    " \\"  >> srclist.inc                          echo    " \\"  >> srclist.inc
# Line 1690  echo "" >> f90srclist.inc Line 1916  echo "" >> f90srclist.inc
1916  echo "" >> hlist.inc  echo "" >> hlist.inc
1917  echo "" >> ad_flow_files.inc  echo "" >> ad_flow_files.inc
1918    
1919  if test -e $MAKEFILE ; then  if test -f $MAKEFILE ; then
1920      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
1921  fi  fi
1922  echo "  Writing makefile: $MAKEFILE"  echo "  Writing makefile: $MAKEFILE"
# Line 1701  echo "#    $THISDATE" >> $MAKEFILE Line 1927  echo "#    $THISDATE" >> $MAKEFILE
1927  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
1928  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
1929  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
1930  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
1931    
1932  EXE_AD=$EXECUTABLE"_ad"  EXE_AD=$EXECUTABLE"_ad"
1933  EXE_FTL=$EXECUTABLE"_ftl"  EXE_FTL=$EXECUTABLE"_ftl"
# Line 1747  ENABLED_PACKAGES = ${ENABLED_PACKAGES} Line 1973  ENABLED_PACKAGES = ${ENABLED_PACKAGES}
1973  DISABLED_PACKAGES = ${DISABLED_PACKAGES}  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
1974    
1975  # These files are created by Makefile  # These files are created by Makefile
1976  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
1977    
1978  EOF  EOF
1979    
# Line 1766  KPP = ${KPP} Line 1992  KPP = ${KPP}
1992  FC = ${FC}  FC = ${FC}
1993  # Fortran compiler  # Fortran compiler
1994  F90C = ${F90C}  F90C = ${F90C}
1995    # C compiler
1996    CC = ${CC}
1997  # Link editor  # Link editor
1998  LINK = ${LINK} ${LDADD}  LINK = ${LINK} ${LDADD}
1999    
# Line 1788  CFLAGS = ${CFLAGS} Line 2016  CFLAGS = ${CFLAGS}
2016  NOOPTFILES = ${NOOPTFILES}  NOOPTFILES = ${NOOPTFILES}
2017  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2018  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2019  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS}
2020  # Name of the Mekfile  # Name of the Mekfile
2021  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2022    
# Line 1849  makefile: Line 2077  makefile:
2077  cleanlinks:  cleanlinks:
2078          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2079    
2080  # Special targets ($SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are create by make
2081  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2082          @echo Creating \$@ ...          @echo Creating \$@ ...
2083          @$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 1860  FC_NAMEMANGLE.h: Line 2088  FC_NAMEMANGLE.h:
2088          @echo Creating \$@ ...          @echo Creating \$@ ...
2089          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
2090    
2091    BUILD_INFO.h:
2092            @echo Creating \$@ ...
2093    EOF
2094    
2095    test ! "x$THISVER" = x  && echo "       -echo \"#define THISVER '$THISVER'\" > \$@"   >> $MAKEFILE
2096    test ! "x$THISUSER" = x && echo "       -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2097    test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2098    test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2099    
2100    cat >>$MAKEFILE <<EOF
2101    
2102  # The normal chain of rules is (  .F - .$FS - .o  )  # The normal chain of rules is (  .F - .$FS - .o  )
2103    
2104  %.o : %.F  ## This nullifies any default implicit rules concerning these two file types:
2105    ## %.o : %.F
2106    
2107  .F.$FS:  .F.$FS:
2108          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
# Line 1918  cat >>$MAKEFILE <<EOF Line 2158  cat >>$MAKEFILE <<EOF
2158    
2159  # ... AD ...  # ... AD ...
2160  adall: ad_taf  adall: ad_taf
2161  adtaf: ad_taf_output.f  adtaf: ad_taf_output.$FS
2162  adtamc: ad_tamc_output.f  adtamc: ad_tamc_output.$FS
2163    
2164  ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2165          @$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
2166          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
2167          -rm -f ad_config.template          -rm -f ad_config.template
2168          @make \$(F77FILES)          @make \$(F77FILES)
2169          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2170          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS
2171    
2172  ad_taf_output.f: ad_input_code.f  ad_taf_output.$FS: ad_input_code.$FS
2173          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2174          cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2175    
2176  adtafonly:  adtafonly:
2177          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2178          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
2179    
2180  ad_taf: ad_taf_output.o \$(OBJFILES)  ad_taf: ad_taf_output.o \$(OBJFILES)
2181          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2182    
2183  ad_tamc_output.f: ad_input_code.f  ad_tamc_output.$FS: ad_input_code.$FS
2184          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2185          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
2186    
2187  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2188          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2189    
2190    adonlyfwd:
2191            patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2192    
2193    adtrick:
2194            patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2195    
2196  # ... FTL ...  # ... FTL ...
2197  ftlall: ftl_taf  ftlall: ftl_taf
2198  ftltaf: ftl_taf_output.f  ftltaf: ftl_taf_output.$FS
2199  ftltamc: ftl_tamc_output.f  ftltamc: ftl_tamc_output.$FS
2200    
2201  ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2202          @$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
2203          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
2204          -rm -f ftl_config.template          -rm -f ftl_config.template
2205          @make \$(F77FILES)          @make \$(F77FILES)
2206          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2207          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2208    
2209  ftl_taf_output.f: ftl_input_code.f  ftl_taf_output.$FS: ftl_input_code.$FS
2210          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2211          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2212    
2213  ftltafonly:  ftltafonly:
2214          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2215          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
2216    
2217  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
2218          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2219    
2220  ftl_tamc_output.f: ftl_input_code.f  ftl_tamc_output.$FS: ftl_input_code.$FS
2221          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2222          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
2223    
2224  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2225          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2226    
2227    
2228  # ... SVD ...  # ... SVD ...
2229  svdtaf: ad_taf_output.f ftl_taf_output.f  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
2230  svdall: svd_taf          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"
2231            @echo "--->>> Do make svdall afterwards to compile. <<<---"
2232    svdall: svd_touch svd_taf
2233    
2234  svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES)  svd_taf: \$(OBJFILES)
2235          \$(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)
2236    
2237            @echo "--->>> Only COMPILE svd code! <<<---"
2238            @echo "--->>> Assumes you previously <<<---"
2239            @echo "--->>> did make svdtaf        <<<---"
2240    
2241    svd_touch:
2242            @echo "--->>> Only COMPILE svd code! <<<---"
2243            @echo "--->>> Assumes you previously <<<---"
2244            @echo "--->>> did make svdtaf        <<<---"
2245            touch ad_taf_output.$FS ftl_taf_output.$FS
2246            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
2247            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
2248            @$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
2249            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2250            -rm -f ftl_config.template
2251    
2252  #=========================================  #=========================================
2253    

Legend:
Removed from v.1.87  
changed lines
  Added in v.1.125

  ViewVC Help
Powered by ViewVC 1.1.22