--- MITgcm/tools/genmake2 2012/01/24 14:54:57 1.229 +++ MITgcm/tools/genmake2 2012/08/24 23:07:27 1.236 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.229 2012/01/24 14:54:57 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.236 2012/08/24 23:07:27 jmc Exp $ # $Name: $ # # Makefile generator for MITgcm UV codes @@ -305,13 +305,12 @@ FS90='fr9' check_for_broken_Ff else - cat <&1 -ERROR: Your file system cannot distinguish between *.F and *.f files - (fails the "make/ln" test) and this program cannot find a suitable - replacement extension. Please try a different build environment or - contact the list for help. - -EOF + echo "ERROR: test: '$MAKE -f $MAKEFILE genmake_hello.$tfs' Failed" + echo " see simple makefile: '$MAKEFILE' (left here)" + echo " Please check (1) your '$MAKE' command, (2) your '$LN' command" + echo " and (3) the allowed sufix '.F' and '.$tfs' in makefile" + echo " or contact the list for help." + echo "" exit -1 return fi @@ -450,7 +449,6 @@ RETVAL=$? if test "x$RETVAL" = x0 ; then echo "OK" - DEFINES="$DEFINES -DHAVE_EMBED_SRC" return 0 fi done @@ -462,7 +460,6 @@ return 1 fi echo "OK" - DEFINES="$DEFINES -DHAVE_EMBED_SRC" } # look for possible C compilers @@ -580,8 +577,8 @@ if test "x$OPTFILE" = x ; then OPTFILE=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$FC if test ! -r $OPTFILE ; then - echo " I looked for the file "$OPTFILE" but did not find it" - fi + echo " I looked for the file "$OPTFILE" but did not find it" + fi fi if test "x$OPTFILE" = x ; then @@ -652,7 +649,7 @@ #echo "FC_NAMEMANGLE = \"$FC_NAMEMANGLE\"" if test ! "x$FC_NAMEMANGLE" = x ; then - return 0 + return 0 fi echo " running: get_fortran_c_namemangling()" >> $LOGFILE @@ -784,7 +781,6 @@ RETVAL=$? if test "x$RETVAL" = x0 ; then HAVE_CLOC=t - DEFINES="$DEFINES -DHAVE_CLOC" fi rm -f genmake_tc* echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE @@ -846,17 +842,12 @@ RETVAL=$? if test "x$RETVAL" = x0 ; then HAVE_SIGREG=t - DEFINES="$DEFINES -DHAVE_SIGREG" fi rm -f genmake_tc* echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE } 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 @@ -894,7 +885,6 @@ RETVAL=$? if test "x$RETVAL" = x0 ; then HAVE_SETRLSTK=t - DEFINES="$DEFINES -DHAVE_SETRLSTK" fi rm -f genmake_tc* echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE @@ -941,7 +931,6 @@ RETVAL=$? if test "x$RETVAL" = x0 ; then HAVE_STAT=t - DEFINES="$DEFINES -DHAVE_STAT" fi rm -f genmake_tc* echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE @@ -1039,6 +1028,109 @@ echo " --> set HAVE_NETCDF='$HAVE_NETCDF'" >> $LOGFILE } +check_lapack_libs() { + if test ! "x$SKIP_LAPACK_CHECK" = x ; then + return + fi + echo >> $LOGFILE + echo "running: check_lapack_libs()" >> $LOGFILE + cat < genmake_tla.F + program fgenla + integer info + integer ipiv( 2 ) + double precision ab( 4, 2 ), b( 2 ) + data ab / 0., 0., 1., 2., 0., 2., 1., 0. / + data b / 1., 1. / + call dgbsv( 2, 1, 1, 1, ab, 4, ipiv, b, 2, info ) + IF (info .NE. 0) write(*,*) 'Error:', info + write(*,*) b + end +EOF + echo "=== genmake_tla.F >>>" > genmake_tla.log + cat genmake_tla.F >> genmake_tla.log + echo "<<< genmake_tla.F ===" >> genmake_tla.log + RET_CPP=f + COMM="cat genmake_tla.F | $CPP $DEFINES $INCLUDES" + echo "$COMM" >> genmake_tla.log + eval $COMM > genmake_tla.$FS 2>/dev/null && RET_CPP=t + if test "x$RET_CPP" = xf ; then + echo " WARNING: CPP failed to pre-process the lapack test." \ + >> genmake_tla.log + echo " Please check that \$INCLUDES is properly set." \ + >> genmake_tla.log + fi + echo "$FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log + echo " && $LINK $FFLAGS $FOPTIM -o genmake_tla.o $LIBS" >> genmake_tla.log + $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1 \ + && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS >> genmake_tla.log 2>&1 + RET_COMPILE=$? + cat genmake_tla.log >> $LOGFILE + + # test program execution not always possible (see check_netcdf_libs) + # + #test -x ./genmake_tla && ./genmake_tla >> genmake_tla.log 2>&1 + #RETVAL=$? + #if test "x$RET_COMPILE" = x0 -a "x$RETVAL" = x0 ; then + + if test "x$RET_COMPILE" = x0 ; then + HAVE_LAPACK=t + echo "check_lapack: successful" >> $LOGFILE + else + # try again with "-llapack" added to the libs + echo "==> try again with added '-llapack'" > genmake_tla.log + echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log + echo " && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log + echo " && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack" >> genmake_tla.log + cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null \ + && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1 \ + && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack >> genmake_tla.log 2>&1 + RET_COMPILE=$? + echo >> $LOGFILE + cat genmake_tla.log >> $LOGFILE + if test "x$RET_COMPILE" = x0 ; then + LIBS="$LIBS -llapack" + HAVE_LAPACK=t + echo "check_lapack: successful" >> $LOGFILE + else + # try again with "-lf77blas -lcblas" added to the libs + echo "==> try again with added '-llapack -lf77blas -lcblas'" > genmake_tla.log + echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log + echo " && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log + echo " && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas" >> genmake_tla.log + cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null \ + && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1 \ + && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas >> genmake_tla.log 2>&1 + RET_COMPILE=$? + echo >> $LOGFILE + cat genmake_tla.log >> $LOGFILE + if test "x$RET_COMPILE" = x0 ; then + LIBS="$LIBS -llapack -lf77blas -lcblas" + HAVE_LAPACK=t + echo "check_lapack: successful" >> $LOGFILE + else + # try again with "-latlas" added to the libs + echo "==> try again with added '-llapack -lf77blas -lcblas -latlas'" > genmake_tla.log + echo "cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS \ " >> genmake_tla.log + echo " && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS \ " >> genmake_tla.log + echo " && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas" >> genmake_tla.log + cat genmake_tla.F | $CPP $DEFINES $INCLUDES > genmake_tla.$FS 2>/dev/null \ + && $FC $FFLAGS $FOPTIM -c genmake_tla.$FS >> genmake_tla.log 2>&1 \ + && $LINK $FFLAGS $FOPTIM -o genmake_tla genmake_tla.o $LIBS -llapack -lf77blas -lcblas -latlas >> genmake_tla.log 2>&1 + RET_COMPILE=$? + echo >> $LOGFILE + cat genmake_tla.log >> $LOGFILE + if test "x$RET_COMPILE" = x0 ; then + LIBS="$LIBS -llapack -lf77blas -lcblas -latlas" + HAVE_LAPACK=t + echo "check_lapack: successful" >> $LOGFILE + fi + fi + fi + fi + rm -f genmake_tla* + echo " --> set HAVE_LAPACK='$HAVE_LAPACK'" >> $LOGFILE +} + ############################################################################### # Sequential part of script starts here @@ -1106,6 +1198,7 @@ HAVE_NETCDF= HAVE_ETIME= IGNORE_TIME= +HAVE_LAPACK= MODS= TOOLSDIR= @@ -1158,7 +1251,7 @@ gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS" gm_s6="TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK" gm_s7="PWD THISHOST THISUSER THISDATE THISVER MACHINE" -gm_s8="FC_NAMEMANGLE HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME" +gm_s8="FC_NAMEMANGLE HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME HAVE_LAPACK" # The following are all related to adjoint/tangent-linear stuff gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS" @@ -1212,79 +1305,79 @@ ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` case $ac_option in - + -help | --help | -h | --h) usage ;; - + -nooptfile | --nooptfile) OPTFILE="NONE" ;; -optfile | --optfile | -of | --of) ac_prev=OPTFILE ;; -optfile=* | --optfile=* | -of=* | --of=*) OPTFILE=$ac_optarg ;; - + -adoptfile | --adoptfile | -adof | --adof) ac_prev=AD_OPTFILE ;; -adoptfile=* | --adoptfile=* | -adof=* | --adof=*) AD_OPTFILE=$ac_optarg ;; - + -pdepend | --pdepend) ac_prev=PKG_DEPEND ;; -pdepend=* | --pdepend=*) PKG_DEPEND=$ac_optarg ;; - + -pgroups | --pgroups) ac_prev=PKG_GROUPS ;; -pgroups=* | --pgroups=*) PKG_GROUPS=$ac_optarg ;; - + -make | --make | -m | --m) ac_prev=MAKE ;; -make=* | --make=* | -m=* | --m=*) MAKE=$ac_optarg ;; - + -bash | --bash) ac_prev=BASH ;; -bash=* | --bash=*) BASH=$ac_optarg ;; - + -makedepend | --makedepend | -md | --md) ac_prev=MAKEDEPEND ;; -makedepend=* | --makedepend=* | -md=* | --md=*) MAKEDEPEND=$ac_optarg ;; - + -makefile | --makefile | -ma | --ma) ac_prev=MAKEFILE ;; -makefile=* | --makefile=* | -ma=* | --ma=*) MAKEFILE=$ac_optarg ;; - + -platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*) echo "ERROR: The platform option has been removed. Please specify" echo " the build options using the \"optfile\" mechanism." echo usage ;; - + -rootdir | --rootdir | -rd | --rd) ac_prev=ROOTDIR ;; -rootdir=* | --rootdir=* | -rd=* | --rd=*) ROOTDIR=$ac_optarg ;; - + -mods | --mods | -mo | --mo) ac_prev=MODS ;; -mods=* | --mods=* | -mo=* | --mo=*) MODS=$ac_optarg ;; - + -disable | --disable) ac_prev=DISABLE ;; -disable=* | --disable=*) DISABLE=$ac_optarg ;; - + -enable | --enable) ac_prev=ENABLE ;; -enable=* | --enable=*) ENABLE=$ac_optarg ;; - + -standarddirs | --standarddirs) ac_prev=STANDARDDIRS ;; -standarddirs=* | --standarddirs=*) @@ -1294,27 +1387,27 @@ # ac_prev=cpp ;; # -cpp=* | --cpp=*) # CPP=$ac_optarg ;; - + -cc | --cc) ac_prev=CC ;; -cc=* | --cc=*) CC=$ac_optarg ;; - + -fortran | --fortran | -fc | --fc) ac_prev=FC ;; -fc=* | --fc=*) FC=$ac_optarg ;; - + -fs | --fs) ac_prev=FS ;; -fs=* | --fs=*) FS=$ac_optarg ;; - + -fs90 | --fs90) ac_prev=FS90 ;; -fs90=* | --fs90=*) FS90=$ac_optarg ;; - + -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 ) USE_R4=true ;; @@ -1347,21 +1440,21 @@ -mpi=* | --mpi=*) MPIPATH=$ac_optarg MPI=true ;; - - -omp | --omp) - OMP=true ;; + + -omp | --omp) + OMP=true ;; -omp=* | --omp=*) OMPFLAG=$ac_optarg OMP=true ;; - + -ds | --ds) DUMPSTATE=t ;; - + -extra_flag | --extra_flag) ac_prev=FEXTRAFLAGS ;; -extra_flag=* | --extra_flag=*) FEXTRAFLAGS=$ac_optarg ;; - + -taf_extra | --taf_extra) ac_prev=TAF_EXTRA ;; -taf_extra=* | --taf_extra=*) @@ -1371,7 +1464,7 @@ ac_prev=TAMC_EXTRA ;; -tamc_extra=* | --tamc_extra=*) TAMC_EXTRA=$ac_optarg ;; - + -ignoretime | -ignore_time | --ignoretime | --ignore_time) IGNORE_TIME="-DIGNORE_TIME" ;; @@ -1382,12 +1475,12 @@ echo "Error: unrecognized option: "$ac_option usage ;; - + *) echo "Error: unrecognized argument: "$ac_option usage ;; - + esac done @@ -1620,7 +1713,7 @@ if test ! "x$TS" = x ; then echo " Turning on timing per timestep" if test ! "x$FOOLAD" = x ; then - DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP" + DEFINES="$DEFINES -DTIME_PER_TIMESTEP_SFP" else DEFINES="$DEFINES -DTIME_PER_TIMESTEP" fi @@ -1656,7 +1749,7 @@ echo " Sticking with PAPI flop summary per timestep!" else echo " Turning on performance analysis with PAPI" - echo " Please make sure PAPIINC, PAPILIB are defined" + echo " Please make sure PAPIINC, PAPILIB are defined" DEFINES="$DEFINES -DUSE_PAPI" INCLUDES="$INCLUDES $PAPIINC" LIBS="$LIBS $PAPILIB" @@ -1668,7 +1761,7 @@ echo " Sticking with PCL flop summary per timestep!" else echo " Turning on performance analysis with PCL" - echo " Please make sure PCLINC, PCLLIB are defined" + echo " Please make sure PCLINC, PCLLIB are defined" DEFINES="$DEFINES -DUSE_PCL" INCLUDES="$INCLUDES $PCLINC" LIBS="$LIBS $PCLLIB" @@ -1683,9 +1776,9 @@ echo " Sticking with PCL!" else echo " Turning on performance analysis with the HPM Toolkit" - echo " Please make sure HPMTINC, HPMTLIB are defined" + echo " Please make sure HPMTINC, HPMTLIB are defined" DEFINES="$DEFINES -DUSE_LIBHPM" - INCLUDES="$INCLUDES $HPMTINC" + INCLUDES="$INCLUDES $HPMTINC" LIBS="$LIBS $HPMTLIB" fi fi @@ -1768,6 +1861,7 @@ printf " Can we call simple C routines (here, \"cloc()\") using $FC... " check_HAVE_CLOC if test "x$HAVE_CLOC" != x ; then + DEFINES="$DEFINES -DHAVE_CLOC" echo "yes" else echo "no" @@ -1782,6 +1876,7 @@ printf " Can we unlimit the stack size using $FC... " check_HAVE_SETRLSTK if test "x$HAVE_SETRLSTK" = xt ; then + DEFINES="$DEFINES -DHAVE_SETRLSTK" echo "yes" else echo "no" @@ -1791,6 +1886,7 @@ printf " Can we register a signal handler using $FC... " check_HAVE_SIGREG if test "x$HAVE_SIGREG" = xt ; then + DEFINES="$DEFINES -DHAVE_SIGREG" echo "yes" else echo "no" @@ -1800,6 +1896,7 @@ printf " Can we use stat() through C calls... " check_HAVE_STAT if test "x$HAVE_STAT" != x ; then + DEFINES="$DEFINES -DHAVE_STAT" echo "yes" else echo "no" @@ -1809,6 +1906,16 @@ printf " Can we create NetCDF-enabled binaries... " check_netcdf_libs if test "x$HAVE_NETCDF" != x ; then + DEFINES="$DEFINES -DHAVE_NETCDF" + echo "yes" +else + echo "no" +fi + +printf " Can we create LAPACK-enabled binaries... " +check_lapack_libs +if test "x$HAVE_LAPACK" != x ; then + DEFINES="$DEFINES -DHAVE_LAPACK" echo "yes" else echo "no" @@ -1820,6 +1927,7 @@ fi if test "x$EMBED_SRC" = xt ; then ENABLE="$ENABLE embed_files" +# DEFINES="$DEFINES -DHAVE_EMBED_SRC" fi printf "\n=== Setting defaults ===\n" @@ -2047,7 +2155,7 @@ j=`echo $i | sed 's/[-+]//'` if test ! -d "$ROOTDIR/pkg/$j" ; then echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'" - exit 1 + exit 1 fi echo $i >> ./.tmp_pack done @@ -2125,6 +2233,27 @@ fi fi +# Check for package RADTRANS: if LAPACK is not available, +# then issue a warning that the direct radtrans solver is not available. +if test "x$HAVE_LAPACK" != xt ; then + echo " $PACKAGES " | grep ' radtrans ' > /dev/null 2>&1 + RETVAL=$? + if test "x$RETVAL" = x0 ; then + cat <> hsrclist.tmp printf " $sf" >> hsrclist.tmp ;; - flow) + flow) echo " \\" >> ad_flow_files.tmp printf " $sf" >> ad_flow_files.tmp ;; @@ -2529,7 +2658,7 @@ done if test "x$deplist" != x ; then if test "$d" != "." ; then - echo "" >> srclinks.tmp + echo "" >> srclinks.tmp echo "# These files are linked from $d" >> srclinks.tmp echo "$deplist :" >> srclinks.tmp # We need to make sure that the link isn't already there. @@ -2683,7 +2812,7 @@ echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')' >> $MAKEFILE echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE echo 'OBJFILES= $(F77_SRC_FILES:.F=.o) $(C_SRC_FILES:.c=.o) $(F90_SRC_FILES:.F90=.o)' >> $MAKEFILE -echo 'FLOFILES = $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE +echo 'FLOWFILES = $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE echo >> $MAKEFILE echo '.SUFFIXES:' >> $MAKEFILE echo '.SUFFIXES: .o .'$FS' .p .F .c .f'$FS90' .'$FS90' .FF90 .F90 .flowdir .flow' >> $MAKEFILE @@ -2729,14 +2858,14 @@ @make -f \$(MAKEFILE) clean @make -f \$(MAKEFILE) cleanlinks -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old - -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log + -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log taf_ftl.log -rm -f genmake_warnings genmake_errors make.log # remove also the executable, files that "genmake2" generates (except Makefile) # and output from a run (plus log files from testreport) CLEAN: @make -f \$(MAKEFILE) Clean - -rm -f \$(EXECUTABLE) \$(EXE_AD) *.bak + -rm -f \$(EXECUTABLE) \$(EXE_AD) \$(EXE_FTL) *.bak -rm -f $LOGFILE genmake_state genmake_*optfile -rm -f SIZE.h.mpi genmake.tr_log make.tr_log -find \$(EXEDIR) -name "*.meta" -exec rm {} \; @@ -2757,7 +2886,7 @@ @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@ AD_CONFIG.h: @echo Creating \$@ ... - @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > \$@ + @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > \$@ FC_NAMEMANGLE.h: @echo Creating \$@ ... echo "$FC_NAMEMANGLE" > \$@ @@ -2871,12 +3000,12 @@ adtamc: ad_tamc_output.$FS ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES) - @$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 > ad_config.template cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h -rm -f ad_config.template @make -f \$(MAKEFILE) \$(F77_PP_SRC_FILES) - @make -f \$(MAKEFILE) \$(FLOFILES) - cat \$(FLOFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS + @make -f \$(MAKEFILE) \$(FLOWFILES) + cat \$(FLOWFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS ad_taf_output.$FS: ad_input_code.$FS \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS @@ -2907,17 +3036,17 @@ adobj: ad_taf_output.o \$(OBJFILES) # ... FTL ... -ftlall: ftl_taf +ftlall: \$(EXE_FTL) ftltaf: ftl_taf_output.$FS ftltamc: ftl_tamc_output.$FS ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) - @$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 > ftl_config.template cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h -rm -f ftl_config.template @make -f \$(MAKEFILE) \$(F77_PP_SRC_FILES) @make -f \$(MAKEFILE) \$(AD_FLOW_FILES) - cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS + cat \$(AD_FLOW_FILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ftl_input_code.$FS ftl_taf_output.$FS: ftl_input_code.$FS \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS @@ -2929,8 +3058,8 @@ ls -l ftl_input_code_ftl.$FS cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS -ftl_taf: ftl_taf_output.o \$(OBJFILES) - \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) +\${EXE_FTL}: ftl_taf_output.o \$(OBJFILES) + \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) ftl_tamc_output.$FS: ftl_input_code.$FS \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS @@ -2959,7 +3088,7 @@ touch ad_taf_output.$FS ftl_taf_output.$FS \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS - @$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 > ftl_config.template cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h -rm -f ftl_config.template @@ -3061,45 +3190,24 @@ f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1 f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1 -# the file included below is created by the -# postProcessor and its inclusion sets the -# variable POSTPROCESSEDFILES -# used below. Because the file is made during -# make it won't be read until the second (recursive) -# invocation in the rule below --include postProcess.make +CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90) -AD_OBJ_FILES_S1=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) \$(POSTPROCESSEDFILES:.f$FS90=.o) +AD_OBJ_FILES_S1=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) OAD_intrinsics_oad.o \$(CB2M_AD_FILES:.f$FS90=_oad.o) AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o) -postProcess.comp: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.tag \$(AD_OBJ_FILES_S1) -ifeq (\$(MAKELEVEL),0) - \$(MAKE) adAll -else - touch \$@ -endif - -\$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.comp \$(AD_OBJ_FILES_S2) -ifeq (\$(MAKELEVEL),1) +\$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.tag \$(AD_OBJ_FILES_S2) \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS) -else - touch \$@ -endif - -# makefile debug rule -openad: ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90 -.PHONY: openad -# create the module files +# create sources files modules from header files containing common blocks %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk -# create the header files +# create new header files with USE statements for the new modules made above %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES) -# change everybody else to use the new module files: +# change the include directives of everybody to refer to the new header files with the USE statements %_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash ../OAD_support/cb2mUseModules.bash $< ${MPI} @@ -3114,93 +3222,59 @@ @printf 'running ... ' @./\$(EXE_AD) > \$@ -CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90) ad_input_code.f$FS90: \$(CB2M_AD_FILES) cat \$^ > \$@ -# strip all comments and blanks to reduce -# the file size in order to reduce perl's memory requirements -ad_input_code_sf.f$FS90 : ad_input_code.f$FS90 - cat \$^ | sed -f ../OAD_support/strip.sed | sed -f ../OAD_support/stop2print.sed > \$@ - -# mfef90 preprocessing -# expand statement functions -# expose mfef90 specific substring handling -# add the w2f__types module -ad_input_code_sf.w2f.f$FS90: ad_input_code_sf.f$FS90 mfef90 whirl2f whirl2f_be w2f__types.f90 - ./mfef90 -r8 -z -F -N132 \$< - mv \$<.B \$(basename \$<).B - ./whirl2f -openad \$(basename \$<).B - cat w2f__types.f90 \$(basename \$<).w2f.f > \$@ - # canonicalizer -ad_input_code_sf.w2f.pre.f$FS90: ad_input_code_sf.w2f.f$FS90 preProcess.py - ./preProcess.py --timing --r8 -H -S \$< -o \$@ +ad_input_code_sf.pre.f90 : \$(CB2M_AD_FILES) + \${OPENADFORTTK_BASE}/tools/SourceProcessing/preProcess.py --timing --r8 -H -S -o \$@ \$^ + +# replace stop statements (to avoid the implied unstructured control flow) with print statements +ad_input_code_sf.pre.s2p.f90 : ad_input_code_sf.pre.f90 + cat \$< | sed -f ../OAD_support/stop2print.sed > ad_input_code_sf.pre.s2p.f90 # F -> WHIRL -# note that the canonicalized version cuts off at col 72 -# doing this also for string constants which is ok as long -# as we are in fixed mode and cut of exactly there. -# Otherwise mfef90 patches in spaces to fill up to 72 (or 132) -# characters respectively. -ad_input_code_sf.w2f.pre.B: ad_input_code_sf.w2f.pre.f$FS90 mfef90 - ./mfef90 -r8 -z -F \$< - mv \$<.B \$@ +ad_input_code_sf.pre.s2p.B: ad_input_code_sf.pre.s2p.f90 + \${OPEN64ROOT}/crayf90/sgi/mfef90 -r8 -z -F ad_input_code_sf.pre.s2p.f90 # WHIRL -> XAIF -ad_input_code_sf.w2f.pre.xaif : ad_input_code_sf.w2f.pre.B whirl2xaif - ./whirl2xaif -s -n --debug 1 -o \$@ \$< +ad_input_code_sf.pre.s2p.xaif : ad_input_code_sf.pre.s2p.B + \${OPENADFORTTK}/bin/whirl2xaif -s -n --debug 1 -o \$@ \$< # XAIF -> XAIF' -ad_input_code_sf.w2f.pre.xb.xaif : ad_input_code_sf.w2f.pre.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd oadDriver - ./oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r +ad_input_code_sf.pre.s2p.xb.xaif : ad_input_code_sf.pre.s2p.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd + \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r # XAIF' -> WHIRL' -ad_input_code_sf.w2f.pre.xb.x2w.B : ad_input_code_sf.w2f.pre.xb.xaif xaif2whirl - ./xaif2whirl --debug 1 ad_input_code_sf.w2f.pre.B \$< +ad_input_code_sf.pre.s2p.xb.x2w.B : ad_input_code_sf.pre.s2p.xb.xaif + \${OPENADFORTTK}/bin/xaif2whirl --debug 1 ad_input_code_sf.pre.s2p.B \$< # WHIRL' -> F' -ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.B whirl2f whirl2f_be - ./whirl2f -FLIST:ftn_file=\$@ -openad \$< +ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.B + \${OPEN64ROOT}/whirl2f/whirl2f -FLIST:ftn_file=\$@ -openad \$< # insert template directives -ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90 ../OAD_support/insertTemplateDir.bash +ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 ../OAD_support/insertTemplateDir.bash ../OAD_support/insertTemplateDir.bash \$< \$@ PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F # postprocess F' -postProcess.tag: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 postProcess.py \$(PPEXTRAS:.F=.f) - # the target is a placeholder to signal execution of the rule +postProcess.tag: ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90 \$(PPEXTRAS:.F=.f) | w2f__types.f90 + \${OPENADFORTTK_BASE}/tools/SourceProcessing/postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed --separateOutput --pathSuffix "" --filenameSuffix "_oad" -m r -i ../OAD_support/ad_inline.f \$< + # the target is a placeholder to trigger a single execution of the rule touch \$@ - # this step also creates the file postProcess.make but we cannot - # name it as the target or else make will try to remake it for - # the include directive above for any rule, e.g. make clean - ./postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed -m r -i ../OAD_support/ad_inline.f --width 4 \$< +# put this so make knows about the postprocessing output +OAD_intrinsics_oad.f \$(CB2M_AD_FILES:.f$FS90=_oad.f): postProcess.tag -# setup some links +# link the XAIF schema files %.xsd: \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ . -mfef90: - \$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 . - # link the support files: \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES): \$(LN) ../OAD_support/\$@ . -whirl2xaif xaif2whirl: - \$(LN) \${OPENADFORTTK}/bin/\$@ . - -preProcess.py postProcess.py: - \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ . - -whirl2f whirl2f_be: - \$(LN) \${OPEN64ROOT}/whirl2f/\$@ . - -oadDriver: - \$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver \$@ - -AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.make postProcess.tag postProcess.comp \$(PPEXTRAS:.F=.f) +AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag \$(PPEXTRAS:.F=.f) # ============ end OpenAD specific section ============== @@ -3259,7 +3333,7 @@ fi fi if test ! -f AD_CONFIG.h ; then - $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > AD_CONFIG.h + $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > AD_CONFIG.h fi # Write the "state" for future records