/[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.116 by edhill, Thu Jan 6 15:32:16 2005 UTC revision 1.138 by edhill, Sun Dec 4 13:57:08 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
127  .SUFFIXES:  .SUFFIXES:
128  .SUFFIXES: .$tfs .F  .SUFFIXES: .$tfs .F
129  .F.$tfs:  .F.$tfs:
# 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
# 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_SIGREG()  {
701        get_fortran_c_namemangling
702        cat <<EOF > genmake_tc_1.c
703    $FC_NAMEMANGLE
704    #include <stdlib.h>
705    #include <stdio.h>
706    #include <signal.h>
707    #include <errno.h>
708    #include <ucontext.h>
709    
710    int * ip;
711    
712    static void killhandler(
713        unsigned int sn, siginfo_t  si, struct ucontext *sc )
714    {
715        *ip = *ip + 1;
716        return;
717    }
718    
719    void FC_NAMEMANGLE(sigreg) (int * aip)
720    {
721        struct sigaction s;
722        ip = aip;
723        s.sa_flags = SA_SIGINFO;
724        s.sa_sigaction = (void *)killhandler;
725        if(sigaction (SIGTERM,&s,(struct sigaction *)NULL)) {
726            printf("Sigaction returned error = %d\n", errno);
727            exit(0);
728        }
729        return;
730    }
731    EOF
732        make genmake_tc_1.o >> genmake_warnings 2>&1
733        RET_C=$?
734        cat <<EOF > genmake_tc_2.$FS
735          program hello
736          integer anint
737          common /iv/ anint
738          external sigreg
739          call sigreg(anint)
740          end
741    EOF
742        echo >> genmake_warnings
743        echo "running: check_HAVE_SIGREG()" >> genmake_warnings
744        cat genmake_tc_2.$FS >> genmake_warnings
745        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
746        echo $COMM >> genmake_warnings
747        $COMM >> genmake_warnings 2>&1
748        RETVAL=$?
749        if test "x$RETVAL" = x0 ; then
750            HAVE_SIGREG=t
751            DEFINES="$DEFINES -DHAVE_SIGREG"
752        fi
753        rm -f genmake_tc*
754    }
755    
756    
757    check_HAVE_SETRLSTK()  {
758        get_fortran_c_namemangling
759        cat <<EOF > genmake_tc_1.c
760    $FC_NAMEMANGLE
761    #include <sys/time.h>
762    #include <sys/resource.h>
763    #include <unistd.h>
764    void FC_NAMEMANGLE(setrlstk) ()
765    {
766        struct rlimit rls;
767        rls.rlim_cur = RLIM_INFINITY;
768        rls.rlim_max = RLIM_INFINITY;
769        setrlimit(RLIMIT_STACK, &rls);
770        return;
771    }
772    EOF
773        make genmake_tc_1.o >> genmake_warnings 2>&1
774        RET_C=$?
775        cat <<EOF > genmake_tc_2.$FS
776          program hello
777          external setrlstk
778          call setrlstk()
779          end
780    EOF
781        echo >> genmake_warnings
782        echo "running: check_HAVE_SETRLSTK()" >> genmake_warnings
783        cat genmake_tc_2.$FS >> genmake_warnings
784        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
785        echo $COMM >> genmake_warnings
786        $COMM >> genmake_warnings 2>&1
787        RETVAL=$?
788        if test "x$RETVAL" = x0 ; then
789            HAVE_SETRLSTK=t
790            DEFINES="$DEFINES -DHAVE_SETRLSTK"
791        fi
792        rm -f genmake_tc*
793    }
794    
795    
796  check_HAVE_STAT()  {  check_HAVE_STAT()  {
797      get_fortran_c_namemangling      get_fortran_c_namemangling
798      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
# Line 698  void FC_NAMEMANGLE(tfsize) ( int *nbyte Line 816  void FC_NAMEMANGLE(tfsize) ( int *nbyte
816  EOF  EOF
817      make genmake_tc_1.o >> genmake_tc.log 2>&1      make genmake_tc_1.o >> genmake_tc.log 2>&1
818      RET_C=$?      RET_C=$?
819      cat <<EOF > genmake_tc_2.f      cat <<EOF > genmake_tc_2.$FS
820        program hello        program hello
821        integer nbyte        integer nbyte
822        call tfsize(nbyte)        call tfsize(nbyte)
823        print *," HELLO WORLD", nbyte        print *," HELLO WORLD", nbyte
824        end program hello        end
825  EOF  EOF
826      $FC $FFLAGS -o genmake_tc genmake_tc_2.f genmake_tc_1.o >> genmake_tc.log 2>&1      echo >> genmake_warnings
827      RET_F=$?      echo "running: check_HAVE_STAT()" >> genmake_warnings
828      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1      cat genmake_tc_2.$FS >> genmake_warnings
829        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
830        echo $COMM >> genmake_warnings
831        $COMM >> genmake_tc.log 2>&1
832      RETVAL=$?      RETVAL=$?
833      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
834          HAVE_STAT=t          HAVE_STAT=t
# Line 721  check_netcdf_libs()  { Line 842  check_netcdf_libs()  {
842      if test ! "x$SKIP_NETCDF_CHECK" = x ; then      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
843          return          return
844      fi      fi
845      echo "" > genmake_tnc.log      echo >> genmake_warnings
846      cat <<EOF > genmake_tnc.for      echo "running: check_netcdf_libs()" >> genmake_warnings
847        cat <<EOF > genmake_tnc.F
848        program fgennc        program fgennc
849  #include "netcdf.inc"  #include "netcdf.inc"
850  EOF  EOF
851      if test ! "x$MPI" = x ; then      if test ! "x$MPI" = x ; then
852          echo '#include "mpif.h"' >> genmake_tnc.for          echo '#include "mpif.h"' >> genmake_tnc.F
853      fi      fi
854      cat <<EOF >> genmake_tnc.for      cat <<EOF >> genmake_tnc.F
855        integer iret, ncid, xid        integer iret, ncid, xid
856        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)        iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
857        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
# Line 739  EOF Line 861  EOF
861        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
862        end        end
863  EOF  EOF
864      echo "Executing:" > genmake_tnc.log      echo "===  genmake_tnc.F  ===" > genmake_tnc.log
865      echo "  $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f" \      cat genmake_tnc.F >> genmake_tnc.log
866          > genmake_tnc.log      echo "===  genmake_tnc.F  ===" >> genmake_tnc.log
867      RET_CPP=f      RET_CPP=f
868      $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f 2>/dev/null  \      COMM="$CPP $DEFINES $INCLUDES genmake_tnc.F"
869          &&  RET_CPP=t      echo "$COMM" >> genmake_tnc.log
870        $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t
871      if test "x$RET_CPP" = xf ; then      if test "x$RET_CPP" = xf ; then
872          echo "  WARNING: CPP failed to pre-process the netcdf test." \          echo "  WARNING: CPP failed to pre-process the netcdf test." \
873              > genmake_tnc.log              >> genmake_tnc.log
874          echo "    Please check that \$INCLUDES is properly set." \          echo "    Please check that \$INCLUDES is properly set." \
875              > genmake_tnc.log              >> genmake_tnc.log
876      fi      fi
877      echo "Executing:" > genmake_tnc.log      echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log
878      echo "  $FC $FFLAGS $FOPTIM -c genmake_tnc.f" > genmake_tnc.log      echo "  &&  $LINK -o genmake_tnc.o $LIBS" >> genmake_tnc.log
879      echo "  $LINK -o genmake_tnc.o $LIBS" > genmake_tnc.log      $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
     $FC $FFLAGS $FOPTIM -c genmake_tnc.f >> genmake_tnc.log 2>&1  \  
880          &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1          &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1
881      RET_COMPILE=$?      RET_COMPILE=$?
882        cat genmake_tnc.log >> genmake_warnings
883    
884      #EH3  Remove test program execution for machines that either disallow      #EH3  Remove test program execution for machines that either disallow
885      #EH3  execution or cannot support it (eg. cross-compilers)      #EH3  execution or cannot support it (eg. cross-compilers)
# Line 769  EOF Line 892  EOF
892          HAVE_NETCDF=t          HAVE_NETCDF=t
893      else      else
894          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
895          $CPP $DEFINES $INCLUDES genmake_tnc.for > genmake_tnc.f 2>/dev/null  \          echo "try again with added '-lnetcdf'" > genmake_tnc.log
896              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.f >> genmake_tnc.log 2>&1  \          echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log
897            echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
898            echo " &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
899            $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
900                &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
901              &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1              &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1
902          RET_COMPILE=$?          RET_COMPILE=$?
903            cat genmake_tnc.log >> genmake_warnings
904          if test "x$RET_COMPILE" = x0 ; then          if test "x$RET_COMPILE" = x0 ; then
905              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
906              HAVE_NETCDF=t              HAVE_NETCDF=t
         else  
             cat genmake_tnc.log >> genmake_warnings  
907          fi          fi
908      fi      fi
909      rm -f genmake_tnc*      rm -f genmake_tnc*
# Line 804  DEFINES= Line 930  DEFINES=
930  PACKAGES=  PACKAGES=
931  ENABLE=  ENABLE=
932  DISABLE=  DISABLE=
933  MAKEFILE=  # MAKEFILE=
934  #MAKEDEPEND=  # MAKEDEPEND=
935  PDEPEND=  PDEPEND=
936  DUMPSTATE=t  DUMPSTATE=t
937  PDEFAULT=  PDEFAULT=
# Line 823  NOOPTFILES= Line 949  NOOPTFILES=
949  NOOPTFLAGS=  NOOPTFLAGS=
950  MPI=  MPI=
951  MPIPATH=  MPIPATH=
952    TS=
953    HAVE_TEST_L=
954    
955  # DEFINES checked by test compilation  # DEFINES checked by test compilation or command-line
956  HAVE_SYSTEM=  HAVE_SYSTEM=
957  HAVE_FDATE=  HAVE_FDATE=
958  FC_NAMEMANGLE=  FC_NAMEMANGLE=
959  HAVE_CLOC=  HAVE_CLOC=
960    HAVE_SETRLSTK=
961  HAVE_STAT=  HAVE_STAT=
962  HAVE_NETCDF=  HAVE_NETCDF=
963  HAVE_ETIME=  HAVE_ETIME=
964    IGNORE_TIME=
965    
966  MODS=  MODS=
967  TOOLSDIR=  TOOLSDIR=
# Line 877  TAMC_EXTRA= Line 1007  TAMC_EXTRA=
1007    
1008  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1009  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
1010  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE TS MPI JAM DUMPSTATE STANDARDDIRS"
1011    
1012  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1013  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 "
# Line 1057  for ac_option in "$@" ; do Line 1187  for ac_option in "$@" ; do
1187          -noieee | --noieee)          -noieee | --noieee)
1188              IEEE= ;;              IEEE= ;;
1189    
1190            -ts | --ts)
1191                TS=true ;;
1192    
1193          -mpi | --mpi)          -mpi | --mpi)
1194              MPI=true ;;              MPI=true ;;
1195          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
# Line 1080  for ac_option in "$@" ; do Line 1213  for ac_option in "$@" ; do
1213              ac_prev=TAMC_EXTRA ;;              ac_prev=TAMC_EXTRA ;;
1214          -tamc_extra=* | --tamc_extra=*)          -tamc_extra=* | --tamc_extra=*)
1215              TAMC_EXTRA=$ac_optarg ;;              TAMC_EXTRA=$ac_optarg ;;
1216            
1217            -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1218                IGNORE_TIME="-DIGNORE_TIME" ;;
1219    
1220          -*)          -*)
1221              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
# Line 1095  for ac_option in "$@" ; do Line 1231  for ac_option in "$@" ; do
1231            
1232  done  done
1233    
1234    
1235  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1236      echo      echo
1237      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 1136  fi Line 1273  fi
1273    
1274  #  Find the MITgcm ${THISVER}  #  Find the MITgcm ${THISVER}
1275  if test -f "${ROOTDIR}/doc/tag-index" ; then  if test -f "${ROOTDIR}/doc/tag-index" ; then
1276      THISVER=`grep checkpoint ${ROOTDIR}/doc/tag-index | head -1`      THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`
1277    fi
1278    
1279    if test "x$MAKEFILE" = x ; then
1280        MAKEFILE="Makefile"
1281  fi  fi
1282    
1283  echo "  getting OPTFILE information:  "  echo "  getting OPTFILE information:  "
# Line 1168  if test "x$OPTFILE" != xNONE ; then Line 1309  if test "x$OPTFILE" != xNONE ; then
1309      fi      fi
1310  fi  fi
1311    
 #  Check for broken systems that cannot correctly distinguish *.F and *.f files  
 # check_for_broken_Ff  
   
1312  echo "  getting AD_OPTFILE information:  "  echo "  getting AD_OPTFILE information:  "
1313  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1314      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" = x ; then
# Line 1198  if test "x${AD_OPTFILE}" != xNONE ; then Line 1336  if test "x${AD_OPTFILE}" != xNONE ; then
1336      fi      fi
1337  fi  fi
1338    
1339    #====================================================================
1340    #  Set default values if not set by the optfile
1341    #
1342  #  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,
1343  #  either set defaults or complain and abort!  #  either set defaults or complain and abort!
1344  if test ! "x$BASH" = x ; then  if test ! "x$BASH" = x ; then
# Line 1274  Error: The command "ln -s" failed -- ple Line 1415  Error: The command "ln -s" failed -- ple
1415  EOF  EOF
1416      exit 1      exit 1
1417  fi  fi
1418    test -L genmake_tlink > /dev/null 2>&1
1419    RETVAL=$?
1420    if test "x$RETVAL" = x0 ; then
1421        HAVE_TEST_L=t
1422    fi
1423  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
1424    
1425  #  Check for broken *.F/*.f handling and fix if possible  #  Check for broken *.F/*.f handling and fix if possible
# Line 1284  if test ! "x$MPI" = x ; then Line 1430  if test ! "x$MPI" = x ; then
1430        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1431  fi  fi
1432    
1433    if test ! "x$TS" = x ; then
1434          echo "  Turning on timing per timestep"
1435          DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1436    fi
1437    
1438  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1439  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1440  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1441        program hello        program hello
1442        call system('echo hi')        call system('echo hi')
1443        end        end
1444  EOF  EOF
1445  $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
1446  RETVAL=$?  RETVAL=$?
1447  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1448      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 1304  fi Line 1455  fi
1455  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1456    
1457  printf "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1458  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1459        program hello        program hello
1460        CHARACTER(128) string        CHARACTER*(128) string
1461        string = ' '        string = ' '
1462        call fdate( string )        call fdate( string )
1463        print *, string        print *, string
1464        end        end
1465  EOF  EOF
1466  $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
1467  RETVAL=$?  RETVAL=$?
1468  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1469      HAVE_FDATE=t      HAVE_FDATE=t
# Line 1325  fi Line 1476  fi
1476  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1477    
1478  printf "  Do we have the etime() command using $FC...  "  printf "  Do we have the etime() command using $FC...  "
1479  cat > genmake_tcomp.f <<EOF  cat > genmake_tcomp.$FS <<EOF
1480        program hello        program hello
1481        REAL*4 ACTUAL, TARRAY(2)        REAL*4 ACTUAL, TARRAY(2)
1482        EXTERNAL ETIME        EXTERNAL ETIME
# Line 1334  cat > genmake_tcomp.f <<EOF Line 1485  cat > genmake_tcomp.f <<EOF
1485        print *, tarray        print *, tarray
1486        end        end
1487  EOF  EOF
1488  $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
1489  RETVAL=$?  RETVAL=$?
1490  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1491      HAVE_ETIME=t      HAVE_ETIME=t
# Line 1355  else Line 1506  else
1506  fi  fi
1507  rm -f genmake_t*  rm -f genmake_t*
1508    
1509    printf "  Can we unlimit the stack size using $FC...  "
1510    check_HAVE_SETRLSTK
1511    if test "x$HAVE_SETRLSTK" != x ; then
1512        echo "yes"
1513    else
1514        echo "no"
1515    fi
1516    rm -f genmake_t*
1517    
1518    printf "  Can we register a signal handler using $FC...  "
1519    check_HAVE_SIGREG
1520    if test "x$HAVE_SIGREG" != x ; then
1521        echo "yes"
1522    else
1523        echo "no"
1524    fi
1525    rm -f genmake_t*
1526    
1527  printf "  Can we use stat() through C calls...  "  printf "  Can we use stat() through C calls...  "
1528  check_HAVE_STAT  check_HAVE_STAT
1529  if test "x$HAVE_STAT" != x ; then  if test "x$HAVE_STAT" != x ; then
# Line 1371  if test "x$HAVE_NETCDF" != x ; then Line 1540  if test "x$HAVE_NETCDF" != x ; then
1540  else  else
1541      echo "no"      echo "no"
1542  fi  fi
1543    DEFINES="$DEFINES $IGNORE_TIME"
1544    
1545  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1546  printf "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
# Line 1388  for d in $MODS ; do Line 1557  for d in $MODS ; do
1557  done  done
1558  echo  echo
1559    
 if test "x$MAKEFILE" = x ; then  
     MAKEFILE="Makefile"  
 fi  
1560  if test "x${PLATFORM}" = x ; then  if test "x${PLATFORM}" = x ; then
1561      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
1562  fi  fi
# Line 1813  for i in $SOURCEDIRS ; do Line 1979  for i in $SOURCEDIRS ; do
1979          cat $i/$j >> ad_files          cat $i/$j >> ad_files
1980      done      done
1981  done  done
1982    if test ! "x"$FS = "x.f" ; then
1983        cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f
1984        mv -f ad_files_f ad_files
1985    fi
1986    
1987  echo  echo
1988  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
# Line 1842  for d in $alldirs ; do Line 2011  for d in $alldirs ; do
2011      for sf in $sfiles ; do      for sf in $sfiles ; do
2012          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
2013              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2014                    ignore_f=f
2015                  case $d/$sf in                  case $d/$sf in
2016                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
2017                          ;;                          ;;
# Line 1852  for d in $alldirs ; do Line 2022  for d in $alldirs ; do
2022                    ./BUILD_INFO.h)                    ./BUILD_INFO.h)
2023                          ;;                          ;;
2024                    *)                    *)
2025                          touch .links.tmp/$sf                          #  For the local directory *ONLY*,
2026                          deplist="$deplist $sf"                          #  ignore all soft-links
2027                            if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
2028                                ignore_f=t
2029                            else
2030                                touch .links.tmp/$sf
2031                                deplist="$deplist $sf"
2032                            fi
2033                          ;;                          ;;
2034                  esac                  esac
2035                  extn=`echo $sf | $AWK -F. '{print $NF}'`                  if test "x$ignore_f" = xf ; then
2036                  case $extn in                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2037                      F)                      case $extn in
2038                          echo    " \\"  >> srclist.inc                          F)
2039                          printf " $sf" >> srclist.inc                              echo    " \\"  >> srclist.inc
2040                          ;;                              printf " $sf" >> srclist.inc
2041                      F90)                              ;;
2042                          echo    " \\"  >> f90srclist.inc                          F90)
2043                          printf " $sf" >> f90srclist.inc                              echo    " \\"  >> f90srclist.inc
2044                          ;;                              printf " $sf" >> f90srclist.inc
2045                      c)                              ;;
2046                          echo    " \\"  >> csrclist.inc                          c)
2047                          printf " $sf" >> csrclist.inc                              echo    " \\"  >> csrclist.inc
2048                          ;;                              printf " $sf" >> csrclist.inc
2049                      h)                              ;;
2050                          echo    " \\"  >> hlist.inc                          h)
2051                          printf " $sf" >> hlist.inc                              echo    " \\"  >> hlist.inc
2052                          ;;                              printf " $sf" >> hlist.inc
2053                      flow)                              ;;
2054                          echo    " \\"  >> ad_flow_files.inc                          flow)
2055                          printf " $sf" >> ad_flow_files.inc                              echo    " \\"  >> ad_flow_files.inc
2056                          ;;                              printf " $sf" >> ad_flow_files.inc
2057                  esac                              ;;
2058                        esac
2059                    fi
2060              fi              fi
2061          fi          fi
2062      done      done
# Line 2009  cat hlist.inc         >> $MAKEFILE Line 2187  cat hlist.inc         >> $MAKEFILE
2187  cat ad_flow_files.inc >> $MAKEFILE  cat ad_flow_files.inc >> $MAKEFILE
2188  echo >> $MAKEFILE  echo >> $MAKEFILE
2189  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE
2190  echo 'F90FILES =  $(F90SRCFILES:.F=.'$FS90')' >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE
2191  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
2192  echo >> $MAKEFILE  echo >> $MAKEFILE
2193  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
# Line 2029  depend: Line 2207  depend:
2207          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2208          -rm -f makedepend.out          -rm -f makedepend.out
2209    
2210    lib: libmitgcmuv.a
2211    
2212    libmitgcmuv.a: \$(OBJFILES)
2213            ar rcv libmitgcmuv.a \$(OBJFILES)
2214    
2215  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
2216    
2217  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77FILES) \$(F90FILES)
# Line 2138  cat >>$MAKEFILE <<EOF Line 2321  cat >>$MAKEFILE <<EOF
2321    
2322  # ... AD ...  # ... AD ...
2323  adall: ad_taf  adall: ad_taf
2324  adtaf: ad_taf_output.f  adtaf: ad_taf_output.$FS
2325  adtamc: ad_tamc_output.f  adtamc: ad_tamc_output.$FS
2326    
2327  ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2328          @$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
2329          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
2330          -rm -f ad_config.template          -rm -f ad_config.template
2331          @make \$(F77FILES)          @make \$(F77FILES)
2332          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2333          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS
2334    
2335  ad_taf_output.f: ad_input_code.f  ad_taf_output.$FS: ad_input_code.$FS
2336          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2337          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
2338    
2339  adtafonly:  adtafonly:
2340          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2341          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
2342    
2343  ad_taf: ad_taf_output.o \$(OBJFILES)  ad_taf: ad_taf_output.o \$(OBJFILES)
2344          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
2345    
2346  ad_tamc_output.f: ad_input_code.f  ad_tamc_output.$FS: ad_input_code.$FS
2347          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
2348          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
2349    
2350  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
2351          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
# Line 2175  adtrick: Line 2358  adtrick:
2358    
2359  # ... FTL ...  # ... FTL ...
2360  ftlall: ftl_taf  ftlall: ftl_taf
2361  ftltaf: ftl_taf_output.f  ftltaf: ftl_taf_output.$FS
2362  ftltamc: ftl_tamc_output.f  ftltamc: ftl_tamc_output.$FS
2363    
2364  ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)
2365          @$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
2366          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
2367          -rm -f ftl_config.template          -rm -f ftl_config.template
2368          @make \$(F77FILES)          @make \$(F77FILES)
2369          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2370          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2371    
2372  ftl_taf_output.f: ftl_input_code.f  ftl_taf_output.$FS: ftl_input_code.$FS
2373          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2374          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
2375    
2376  ftltafonly:  ftltafonly:
2377          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2378          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
2379    
2380  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
2381          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
2382    
2383  ftl_tamc_output.f: ftl_input_code.f  ftl_tamc_output.$FS: ftl_input_code.$FS
2384          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
2385          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
2386    
2387  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)  ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
2388          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
2389    
2390    
2391  # ... SVD ...  # ... SVD ...
2392  svdtaf: ad_taf_output.f ftl_taf_output.f  svdtaf: ad_taf_output.$FS ftl_taf_output.$FS
2393          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"          @echo "--->>> Only ran TAF to generate SVD code!    <<<---"
2394          @echo "--->>> Do make svdall afterwards to compile. <<<---"          @echo "--->>> Do make svdall afterwards to compile. <<<---"
2395  svdall: svd_touch svd_taf  svdall: svd_touch svd_taf
# Line 2222  svd_touch: Line 2405  svd_touch:
2405          @echo "--->>> Only COMPILE svd code! <<<---"          @echo "--->>> Only COMPILE svd code! <<<---"
2406          @echo "--->>> Assumes you previously <<<---"          @echo "--->>> Assumes you previously <<<---"
2407          @echo "--->>> did make svdtaf        <<<---"          @echo "--->>> did make svdtaf        <<<---"
2408          touch ad_taf_output.f ftl_taf_output.f          touch ad_taf_output.$FS ftl_taf_output.$FS
2409          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.f          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS
2410          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.f          \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS
2411          @$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
2412          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
2413          -rm -f ftl_config.template          -rm -f ftl_config.template

Legend:
Removed from v.1.116  
changed lines
  Added in v.1.138

  ViewVC Help
Powered by ViewVC 1.1.22