--- MITgcm/tools/genmake2 2006/02/14 16:21:09 1.143 +++ MITgcm/tools/genmake2 2006/06/15 17:11:37 1.152 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.143 2006/02/14 16:21:09 edhill Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.152 2006/06/15 17:11:37 jmc Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -13,20 +13,28 @@ test_for_package_in_cpp_options() { cpp_options=$1 pkg=$2 - test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg" || exit 99 - test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg" || exit 99 - test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg" || exit 99 - test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg" || exit 99 + test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg[ ]" + test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg[ ]" + test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg[ ]" + test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg[ ]" + test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg$" + test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg$" + test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg$" + test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg$" } # Search for particular CPP #cmds associated with MPI # usage: test_for_mpi_in_cpp_eeoptions CPP_file test_for_mpi_in_cpp_eeoptions() { cpp_options=$1 - test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI" || exit 99 - test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI" || exit 99 - test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI" || exit 99 - test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI" || exit 99 + test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI[ ]" + test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI[ ]" + test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI[ ]" + test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI[ ]" + test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI$" + test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI$" + test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI$" + test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI$" } # Search for particular string in a file. Return 1 if detected, 0 if not @@ -39,7 +47,7 @@ if test "x${RETVAL}" = x0 ; then printf "Error: In $file there is an illegal line: " grep -i "$strng" $file - return 1 + exit 99 fi return 0 } @@ -579,11 +587,15 @@ -ts | --ts Produce timing information per timestep -papis | --papis - Produce summary MFlop/s with PAPI per timestep + Produce summary MFlop/s (and IPC) with PAPI per timestep + -pcls | --pcls + Produce summary MFlop/s etc. with PCL per timestep -foolad | --foolad Fool the AD code generator -papi | --papi Performance analysis with PAPI + -pcl | --pcl + Performance analysis with PCL -hpmt | --hpmt Performance analysis with the HPM Toolkit @@ -755,6 +767,9 @@ check_HAVE_SIGREG() { + if test ! "x$HAVE_SIGREG" = x ; then + return + fi get_fortran_c_namemangling cat < genmake_tc_1.c $FC_NAMEMANGLE @@ -812,6 +827,13 @@ check_HAVE_SETRLSTK() { + if test "x$HAVE_SETRLSTK" = xt ; then + DEFINES="$DEFINES -DHAVE_SETRLSTK" + return + fi + if test ! "x$HAVE_SETRLSTK" = x ; then + return + fi get_fortran_c_namemangling cat < genmake_tc_1.c $FC_NAMEMANGLE @@ -922,7 +944,7 @@ cat genmake_tnc.F >> genmake_tnc.log echo "=== genmake_tnc.F ===" >> genmake_tnc.log RET_CPP=f - COMM="$CPP $DEFINES $INCLUDES genmake_tnc.F" + COMM="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES" echo "$COMM" >> genmake_tnc.log $COMM > genmake_tnc.$FS 2>/dev/null && RET_CPP=t if test "x$RET_CPP" = xf ; then @@ -950,10 +972,10 @@ else # try again with "-lnetcdf" added to the libs echo "try again with added '-lnetcdf'" > genmake_tnc.log - echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log + echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log echo " && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log echo " && $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log - $CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null \ + cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null \ && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \ && $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1 RET_COMPILE=$? @@ -1008,8 +1030,10 @@ MPIPATH= TS= PAPIS= +PCLS= FOOLAD= PAPI= +PCL= HPMT= GSL= HAVE_TEST_L= @@ -1019,7 +1043,7 @@ HAVE_FDATE= FC_NAMEMANGLE= HAVE_CLOC= -HAVE_SETRLSTK= +# HAVE_SETRLSTK= HAVE_STAT= HAVE_NETCDF= HAVE_ETIME= @@ -1070,7 +1094,7 @@ # The following state can be set directly by command-line switches gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE" -gm_s2="FC CPP IEEE TS PAPIS PAPI HPMT GSL MPI JAM DUMPSTATE STANDARDDIRS" +gm_s2="FC CPP IEEE TS PAPIS PCLS PAPI PCL HPMT GSL MPI JAM DUMPSTATE STANDARDDIRS" # The following state is not directly set by command-line switches gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM " @@ -1254,10 +1278,14 @@ TS=true ;; -papis | --papis) PAPIS=true ;; + -pcls | --pcls) + PCLS=true ;; -foolad | --foolad) FOOLAD=true ;; -papi | --papi) PAPI=true ;; + -pcl | --pcl) + PCL=true ;; -hpmt | --hpmt) HPMT=true ;; @@ -1526,6 +1554,17 @@ INCLUDES="$INCLUDES $PAPIINC" LIBS="$LIBS $PAPILIB" fi +if test ! "x$PCLS" = x ; then + echo " Turning on PCL counter summary per timestep" + echo " Please make sure PCLINC, PCLLIB are defined" + if test ! "x$FOOLAD" = x ; then + DEFINES="$DEFINES -DUSE_PCL_FLOPS_SFP" + else + DEFINES="$DEFINES -DUSE_PCL_FLOPS" + fi + INCLUDES="$INCLUDES $PCLINC" + LIBS="$LIBS $PCLLIB" +fi if test ! "x$PAPI" = x ; then if test ! "x$PAPIS" = x ; then echo " PAPI performance analysis and flop summary per timestep cannot co-exist!" @@ -1538,10 +1577,25 @@ LIBS="$LIBS $PAPILIB" fi fi +if test ! "x$PCL" = x ; then + if test ! "x$PCLS" = x ; then + echo " PCL performance analysis and flop summary per timestep cannot co-exist!" + echo " Sticking with PCL flop summary per timestep!" + else + echo " Turning on performance analysis with PCL" + echo " Please make sure PCLINC, PCLLIB are defined" + DEFINES="$DEFINES -DUSE_PCL" + INCLUDES="$INCLUDES $PCLINC" + LIBS="$LIBS $PCLLIB" + fi +fi if test ! "x$HPMT" = x ; then if test ! "x$PAPI" = x ; then echo " PAPI and the HPM Toolkit cannot co-exist!" echo " Sticking with PAPI!" + else if test ! "x$PCL" = x ; then + echo " PCL and the HPM Toolkit cannot co-exist!" + echo " Sticking with PCL!" else echo " Turning on performance analysis with the HPM Toolkit" echo " Please make sure HPMTINC, HPMTLIB are defined" @@ -1549,6 +1603,7 @@ INCLUDES="$INCLUDES $HPMTINC" LIBS="$LIBS $HPMTLIB" fi + fi fi if test ! "x$GSL" = x ; then echo " Turning on use of GSL to control floating point calculations" @@ -1636,7 +1691,7 @@ printf " Can we unlimit the stack size using $FC... " check_HAVE_SETRLSTK -if test "x$HAVE_SETRLSTK" != x ; then +if test "x$HAVE_SETRLSTK" = xt ; then echo "yes" else echo "no" @@ -1645,7 +1700,7 @@ printf " Can we register a signal handler using $FC... " check_HAVE_SIGREG -if test "x$HAVE_SIGREG" != x ; then +if test "x$HAVE_SIGREG" = xt ; then echo "yes" else echo "no" @@ -2422,7 +2477,8 @@ -find \$(EXEDIR) -name "*.meta" -exec rm {} \; -find \$(EXEDIR) -name "*.data" -exec rm {} \; -find \$(EXEDIR) -name "fort.*" -exec rm {} \; - -rm -f \$(EXECUTABLE) output.txt STD* + -rm -f \$(EXECUTABLE) \$(EXE_AD) *.txt STD* *diagnostics.log datetime + -rm -rf mnc_test_* #eh3 Makefile: makefile makefile: @@ -2509,10 +2565,10 @@ ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS" for i in $ad_vars ; do name=$i - t1="t2=\$"`echo $i` + t1="t2=\$"`echo "$i"` eval $t1 printf "%-20s = " $name >> $MAKEFILE - echo $t2 >> $MAKEFILE + echo "$t2" | sed -e 's| \+| |g' >> $MAKEFILE done echo " Add the source list for AD code generation" @@ -2529,7 +2585,7 @@ cat >>$MAKEFILE < ad_taf_output.$FS -ad_taf: ad_taf_output.o \$(OBJFILES) - \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) +\${EXE_AD}: ad_taf_output.o \$(OBJFILES) + \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) ad_tamc_output.$FS: ad_input_code.$FS \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS