--- MITgcm/tools/genmake2 2012/08/14 22:10:39 1.233 +++ MITgcm/tools/genmake2 2012/09/19 20:46:03 1.241 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.233 2012/08/14 22:10:39 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.241 2012/09/19 20:46:03 utke Exp $ # $Name: $ # # Makefile generator for MITgcm UV codes @@ -17,139 +17,139 @@ where [OPTIONS] can be: -help | --help | -h | --h - Print this help message and exit. + Print this help message and exit. -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME - Use "NAME" as the adoptfile. By default, the file at - "tools/adjoint_options/adjoint_default" will be used. + Use "NAME" as the adoptfile. By default, the file at + "tools/adjoint_options/adjoint_default" will be used. -nooptfile | --nooptfile -optfile NAME | --optfile NAME | -of NAME | --of NAME -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME - Use "NAME" as the optfile. By default, an attempt will be - made to find an appropriate "standard" optfile in the - tools/build_options/ directory. + Use "NAME" as the optfile. By default, an attempt will be + made to find an appropriate "standard" optfile in the + tools/build_options/ directory. -pdepend NAME | --pdepend NAME -pdepend=NAME | --pdepend=NAME - Get package dependency information from "NAME". + Get package dependency information from "NAME". -pgroups NAME | --pgroups NAME -pgroups=NAME | --pgroups=NAME - Get the package groups information from "NAME". + Get the package groups information from "NAME". -bash NAME - Explicitly specify the Bourne or BASH shell to use + Explicitly specify the Bourne or BASH shell to use -make NAME | -m NAME --make=NAME | -m=NAME - Use "NAME" for the MAKE program. The default is "make" but - many platforms, "gmake" is the preferred choice. + Use "NAME" for the MAKE program. The default is "make" but + many platforms, "gmake" is the preferred choice. -makefile NAME | -mf NAME --makefile=NAME | -mf=NAME - Call the makefile "NAME". The default is "Makefile". + Call the makefile "NAME". The default is "Makefile". -makedepend NAME | -md NAME --makedepend=NAME | -md=NAME - Use "NAME" for the MAKEDEPEND program. + Use "NAME" for the MAKEDEPEND program. -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME - Specify the location of the MITgcm ROOTDIR as "NAME". - By default, genamke will try to find the location by - looking in parent directories (up to the 5th parent). + Specify the location of the MITgcm ROOTDIR as "NAME". + By default, genamke will try to find the location by + looking in parent directories (up to the 5th parent). -mods NAME | --mods NAME | -mo NAME | --mo NAME -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME - Here, "NAME" specifies a list of directories that are - used for additional source code. Files found in the - "mods list" are given preference over files of the same - name found elsewhere. + Here, "NAME" specifies a list of directories that are + used for additional source code. Files found in the + "mods list" are given preference over files of the same + name found elsewhere. -disable NAME | --disable NAME -disable=NAME | --disable=NAME - Here "NAME" specifies a list of packages that we don't - want to use. If this violates package dependencies, - genamke will exit with an error message. + Here "NAME" specifies a list of packages that we don't + want to use. If this violates package dependencies, + genamke will exit with an error message. -enable NAME | --enable NAME -enable=NAME | --enable=NAME - Here "NAME" specifies a list of packages that we wish - to specifically enable. If this violates package - dependencies, genamke will exit with an error message. + Here "NAME" specifies a list of packages that we wish + to specifically enable. If this violates package + dependencies, genamke will exit with an error message. -standarddirs NAME | --standarddirs NAME -standarddirs=NAME | --standarddirs=NAME - Here, "NAME" specifies a list of directories to be - used as the "standard" code. + Here, "NAME" specifies a list of directories to be + used as the "standard" code. -fortran NAME | --fortran NAME | -fc NAME | --fc NAME -fc=NAME | --fc=NAME - Use "NAME" as the fortran compiler. By default, genmake - will search for a working compiler by trying a list of - "usual suspects" such as g77, f77, etc. + Use "NAME" as the fortran compiler. By default, genmake + will search for a working compiler by trying a list of + "usual suspects" such as g77, f77, etc. -cc NAME | --cc NAME | -cc=NAME | --cc=NAME - Use "NAME" as the C compiler. By default, genmake - will search for a working compiler by trying a list of - "usual suspects" such as gcc, c89, cc, etc. + Use "NAME" as the C compiler. By default, genmake + will search for a working compiler by trying a list of + "usual suspects" such as gcc, c89, cc, etc. -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 - Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW) - *only* works if CPP_EEOPTIONS.h allows this. + Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW) + *only* works if CPP_EEOPTIONS.h allows this. -ignoretime | -ignore_time | --ignoretime | --ignore_time - Ignore all the "wall clock" routines entirely. This will - not in any way hurt the model results -- it simply means - that the code that checks how long the model spends in - various routines will give junk values. + Ignore all the "wall clock" routines entirely. This will + not in any way hurt the model results -- it simply means + that the code that checks how long the model spends in + various routines will give junk values. -ts | --ts - Produce timing information per timestep + Produce timing information per timestep -papis | --papis - Produce summary MFlop/s (and IPC) 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 + Produce summary MFlop/s etc. with PCL per timestep -foolad | --foolad - Fool the AD code generator + Fool the AD code generator -papi | --papi - Performance analysis with PAPI + Performance analysis with PAPI -pcl | --pcl - Performance analysis with PCL + Performance analysis with PCL -hpmt | --hpmt - Performance analysis with the HPM Toolkit + Performance analysis with the HPM Toolkit -ieee | --ieee - use IEEE numerics. Note that this option *only* works - if it is supported by the OPTFILE that is being used. + use IEEE numerics. Note that this option *only* works + if it is supported by the OPTFILE that is being used. -devel | --devel - Add additional warning and debugging flags for development - (if supported by the OPTFILE); also switch to IEEE numerics. + Add additional warning and debugging flags for development + (if supported by the OPTFILE); also switch to IEEE numerics. -gsl | --gsl - Use GSL to control floating point rounding and precision + Use GSL to control floating point rounding and precision -mpi | --mpi - Include MPI header files and link to MPI libraries + Include MPI header files and link to MPI libraries -mpi=PATH | --mpi=PATH - Include MPI header files and link to MPI libraries using MPI_ROOT - set to PATH. i.e. Include files from \$PATH/include, link to libraries - from \$PATH/lib and use binaries from \$PATH/bin. + Include MPI header files and link to MPI libraries using MPI_ROOT + set to PATH. i.e. Include files from \$PATH/include, link to libraries + from \$PATH/lib and use binaries from \$PATH/bin. -omp | --omp - Activate OpenMP code + use Compiler option OMPFLAG + Activate OpenMP code + use Compiler option OMPFLAG -omp=OMPFLAG | --omp=OMPFLAG - Activate OpenMP code + use Compiler option OMPFLAG + Activate OpenMP code + use Compiler option OMPFLAG -es | --es | -embed-source | --embed-source - Embed a tarball containing the full source code - (including the Makefile, etc.) used to build the - executable [off by default] + Embed a tarball containing the full source code + (including the Makefile, etc.) used to build the + executable [off by default] -ds | --ds - Report genmake internal variables status (DUMPSTATE) - to file "genmake_state" (for debug purpose) + Report genmake internal variables status (DUMPSTATE) + to file "genmake_state" (for debug purpose) While it is most often a single word, the "NAME" variables specified above can in many cases be a space-delimited string such as: @@ -174,28 +174,18 @@ test_for_package_in_cpp_options() { cpp_options=$1 pkg=$2 - 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$" + test_for_string_in_file $cpp_options "^ *# *define *\" + test_for_string_in_file $cpp_options "^ *# *undef *\" + test_for_string_in_file $cpp_options "^ *# *define *\" + test_for_string_in_file $cpp_options "^ *# *undef *\" } # 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[ ]" - 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$" + test_for_string_in_file $cpp_options "^ *# *define *\" + test_for_string_in_file $cpp_options "^ *# *undef *\" } # Search for particular string in a file. Return 1 if detected, 0 if not @@ -203,11 +193,11 @@ test_for_string_in_file() { file=$1 strng=$2 - grep -i "$strng" $file > /dev/null 2>&1 + grep "$strng" $file > /dev/null 2>&1 RETVAL=$? if test "x${RETVAL}" = x0 ; then printf "Error: In $file there is an illegal line: " - grep -i "$strng" $file + grep -i "$strng" $file exit 99 fi return 0 @@ -305,13 +295,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 @@ -412,7 +401,7 @@ ( cd $ROOTDIR/tools/cyrus-imapd-makedepend \ && ./configure > /dev/null 2>&1 \ - && make > /dev/null 2>&1 + && $MAKE > /dev/null 2>&1 if test -x ./makedepend.exe ; then $LN ./makedepend.exe ./makedepend fi @@ -436,13 +425,13 @@ { printf " building the embed-encode utility... " if test ! -e "$ROOTDIR/tools/embed_encode/encode_files" ; then - if test ! -d "$ROOTDIR/tools/embed_encode" ; then - echo - echo " Error: can't locate \"$ROOTDIR/tools/embed_encode\"" - echo - EMBED_SRC=f + if test ! -d "$ROOTDIR/tools/embed_encode" ; then + echo + echo " Error: can't locate \"$ROOTDIR/tools/embed_encode\"" + echo + EMBED_SRC=f return 1 - fi + fi clist="cc gcc c89 $CC" for ic in $clist ; do comm="$ic -o encode_files encode_files.c" @@ -578,8 +567,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 @@ -597,35 +586,6 @@ EOF exit 1 fi - -# # look for possible MPI libraries -# mpi_libs= -# mpi_fort=`which mpif77 2>/dev/null` -# RETVAL=$? -# if test "x${RETVAL}" = x0 ; then -# cat >>test.f < out" -# RETVAL=$? -# if test "x${RETVAL}" = x0 ; then -# a=`cat out` -# for i in $a ; do -# case $i in -# -*) -# mpi_libs="$mpi_libs $i" ;; -# esac -# done -# echo "The MPI libs appear to be:" -# echo " "$mpi_libs -# fi -# rm -f test.f out -# fi } # Parse the package dependency information @@ -650,7 +610,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 @@ -1037,7 +997,7 @@ echo "running: check_lapack_libs()" >> $LOGFILE cat < genmake_tla.F program fgenla - integer info + integer info integer ipiv( 2 ) double precision ab( 4, 2 ), b( 2 ) data ab / 0., 0., 1., 2., 0., 2., 1., 0. / @@ -1108,23 +1068,23 @@ 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 + 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 @@ -1207,6 +1167,9 @@ INCLUDEDIRS= STANDARDDIRS="USE_THE_DEFAULT" +#- local config file +gm_local="genmake_local" + G2ARGS= BASH= PWD=`pwd` @@ -1243,12 +1206,12 @@ TAMC_EXTRA= # The following state can be set directly by command-line switches -gm_s1="OPTFILE PKG_DEPEND PKG_GROUPS DISABLE ENABLE MAKEFILE MAKEDEPEND PLATFORM" -gm_s2="FC CC MPI OMP USE_R4 TS PAPIS PCLS PAPI PCL HPMT IEEE DEVEL GSL FEXTRAFLAGS" -gm_s3="ROOTDIR STANDARDDIRS MODS DUMPSTATE" +gm_s1="ROOTDIR STANDARDDIRS MODS PKG_DEPEND PKG_GROUPS DISABLE ENABLE" +gm_s2="PLATFORM OPTFILE MAKE MAKEFILE MAKEDEPEND FC CC MPI OMP USE_R4" +gm_s3="FEXTRAFLAGS IEEE DEVEL GSL TS PAPIS PCLS PAPI PCL HPMT DUMPSTATE" # The following state is not directly set by command-line switches -gm_s4="LN S64 LINK MAKE PACKAGES INCLUDES FFLAGS FOPTIM" +gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM" 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" @@ -1278,16 +1241,6 @@ rm -f genmake_state genmake_*optfile $LOGFILE echo "=== Processing options files and arguments ===" -gm_local="genmake_local" -printf " getting local config information: " -if test -f $gm_local ; then - echo "using $gm_local" - . $gm_local - # echo "DISABLE=$DISABLE" - # echo "ENABLE=$ENABLE" -else - echo "none found" -fi #echo "$0::$1:$2:$3:$4:$5:$6:$7:" #parse_options @@ -1306,79 +1259,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) + + -makefile | --makefile | -mf | --mf) ac_prev=MAKEFILE ;; - -makefile=* | --makefile=* | -ma=* | --ma=*) + -makefile=* | --makefile=* | -mf=* | --mf=*) 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=*) @@ -1388,27 +1341,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 ;; @@ -1416,9 +1369,9 @@ IEEE=true ;; -noieee | --noieee) echo "Warning: ignore option '$ac_option' (default is already without '-ieee')" ;; - -devel | --devel) + -devel | --devel) IEEE=true ; DEVEL=true ;; - -gsl | --gsl) + -gsl | --gsl) GSL=true ;; -ts | --ts) @@ -1441,21 +1394,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=*) @@ -1465,7 +1418,7 @@ ac_prev=TAMC_EXTRA ;; -tamc_extra=* | --tamc_extra=*) TAMC_EXTRA=$ac_optarg ;; - + -ignoretime | -ignore_time | --ignoretime | --ignore_time) IGNORE_TIME="-DIGNORE_TIME" ;; @@ -1476,16 +1429,24 @@ echo "Error: unrecognized option: "$ac_option usage ;; - + *) echo "Error: unrecognized argument: "$ac_option usage ;; - + esac done +printf " getting local config information: " +if test -f $gm_local ; then + echo "using $gm_local" + . $gm_local +else + echo "none found" +fi + if test -f ./.genmakerc ; then echo echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\"" @@ -1697,7 +1658,7 @@ if test ! "x$MPI" = x ; then echo " Turning on MPI cpp macros" - DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI" + DEFINES="$DEFINES -DALLOW_USE_MPI" fi if test ! "x$OMP" = x ; then echo " Add OMPFLAG and turn on OpenMP cpp macros" @@ -1714,7 +1675,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 @@ -1750,7 +1711,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" @@ -1762,7 +1723,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" @@ -1772,16 +1733,17 @@ 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 + else + if test ! "x$PCL" = x ; then echo " PCL and the HPM Toolkit cannot co-exist!" echo " Sticking with PCL!" - else + 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 fi fi if test ! "x$GSL" = x ; then @@ -2106,7 +2068,7 @@ exit 1 else echo " using PKG_LIST=\"$PKG_LIST\"" - # Strip the comments and add all the names + # Strip the comments and add all the names pkg_list=`cat $PKG_LIST | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'` RETVAL=$? if test "x${RETVAL}" != x0 ; then @@ -2156,7 +2118,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 @@ -2201,7 +2163,7 @@ echo "Error: problem encountered while building source files in pkg/mnc:" cat make_mnc.errors 1>&2 if test "x$mnc_in" = x0 ; then - exit 1 + exit 1 else DISABLE="$DISABLE mnc" fi @@ -2300,7 +2262,7 @@ # Do we need to add $dname according to the dependency rules? if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then - #echo " " $pname ": need to add :" $dname + #echo " " $pname ": need to add :" $dname in_dis="f" for dis in $DISABLE ; do if test "x$dis" = "x$dname" ; then @@ -2325,7 +2287,7 @@ echo " the dependency rules for \"$dname\"" exit 1 fi - i=`echo "$i + 1" | bc -l` + i=`echo "$i + 1" | bc -l` #i=$(( $i + 1 )) done ck=$ck"t" @@ -2366,7 +2328,7 @@ done if test "x$has_pack" = xf ; then undef=`echo "ALLOW_$n" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef" + DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef" fi fi done @@ -2379,7 +2341,7 @@ #EH3 WARNING : This is an UGLY HACK that needs to be removed!!! case $i in aim_v23) - ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM" + ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM" echo "Warning: ALLOW_AIM is set to enable aim_v23." ;; esac @@ -2421,15 +2383,15 @@ if test -f $try -a -r $try -a "x$CPP_OPTIONS" = x ; then echo " found CPP_OPTIONS=\"$try\"" CPP_OPTIONS="$try" - # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h - for n in $names ; do - test_for_package_in_cpp_options $CPP_OPTIONS $n - done + # New safety test: make sure packages are not mentioned in CPP_OPTIONS.h + for n in $names ; do + test_for_package_in_cpp_options $CPP_OPTIONS $n + done fi try="$i/CPP_EEOPTIONS.h" if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" = x ; then echo " found CPP_EEOPTIONS=\"$try\"" - # New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h + # New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h #**** not yet enabled **** # test_for_mpi_in_cpp_eeoptions $try #**** not yet enabled **** @@ -2575,23 +2537,23 @@ if test ! -r ".links.tmp/$sf" ; then if test -f "$d/$sf" ; then ignore_f=f - case $d/$sf in - ./$PACKAGES_DOT_H) + case $d/$sf in + ./$PACKAGES_DOT_H) ignore_f=t ;; - ./AD_CONFIG.h) + ./AD_CONFIG.h) ignore_f=t ;; - ./FC_NAMEMANGLE.h) + ./FC_NAMEMANGLE.h) ignore_f=t ;; - ./BUILD_INFO.h) + ./BUILD_INFO.h) ignore_f=t ;; - ./EMBEDDED_FILES.h) + ./EMBEDDED_FILES.h) ignore_f=t ;; - *) + *) # For the local directory *ONLY*, # ignore all soft-links if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then @@ -2601,7 +2563,7 @@ deplist="$deplist $sf" fi ;; - esac + esac if test "x$ignore_f" = xf ; then extn=`echo $sf | $AWK -F. '{print $NF}'` case $extn in @@ -2648,7 +2610,7 @@ echo " \\" >> hsrclist.tmp printf " $sf" >> hsrclist.tmp ;; - flow) + flow) echo " \\" >> ad_flow_files.tmp printf " $sf" >> ad_flow_files.tmp ;; @@ -2659,7 +2621,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. @@ -2680,7 +2642,7 @@ CMDLINE=$0 for xx in "$@" ; do nw=`echo $xx | wc -w` if test $nw = '1' ; then CMDLINE="$CMDLINE $xx" - else CMDLINE="$CMDLINE '$xx'" ; fi + else CMDLINE="$CMDLINE '$xx'" ; fi done if test -f $MAKEFILE ; then @@ -2714,8 +2676,6 @@ # INCLUDES : Directories searched for header files # DEFINES : Macro definitions for CPP # MAKEDEPEND : Dependency generator -# KPP : Special preprocessor command (specific to platform) -# KFLAGS : Flags for KPP # FC : Fortran compiler command # FFLAGS : Configuration/debugging options for FC # FOPTIM : Optimization options for FC @@ -2752,8 +2712,6 @@ cat >>$MAKEFILE <> $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 cat >>$MAKEFILE < 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) \$(EXECUTABLE) + \$(EXECUTABLE): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(EMBEDDED_FILES) @echo Creating \$@ ... \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) depend: - @make -f \$(MAKEFILE) links + @\$(MAKE) -f \$(MAKEFILE) links \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES) \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE) -rm -f makedepend.out @@ -2856,8 +2823,8 @@ # remove most of the files that "make" and "make depend" generate Clean: - @make -f \$(MAKEFILE) clean - @make -f \$(MAKEFILE) cleanlinks + @\$(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 taf_ftl.log -rm -f genmake_warnings genmake_errors make.log @@ -2865,7 +2832,7 @@ # 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 + @\$(MAKE) -f \$(MAKEFILE) Clean -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 @@ -2884,10 +2851,10 @@ # Special targets (SPECIAL_FILES) which are created by make ${PACKAGES_DOT_H}: @echo Creating \$@ ... - @$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) > \$@ + @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines -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 > \$@ + @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Default version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > \$@ FC_NAMEMANGLE.h: @echo Creating \$@ ... echo "$FC_NAMEMANGLE" > \$@ @@ -2927,16 +2894,19 @@ ## This nullifies any default implicit rules concerning these two file types: ## %.o : %.F +# C preprocessing and replacing the _d in constants: +CPPCMD = cat \$< | ${CPP} \$(DEFINES) \$(INCLUDES) | ${S64} + .F.$FS: - \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ + \$(CPPCMD) > \$@ .$FS.o: \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< .F.o: \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< .F90.$FS90: - \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ + \$(CPPCMD) > \$@ .FF90.f$FS90: - \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ + \$(CPPCMD) > \$@ .$FS90.o: \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$< .f$FS90.o: @@ -2945,11 +2915,11 @@ .c.o: \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$< .flow.flowdir: - \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ + \$(CPPCMD) > \$@ # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain .F.p: - \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ + \$(CPPCMD) > \$@ .p.$FS: \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< @@ -2996,17 +2966,24 @@ cat >>$MAKEFILE < ad_config.template +ad_exe_target: + @echo Update AD_CONFIG.h and make \$(EXE_AD) + @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -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) \$(EXE_AD) + +ad_input_code.$FS: \$(AD_FILES) \$(AD_FLOW_FILES) + @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -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 + @-rm -f ad_config.template + @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES) + @\$(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 @@ -3018,7 +2995,7 @@ ls -l ad_input_code_ad.$FS cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS -\${EXE_AD}: ad_taf_output.o \$(OBJFILES) +\$(EXE_AD): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) ad_taf_output.o \$(OBJFILES) \$(EMBEDDED_FILES) \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) ad_tamc_output.$FS: ad_input_code.$FS @@ -3037,17 +3014,24 @@ adobj: ad_taf_output.o \$(OBJFILES) # ... FTL ... -ftlall: \$(EXE_FTL) +ftlall: ftl_exe_target 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 > 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 +ftl_exe_target: + @echo Update AD_CONFIG.h and make \$(EXE_FTL) + @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_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) \$(EXE_FTL) + +ftl_input_code.$FS: \$(AD_FILES) + @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_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) \$(AD_FLOW_FILES) + 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 @@ -3059,7 +3043,7 @@ ls -l ftl_input_code_ftl.$FS cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS -\${EXE_FTL}: ftl_taf_output.o \$(OBJFILES) +\$(EXE_FTL): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) ftl_taf_output.o \$(OBJFILES) \$(EMBEDDED_FILES) \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) ftl_tamc_output.$FS: ftl_input_code.$FS @@ -3089,9 +3073,9 @@ 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 > ftl_config.template - cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h - -rm -f ftl_config.template + @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "SVD version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template + cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h + @-rm -f ad_config.template EOF @@ -3191,45 +3175,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} @@ -3244,93 +3207,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 ============== @@ -3375,7 +3304,7 @@ printf "\n=== Done ===\n" # Create special header files -$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 > $PACKAGES_DOT_H".tmp" +$BASH $TOOLSDIR/convert_cpp_cmd2defines -bPACKAGES_CONFIG_H "Disabled packages:" $DISABLED_PACKAGES " " "Enabled packages:" $ENABLED_PACKAGES > $PACKAGES_DOT_H".tmp" if test ! -f $PACKAGES_DOT_H ; then mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H else @@ -3389,7 +3318,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 > AD_CONFIG.h + $BASH $TOOLSDIR/convert_cpp_cmd2defines "Default version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > AD_CONFIG.h fi # Write the "state" for future records