/[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.124 by edhill, Tue Jun 7 20:52:42 2005 UTC revision 1.144 by edhill, Sat Mar 11 02:53:48 2006 UTC
# Line 248  build_cyrus_makedepend()  { Line 248  build_cyrus_makedepend()  {
248      fi      fi
249  }  }
250    
251    
252    build_embed_encode()
253    {
254        printf "  building the embed-encode utility...  "
255        if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then
256            if test ! -d "$ROOTDIR/tools/embed_encode" ; then
257                echo
258                echo "    Error: can't locate \"$ROOTDIR/tools/embed_encode\""
259                echo
260                EMBED_SRC=f
261                return 1
262            fi
263            clist="cc gcc c89 $CC"
264            for ic in $clist ; do
265                comm="$ic -o encode_files encode_files.c"
266                ( cd $ROOTDIR/tools/embed_encode && $comm ) > /dev/null 2>&1
267                RETVAL=$?
268                if test "x$RETVAL" = x0 ; then
269                    echo "OK"
270                    DEFINES="$DEFINES -DHAVE_EMBED_SRC"
271                    return 0
272                fi
273            done
274            echo
275            echo "    Error: unable to build $ROOTDIR/embed_encode/encode_files"
276            echo "      so it has been disabled"
277            echo
278            EMBED_SRC=f
279            return 1
280        fi
281        echo "OK"
282        DEFINES="$DEFINES -DHAVE_EMBED_SRC"
283    }
284    
285    
286  # Guess possible config options for this host  # Guess possible config options for this host
287  find_possible_configs()  {  find_possible_configs()  {
288    
# Line 353  EOF Line 388  EOF
388      else      else
389          echo "  The possible FORTRAN compilers found in your path are:"          echo "  The possible FORTRAN compilers found in your path are:"
390          echo "   "$p_FC          echo "   "$p_FC
391          if test "x$FC" = x ; then      fi
392              FC=`echo $p_FC | $AWK '{print $1}'`  
393              echo "  Setting FORTRAN compiler to: "$FC      #  Use the first of the compilers found in the current PATH
394          fi      #  that has a correctly-named optfile
395        if test "x$OPTFILE" = x  -a  "x$FC" = x ; then
396            for i in $p_FC ; do
397                OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i
398                if test -r $OPTFILE ; then
399                    echo "  Setting OPTFILE to: "$OPTFILE
400                    break
401                fi
402            done
403      fi      fi
404    
405      if test "x$OPTFILE" = x ; then      if test "x$OPTFILE" = x ; then
# Line 527  Usage: "$0" [OPTIONS] Line 570  Usage: "$0" [OPTIONS]
570            *only* works if it is supported by the OPTFILE that            *only* works if it is supported by the OPTFILE that
571            is being used.            is being used.
572    
573        -ignoretime | -ignore_time | --ignoretime | --ignore_time
574              Ignore all the "wall clock" routines entirely.  This will
575              not in any way hurt the model results -- it simply means
576              that the code that checks how long the model spends in
577              various routines will give junk values.
578    
579        -ts | --ts
580              Produce timing information per timestep
581        -papis | --papis
582              Produce summary MFlop/s with PAPI per timestep
583        -foolad | --foolad
584              Fool the AD code generator
585        -papi | --papi
586              Performance analysis with PAPI
587        -hpmt | --hpmt
588              Performance analysis with the HPM Toolkit
589    
590        -gsl | --gsl
591              Use GSL to control floating point rounding and precision
592    
593      -mpi | --mpi      -mpi | --mpi
594            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
595      -mpi=PATH | --mpi=PATH      -mpi=PATH | --mpi=PATH
# Line 534  Usage: "$0" [OPTIONS] Line 597  Usage: "$0" [OPTIONS]
597            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
598            from \$PATH/lib and use binaries from \$PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
599    
600        -es | --es | -embed-source | --embed-source
601              Embed a tarball containing the full source code
602              (including the Makefile, etc.) used to build the
603              executable [off by default]
604    
605      -bash NAME      -bash NAME
606            Explicitly specify the Bourne or BASH shell to use            Explicitly specify the Bourne or BASH shell to use
607    
# Line 598  EOF Line 666  EOF
666        call tsub( string )        call tsub( string )
667        end        end
668  EOF  EOF
669      $FC $FFLAGS $DEFINES -c genmake_tcomp.$FS >> genmake_warnings 2>&1      $FC $FFLAGS -c genmake_tcomp.$FS >> genmake_warnings 2>&1
670      RETVAL=$?      RETVAL=$?
671      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
672          FC_NAMEMANGLE=$default_nm          FC_NAMEMANGLE=$default_nm
# Line 668  EOF Line 736  EOF
736      RET_C=$?      RET_C=$?
737      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
738        program hello        program hello
739        Real*8 wtime        REAL*8 wtime
740        external cloc        external cloc
741        call cloc(wtime)        call cloc(wtime)
742        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
743        end program hello        end
744  EOF  EOF
745      $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1      $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1
746      RET_F=$?      RET_F=$?
# Line 686  EOF Line 754  EOF
754  }  }
755    
756    
757    check_HAVE_SIGREG()  {
758        get_fortran_c_namemangling
759        cat <<EOF > genmake_tc_1.c
760    $FC_NAMEMANGLE
761    #include <stdlib.h>
762    #include <stdio.h>
763    #include <signal.h>
764    #include <errno.h>
765    #include <ucontext.h>
766    
767    int * ip;
768    
769    static void killhandler(
770        unsigned int sn, siginfo_t  si, struct ucontext *sc )
771    {
772        *ip = *ip + 1;
773        return;
774    }
775    
776    void FC_NAMEMANGLE(sigreg) (int * aip)
777    {
778        struct sigaction s;
779        ip = aip;
780        s.sa_flags = SA_SIGINFO;
781        s.sa_sigaction = (void *)killhandler;
782        if(sigaction (SIGTERM,&s,(struct sigaction *)NULL)) {
783            printf("Sigaction returned error = %d\n", errno);
784            exit(0);
785        }
786        return;
787    }
788    EOF
789        make genmake_tc_1.o >> genmake_warnings 2>&1
790        RET_C=$?
791        cat <<EOF > genmake_tc_2.$FS
792          program hello
793          integer anint
794          common /iv/ anint
795          external sigreg
796          call sigreg(anint)
797          end
798    EOF
799        echo >> genmake_warnings
800        echo "running: check_HAVE_SIGREG()" >> genmake_warnings
801        cat genmake_tc_2.$FS >> genmake_warnings
802        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
803        echo $COMM >> genmake_warnings
804        $COMM >> genmake_warnings 2>&1
805        RETVAL=$?
806        if test "x$RETVAL" = x0 ; then
807            HAVE_SIGREG=t
808            DEFINES="$DEFINES -DHAVE_SIGREG"
809        fi
810        rm -f genmake_tc*
811    }
812    
813    
814    check_HAVE_SETRLSTK()  {
815        get_fortran_c_namemangling
816        cat <<EOF > genmake_tc_1.c
817    $FC_NAMEMANGLE
818    #include <sys/time.h>
819    #include <sys/resource.h>
820    #include <unistd.h>
821    void FC_NAMEMANGLE(setrlstk) ()
822    {
823        struct rlimit rls;
824        rls.rlim_cur = RLIM_INFINITY;
825        rls.rlim_max = RLIM_INFINITY;
826        setrlimit(RLIMIT_STACK, &rls);
827        return;
828    }
829    EOF
830        make genmake_tc_1.o >> genmake_warnings 2>&1
831        RET_C=$?
832        cat <<EOF > genmake_tc_2.$FS
833          program hello
834          external setrlstk
835          call setrlstk()
836          end
837    EOF
838        echo >> genmake_warnings
839        echo "running: check_HAVE_SETRLSTK()" >> genmake_warnings
840        cat genmake_tc_2.$FS >> genmake_warnings
841        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
842        echo $COMM >> genmake_warnings
843        $COMM >> genmake_warnings 2>&1
844        RETVAL=$?
845        if test "x$RETVAL" = x0 ; then
846            HAVE_SETRLSTK=t
847            DEFINES="$DEFINES -DHAVE_SETRLSTK"
848        fi
849        rm -f genmake_tc*
850    }
851    
852    
853  check_HAVE_STAT()  {  check_HAVE_STAT()  {
854      get_fortran_c_namemangling      get_fortran_c_namemangling
855      cat <<EOF > genmake_tc_1.c      cat <<EOF > genmake_tc_1.c
# Line 714  EOF Line 878  EOF
878        integer nbyte        integer nbyte
879        call tfsize(nbyte)        call tfsize(nbyte)
880        print *," HELLO WORLD", nbyte        print *," HELLO WORLD", nbyte
881        end program hello        end
882  EOF  EOF
883      $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_tc.log 2>&1      echo >> genmake_warnings
884      RET_F=$?      echo "running: check_HAVE_STAT()" >> genmake_warnings
885      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_tc.log 2>&1      cat genmake_tc_2.$FS >> genmake_warnings
886        COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
887        echo $COMM >> genmake_warnings
888        $COMM >> genmake_tc.log 2>&1
889      RETVAL=$?      RETVAL=$?
890      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
891          HAVE_STAT=t          HAVE_STAT=t
# Line 732  check_netcdf_libs()  { Line 899  check_netcdf_libs()  {
899      if test ! "x$SKIP_NETCDF_CHECK" = x ; then      if test ! "x$SKIP_NETCDF_CHECK" = x ; then
900          return          return
901      fi      fi
902      echo "" > genmake_tnc.log      echo >> genmake_warnings
903        echo "running: check_netcdf_libs()" >> genmake_warnings
904      cat <<EOF > genmake_tnc.F      cat <<EOF > genmake_tnc.F
905        program fgennc        program fgennc
906  #include "netcdf.inc"  #include "netcdf.inc"
# Line 750  EOF Line 918  EOF
918        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)        IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
919        end        end
920  EOF  EOF
921      echo "Executing:" > genmake_tnc.log      echo "===  genmake_tnc.F  ===" > genmake_tnc.log
922      echo "  $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS" \      cat genmake_tnc.F >> genmake_tnc.log
923          > genmake_tnc.log      echo "===  genmake_tnc.F  ===" >> genmake_tnc.log
924      RET_CPP=f      RET_CPP=f
925      $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \      COMM="$CPP $DEFINES $INCLUDES genmake_tnc.F"
926          &&  RET_CPP=t      echo "$COMM" >> genmake_tnc.log
927        $COMM > genmake_tnc.$FS 2>/dev/null  &&  RET_CPP=t
928      if test "x$RET_CPP" = xf ; then      if test "x$RET_CPP" = xf ; then
929          echo "  WARNING: CPP failed to pre-process the netcdf test." \          echo "  WARNING: CPP failed to pre-process the netcdf test." \
930              > genmake_tnc.log              >> genmake_tnc.log
931          echo "    Please check that \$INCLUDES is properly set." \          echo "    Please check that \$INCLUDES is properly set." \
932              > genmake_tnc.log              >> genmake_tnc.log
933      fi      fi
934      echo "Executing:" > genmake_tnc.log      echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS  \ " >> genmake_tnc.log
935      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  
936      $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \      $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
937          &&  $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
938      RET_COMPILE=$?      RET_COMPILE=$?
939        cat genmake_tnc.log >> genmake_warnings
940    
941      #EH3  Remove test program execution for machines that either disallow      #EH3  Remove test program execution for machines that either disallow
942      #EH3  execution or cannot support it (eg. cross-compilers)      #EH3  execution or cannot support it (eg. cross-compilers)
# Line 780  EOF Line 949  EOF
949          HAVE_NETCDF=t          HAVE_NETCDF=t
950      else      else
951          # try again with "-lnetcdf" added to the libs          # try again with "-lnetcdf" added to the libs
952            echo "try again with added '-lnetcdf'" > genmake_tnc.log
953            echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log
954            echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
955            echo " &&  $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
956          $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \          $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null  \
957              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \              &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
958              &&  $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
959          RET_COMPILE=$?          RET_COMPILE=$?
960            cat genmake_tnc.log >> genmake_warnings
961          if test "x$RET_COMPILE" = x0 ; then          if test "x$RET_COMPILE" = x0 ; then
962              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
963              HAVE_NETCDF=t              HAVE_NETCDF=t
         else  
             cat genmake_tnc.log >> genmake_warnings  
964          fi          fi
965      fi      fi
966      rm -f genmake_tnc*      rm -f genmake_tnc*
# Line 834  NOOPTFILES= Line 1006  NOOPTFILES=
1006  NOOPTFLAGS=  NOOPTFLAGS=
1007  MPI=  MPI=
1008  MPIPATH=  MPIPATH=
1009    TS=
1010    PAPIS=
1011    FOOLAD=
1012    PAPI=
1013    HPMT=
1014    GSL=
1015    HAVE_TEST_L=
1016    
1017  # DEFINES checked by test compilation or command-line  # DEFINES checked by test compilation or command-line
1018  HAVE_SYSTEM=  HAVE_SYSTEM=
1019  HAVE_FDATE=  HAVE_FDATE=
1020  FC_NAMEMANGLE=  FC_NAMEMANGLE=
1021  HAVE_CLOC=  HAVE_CLOC=
1022    HAVE_SETRLSTK=
1023  HAVE_STAT=  HAVE_STAT=
1024  HAVE_NETCDF=  HAVE_NETCDF=
1025  HAVE_ETIME=  HAVE_ETIME=
# Line 856  BASH= Line 1036  BASH=
1036  PWD=`pwd`  PWD=`pwd`
1037  test "x$MAKE" = x  &&  MAKE=make  test "x$MAKE" = x  &&  MAKE=make
1038  test "x$AWK" = x   &&  AWK=awk  test "x$AWK" = x   &&  AWK=awk
1039    EMBED_SRC=
1040  THISHOST=`hostname`  THISHOST=`hostname`
1041  THISCWD=`pwd`  THISCWD=`pwd`
1042  THISDATE=`date`  THISDATE=`date`
# Line 889  TAMC_EXTRA= Line 1070  TAMC_EXTRA=
1070    
1071  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1072  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
1073  gm_s2="FC CPP IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE TS PAPIS PAPI HPMT GSL MPI JAM DUMPSTATE STANDARDDIRS"
1074    
1075  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1076  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 1069  for ac_option in "$@" ; do Line 1250  for ac_option in "$@" ; do
1250          -noieee | --noieee)          -noieee | --noieee)
1251              IEEE= ;;              IEEE= ;;
1252    
1253            -ts | --ts)
1254                TS=true ;;
1255            -papis | --papis)
1256                PAPIS=true ;;
1257            -foolad | --foolad)
1258                FOOLAD=true ;;
1259            -papi | --papi)
1260                PAPI=true ;;
1261            -hpmt | --hpmt)
1262                HPMT=true ;;
1263    
1264            -gsl | --gsl)
1265                GSL=true ;;
1266    
1267          -mpi | --mpi)          -mpi | --mpi)
1268              MPI=true ;;              MPI=true ;;
1269          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
# Line 1096  for ac_option in "$@" ; do Line 1291  for ac_option in "$@" ; do
1291          -ignoretime | -ignore_time | --ignoretime | --ignore_time)          -ignoretime | -ignore_time | --ignoretime | --ignore_time)
1292              IGNORE_TIME="-DIGNORE_TIME" ;;              IGNORE_TIME="-DIGNORE_TIME" ;;
1293    
1294            -es | --es | -embed-source | --embed-source)
1295                EMBED_SRC=t ;;
1296    
1297          -*)          -*)
1298              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
1299              usage              usage
# Line 1152  fi Line 1350  fi
1350    
1351  #  Find the MITgcm ${THISVER}  #  Find the MITgcm ${THISVER}
1352  if test -f "${ROOTDIR}/doc/tag-index" ; then  if test -f "${ROOTDIR}/doc/tag-index" ; then
1353      THISVER=`grep checkpoint ${ROOTDIR}/doc/tag-index | head -1`      THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`
1354  fi  fi
1355    
1356  if test "x$MAKEFILE" = x ; then  if test "x$MAKEFILE" = x ; then
# Line 1294  Error: The command "ln -s" failed -- ple Line 1492  Error: The command "ln -s" failed -- ple
1492  EOF  EOF
1493      exit 1      exit 1
1494  fi  fi
1495    test -L genmake_tlink > /dev/null 2>&1
1496    RETVAL=$?
1497    if test "x$RETVAL" = x0 ; then
1498        HAVE_TEST_L=t
1499    fi
1500  rm -f genmake_test_ln genmake_tlink  rm -f genmake_test_ln genmake_tlink
1501    
1502  #  Check for broken *.F/*.f handling and fix if possible  #  Check for broken *.F/*.f handling and fix if possible
# Line 1304  if test ! "x$MPI" = x ; then Line 1507  if test ! "x$MPI" = x ; then
1507        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1508  fi  fi
1509    
1510    if test ! "x$TS" = x ; then
1511          echo "  Turning on timing per timestep"
1512          if test ! "x$FOOLAD" = x ; then
1513                DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP"
1514          else
1515                DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1516          fi
1517    fi
1518    if test ! "x$PAPIS" = x ; then
1519          echo "  Turning on PAPI flop summary per timestep"
1520          echo "  Please make sure PAPIINC, PAPILIB are defined"
1521          if test ! "x$FOOLAD" = x ; then
1522                DEFINES="$DEFINES -DUSE_PAPI_FLOPS_SFP"
1523          else
1524                DEFINES="$DEFINES -DUSE_PAPI_FLOPS"
1525          fi
1526          INCLUDES="$INCLUDES $PAPIINC"
1527          LIBS="$LIBS $PAPILIB"
1528    fi
1529    if test ! "x$PAPI" = x ; then
1530          if test ! "x$PAPIS" = x ; then
1531              echo "  PAPI performance analysis and flop summary per timestep cannot co-exist!"
1532              echo "  Sticking with PAPI flop summary per timestep!"
1533          else
1534              echo "  Turning on performance analysis with PAPI"
1535              echo "  Please make sure PAPIINC, PAPILIB are defined"
1536              DEFINES="$DEFINES -DUSE_PAPI"
1537              INCLUDES="$INCLUDES $PAPIINC"
1538              LIBS="$LIBS $PAPILIB"
1539          fi
1540    fi
1541    if test ! "x$HPMT" = x ; then
1542          if test ! "x$PAPI" = x ; then
1543              echo "  PAPI and the HPM Toolkit cannot co-exist!"
1544              echo "  Sticking with PAPI!"
1545          else
1546              echo "  Turning on performance analysis with the HPM Toolkit"
1547              echo "  Please make sure HPMTINC, HPMTLIB are defined"
1548              DEFINES="$DEFINES -DUSE_LIBHPM"
1549              INCLUDES="$INCLUDES $HPMTINC"
1550              LIBS="$LIBS $HPMTLIB"
1551          fi
1552    fi
1553    if test ! "x$GSL" = x ; then
1554          echo "  Turning on use of GSL to control floating point calculations"
1555          echo "  Please make sure GSLINC, GSLLIB are defined"
1556          DEFINES="$DEFINES -DUSE_GSL_IEEE"
1557          INCLUDES="$INCLUDES $GSLINC"
1558          LIBS="$LIBS $GSLLIB"
1559    fi
1560    
1561  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1562  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
1563  cat > genmake_tcomp.$FS <<EOF  cat > genmake_tcomp.$FS <<EOF
# Line 1311  cat > genmake_tcomp.$FS <<EOF Line 1565  cat > genmake_tcomp.$FS <<EOF
1565        call system('echo hi')        call system('echo hi')
1566        end        end
1567  EOF  EOF
1568  $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
1569  RETVAL=$?  RETVAL=$?
1570  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1571      HAVE_SYSTEM=t      HAVE_SYSTEM=t
# Line 1326  rm -f genmake_tcomp* Line 1580  rm -f genmake_tcomp*
1580  printf "  Do we have the fdate() command using $FC...  "  printf "  Do we have the fdate() command using $FC...  "
1581  cat > genmake_tcomp.$FS <<EOF  cat > genmake_tcomp.$FS <<EOF
1582        program hello        program hello
1583        CHARACTER(128) string        CHARACTER*(128) string
1584        string = ' '        string = ' '
1585        call fdate( string )        call fdate( string )
1586        print *, string        print *, string
1587        end        end
1588  EOF  EOF
1589  $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
1590  RETVAL=$?  RETVAL=$?
1591  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1592      HAVE_FDATE=t      HAVE_FDATE=t
# Line 1354  cat > genmake_tcomp.$FS <<EOF Line 1608  cat > genmake_tcomp.$FS <<EOF
1608        print *, tarray        print *, tarray
1609        end        end
1610  EOF  EOF
1611  $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
1612  RETVAL=$?  RETVAL=$?
1613  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1614      HAVE_ETIME=t      HAVE_ETIME=t
# Line 1372  if test "x$HAVE_CLOC" != x ; then Line 1626  if test "x$HAVE_CLOC" != x ; then
1626      echo "yes"      echo "yes"
1627  else  else
1628      echo "no"      echo "no"
1629        if test "x$EMBED_SRC" = xt ; then
1630            echo "    WARNING: you requested file embedding but it has"
1631            echo "      been disabled since C code cannot be called"
1632            EMBED_SRC=
1633        fi
1634    fi
1635    rm -f genmake_t*
1636    
1637    printf "  Can we unlimit the stack size using $FC...  "
1638    check_HAVE_SETRLSTK
1639    if test "x$HAVE_SETRLSTK" != x ; then
1640        echo "yes"
1641    else
1642        echo "no"
1643    fi
1644    rm -f genmake_t*
1645    
1646    printf "  Can we register a signal handler using $FC...  "
1647    check_HAVE_SIGREG
1648    if test "x$HAVE_SIGREG" != x ; then
1649        echo "yes"
1650    else
1651        echo "no"
1652  fi  fi
1653  rm -f genmake_t*  rm -f genmake_t*
1654    
# Line 1393  else Line 1670  else
1670  fi  fi
1671  DEFINES="$DEFINES $IGNORE_TIME"  DEFINES="$DEFINES $IGNORE_TIME"
1672    
1673    if test "x$EMBED_SRC" = xt ; then
1674        build_embed_encode
1675    fi
1676    if test "x$EMBED_SRC" = xt ; then
1677        ENABLE="$ENABLE embed_files"
1678    fi
1679    
1680    
1681  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1682  printf "  Adding MODS directories:  "  printf "  Adding MODS directories:  "
1683  for d in $MODS ; do  for d in $MODS ; do
# Line 1844  for i in $INCLUDEDIRS ; do Line 2129  for i in $INCLUDEDIRS ; do
2129      fi      fi
2130  done  done
2131    
2132    if test ! "x$DIVA" = x ; then
2133        echo "  Creating the pseudo-MPI include directory"
2134        INCLUDES="-I./mpi_headers $INCLUDES"
2135        rm -rf ./mpi_headers
2136        mkdir -p ./mpi_headers
2137    
2138        if test "x$MPIINCLUDEDIR" = x ; then
2139            if test "x$MPIHOME" = x ; then
2140                MPIHOME='/usr'
2141            fi
2142            MPIINCLUDEDIR='$MPIHOME/include'
2143        fi
2144        
2145        if test -r $MPIINCLUDEDIR/mpif.h ; then
2146            for i in $MPI_HEADER_FILES; do
2147                cp -p $MPIINCLUDEDIR/$i ./mpi_headers
2148            done
2149    
2150            perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h
2151        else
2152            echo " We cannot create a copy of mpif.h!"
2153            exit -1
2154        fi
2155    fi
2156    
2157  echo "  Determining the list of source and include files"  echo "  Determining the list of source and include files"
2158  rm -rf .links.tmp  rm -rf .links.tmp
2159  mkdir .links.tmp  mkdir .links.tmp
2160    touch .links.tmp/foo
2161    if test ! -r ".links.tmp/foo" ; then
2162        echo
2163        echo "ERROR : something is wrong with your directory permissions or"
2164        echo "   your user file-creation mask (\"umask\") since creating a"
2165        echo "   sub-dir, touch-ing a file within it, and then reading it is"
2166        echo "   not working.  Please try setting your umask to something"
2167        echo "   sane such as:"
2168        echo
2169        echo "      umask 0002"
2170        echo
2171        echo "   and please verify that you have the proper permissions for"
2172        echo "   creating sub-directories and then reading files created"
2173        echo "   within them."
2174        echo
2175        exit 1
2176    fi
2177    rm -f .links.tmp/foo
2178  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
2179  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
2180  printf 'SRCFILES = '    > srclist.inc  printf 'SRCFILES = '    > srclist.inc
# Line 1862  for d in $alldirs ; do Line 2190  for d in $alldirs ; do
2190      for sf in $sfiles ; do      for sf in $sfiles ; do
2191          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
2192              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2193                    ignore_f=f
2194                  case $d/$sf in                  case $d/$sf in
2195                    ./$PACKAGES_DOT_H)                    ./$PACKAGES_DOT_H)
2196                            ignore_f=t
2197                          ;;                          ;;
2198                    ./AD_CONFIG.h)                    ./AD_CONFIG.h)
2199                            ignore_f=t
2200                          ;;                          ;;
2201                    ./FC_NAMEMANGLE.h)                    ./FC_NAMEMANGLE.h)
2202                            ignore_f=t
2203                          ;;                          ;;
2204                    ./BUILD_INFO.h)                    ./BUILD_INFO.h)
2205                            ignore_f=t
2206                            ;;
2207                      ./EMBEDDED_FILES.h)
2208                            ignore_f=t
2209                          ;;                          ;;
2210                    *)                    *)
2211                          touch .links.tmp/$sf                          #  For the local directory *ONLY*,
2212                          deplist="$deplist $sf"                          #  ignore all soft-links
2213                            if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
2214                                ignore_f=t
2215                            else
2216                                touch .links.tmp/$sf
2217                                deplist="$deplist $sf"
2218                            fi
2219                          ;;                          ;;
2220                  esac                  esac
2221                  extn=`echo $sf | $AWK -F. '{print $NF}'`                  if test "x$ignore_f" = xf ; then
2222                  case $extn in                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2223                      F)                      case $extn in
2224                          echo    " \\"  >> srclist.inc                          F)
2225                          printf " $sf" >> srclist.inc                              echo    " \\"  >> srclist.inc
2226                          ;;                              printf " $sf" >> srclist.inc
2227                      F90)                              ;;
2228                          echo    " \\"  >> f90srclist.inc                          F90)
2229                          printf " $sf" >> f90srclist.inc                              echo    " \\"  >> f90srclist.inc
2230                          ;;                              printf " $sf" >> f90srclist.inc
2231                      c)                              ;;
2232                          echo    " \\"  >> csrclist.inc                          c)
2233                          printf " $sf" >> csrclist.inc                              echo    " \\"  >> csrclist.inc
2234                          ;;                              printf " $sf" >> csrclist.inc
2235                      h)                              ;;
2236                          echo    " \\"  >> hlist.inc                          h)
2237                          printf " $sf" >> hlist.inc                              echo    " \\"  >> hlist.inc
2238                          ;;                              printf " $sf" >> hlist.inc
2239                      flow)                              ;;
2240                          echo    " \\"  >> ad_flow_files.inc                          flow)
2241                          printf " $sf" >> ad_flow_files.inc                              echo    " \\"  >> ad_flow_files.inc
2242                          ;;                              printf " $sf" >> ad_flow_files.inc
2243                  esac                              ;;
2244                        esac
2245                    fi
2246              fi              fi
2247          fi          fi
2248      done      done
# Line 1974  DISABLED_PACKAGES = ${DISABLED_PACKAGES} Line 2318  DISABLED_PACKAGES = ${DISABLED_PACKAGES}
2318    
2319  # These files are created by Makefile  # These files are created by Makefile
2320  SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h  SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h BUILD_INFO.h
   
2321  EOF  EOF
2322    
2323  #  Note: figure out some way to add Hyades JAM libraries here  if test "x$EMBED_SRC" = xt ; then
2324        echo "EMBEDDED_FILES = EMBEDDED_FILES.h" >>$MAKEFILE
2325    else
2326        echo "EMBEDDED_FILES = " >>$MAKEFILE
2327    fi
2328    
2329    #  Note: figure out some way to add Hyades JAM libraries here
2330  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2331  # Unix ln (link)  # Unix ln (link)
2332  LN = ${LN}  LN = ${LN}
# Line 2029  cat hlist.inc         >> $MAKEFILE Line 2377  cat hlist.inc         >> $MAKEFILE
2377  cat ad_flow_files.inc >> $MAKEFILE  cat ad_flow_files.inc >> $MAKEFILE
2378  echo >> $MAKEFILE  echo >> $MAKEFILE
2379  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE
2380  echo 'F90FILES =  $(F90SRCFILES:.F=.'$FS90')' >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE
2381  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
2382  echo >> $MAKEFILE  echo >> $MAKEFILE
2383  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
# Line 2040  rm -f ad_flow_files.inc Line 2388  rm -f ad_flow_files.inc
2388  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2389    
2390  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
2391  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES) \$(EMBEDDED_FILES)
2392          @echo Creating \$@ ...          @echo Creating \$@ ...
2393          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2394  depend:  depend:
# Line 2049  depend: Line 2397  depend:
2397          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2398          -rm -f makedepend.out          -rm -f makedepend.out
2399    
2400    lib: libmitgcmuv.a
2401    
2402    libmitgcmuv.a: \$(OBJFILES)
2403            ar rcv libmitgcmuv.a \$(OBJFILES)
2404    
2405  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)
2406    
2407  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77FILES) \$(F90FILES)
# Line 2063  Clean: Line 2416  Clean:
2416          @make clean          @make clean
2417          @make cleanlinks          @make cleanlinks
2418          -rm -f \$(SPECIAL_FILES)          -rm -f \$(SPECIAL_FILES)
2419          -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak          -rm -f genmake* make.log run.log *.bak
2420  CLEAN:  CLEAN:
2421          @make Clean          @make Clean
2422          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2423          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2424          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2425          -rm -f \$(EXECUTABLE) output.txt STD*          -rm -f \$(EXECUTABLE) *.txt STD* *diagnostics.log datetime
2426            -rm -rf mnc_test_*
2427    
2428  #eh3 Makefile: makefile  #eh3 Makefile: makefile
2429  makefile:  makefile:
# Line 2097  test ! "x$THISUSER" = x && echo "      -echo Line 2451  test ! "x$THISUSER" = x && echo "      -echo
2451  test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE  test ! "x$THISDATE" = x && echo "       -echo \"#define THISDATE '$THISDATE'\" >> \$@" >> $MAKEFILE
2452  test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE  test ! "x$THISHOST" = x && echo "       -echo \"#define THISHOST '$THISHOST'\" >> \$@" >> $MAKEFILE
2453    
2454    if test "x$EMBED_SRC" = xt ; then
2455        cat >>$MAKEFILE <<EOF
2456    
2457    decode_files.o : EMBEDDED_FILES.h
2458    
2459    ##  \$(F77FILES)
2460    all_fF.tar.gz : \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(F77FILES) Makefile
2461            @echo Creating \$@ ...
2462            -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(F77FILES) Makefile
2463            -rm -f all_fF.tar.gz
2464            -gzip all_fF.tar
2465    
2466    EMBEDDED_FILES.h : all_fF.tar.gz
2467            @echo Creating \$@ ...
2468            -\${ROOTDIR}/tools/embed_encode/encode_files EMBEDDED_FILES.h all_fF.tar.gz
2469    
2470    EOF
2471    fi
2472    
2473  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2474    
2475  # The normal chain of rules is (  .F - .$FS - .o  )  # The normal chain of rules is (  .F - .$FS - .o  )
# Line 2113  cat >>$MAKEFILE <<EOF Line 2486  cat >>$MAKEFILE <<EOF
2486  .$FS90.o:  .$FS90.o:
2487          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2488  .c.o:  .c.o:
2489          \$(CC) \$(CFLAGS) -c \$<          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
2490    
2491  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2492  .F.p:  .F.p:

Legend:
Removed from v.1.124  
changed lines
  Added in v.1.144

  ViewVC Help
Powered by ViewVC 1.1.22