/[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.131 by edhill, Wed Sep 14 17:57:54 2005 UTC revision 1.139 by ce107, Thu Dec 22 01:22:27 2005 UTC
# Line 353  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 529  Usage: "$0" [OPTIONS] Line 537  Usage: "$0" [OPTIONS]
537    
538      -ts | --ts      -ts | --ts
539            Produce timing information per timestep            Produce timing information per timestep
540        -papis | --papis
541              Produce summary MFlop/s with PAPI per timestep
542        -foolad | --foolad
543              Fool the AD code generator
544        -papi | --papi
545              Performance analysis with PAPI
546        -hpmt | --hpmt
547              Performance analysis with the HPM Toolkit
548    
549        -gsl | --gsl
550              Use GSL to control floating point rounding and precision
551    
552      -mpi | --mpi      -mpi | --mpi
553            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
# Line 601  EOF Line 620  EOF
620        call tsub( string )        call tsub( string )
621        end        end
622  EOF  EOF
623      $FC $FFLAGS $DEFINES -c genmake_tcomp.$FS >> genmake_warnings 2>&1      $FC $FFLAGS -c genmake_tcomp.$FS >> genmake_warnings 2>&1
624      RETVAL=$?      RETVAL=$?
625      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
626          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 689  EOF Line 708  EOF
708  }  }
709    
710    
711    check_HAVE_SIGREG()  {
712        get_fortran_c_namemangling
713        cat <<EOF > genmake_tc_1.c
714    $FC_NAMEMANGLE
715    #include <stdlib.h>
716    #include <stdio.h>
717    #include <signal.h>
718    #include <errno.h>
719    #include <ucontext.h>
720    
721    int * ip;
722    
723    static void killhandler(
724        unsigned int sn, siginfo_t  si, struct ucontext *sc )
725    {
726        *ip = *ip + 1;
727        return;
728    }
729    
730    void FC_NAMEMANGLE(sigreg) (int * aip)
731    {
732        struct sigaction s;
733        ip = aip;
734        s.sa_flags = SA_SIGINFO;
735        s.sa_sigaction = (void *)killhandler;
736        if(sigaction (SIGTERM,&s,(struct sigaction *)NULL)) {
737            printf("Sigaction returned error = %d\n", errno);
738            exit(0);
739        }
740        return;
741    }
742    EOF
743        make genmake_tc_1.o >> genmake_warnings 2>&1
744        RET_C=$?
745        cat <<EOF > genmake_tc_2.$FS
746          program hello
747          integer anint
748          common /iv/ anint
749          external sigreg
750          call sigreg(anint)
751          end
752    EOF
753        echo >> genmake_warnings
754        echo "running: check_HAVE_SIGREG()" >> genmake_warnings
755        cat genmake_tc_2.$FS >> genmake_warnings
756        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
757        echo $COMM >> genmake_warnings
758        $COMM >> genmake_warnings 2>&1
759        RETVAL=$?
760        if test "x$RETVAL" = x0 ; then
761            HAVE_SIGREG=t
762            DEFINES="$DEFINES -DHAVE_SIGREG"
763        fi
764        rm -f genmake_tc*
765    }
766    
767    
768  check_HAVE_SETRLSTK()  {  check_HAVE_SETRLSTK()  {
769      get_fortran_c_namemangling      get_fortran_c_namemangling
770      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
# Line 713  EOF Line 789  EOF
789        call setrlstk()        call setrlstk()
790        end        end
791  EOF  EOF
792      $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1      echo >> genmake_warnings
793      RET_F=$?      echo "running: check_HAVE_SETRLSTK()" >> genmake_warnings
794      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1      cat genmake_tc_2.$FS >> genmake_warnings
795        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
796        echo $COMM >> genmake_warnings
797        $COMM >> genmake_warnings 2>&1
798      RETVAL=$?      RETVAL=$?
799      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
800          HAVE_SETRLSTK=t          HAVE_SETRLSTK=t
# Line 755  EOF Line 834  EOF
834        print *," HELLO WORLD", nbyte        print *," HELLO WORLD", nbyte
835        end        end
836  EOF  EOF
837      $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_tc.log 2>&1      echo >> genmake_warnings
838      RET_F=$?      echo "running: check_HAVE_STAT()" >> genmake_warnings
839      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1      cat genmake_tc_2.$FS >> genmake_warnings
840        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
841        echo $COMM >> genmake_warnings
842        $COMM >> genmake_tc.log 2>&1
843      RETVAL=$?      RETVAL=$?
844      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
845          HAVE_STAT=t          HAVE_STAT=t
# Line 771  check_netcdf_libs()  { Line 853  check_netcdf_libs()  {
853      if test ! "x$SKIP_NETCDF_CHECK" = x ; then      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
854          return          return
855      fi      fi
856      echo "" > genmake_tnc.log      echo >> genmake_warnings
857        echo "running: check_netcdf_libs()" >> genmake_warnings
858      cat <<EOF > genmake_tnc.F      cat <<EOF > genmake_tnc.F
859        program fgennc        program fgennc
860  #include "netcdf.inc"  #include "netcdf.inc"
# Line 789  EOF Line 872  EOF
872        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
873        end        end
874  EOF  EOF
875      echo "Executing:" > genmake_tnc.log      echo "===  genmake_tnc.F  ===" > genmake_tnc.log
876      echo "  $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS" \      cat genmake_tnc.F >> genmake_tnc.log
877          > genmake_tnc.log      echo "===  genmake_tnc.F  ===" >> genmake_tnc.log
878      RET_CPP=f      RET_CPP=f
879      $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \      COMM="$CPP $DEFINES $INCLUDES genmake_tnc.F"
880          &&  RET_CPP=t      echo "$COMM" >> genmake_tnc.log
881        $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t
882      if test "x$RET_CPP" = xf ; then      if test "x$RET_CPP" = xf ; then
883          echo "  WARNING: CPP failed to pre-process the netcdf test." \          echo "  WARNING: CPP failed to pre-process the netcdf test." \
884              > genmake_tnc.log              >> genmake_tnc.log
885          echo "    Please check that \$INCLUDES is properly set." \          echo "    Please check that \$INCLUDES is properly set." \
886              > genmake_tnc.log              >> genmake_tnc.log
887      fi      fi
888      echo "Executing:" > genmake_tnc.log      echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log
889      echo "  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS" > genmake_tnc.log      echo "  &&  $LINK -o genmake_tnc.o $LIBS" >> genmake_tnc.log
     echo "  $LINK -o genmake_tnc.o $LIBS" > genmake_tnc.log  
890      $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \      $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
891          &&  $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
892      RET_COMPILE=$?      RET_COMPILE=$?
893        cat genmake_tnc.log >> genmake_warnings
894    
895      #EH3  Remove test program execution for machines that either disallow      #EH3  Remove test program execution for machines that either disallow
896      #EH3  execution or cannot support it (eg. cross-compilers)      #EH3  execution or cannot support it (eg. cross-compilers)
# Line 819  EOF Line 903  EOF
903          HAVE_NETCDF=t          HAVE_NETCDF=t
904      else      else
905          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
906            echo "try again with added '-lnetcdf'" > genmake_tnc.log
907            echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log
908            echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
909            echo " &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
910          $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \          $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
911              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
912              &&  $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
913          RET_COMPILE=$?          RET_COMPILE=$?
914            cat genmake_tnc.log >> genmake_warnings
915          if test "x$RET_COMPILE" = x0 ; then          if test "x$RET_COMPILE" = x0 ; then
916              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
917              HAVE_NETCDF=t              HAVE_NETCDF=t
         else  
             cat genmake_tnc.log >> genmake_warnings  
918          fi          fi
919      fi      fi
920      rm -f genmake_tnc*      rm -f genmake_tnc*
# Line 874  NOOPTFLAGS= Line 961  NOOPTFLAGS=
961  MPI=  MPI=
962  MPIPATH=  MPIPATH=
963  TS=  TS=
964    PAPIS=
965    FOOLAD=
966    PAPI=
967    HPMT=
968    GSL=
969  HAVE_TEST_L=  HAVE_TEST_L=
970    
971  # DEFINES checked by test compilation or command-line  # DEFINES checked by test compilation or command-line
# Line 931  TAMC_EXTRA= Line 1023  TAMC_EXTRA=
1023    
1024  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1025  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
1026  gm_s2="FC CPP IEEE TS MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE TS PAPIS PAPI HPMT GSL MPI JAM DUMPSTATE STANDARDDIRS"
1027    
1028  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1029  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 1113  for ac_option in "$@" ; do Line 1205  for ac_option in "$@" ; do
1205    
1206          -ts | --ts)          -ts | --ts)
1207              TS=true ;;              TS=true ;;
1208            -papis | --papis)
1209                PAPIS=true ;;
1210            -foolad | --foolad)
1211                FOOLAD=true ;;
1212            -papi | --papi)
1213                PAPI=true ;;
1214            -hpmt | --hpmt)
1215                HPMT=true ;;
1216    
1217            -gsl | --gsl)
1218                GSL=true ;;
1219    
1220          -mpi | --mpi)          -mpi | --mpi)
1221              MPI=true ;;              MPI=true ;;
# Line 1356  fi Line 1459  fi
1459    
1460  if test ! "x$TS" = x ; then  if test ! "x$TS" = x ; then
1461        echo "  Turning on timing per timestep"        echo "  Turning on timing per timestep"
1462        DEFINES="$DEFINES -DTIME_PER_TIMESTEP"        if test ! "x$FOOLAD" = x ; then
1463                DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"
1464          else
1465                DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1466          fi
1467    fi
1468    if test ! "x$PAPIS" = x ; then
1469          echo "  Turning on PAPI flop summary per timestep"
1470          echo "  Please make sure PAPIINC, PAPILIB are defined"
1471          if test ! "x$FOOLAD" = x ; then
1472                DEFINES="$DEFINES -DUSE_PAPI_FLOPS_SFP"
1473          else
1474                DEFINES="$DEFINES -DUSE_PAPI_FLOPS"
1475          fi
1476          INCLUDES="$INCLUDES $PAPIINC"
1477          LIBS="$LIBS $PAPILIB"
1478    fi
1479    if test ! "x$PAPI" = x ; then
1480          if test ! "x$PAPIS" = x ; then
1481              echo "  PAPI performance analysis and flop summary per timestep cannot co-exist!"
1482              echo "  Sticking with PAPI flop summary per timestep!"
1483          else
1484              echo "  Turning on performance analysis with PAPI"
1485              echo "  Please make sure PAPIINC, PAPILIB are defined"
1486              DEFINES="$DEFINES -DUSE_PAPI"
1487              INCLUDES="$INCLUDES $PAPIINC"
1488              LIBS="$LIBS $PAPILIB"
1489          fi
1490    fi
1491    if test ! "x$HPMT" = x ; then
1492          if test ! "x$PAPI" = x ; then
1493              echo "  PAPI and the HPM Toolkit cannot co-exist!"
1494              echo "  Sticking with PAPI!"
1495          else
1496              echo "  Turning on performance analysis with the HPM Toolkit"
1497              echo "  Please make sure HPMTINC, HPMTLIB are defined"
1498              DEFINES="$DEFINES -DUSE_LIBHPM"
1499              INCLUDES="$INCLUDES $HPMTINC"
1500              LIBS="$LIBS $HPMTLIB"
1501          fi
1502    fi
1503    if test ! "x$GSL" = x ; then
1504          echo "  Turning on use of GSL to control floating point calculations"
1505          echo "  Please make sure GSLINC, GSLLIB are defined"
1506          DEFINES="$DEFINES -DUSE_GSL_IEEE"
1507          INCLUDES="$INCLUDES $GSLINC"
1508          LIBS="$LIBS $GSLLIB"
1509  fi  fi
1510    
1511  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
# Line 1366  cat > genmake_tcomp.$FS <<EOF Line 1515  cat > genmake_tcomp.$FS <<EOF
1515        call system('echo hi')        call system('echo hi')
1516        end        end
1517  EOF  EOF
1518  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1519  RETVAL=$?  RETVAL=$?
1520  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1521      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 1387  cat > genmake_tcomp.$FS <<EOF Line 1536  cat > genmake_tcomp.$FS <<EOF
1536        print *, string        print *, string
1537        end        end
1538  EOF  EOF
1539  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1540  RETVAL=$?  RETVAL=$?
1541  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1542      HAVE_FDATE=t      HAVE_FDATE=t
# Line 1409  cat > genmake_tcomp.$FS <<EOF Line 1558  cat > genmake_tcomp.$FS <<EOF
1558        print *, tarray        print *, tarray
1559        end        end
1560  EOF  EOF
1561  $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1
1562  RETVAL=$?  RETVAL=$?
1563  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1564      HAVE_ETIME=t      HAVE_ETIME=t
# Line 1439  else Line 1588  else
1588  fi  fi
1589  rm -f genmake_t*  rm -f genmake_t*
1590    
1591    printf "  Can we register a signal handler using $FC...  "
1592    check_HAVE_SIGREG
1593    if test "x$HAVE_SIGREG" != x ; then
1594        echo "yes"
1595    else
1596        echo "no"
1597    fi
1598    rm -f genmake_t*
1599    
1600  printf "  Can we use stat() through C calls...  "  printf "  Can we use stat() through C calls...  "
1601  check_HAVE_STAT  check_HAVE_STAT
1602  if test "x$HAVE_STAT" != x ; then  if test "x$HAVE_STAT" != x ; then
# Line 1908  for i in $INCLUDEDIRS ; do Line 2066  for i in $INCLUDEDIRS ; do
2066      fi      fi
2067  done  done
2068    
2069    echo "  Creating the pseudo-MPI include directory"
2070    if test ! "x$DIVA" = x ; then
2071        INCLUDES="-I./mpi_headers $INCLUDES"
2072        rm -rf ./mpi_headers
2073        mkdir -p ./mpi_headers
2074    
2075        if test "x$MPIINCLUDEDIR" = x ; then
2076            if test "x$MPIHOME" = x ; then
2077                MPIHOME='/usr'
2078            fi
2079            MPIINCLUDEDIR='$MPIHOME/include'
2080        fi
2081        
2082        if test -r $MPIINCLUDEDIR/mpif.h ; then
2083            for i in $MPI_HEADER_FILES; do
2084                cp -p $MPIINCLUDEDIR/$i ./mpi_headers
2085            done
2086    
2087            perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h
2088        else
2089            echo " We cannot create a copy of mpif.h!"
2090            exit -1
2091        fi
2092    fi
2093    
2094  echo "  Determining the list of source and include files"  echo "  Determining the list of source and include files"
2095  rm -rf .links.tmp  rm -rf .links.tmp
2096  mkdir .links.tmp  mkdir .links.tmp
# Line 2122  depend: Line 2305  depend:
2305          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2306          -rm -f makedepend.out          -rm -f makedepend.out
2307    
2308    lib: libmitgcmuv.a
2309    
2310    libmitgcmuv.a: \$(OBJFILES)
2311            ar rcv libmitgcmuv.a \$(OBJFILES)
2312    
2313  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
2314    
2315  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77FILES) \$(F90FILES)
# Line 2186  cat >>$MAKEFILE <<EOF Line 2374  cat >>$MAKEFILE <<EOF
2374  .$FS90.o:  .$FS90.o:
2375          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2376  .c.o:  .c.o:
2377          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
2378    
2379  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2380  .F.p:  .F.p:

Legend:
Removed from v.1.131  
changed lines
  Added in v.1.139

  ViewVC Help
Powered by ViewVC 1.1.22