/[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.92 by edhill, Fri Jul 30 15:59:33 2004 UTC revision 1.136 by edhill, Thu Nov 24 17:52:15 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
# Line 310  EOF Line 321  EOF
321    
322      #================================================================      #================================================================
323      #  look for possible FORTRAN compilers      #  look for possible FORTRAN compilers
324      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"      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 342  EOF Line 353  EOF
353      else      else
354          echo "  The possible FORTRAN compilers found in your path are:"          echo "  The possible FORTRAN compilers found in your path are:"
355          echo "   "$p_FC          echo "   "$p_FC
356          if test "x$FC" = x ; then      fi
357              FC=`echo $p_FC | $AWK '{print $1}'`  
358              echo "  Setting FORTRAN compiler to: "$FC      #  Use the first of the compilers found in the current PATH
359          fi      #  that has a correctly-named optfile
360        if test "x$OPTFILE" = x  -a  "x$FC" = x ; then
361            for i in $p_FC ; do
362                OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
363                if test -r $OPTFILE ; then
364                    echo "  Setting OPTFILE to: "$OPTFILE
365                    break
366                fi
367            done
368      fi      fi
369    
370      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
# Line 516  Usage: "$0" [OPTIONS] Line 535  Usage: "$0" [OPTIONS]
535            *only* works if it is supported by the OPTFILE that            *only* works if it is supported by the OPTFILE that
536            is being used.            is being used.
537    
538        -ts | --ts
539              Produce timing information per timestep
540    
541      -mpi | --mpi      -mpi | --mpi
542            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
543      -mpi=PATH | --mpi=PATH      -mpi=PATH | --mpi=PATH
544            Include MPI header files and link to MPI libraries using MPI_ROOT            Include MPI header files and link to MPI libraries using MPI_ROOT
545            set to PATH. i.e. Include files from $PATH/include, link to libraries            set to PATH. i.e. Include files from \$PATH/include, link to libraries
546            from $PATH/lib and use binaries from $PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
547    
548      -bash NAME      -bash NAME
549            Explicitly specify the Bourne or BASH shell to use            Explicitly specify the Bourne or BASH shell to use
# Line 581  WARNING: Please contact <MITgcm-support@ Line 603  WARNING: Please contact <MITgcm-support@
603  EOF  EOF
604          return 1          return 1
605      fi      fi
606      cat > genmake_tcomp.f <<EOF      cat > genmake_tcomp.$FS <<EOF
607        subroutine tcall( string )        subroutine tcall( string )
608        character*(*) string        character*(*) string
609        call tsub( string )        call tsub( string )
610        end        end
611  EOF  EOF
612      $FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1      $FC $FFLAGS -c genmake_tcomp.$FS >> genmake_warnings 2>&1
613      RETVAL=$?      RETVAL=$?
614      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
615          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 653  void FC_NAMEMANGLE(cloc) ( double *curti Line 675  void FC_NAMEMANGLE(cloc) ( double *curti
675   *curtim = *curtim/1.E6;   *curtim = *curtim/1.E6;
676  }  }
677  EOF  EOF
678      make genmake_tc_1.o >> genmake_tc.log 2>&1      make genmake_tc_1.o >> genmake_warnings 2>&1
679      RET_C=$?      RET_C=$?
680      cat <<EOF > genmake_tc_2.f      cat <<EOF > genmake_tc_2.$FS
681        program hello        program hello
682        Real*8 wtime        REAL*8 wtime
683        external cloc        external cloc
684        call cloc(wtime)        call cloc(wtime)
685        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
686        end program hello        end
687  EOF  EOF
688      $FC $FFLAGS -o genmake_tc genmake_tc_2.f genmake_tc_1.o >> genmake_tc.log 2>&1      $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1
689      RET_F=$?      RET_F=$?
690      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1
691      RETVAL=$?      RETVAL=$?
692      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
693          HAVE_CLOC=t          HAVE_CLOC=t
# Line 675  EOF Line 697  EOF
697  }  }
698    
699    
700    check_HAVE_SETRLSTK()  {
701        get_fortran_c_namemangling
702        cat <<EOF > genmake_tc_1.c
703    $FC_NAMEMANGLE
704    #include <sys/time.h>
705    #include <sys/resource.h>
706    #include <unistd.h>
707    void FC_NAMEMANGLE(setrlstk) ()
708    {
709        struct rlimit rls;
710        rls.rlim_cur = RLIM_INFINITY;
711        rls.rlim_max = RLIM_INFINITY;
712        setrlimit(RLIMIT_STACK, &rls);
713        return;
714    }
715    EOF
716        make genmake_tc_1.o >> genmake_warnings 2>&1
717        RET_C=$?
718        cat <<EOF > genmake_tc_2.$FS
719          program hello
720          external setrlstk
721          call setrlstk()
722          end
723    EOF
724        echo >> genmake_warnings
725        echo "running: check_HAVE_SETRLSTK()" >> genmake_warnings
726        cat genmake_tc_2.$FS >> genmake_warnings
727        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
728        echo $COMM >> genmake_warnings
729        $COMM >> genmake_warnings 2>&1
730        RETVAL=$?
731        if test "x$RETVAL" = x0 ; then
732            HAVE_SETRLSTK=t
733            DEFINES="$DEFINES -DHAVE_SETRLSTK"
734        fi
735        rm -f genmake_tc*
736    }
737    
738    
739    check_HAVE_STAT()  {
740        get_fortran_c_namemangling
741        cat <<EOF > genmake_tc_1.c
742    $FC_NAMEMANGLE
743    #include <stdio.h>
744    #include <stdlib.h>
745    #include <unistd.h>
746    #include <sys/stat.h>
747    #include <sys/types.h>
748    void FC_NAMEMANGLE(tfsize) ( int *nbyte )
749    {
750        char name[512];
751        struct stat astat;
752    
753        name[0] = 'a'; name[1] = '\0';
754        if (! stat(name, &astat))
755            *nbyte = (int)(astat.st_size);
756        else
757            *nbyte = -1;
758    }
759    EOF
760        make genmake_tc_1.o >> genmake_tc.log 2>&1
761        RET_C=$?
762        cat <<EOF > genmake_tc_2.$FS
763          program hello
764          integer nbyte
765          call tfsize(nbyte)
766          print *," HELLO WORLD", nbyte
767          end
768    EOF
769        echo >> genmake_warnings
770        echo "running: check_HAVE_STAT()" >> genmake_warnings
771        cat genmake_tc_2.$FS >> genmake_warnings
772        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
773        echo $COMM >> genmake_warnings
774        $COMM >> genmake_tc.log 2>&1
775        RETVAL=$?
776        if test "x$RETVAL" = x0 ; then
777            HAVE_STAT=t
778            DEFINES="$DEFINES -DHAVE_STAT"
779        fi
780        rm -f genmake_tc*
781    }
782    
783    
784  check_netcdf_libs()  {  check_netcdf_libs()  {
785      echo "" > genmake_tnc.log      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
786      cat <<EOF > genmake_tnc.for          return
787        fi
788        echo >> genmake_warnings
789        echo "running: check_netcdf_libs()" >> genmake_warnings
790        cat <<EOF > genmake_tnc.F
791        program fgennc        program fgennc
792  #include "netcdf.inc"  #include "netcdf.inc"
793    EOF
794        if test ! "x$MPI" = x ; then
795            echo '#include "mpif.h"' >> genmake_tnc.F
796        fi
797        cat <<EOF >> genmake_tnc.F
798        integer iret, ncid, xid        integer iret, ncid, xid
799        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
800        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
# Line 689  check_netcdf_libs()  { Line 804  check_netcdf_libs()  {
804        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
805        end        end
806  EOF  EOF
807      #echo "$CPP $DEFINES $INCLUDES"      echo "===  genmake_tnc.F  ===" > genmake_tnc.log
808      $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f 2>/dev/null  \      cat genmake_tnc.F >> genmake_tnc.log
809          &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1      echo "===  genmake_tnc.F  ===" >> genmake_tnc.log
810        RET_CPP=f
811        COMM="$CPP $DEFINES $INCLUDES genmake_tnc.F"
812        echo "$COMM" >> genmake_tnc.log
813        $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t
814        if test "x$RET_CPP" = xf ; then
815            echo "  WARNING: CPP failed to pre-process the netcdf test." \
816                >> genmake_tnc.log
817            echo "    Please check that \$INCLUDES is properly set." \
818                >> genmake_tnc.log
819        fi
820        echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log
821        echo "  &&  $LINK -o genmake_tnc.o $LIBS" >> genmake_tnc.log
822        $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
823            &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
824      RET_COMPILE=$?      RET_COMPILE=$?
825      test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1      cat genmake_tnc.log >> genmake_warnings
826      RETVAL=$?  
827      if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then      #EH3  Remove test program execution for machines that either disallow
828        #EH3  execution or cannot support it (eg. cross-compilers)
829        #EH3
830        #EH3 test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1
831        #EH3 RETVAL=$?
832        #EH3 if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then
833    
834        if test "x$RET_COMPILE" = x0 ; then
835          HAVE_NETCDF=t          HAVE_NETCDF=t
836      else      else
837          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
838          $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f 2>/dev/null  \          echo "try again with added '-lnetcdf'" > genmake_tnc.log
839              &&  $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \          echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log
840              $LIBS -lnetcdf >> genmake_tnc_2.log 2>&1          echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
841            echo " &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
842            $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
843                &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
844                &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
845          RET_COMPILE=$?          RET_COMPILE=$?
846          test -x ./genmake_tnc  &&  ./genmake_tnc >> genmake_tnc.log 2>&1          cat genmake_tnc.log >> genmake_warnings
847          RETVAL=$?          if test "x$RET_COMPILE" = x0 ; then
         if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then  
848              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
849              HAVE_NETCDF=t              HAVE_NETCDF=t
         else  
             cat genmake_tnc.log >> genmake_warnings  
850          fi          fi
851      fi      fi
852      rm -f genmake_tnc*      rm -f genmake_tnc*
# Line 728  PLATFORM= Line 865  PLATFORM=
865  LN=  LN=
866  S64=  S64=
867  KPP=  KPP=
868  FC=  #FC=
869  CC=  #CC=gcc
870  CPP=  #CPP=
871  LINK=  LINK=
872  DEFINES=  DEFINES=
873  PACKAGES=  PACKAGES=
874  ENABLE=  ENABLE=
875  DISABLE=  DISABLE=
876  MAKEFILE=  # MAKEFILE=
877  #MAKEDEPEND=  # MAKEDEPEND=
878  PDEPEND=  PDEPEND=
879  DUMPSTATE=t  DUMPSTATE=t
880  PDEFAULT=  PDEFAULT=
881  OPTFILE=  OPTFILE=
882  INCLUDES="-I."  INCLUDES="-I. $INCLUDES"
883  FFLAGS=  FFLAGS=
884  FOPTIM=  FOPTIM=
885  CFLAGS=  CFLAGS=
# Line 755  NOOPTFILES= Line 892  NOOPTFILES=
892  NOOPTFLAGS=  NOOPTFLAGS=
893  MPI=  MPI=
894  MPIPATH=  MPIPATH=
895    TS=
896    HAVE_TEST_L=
897    
898  # DEFINES checked by test compilation  # DEFINES checked by test compilation or command-line
899  HAVE_SYSTEM=  HAVE_SYSTEM=
900  HAVE_FDATE=  HAVE_FDATE=
901  FC_NAMEMANGLE=  FC_NAMEMANGLE=
902  HAVE_CLOC=  HAVE_CLOC=
903    HAVE_SETRLSTK=
904    HAVE_STAT=
905  HAVE_NETCDF=  HAVE_NETCDF=
906  HAVE_ETIME=  HAVE_ETIME=
907    IGNORE_TIME=
908    
909  MODS=  MODS=
910  TOOLSDIR=  TOOLSDIR=
# Line 773  STANDARDDIRS="USE_THE_DEFAULT" Line 915  STANDARDDIRS="USE_THE_DEFAULT"
915  G2ARGS=  G2ARGS=
916  BASH=  BASH=
917  PWD=`pwd`  PWD=`pwd`
918  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
919  AWK=awk  test "x$AWK" = x   &&  AWK=awk
920  THISHOSTNAME=`hostname`  THISHOST=`hostname`
921  THISCWD=`pwd`  THISCWD=`pwd`
922  THISDATE=`date`  THISDATE=`date`
923    THISUSER=`echo $USER`
924    THISVER=
925  MACHINE=`uname -a`  MACHINE=`uname -a`
926  EXECUTABLE=  EXECUTABLE=
927  EXEHOOK=  EXEHOOK=
# Line 806  TAMC_EXTRA= Line 950  TAMC_EXTRA=
950    
951  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
952  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
953  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE TS MPI JAM DUMPSTATE STANDARDDIRS"
954    
955  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
956  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "
957  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
958  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
959  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
960  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"  gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE HAVE_ETIME"
961    
# Line 852  else Line 996  else
996      echo "none found"      echo "none found"
997  fi  fi
998    
999  #  echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
1000  #OPTIONS=  #OPTIONS=
1001  #n=0  #n=0
1002  #for i ; do  #for i ; do
# Line 864  fi Line 1008  fi
1008  #done  #done
1009  #parse_options  #parse_options
1010  ac_prev=  ac_prev=
1011  for ac_option in $@ ; do  for ac_option in "$@" ; do
1012    
1013      G2ARGS="$G2ARGS \"$ac_option\""      G2ARGS="$G2ARGS \"$ac_option\""
1014    
# Line 986  for ac_option in $@ ; do Line 1130  for ac_option in $@ ; do
1130          -noieee | --noieee)          -noieee | --noieee)
1131              IEEE= ;;              IEEE= ;;
1132    
1133            -ts | --ts)
1134                TS=true ;;
1135    
1136          -mpi | --mpi)          -mpi | --mpi)
1137              MPI=true ;;              MPI=true ;;
1138          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
# Line 1009  for ac_option in $@ ; do Line 1156  for ac_option in $@ ; do
1156              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1157          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1158              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1159            
1160            -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1161                IGNORE_TIME="-DIGNORE_TIME" ;;
1162    
1163          -*)          -*)
1164              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
# Line 1024  for ac_option in $@ ; do Line 1174  for ac_option in $@ ; do
1174            
1175  done  done
1176    
1177    
1178  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1179      echo      echo
1180      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
# Line 1036  if test -f ./.genmakerc ; then Line 1187  if test -f ./.genmakerc ; then
1187      echo      echo
1188  fi  fi
1189    
1190    #  Find the MITgcm ${ROOTDIR}
1191  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
1192      tmp=`echo $PWD | sed -e 's/\// /g' | awk '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1193      if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
1194          ROOTDIR=".."          ROOTDIR=".."
1195      else      else
# Line 1062  if test ! -d ${ROOTDIR} ; then Line 1214  if test ! -d ${ROOTDIR} ; then
1214      exit 1      exit 1
1215  fi  fi
1216    
1217    #  Find the MITgcm ${THISVER}
1218    if test -f "${ROOTDIR}/doc/tag-index" ; then
1219        THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`
1220    fi
1221    
1222    if test "x$MAKEFILE" = x ; then
1223        MAKEFILE="Makefile"
1224    fi
1225    
1226  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
1227  if test "x${OPTFILE}" = x ; then  if test "x${OPTFILE}" = x ; then
1228      if test "x$MITGCM_OF" = x ; then      if test "x$MITGCM_OF" = x ; then
# Line 1091  if test "x$OPTFILE" != xNONE ; then Line 1252  if test "x$OPTFILE" != xNONE ; then
1252      fi      fi
1253  fi  fi
1254    
 #  Check for broken systems that cannot correctly distinguish *.F and *.f files  
 # check_for_broken_Ff  
   
1255  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:  "
1256  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1257      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" = x ; then
# Line 1121  if test "x${AD_OPTFILE}" != xNONE ; then Line 1279  if test "x${AD_OPTFILE}" != xNONE ; then
1279      fi      fi
1280  fi  fi
1281    
1282    #====================================================================
1283    #  Set default values if not set by the optfile
1284    #
1285  #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
1286  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1287  if test ! "x$BASH" = x ; then  if test ! "x$BASH" = x ; then
# Line 1138  EOF Line 1299  EOF
1299      exit 1      exit 1
1300  fi  fi
1301  if test "x$CC" = x ; then  if test "x$CC" = x ; then
1302      cat <<EOF 1>&2      CC=cc
1303    #     cat <<EOF 1>&2
1304  Error: no C compiler: please specify using one of the following:  # Error: no C compiler: please specify using one of the following:
1305    1) within the options file ("CC=...") as specified by "-of=OPTFILE"  #   1) within the options file ("CC=...") as specified by "-of=OPTFILE"
1306    2) the "-cc=XXX" command-line option  #   2) the "-cc=XXX" command-line option
1307    3) the "./genmake_local" file  #   3) the "./genmake_local" file
1308  EOF  # EOF
1309      exit 1  #     exit 1
1310  fi  fi
1311  if test "x$LINK" = x ; then  if test "x$LINK" = x ; then
1312      LINK=$FC      LINK=$FC
# Line 1197  Error: The command "ln -s" failed -- ple Line 1358  Error: The command "ln -s" failed -- ple
1358  EOF  EOF
1359      exit 1      exit 1
1360  fi  fi
1361    test -L genmake_tlink > /dev/null 2>&1
1362    RETVAL=$?
1363    if test "x$RETVAL" = x0 ; then
1364        HAVE_TEST_L=t
1365    fi
1366  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
1367    
1368  #  Check for broken *.F/*.f handling and fix if possible  #  Check for broken *.F/*.f handling and fix if possible
# Line 1207  if test ! "x$MPI" = x ; then Line 1373  if test ! "x$MPI" = x ; then
1373        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1374  fi  fi
1375    
1376    if test ! "x$TS" = x ; then
1377          echo "  Turning on timing per timestep"
1378          DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1379    fi
1380    
1381  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1382  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1383  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1384        program hello        program hello
1385        call system('echo hi')        call system('echo hi')
1386        end        end
1387  EOF  EOF
1388  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1389  RETVAL=$?  RETVAL=$?
1390  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1391      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 1227  fi Line 1398  fi
1398  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1399    
1400  printf "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1401  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1402        program hello        program hello
1403        CHARACTER(128) string        CHARACTER*(128) string
1404        string = ' '        string = ' '
1405        call fdate( string )        call fdate( string )
1406        print *, string        print *, string
1407        end        end
1408  EOF  EOF
1409  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1410  RETVAL=$?  RETVAL=$?
1411  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1412      HAVE_FDATE=t      HAVE_FDATE=t
# Line 1248  fi Line 1419  fi
1419  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1420    
1421  printf "  Do we have the etime() command using $FC...  "  printf "  Do we have the etime() command using $FC...  "
1422  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1423        program hello        program hello
1424        REAL*4 ACTUAL, TARRAY(2)        REAL*4 ACTUAL, TARRAY(2)
1425        EXTERNAL ETIME        EXTERNAL ETIME
# Line 1257  cat > genmake_tcomp.f <<EOF Line 1428  cat > genmake_tcomp.f <<EOF
1428        print *, tarray        print *, tarray
1429        end        end
1430  EOF  EOF
1431  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1432  RETVAL=$?  RETVAL=$?
1433  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1434      HAVE_ETIME=t      HAVE_ETIME=t
# Line 1278  else Line 1449  else
1449  fi  fi
1450  rm -f genmake_t*  rm -f genmake_t*
1451    
1452    printf "  Can we unlimit the stack size using $FC...  "
1453    check_HAVE_SETRLSTK
1454    if test "x$HAVE_SETRLSTK" != x ; then
1455        echo "yes"
1456    else
1457        echo "no"
1458    fi
1459    rm -f genmake_t*
1460    
1461    printf "  Can we use stat() through C calls...  "
1462    check_HAVE_STAT
1463    if test "x$HAVE_STAT" != x ; then
1464        echo "yes"
1465    else
1466        echo "no"
1467    fi
1468    rm -f genmake_t*
1469    
1470  printf "  Can we create NetCDF-enabled binaries...  "  printf "  Can we create NetCDF-enabled binaries...  "
1471  check_netcdf_libs  check_netcdf_libs
1472  if test "x$HAVE_NETCDF" != x ; then  if test "x$HAVE_NETCDF" != x ; then
# Line 1285  if test "x$HAVE_NETCDF" != x ; then Line 1474  if test "x$HAVE_NETCDF" != x ; then
1474  else  else
1475      echo "no"      echo "no"
1476  fi  fi
1477    DEFINES="$DEFINES $IGNORE_TIME"
1478    
1479  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1480  printf "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
# Line 1302  for d in $MODS ; do Line 1491  for d in $MODS ; do
1491  done  done
1492  echo  echo
1493    
 if test "x$MAKEFILE" = x ; then  
     MAKEFILE="Makefile"  
 fi  
1494  if test "x${PLATFORM}" = x ; then  if test "x${PLATFORM}" = x ; then
1495      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
1496  fi  fi
1497    
1498  if test "x${EXEDIR}" = x ; then  if test "x${EXEDIR}" = x ; then
1499      tmp=`echo $PWD | sed -e 's/\// /g' | awk '{print $NR}'`      tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'`
1500      if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then      if test "x$tmp" = "xbin" -a -d ../exe -a $ROOTDIR = .. ; then
1501          EXEDIR=../exe          EXEDIR=../exe
1502      else      else
# Line 1330  if test ! -d ${TOOLSDIR} ; then Line 1516  if test ! -d ${TOOLSDIR} ; then
1516      exit 1      exit 1
1517  fi  fi
1518  if test "x$S64" = x ; then  if test "x$S64" = x ; then
1519      S64='$(TOOLSDIR)/set64bitConst.sh'      echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.sh > /dev/null 2>&1
1520        RETVAL=$?
1521        if test "x${RETVAL}" = x0 ; then
1522            S64='$(TOOLSDIR)/set64bitConst.sh'
1523        else
1524            echo "3.0 _d 3" | ${TOOLSDIR}/set64bitConst.csh > /dev/null 2>&1
1525            RETVAL=$?
1526            if test "x${RETVAL}" = x0 ; then
1527                S64='$(TOOLSDIR)/set64bitConst.csh'
1528            else
1529                cat <<EOF
1530    
1531    ERROR: neither of the two default scripts:
1532    
1533        ${TOOLSDIR}/set64bitConst.sh
1534        ${TOOLSDIR}/set64bitConst.csh
1535    
1536      are working so please check paths or specify (with \$S64) a
1537      working version of this script.
1538    
1539    EOF
1540                exit 1
1541            fi
1542        fi
1543  fi  fi
1544  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`  THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'`
1545    
# Line 1475  done Line 1684  done
1684  rm -f ./.tmp_pack  rm -f ./.tmp_pack
1685  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
1686    
1687    #  Check availability of NetCDF and then either build the MNC template
1688    #  files or delete mnc from the list of available packages.
1689    echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
1690    RETVAL=$?
1691    if test "x$RETVAL" = x0 ; then
1692        if test "x$HAVE_NETCDF" != xt ; then
1693            cat <<EOF
1694    
1695    *********************************************************************
1696    WARNING: the "mnc" package was enabled but tests failed to compile
1697      NetCDF applications.  Please check that:
1698    
1699      1) NetCDF is correctly installed for this compiler and
1700      2) the LIBS variable (within the "optfile") specifies the correct
1701           NetCDF library to link against.
1702    
1703      Due to this failure, the "mnc" package is now DISABLED.
1704    *********************************************************************
1705    
1706    EOF
1707            PACKAGES=`echo $PACKAGES | sed -e 's/mnc//g'`
1708            DISABLE="$DISABLE mnc"
1709        else
1710            ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1
1711            RETVAL=$?
1712            if test "x${RETVAL}" = x0 ; then
1713                rm -f make_mnc.errors
1714            else
1715                echo "Error: problem encountered while building source files in pkg/mnc:"
1716                cat make_mnc.errors 1>&2
1717                exit 1
1718            fi
1719        fi
1720    fi
1721    
1722  echo "  applying package dependency rules"  echo "  applying package dependency rules"
1723  ck=  ck=
1724  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
# Line 1559  for i in $PACKAGES ; do Line 1803  for i in $PACKAGES ; do
1803      fi      fi
1804  done  done
1805    
 #  Build MNC templates and check for ability to build and use NetCDF  
 echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1  
 RETVAL=$?  
 if test "x$RETVAL" = x0 ; then  
     ( cd $ROOTDIR"/pkg/mnc" && $MAKE templates ) > make_mnc.errors 2>&1  
     RETVAL=$?  
     if test "x${RETVAL}" = x0 ; then  
         rm -f make_mnc.errors  
     else  
         echo "Error: problem encountered while building source files in pkg/mnc:"  
         cat make_mnc.errors 1>&2  
         exit 1  
     fi  
     if test "x$HAVE_NETCDF" != xt ; then  
         cat <<EOF  
   
 WARNING: the "mnc" package has been enabled but tests failed to  
   compile and/or execute NetCDF applications.  Please check that:  
   
   1) NetCDF is installed for your compiler and  
   2) the LIBS variable (within the 'optfile") specifies the correct  
        NetCDF library to link against.  
     
 EOF  
     fi  
 fi  
   
1806  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
1807  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
1808  #  The following UGLY HACK sets multiple "#undef"s and it needs to go  #  The following UGLY HACK sets multiple "#undef"s and it needs to go
# Line 1605  for n in $names ; do Line 1822  for n in $names ; do
1822              fi              fi
1823          done          done
1824          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1825              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1826              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"              DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef"
1827          fi          fi
1828      fi      fi
1829  done  done
1830  ENABLED_PACKAGES=  ENABLED_PACKAGES=
1831  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1832      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`      def=`echo "ALLOW_$i" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1833      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"      ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def"
1834  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
1835    
# Line 1696  for i in $SOURCEDIRS ; do Line 1913  for i in $SOURCEDIRS ; do
1913          cat $i/$j >> ad_files          cat $i/$j >> ad_files
1914      done      done
1915  done  done
1916    if test ! "x"$FS = "x.f" ; then
1917        cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f
1918        mv -f ad_files_f ad_files
1919    fi
1920    
1921  echo  echo
1922  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
# Line 1725  for d in $alldirs ; do Line 1945  for d in $alldirs ; do
1945      for sf in $sfiles ; do      for sf in $sfiles ; do
1946          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
1947              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
1948                    ignore_f=f
1949                  case $d/$sf in                  case $d/$sf in
1950                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
1951                          ;;                          ;;
# Line 1732  for d in $alldirs ; do Line 1953  for d in $alldirs ; do
1953                          ;;                          ;;
1954                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
1955                          ;;                          ;;
1956                      ./BUILD_INFO.h)
1957                            ;;
1958                    *)                    *)
1959                          touch .links.tmp/$sf                          #  For the local directory *ONLY*,
1960                          deplist="$deplist $sf"                          #  ignore all soft-links
1961                            if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
1962                                ignore_f=t
1963                            else
1964                                touch .links.tmp/$sf
1965                                deplist="$deplist $sf"
1966                            fi
1967                          ;;                          ;;
1968                  esac                  esac
1969                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`                  if test "x$ignore_f" = xf ; then
1970                  case $extn in                      extn=`echo $sf | $AWK -F. '{print $NF}'`
1971                      F)                      case $extn in
1972                          echo    " \\"  >> srclist.inc                          F)
1973                          printf " $sf" >> srclist.inc                              echo    " \\"  >> srclist.inc
1974                          ;;                              printf " $sf" >> srclist.inc
1975                      F90)                              ;;
1976                          echo    " \\"  >> f90srclist.inc                          F90)
1977                          printf " $sf" >> f90srclist.inc                              echo    " \\"  >> f90srclist.inc
1978                          ;;                              printf " $sf" >> f90srclist.inc
1979                      c)                              ;;
1980                          echo    " \\"  >> csrclist.inc                          c)
1981                          printf " $sf" >> csrclist.inc                              echo    " \\"  >> csrclist.inc
1982                          ;;                              printf " $sf" >> csrclist.inc
1983                      h)                              ;;
1984                          echo    " \\"  >> hlist.inc                          h)
1985                          printf " $sf" >> hlist.inc                              echo    " \\"  >> hlist.inc
1986                          ;;                              printf " $sf" >> hlist.inc
1987                      flow)                              ;;
1988                          echo    " \\"  >> ad_flow_files.inc                          flow)
1989                          printf " $sf" >> ad_flow_files.inc                              echo    " \\"  >> ad_flow_files.inc
1990                          ;;                              printf " $sf" >> ad_flow_files.inc
1991                  esac                              ;;
1992                        esac
1993                    fi
1994              fi              fi
1995          fi          fi
1996      done      done
# Line 1788  echo "#    $THISDATE" >> $MAKEFILE Line 2019  echo "#    $THISDATE" >> $MAKEFILE
2019  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2020  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $0 $G2ARGS" >> $MAKEFILE
2021  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2022  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2023    
2024  EXE_AD=$EXECUTABLE"_ad"  EXE_AD=$EXECUTABLE"_ad"
2025  EXE_FTL=$EXECUTABLE"_ftl"  EXE_FTL=$EXECUTABLE"_ftl"
# Line 1834  ENABLED_PACKAGES = ${ENABLED_PACKAGES} Line 2065  ENABLED_PACKAGES = ${ENABLED_PACKAGES}
2065  DISABLED_PACKAGES = ${DISABLED_PACKAGES}  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
2066    
2067  # These files are created by Makefile  # These files are created by Makefile
2068  SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h  SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h
2069    
2070  EOF  EOF
2071    
# Line 1850  MAKEDEPEND = ${MAKEDEPEND} Line 2081  MAKEDEPEND = ${MAKEDEPEND}
2081  # Special preprocessor (KAP on DECs, FPP on Crays)  # Special preprocessor (KAP on DECs, FPP on Crays)
2082  KPP = ${KPP}  KPP = ${KPP}
2083  # Fortran compiler  # Fortran compiler
2084  FC = ${FC} in  FC = ${FC}
2085  # Fortran compiler  # Fortran compiler
2086  F90C = ${F90C}  F90C = ${F90C}
2087  # C compiler  # C compiler
# Line 1877  CFLAGS = ${CFLAGS} Line 2108  CFLAGS = ${CFLAGS}
2108  NOOPTFILES = ${NOOPTFILES}  NOOPTFILES = ${NOOPTFILES}
2109  NOOPTFLAGS = ${NOOPTFLAGS}  NOOPTFLAGS = ${NOOPTFLAGS}
2110  # Flags and libraries needed for linking  # Flags and libraries needed for linking
2111  LIBS = ${LIBS} \$(XLIBS)  LIBS = ${LIBS}
2112  # Name of the Mekfile  # Name of the Mekfile
2113  MAKEFILE=${MAKEFILE}  MAKEFILE=${MAKEFILE}
2114    
# Line 1890  cat hlist.inc         >> $MAKEFILE Line 2121  cat hlist.inc         >> $MAKEFILE
2121  cat ad_flow_files.inc >> $MAKEFILE  cat ad_flow_files.inc >> $MAKEFILE
2122  echo >> $MAKEFILE  echo >> $MAKEFILE
2123  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE
2124  echo 'F90FILES =  $(F90SRCFILES:.F=.'$FS90')' >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE
2125  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
2126  echo >> $MAKEFILE  echo >> $MAKEFILE
2127  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
# Line 1910  depend: Line 2141  depend:
2141          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2142          -rm -f makedepend.out          -rm -f makedepend.out
2143    
2144    lib: libmitgcmuv.a
2145    
2146    libmitgcmuv.a: \$(OBJFILES)
2147            ar rcv libmitgcmuv.a \$(OBJFILES)
2148    
2149  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
2150    
2151  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77FILES) \$(F90FILES)
# Line 1938  makefile: Line 2174  makefile:
2174  cleanlinks:  cleanlinks:
2175          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2176    
2177  # Special targets ($SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are create by make
2178  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2179          @echo Creating \$@ ...          @echo Creating \$@ ...
2180          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@
# Line 1949  FC_NAMEMANGLE.h: Line 2185  FC_NAMEMANGLE.h:
2185          @echo Creating \$@ ...          @echo Creating \$@ ...
2186          echo "$FC_NAMEMANGLE" > \$@          echo "$FC_NAMEMANGLE" > \$@
2187    
2188    BUILD_INFO.h:
2189            @echo Creating \$@ ...
2190    EOF
2191    
2192    test ! "x$THISVER" = x  && echo "       -echo \"#define THISVER '$THISVER'\" > \$@"   >> $MAKEFILE
2193    test ! "x$THISUSER" = x && echo "       -echo \"#define THISUSER '$THISUSER'\" >> \$@" >> $MAKEFILE
2194    test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2195    test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2196    
2197    cat >>$MAKEFILE <<EOF
2198    
2199  # The normal chain of rules is (  .F - .$FS - .o  )  # The normal chain of rules is (  .F - .$FS - .o  )
2200    
2201  %.o : %.F  ## This nullifies any default implicit rules concerning these two file types:
2202    ## %.o : %.F
2203    
2204  .F.$FS:  .F.$FS:
2205          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
# Line 2007  cat >>$MAKEFILE <<EOF Line 2255  cat >>$MAKEFILE <<EOF
2255    
2256  # ... AD ...  # ... AD ...
2257  adall: ad_taf  adall: ad_taf
2258  adtaf: ad_taf_output.f  adtaf: ad_taf_output.$FS
2259  adtamc: ad_tamc_output.f  adtamc: ad_tamc_output.$FS
2260    
2261  ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2262          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template
2263          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2264          -rm -f ad_config.template          -rm -f ad_config.template
2265          @make \$(F77FILES)          @make \$(F77FILES)
2266          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2267          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS
2268    
2269  ad_taf_output.f: ad_input_code.f  ad_taf_output.$FS: ad_input_code.$FS
2270          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2271          cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2272    
2273  adtafonly:  adtafonly:
2274          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2275          cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
2276    
2277  ad_taf: ad_taf_output.o \$(OBJFILES)  ad_taf: ad_taf_output.o \$(OBJFILES)
2278          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2279    
2280  ad_tamc_output.f: ad_input_code.f  ad_tamc_output.$FS: ad_input_code.$FS
2281          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2282          cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.f          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
2283    
2284  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2285          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
2286    
2287    adonlyfwd:
2288            patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
2289    
2290    adtrick:
2291            patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
2292    
2293  # ... FTL ...  # ... FTL ...
2294  ftlall: ftl_taf  ftlall: ftl_taf
2295  ftltaf: ftl_taf_output.f  ftltaf: ftl_taf_output.$FS
2296  ftltamc: ftl_tamc_output.f  ftltamc: ftl_tamc_output.$FS
2297    
2298  ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2299          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template
2300          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2301          -rm -f ftl_config.template          -rm -f ftl_config.template
2302          @make \$(F77FILES)          @make \$(F77FILES)
2303          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2304          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2305    
2306  ftl_taf_output.f: ftl_input_code.f  ftl_taf_output.$FS: ftl_input_code.$FS
2307          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2308          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2309    
2310  ftltafonly:  ftltafonly:
2311          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2312          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2313    
2314  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
2315          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2316    
2317  ftl_tamc_output.f: ftl_input_code.f  ftl_tamc_output.$FS: ftl_input_code.$FS
2318          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2319          cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.f          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS
2320    
2321  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2322          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2323    
2324    
2325  # ... SVD ...  # ... SVD ...
2326  svdtaf: ad_taf_output.f ftl_taf_output.f  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
2327  svdall: svd_taf          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"
2328            @echo "--->>> Do make svdall afterwards to compile. <<<---"
2329    svdall: svd_touch svd_taf
2330    
2331  svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES)  svd_taf: \$(OBJFILES)
2332          \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS)          \$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS)
2333    
2334            @echo "--->>> Only COMPILE svd code! <<<---"
2335            @echo "--->>> Assumes you previously <<<---"
2336            @echo "--->>> did make svdtaf        <<<---"
2337    
2338    svd_touch:
2339            @echo "--->>> Only COMPILE svd code! <<<---"
2340            @echo "--->>> Assumes you previously <<<---"
2341            @echo "--->>> did make svdtaf        <<<---"
2342            touch ad_taf_output.$FS ftl_taf_output.$FS
2343            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
2344            \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
2345            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template
2346            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2347            -rm -f ftl_config.template
2348    
2349  #=========================================  #=========================================
2350    

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

  ViewVC Help
Powered by ViewVC 1.1.22