/[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.88 by edhill, Tue Jul 20 19:43:45 2004 UTC revision 1.126 by ce107, Fri Aug 5 23:31:56 2005 UTC
# Line 122  EOF Line 122  EOF
122        stop        stop
123        end        end
124  EOF  EOF
125      test -f 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=$?
# 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 -f 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
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 483  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 500  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 512  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 530  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 584  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
# Line 594  EOF Line 677  EOF
677        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
678        end program hello        end program hello
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 606  EOF Line 689  EOF
689  }  }
690    
691    
692    check_HAVE_STAT()  {
693        get_fortran_c_namemangling
694        cat <<EOF > genmake_tc_1.c
695    $FC_NAMEMANGLE
696    #include <stdio.h>
697    #include <stdlib.h>
698    #include <unistd.h>
699    #include <sys/stat.h>
700    #include <sys/types.h>
701    void FC_NAMEMANGLE(tfsize) ( int *nbyte )
702    {
703        char name[512];
704        struct stat astat;
705    
706        name[0] = 'a'; name[1] = '\0';
707        if (! stat(name, &astat))
708            *nbyte = (int)(astat.st_size);
709        else
710            *nbyte = -1;
711    }
712    EOF
713        make genmake_tc_1.o >> genmake_tc.log 2>&1
714        RET_C=$?
715        cat <<EOF > genmake_tc_2.$FS
716          program hello
717          integer nbyte
718          call tfsize(nbyte)
719          print *," HELLO WORLD", nbyte
720          end program hello
721    EOF
722        $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_tc.log 2>&1
723        RET_F=$?
724        test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1
725        RETVAL=$?
726        if test "x$RETVAL" = x0 ; then
727            HAVE_STAT=t
728            DEFINES="$DEFINES -DHAVE_STAT"
729        fi
730        rm -f genmake_tc*
731    }
732    
733    
734  check_netcdf_libs()  {  check_netcdf_libs()  {
735      cat <<EOF > genmake_tnc.for      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
736            return
737        fi
738        echo "" > genmake_tnc.log
739        cat <<EOF > genmake_tnc.F
740        program fgennc        program fgennc
741  #include "netcdf.inc"  #include "netcdf.inc"
742    EOF
743        if test ! "x$MPI" = x ; then
744            echo '#include "mpif.h"' >> genmake_tnc.F
745        fi
746        cat <<EOF >> genmake_tnc.F
747        integer iret, ncid, xid        integer iret, ncid, xid
748        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
749        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
# Line 619  check_netcdf_libs()  { Line 753  check_netcdf_libs()  {
753        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
754        end        end
755  EOF  EOF
756      $CPP genmake_tnc.for > genmake_tnc.f  \      echo "Executing:" > genmake_tnc.log
757          &&  $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" \
758            > genmake_tnc.log
759        RET_CPP=f
760        $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
761            &&  RET_CPP=t
762        if test "x$RET_CPP" = xf ; then
763            echo "  WARNING: CPP failed to pre-process the netcdf test." \
764                > genmake_tnc.log
765            echo "    Please check that \$INCLUDES is properly set." \
766                > genmake_tnc.log
767        fi
768        echo "Executing:" > genmake_tnc.log
769        echo "  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS" > genmake_tnc.log
770        echo "  $LINK -o genmake_tnc.o $LIBS" > genmake_tnc.log
771        $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
772            &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
773      RET_COMPILE=$?      RET_COMPILE=$?
774      test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1  
775      RETVAL=$?      #EH3  Remove test program execution for machines that either disallow
776      if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then      #EH3  execution or cannot support it (eg. cross-compilers)
777        #EH3
778        #EH3 test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
779        #EH3 RETVAL=$?
780        #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
781    
782        if test "x$RET_COMPILE" = x0 ; then
783          HAVE_NETCDF=t          HAVE_NETCDF=t
784      else      else
785          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
786          $CPP genmake_tnc.for > genmake_tnc.f  \          $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
787              &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
788              $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1              &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
789          RET_COMPILE=$?          RET_COMPILE=$?
790          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  
791              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
792              HAVE_NETCDF=t              HAVE_NETCDF=t
793          else          else
# Line 657  PLATFORM= Line 810  PLATFORM=
810  LN=  LN=
811  S64=  S64=
812  KPP=  KPP=
813  FC=  #FC=
814  CPP=  #CC=gcc
815    #CPP=
816  LINK=  LINK=
817  DEFINES=  DEFINES=
818  PACKAGES=  PACKAGES=
819  ENABLE=  ENABLE=
820  DISABLE=  DISABLE=
821  MAKEFILE=  # MAKEFILE=
822  MAKEDEPEND=  # MAKEDEPEND=
823  PDEPEND=  PDEPEND=
824  DUMPSTATE=t  DUMPSTATE=t
825  PDEFAULT=  PDEFAULT=
826  OPTFILE=  OPTFILE=
827  INCLUDES="-I."  INCLUDES="-I. $INCLUDES"
828  FFLAGS=  FFLAGS=
829  FOPTIM=  FOPTIM=
830  CFLAGS=  CFLAGS=
# Line 683  NOOPTFILES= Line 837  NOOPTFILES=
837  NOOPTFLAGS=  NOOPTFLAGS=
838  MPI=  MPI=
839  MPIPATH=  MPIPATH=
840    TS=
841    
842  # DEFINES checked by test compilation  # DEFINES checked by test compilation or command-line
843  HAVE_SYSTEM=  HAVE_SYSTEM=
844  HAVE_FDATE=  HAVE_FDATE=
845  FC_NAMEMANGLE=  FC_NAMEMANGLE=
846  HAVE_CLOC=  HAVE_CLOC=
847    HAVE_STAT=
848  HAVE_NETCDF=  HAVE_NETCDF=
849  HAVE_ETIME=  HAVE_ETIME=
850    IGNORE_TIME=
851    
852  MODS=  MODS=
853  TOOLSDIR=  TOOLSDIR=
# Line 701  STANDARDDIRS="USE_THE_DEFAULT" Line 858  STANDARDDIRS="USE_THE_DEFAULT"
858  G2ARGS=  G2ARGS=
859  BASH=  BASH=
860  PWD=`pwd`  PWD=`pwd`
861  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
862  AWK=awk  test "x$AWK" = x   &&  AWK=awk
863  THISHOSTNAME=`hostname`  THISHOST=`hostname`
864  THISCWD=`pwd`  THISCWD=`pwd`
865  THISDATE=`date`  THISDATE=`date`
866    THISUSER=`echo $USER`
867    THISVER=
868  MACHINE=`uname -a`  MACHINE=`uname -a`
869  EXECUTABLE=  EXECUTABLE=
870  EXEHOOK=  EXEHOOK=
# Line 734  TAMC_EXTRA= Line 893  TAMC_EXTRA=
893    
894  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
895  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
896  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE TS MPI JAM DUMPSTATE STANDARDDIRS"
897    
898  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
899  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 "
900  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
901  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
902  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
903  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
904    
# Line 780  else Line 939  else
939      echo "none found"      echo "none found"
940  fi  fi
941    
942  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
943  #OPTIONS=  #OPTIONS=
944  #n=0  #n=0
945  #for i ; do  #for i ; do
# Line 792  fi Line 951  fi
951  #done  #done
952  #parse_options  #parse_options
953  ac_prev=  ac_prev=
954  for ac_option in $@ ; do  for ac_option in "$@" ; do
955    
956      G2ARGS="$G2ARGS \"$ac_option\""      G2ARGS="$G2ARGS \"$ac_option\""
957    
# Line 888  for ac_option in $@ ; do Line 1047  for ac_option in $@ ; do
1047  #               ac_prev=cpp ;;  #               ac_prev=cpp ;;
1048  #           -cpp=* | --cpp=*)  #           -cpp=* | --cpp=*)
1049  #               CPP=$ac_optarg ;;  #               CPP=$ac_optarg ;;
1050                        
1051            -cc | --cc)
1052                ac_prev=CC ;;
1053            -cc=* | --cc=*)
1054                CC=$ac_optarg ;;
1055            
1056          -fortran | --fortran | -fc | --fc)          -fortran | --fortran | -fc | --fc)
1057              ac_prev=FC ;;              ac_prev=FC ;;
1058          -fc=* | --fc=*)          -fc=* | --fc=*)
# Line 909  for ac_option in $@ ; do Line 1073  for ac_option in $@ ; do
1073          -noieee | --noieee)          -noieee | --noieee)
1074              IEEE= ;;              IEEE= ;;
1075    
1076            -ts | --ts)
1077                TS=true ;;
1078    
1079          -mpi | --mpi)          -mpi | --mpi)
1080              MPI=true ;;              MPI=true ;;
1081          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
# Line 932  for ac_option in $@ ; do Line 1099  for ac_option in $@ ; do
1099              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1100          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1101              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1102            
1103            -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1104                IGNORE_TIME="-DIGNORE_TIME" ;;
1105    
1106          -*)          -*)
1107              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
# Line 947  for ac_option in $@ ; do Line 1117  for ac_option in $@ ; do
1117            
1118  done  done
1119    
1120    
1121  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1122      echo      echo
1123      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 1130  if test -f ./.genmakerc ; then
1130      echo      echo
1131  fi  fi
1132    
1133    #  Find the MITgcm ${ROOTDIR}
1134  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1135      tmp=`echo $PWD | sed -e 's/\// /g' | awk '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1136      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
1137          ROOTDIR=".."          ROOTDIR=".."
1138      else      else
# Line 985  if test ! -d ${ROOTDIR} ; then Line 1157  if test ! -d ${ROOTDIR} ; then
1157      exit 1      exit 1
1158  fi  fi
1159    
1160    #  Find the MITgcm ${THISVER}
1161    if test -f "${ROOTDIR}/doc/tag-index" ; then
1162        THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`
1163    fi
1164    
1165    if test "x$MAKEFILE" = x ; then
1166        MAKEFILE="Makefile"
1167    fi
1168    
1169  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
1170  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1171      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
# Line 1014  if test "x$OPTFILE" != xNONE ; then Line 1195  if test "x$OPTFILE" != xNONE ; then
1195      fi      fi
1196  fi  fi
1197    
 #  Check for broken systems that cannot correctly distinguish *.F and *.f files  
 # check_for_broken_Ff  
   
1198  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:  "
1199  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1200      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 1222  if test "x${AD_OPTFILE}" != xNONE ; then
1222      fi      fi
1223  fi  fi
1224    
1225  #  Check that FC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #====================================================================
1226    #  Set default values if not set by the optfile
1227    #
1228    #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1229  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1230  if test ! "x$BASH" = x ; then  if test ! "x$BASH" = x ; then
1231      # 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 1241  Error: no Fortran compiler: please speci
1241  EOF  EOF
1242      exit 1      exit 1
1243  fi  fi
1244    if test "x$CC" = x ; then
1245        CC=cc
1246    #     cat <<EOF 1>&2
1247    # Error: no C compiler: please specify using one of the following:
1248    #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1249    #   2) the "-cc=XXX" command-line option
1250    #   3) the "./genmake_local" file
1251    # EOF
1252    #     exit 1
1253    fi
1254  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1255      LINK=$FC      LINK=$FC
1256  fi  fi
# Line 1120  if test ! "x$MPI" = x ; then Line 1311  if test ! "x$MPI" = x ; then
1311        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1312  fi  fi
1313    
1314    if test ! "x$TS" = x ; then
1315          echo "  Turning on timing per timestep"
1316          DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1317    fi
1318    
1319  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1320  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1321  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1322        program hello        program hello
1323        call system('echo hi')        call system('echo hi')
1324        end        end
1325  EOF  EOF
1326  $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
1327  RETVAL=$?  RETVAL=$?
1328  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1329      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 1140  fi Line 1336  fi
1336  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1337    
1338  printf "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1339  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1340        program hello        program hello
1341        CHARACTER(128) string        CHARACTER(128) string
1342        string = ' '        string = ' '
# Line 1148  cat > genmake_tcomp.f <<EOF Line 1344  cat > genmake_tcomp.f <<EOF
1344        print *, string        print *, string
1345        end        end
1346  EOF  EOF
1347  $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
1348  RETVAL=$?  RETVAL=$?
1349  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1350      HAVE_FDATE=t      HAVE_FDATE=t
# Line 1161  fi Line 1357  fi
1357  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1358    
1359  printf "  Do we have the etime() command using $FC...  "  printf "  Do we have the etime() command using $FC...  "
1360  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1361        program hello        program hello
1362        REAL*4 ACTUAL, TARRAY(2)        REAL*4 ACTUAL, TARRAY(2)
1363        EXTERNAL ETIME        EXTERNAL ETIME
# Line 1170  cat > genmake_tcomp.f <<EOF Line 1366  cat > genmake_tcomp.f <<EOF
1366        print *, tarray        print *, tarray
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_ETIME=t      HAVE_ETIME=t
# Line 1191  else Line 1387  else
1387  fi  fi
1388  rm -f genmake_t*  rm -f genmake_t*
1389    
1390    printf "  Can we use stat() through C calls...  "
1391    check_HAVE_STAT
1392    if test "x$HAVE_STAT" != x ; then
1393        echo "yes"
1394    else
1395        echo "no"
1396    fi
1397    rm -f genmake_t*
1398    
1399  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1400  check_netcdf_libs  check_netcdf_libs
1401  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
# Line 1198  if test "x$HAVE_NETCDF" != x ; then Line 1403  if test "x$HAVE_NETCDF" != x ; then
1403  else  else
1404      echo "no"      echo "no"
1405  fi  fi
1406    DEFINES="$DEFINES $IGNORE_TIME"
1407    
1408  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1409  printf "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
# Line 1215  for d in $MODS ; do Line 1420  for d in $MODS ; do
1420  done  done
1421  echo  echo
1422    
 if test "x$MAKEFILE" = x ; then  
     MAKEFILE="Makefile"  
 fi  
1423  if test "x${PLATFORM}" = x ; then  if test "x${PLATFORM}" = x ; then
1424      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
1425  fi  fi
1426    
1427  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1428      tmp=`echo $PWD | sed -e 's/\// /g' | awk '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1429      if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then      if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1430          EXEDIR=../exe          EXEDIR=../exe
1431      else      else
# Line 1243  if test ! -d ${TOOLSDIR} ; then Line 1445  if test ! -d ${TOOLSDIR} ; then
1445      exit 1      exit 1
1446  fi  fi
1447  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1448      S64='$(TOOLSDIR)/set64bitConst.sh'      echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1449        RETVAL=$?
1450        if test "x${RETVAL}" = x0 ; then
1451            S64='$(TOOLSDIR)/set64bitConst.sh'
1452        else
1453            echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1454            RETVAL=$?
1455            if test "x${RETVAL}" = x0 ; then
1456                S64='$(TOOLSDIR)/set64bitConst.csh'
1457            else
1458                cat <<EOF
1459    
1460    ERROR: neither of the two default scripts:
1461    
1462        ${TOOLSDIR}/set64bitConst.sh
1463        ${TOOLSDIR}/set64bitConst.csh
1464    
1465      are working so please check paths or specify (with \$S64) a
1466      working version of this script.
1467    
1468    EOF
1469                exit 1
1470            fi
1471        fi
1472  fi  fi
1473  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1474    
# Line 1388  done Line 1613  done
1613  rm -f ./.tmp_pack  rm -f ./.tmp_pack
1614  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1615    
1616    #  Check availability of NetCDF and then either build the MNC template
1617    #  files or delete mnc from the list of available packages.
1618    echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1619    RETVAL=$?
1620    if test "x$RETVAL" = x0 ; then
1621        if test "x$HAVE_NETCDF" != xt ; then
1622            cat <<EOF
1623    
1624    *********************************************************************
1625    WARNING: the "mnc" package was enabled but tests failed to compile
1626      NetCDF applications.  Please check that:
1627    
1628      1) NetCDF is correctly installed for this compiler and
1629      2) the LIBS variable (within the "optfile") specifies the correct
1630           NetCDF library to link against.
1631    
1632      Due to this failure, the "mnc" package is now DISABLED.
1633    *********************************************************************
1634    
1635    EOF
1636            PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
1637            DISABLE="$DISABLE mnc"
1638        else
1639            ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
1640            RETVAL=$?
1641            if test "x${RETVAL}" = x0 ; then
1642                rm -f make_mnc.errors
1643            else
1644                echo "Error: problem encountered while building source files in pkg/mnc:"
1645                cat make_mnc.errors 1>&2
1646                exit 1
1647            fi
1648        fi
1649    fi
1650    
1651  echo "  applying package dependency rules"  echo "  applying package dependency rules"
1652  ck=  ck=
1653  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
# Line 1472  for i in $PACKAGES ; do Line 1732  for i in $PACKAGES ; do
1732      fi      fi
1733  done  done
1734    
 #  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  
   
1735  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
1736  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
1737  #  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 1751  for n in $names ; do
1751              fi              fi
1752          done          done
1753          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1754              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1755              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
1756          fi          fi
1757      fi      fi
1758  done  done
1759  ENABLED_PACKAGES=  ENABLED_PACKAGES=
1760  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1761      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`      def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1762      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1763  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
1764    
# Line 1609  for i in $SOURCEDIRS ; do Line 1842  for i in $SOURCEDIRS ; do
1842          cat $i/$j >> ad_files          cat $i/$j >> ad_files
1843      done      done
1844  done  done
1845    if test ! "x"$FS = "x.f" ; then
1846        cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f
1847        mv -f ad_files_f ad_files
1848    fi
1849    
1850  echo  echo
1851  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
# Line 1645  for d in $alldirs ; do Line 1881  for d in $alldirs ; do
1881                          ;;                          ;;
1882                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
1883                          ;;                          ;;
1884                      ./BUILD_INFO.h)
1885                            ;;
1886                    *)                    *)
1887                          touch .links.tmp/$sf                          touch .links.tmp/$sf
1888                          deplist="$deplist $sf"                          deplist="$deplist $sf"
1889                          ;;                          ;;
1890                  esac                  esac
1891                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`                  extn=`echo $sf | $AWK -F. '{print $NF}'`
1892                  case $extn in                  case $extn in
1893                      F)                      F)
1894                          echo    " \\"  >> srclist.inc                          echo    " \\"  >> srclist.inc
# Line 1701  echo "#    $THISDATE" >> $MAKEFILE Line 1939  echo "#    $THISDATE" >> $MAKEFILE
1939  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
1940  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
1941  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
1942  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
1943    
1944  EXE_AD=$EXECUTABLE"_ad"  EXE_AD=$EXECUTABLE"_ad"
1945  EXE_FTL=$EXECUTABLE"_ftl"  EXE_FTL=$EXECUTABLE"_ftl"
# Line 1747  ENABLED_PACKAGES = ${ENABLED_PACKAGES} Line 1985  ENABLED_PACKAGES = ${ENABLED_PACKAGES}
1985  DISABLED_PACKAGES = ${DISABLED_PACKAGES}  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
1986    
1987  # These files are created by Makefile  # These files are created by Makefile
1988  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
1989    
1990  EOF  EOF
1991    
# Line 1766  KPP = ${KPP} Line 2004  KPP = ${KPP}
2004  FC = ${FC}  FC = ${FC}
2005  # Fortran compiler  # Fortran compiler
2006  F90C = ${F90C}  F90C = ${F90C}
2007    # C compiler
2008    CC = ${CC}
2009  # Link editor  # Link editor
2010  LINK = ${LINK} ${LDADD}  LINK = ${LINK} ${LDADD}
2011    
# Line 1788  CFLAGS = ${CFLAGS} Line 2028  CFLAGS = ${CFLAGS}
2028  NOOPTFILES = ${NOOPTFILES}  NOOPTFILES = ${NOOPTFILES}
2029  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2030  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2031  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS}
2032  # Name of the Mekfile  # Name of the Mekfile
2033  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2034    
# Line 1849  makefile: Line 2089  makefile:
2089  cleanlinks:  cleanlinks:
2090          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2091    
2092  # Special targets ($SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are create by make
2093  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2094          @echo Creating \$@ ...          @echo Creating \$@ ...
2095          @$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 2100  FC_NAMEMANGLE.h:
2100          @echo Creating \$@ ...          @echo Creating \$@ ...
2101          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
2102    
2103    BUILD_INFO.h:
2104            @echo Creating \$@ ...
2105    EOF
2106    
2107    test ! "x$THISVER" = x  && echo "       -echo \"#define THISVER '$THISVER'\" > \$@"   >> $MAKEFILE
2108    test ! "x$THISUSER" = x && echo "       -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2109    test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2110    test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2111    
2112    cat >>$MAKEFILE <<EOF
2113    
2114  # The normal chain of rules is (  .F - .$FS - .o  )  # The normal chain of rules is (  .F - .$FS - .o  )
2115    
2116  %.o : %.F  ## This nullifies any default implicit rules concerning these two file types:
2117    ## %.o : %.F
2118    
2119  .F.$FS:  .F.$FS:
2120          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
# Line 1918  cat >>$MAKEFILE <<EOF Line 2170  cat >>$MAKEFILE <<EOF
2170    
2171  # ... AD ...  # ... AD ...
2172  adall: ad_taf  adall: ad_taf
2173  adtaf: ad_taf_output.f  adtaf: ad_taf_output.$FS
2174  adtamc: ad_tamc_output.f  adtamc: ad_tamc_output.$FS
2175    
2176  ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2177          @$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
2178          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
2179          -rm -f ad_config.template          -rm -f ad_config.template
2180          @make \$(F77FILES)          @make \$(F77FILES)
2181          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2182          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS
2183    
2184  ad_taf_output.f: ad_input_code.f  ad_taf_output.$FS: ad_input_code.$FS
2185          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2186          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
2187    
2188  adtafonly:  adtafonly:
2189          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2190          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
2191    
2192  ad_taf: ad_taf_output.o \$(OBJFILES)  ad_taf: ad_taf_output.o \$(OBJFILES)
2193          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2194    
2195  ad_tamc_output.f: ad_input_code.f  ad_tamc_output.$FS: ad_input_code.$FS
2196          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2197          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
2198    
2199  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2200          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2201    
2202    adonlyfwd:
2203            patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2204    
2205    adtrick:
2206            patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2207    
2208  # ... FTL ...  # ... FTL ...
2209  ftlall: ftl_taf  ftlall: ftl_taf
2210  ftltaf: ftl_taf_output.f  ftltaf: ftl_taf_output.$FS
2211  ftltamc: ftl_tamc_output.f  ftltamc: ftl_tamc_output.$FS
2212    
2213  ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2214          @$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
2215          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
2216          -rm -f ftl_config.template          -rm -f ftl_config.template
2217          @make \$(F77FILES)          @make \$(F77FILES)
2218          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2219          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2220    
2221  ftl_taf_output.f: ftl_input_code.f  ftl_taf_output.$FS: ftl_input_code.$FS
2222          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2223          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
2224    
2225  ftltafonly:  ftltafonly:
2226          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2227          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
2228    
2229  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
2230          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2231    
2232  ftl_tamc_output.f: ftl_input_code.f  ftl_tamc_output.$FS: ftl_input_code.$FS
2233          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2234          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
2235    
2236  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2237          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2238    
2239    
2240  # ... SVD ...  # ... SVD ...
2241  svdtaf: ad_taf_output.f ftl_taf_output.f  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
2242  svdall: svd_taf          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"
2243            @echo "--->>> Do make svdall afterwards to compile. <<<---"
2244    svdall: svd_touch svd_taf
2245    
2246  svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES)  svd_taf: \$(OBJFILES)
2247          \$(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)
2248    
2249            @echo "--->>> Only COMPILE svd code! <<<---"
2250            @echo "--->>> Assumes you previously <<<---"
2251            @echo "--->>> did make svdtaf        <<<---"
2252    
2253    svd_touch:
2254            @echo "--->>> Only COMPILE svd code! <<<---"
2255            @echo "--->>> Assumes you previously <<<---"
2256            @echo "--->>> did make svdtaf        <<<---"
2257            touch ad_taf_output.$FS ftl_taf_output.$FS
2258            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
2259            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
2260            @$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
2261            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2262            -rm -f ftl_config.template
2263    
2264  #=========================================  #=========================================
2265    

Legend:
Removed from v.1.88  
changed lines
  Added in v.1.126

  ViewVC Help
Powered by ViewVC 1.1.22