--- MITgcm/tools/genmake2 2009/04/21 22:35:41 1.189 +++ MITgcm/tools/genmake2 2010/05/23 18:34:43 1.206 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.189 2009/04/21 22:35:41 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.206 2010/05/23 18:34:43 jmc Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -110,9 +110,9 @@ check_for_broken_Ff else cat <&1 -ERROR: Your file system cannot distinguish between *.F and *.f files - (fails the "cp" test) and this program cannot find a suitable - replacement extension. Please try a different build environment or +ERROR: Your file system cannot distinguish between *.F and *.f files + (fails the "cp" test) and this program cannot find a suitable + replacement extension. Please try a different build environment or contact the list for help. EOF @@ -146,9 +146,9 @@ 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 +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 @@ -194,8 +194,8 @@ cat <> $MAKEFILE # THIS IS A TEST MAKEFILE GENERATED BY "genmake2" # -# Some "makedepend" implementations will die if they cannot -# find a Makefile -- so this file is here to gives them an +# Some "makedepend" implementations will die if they cannot +# find a Makefile -- so this file is here to gives them an # empty one to find and parse. EOF cat <> genmake_tc.f @@ -212,7 +212,7 @@ MAKEDEPEND=makedepend else echo " a system-default makedepend was not found." - + # Try to build the cyrus implementation build_cyrus_makedepend RETVAL=$? @@ -269,7 +269,7 @@ return 1 fi clist="cc gcc c89 $CC" - for ic in $clist ; do + for ic in $clist ; do comm="$ic -o encode_files encode_files.c" ( cd $ROOTDIR/tools/embed_encode && $comm ) > /dev/null 2>&1 RETVAL=$? @@ -304,7 +304,7 @@ echo $PLATFORM | grep cygwin > /dev/null 2>&1 && PLATFORM=cygwin_ia32 OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` echo " The platform appears to be: $PLATFORM" - + echo "test" > test ln -s ./test link RETVAL=$? @@ -442,7 +442,7 @@ EOF exit 1 fi - + # # look for possible MPI libraries # mpi_libs= # mpi_fort=`which mpif77 2>/dev/null` @@ -461,7 +461,7 @@ # if test "x${RETVAL}" = x0 ; then # a=`cat out` # for i in $a ; do -# case $i in +# case $i in # -*) # mpi_libs="$mpi_libs $i" ;; # esac @@ -480,12 +480,16 @@ # strip the comments and then convert the dependency file into # two arrays: PNAME, DNAME cat $1 | sed -e 's/#.*$//g' \ - | $AWK 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \ + | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \ > ./.pd_tmp + RETVAL=$? + if test ! "x${RETVAL}" = x0 ; then + echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$1\"" + exit 1 + fi . ./.pd_tmp rm -f ./.pd_tmp - printf "PNAME = "${} } @@ -508,7 +512,7 @@ -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 + made to find an appropriate "standard" optfile in the tools/build_options/ directory. -pdepend NAME | --pdepend NAME @@ -519,9 +523,12 @@ -pdefault=NAME | --pdefault=NAME Get the default package list from "NAME". + -bash NAME + 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 + Use "NAME" for the MAKE program. The default is "make" but many platforms, "gmake" is the preferred choice. -makefile NAME | -mf NAME @@ -535,53 +542,57 @@ -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 + 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 + 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, + 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 + 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 + 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 + 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 + 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. -[no]ieee | --[no]ieee - Do or don't use IEEE numerics. Note that this option - *only* works if it is supported by the OPTFILE that + Do or don't use IEEE numerics. Note that this option + *only* works if it is supported by the OPTFILE that is being used. + -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. + -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 + 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 @@ -617,14 +628,11 @@ 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 + Embed a tarball containing the full source code + (including the Makefile, etc.) used to build the executable [off by default] - -bash NAME - Explicitly specify the Bourne or BASH shell to use - - While it is most often a single word, the "NAME" variables specified + While it is most often a single word, the "NAME" variables specified above can in many cases be a space-delimited string such as: --enable pkg1 --enable 'pkg1 pkg2' --enable 'pkg1 pkg2 pkg3' @@ -635,7 +643,7 @@ For more detailed genmake documentation, please see: - http://mitgcm.org/devel_HOWTO/ + http://mitgcm.org/public/devel_HOWTO/ EOF @@ -651,7 +659,7 @@ fi default_nm="#define FC_NAMEMANGLE(X) X ## _" - + cat > genmake_test.c < /dev/null 2>&1 - RETVAL=$? - if test "x$RETVAL" = x0 ; then - printf "Un-linking $name ; " - rm -f $name - fi - fi - else - # YES: We symbolically link this file (with conditions if already there) - if test -L $name ; then - cmp $d/$ii $name > /dev/null 2>&1 - RETVAL=$? - yy=0 ; - for xx in $MPI_LNKF ; do if test $xx = $name ; then yy=1 ; fi ; done - if test "x$RETVAL" != x0 -a $yy = 0 ; then - # remove sym-link if different and has not just been linked - printf "Un-link + " - rm -f $name - fi - if test "x$RETVAL" = x0 ; then - # if identical, keep sym-link and keep record of it - MPI_LNKF="$MPI_LNKF $name" - fi - fi - if ! test -f $name ; then - # make sym-link and keep record of it - printf "Linking $ii to $name ; " - ln -sf $d/$ii $name - MPI_LNKF="$MPI_LNKF $name" - fi - fi - done - #------------------------------------------------------- fi done echo -#echo "MPI_LNKF='$MPI_LNKF'" if test "x${PLATFORM}" = x ; then PLATFORM=$p_PLATFORM @@ -1889,7 +1853,7 @@ ${TOOLSDIR}/set64bitConst.sh ${TOOLSDIR}/set64bitConst.csh - are working so please check paths or specify (with \$S64) a + are working so please check paths or specify (with \$S64) a working version of this script. EOF @@ -1901,6 +1865,19 @@ EXECUTABLE=${EXECUTABLE:-mitgcmuv} +# Set Standard Code Directories: +if test "x$STANDARDDIRS" = xUSE_THE_DEFAULT ; then + STANDARDDIRS="eesupp model" +fi +# if model in Standard-Code-Dir, add eesupp (needed to compile model) +echo " $STANDARDDIRS " | grep ' model ' > /dev/null 2>&1 +ckM=$? +echo " $STANDARDDIRS " | grep ' eesupp ' > /dev/null 2>&1 +ckE=$? +if test $ckM = 0 -a $ckE = 1 ; then + STANDARDDIRS="$STANDARDDIRS eesupp" +fi + # We have a special set of source files in eesupp/src which are # generated from some template source files. We'll make them first so # they appear as regular source code @@ -1951,20 +1928,11 @@ echo " getting package dependency info from $PDEPEND" # Strip the comments and then convert the dependency file into # two arrays: PNAME, DNAME -cat $PDEPEND | sed -e 's/#.*$//g' \ - | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \ - > ./.pd_tmp -RETVAL=$? -if test ! "x${RETVAL}" = x0 ; then - echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\"" - exit 1 -fi -. ./.pd_tmp -rm -f ./.pd_tmp +get_pdepend_list $PDEPEND # Search for default packages. Note that a "$ROOTDIR/pkg/pkg_groups" -# file should eventually be added so that, for convenience, one can -# specify groups of packages using names like "ocean" and "atmosphere". +# file has been added so that, for convenience, one can specify +# groups of packages using names like "ocean" and "atmosphere". echo " checking default package list: " if test "x${PDEFAULT}" = x ; then for i in "." $MODS ; do @@ -1995,14 +1963,15 @@ for i in $def ; do PACKAGES="$PACKAGES $i" done - echo " before group expansion packages are: $PACKAGES" + echo " before group expansion packages are:$PACKAGES" RET=1 while test $RET = 1 ; do expand_pkg_groups; RET=$?; done - echo " after group expansion packages are: $PACKAGES" + echo " after group expansion packages are: $PACKAGES" fi fi echo " applying DISABLE settings" +echo "" > ./.tmp_pack for i in $PACKAGES ; do echo $i >> ./.tmp_pack done @@ -2040,14 +2009,14 @@ PACKAGES="$PACKAGES $i" done rm -f ./.tmp_pack -echo " packages are: $PACKAGES" +echo " packages are: $PACKAGES" -# Check for package MNC: if NetCDF is available, then build the MNC +# Check for package MNC: if NetCDF is available, then build the MNC # template files ; otherwise, delete mnc from the list of packages. -echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1 -RETVAL=$? -if test "x$RETVAL" = x0 ; then - if test "x$HAVE_NETCDF" != xt ; then +echo " $PACKAGES " | grep ' mnc ' > /dev/null 2>&1 +mnc_in=$? +if test "x$HAVE_NETCDF" != xt ; then + if test "x$mnc_in" = x0 ; then cat < make_mnc.errors 2>&1 - RETVAL=$? - if test "x${RETVAL}" = x0 ; then - rm -f make_mnc.errors + # this prevent to add mnc (due to pdepend rules) if not available + DISABLE="$DISABLE mnc" + fi +else + # we have NetCDF, we try to build MNC template files + ( cd $ROOTDIR"/pkg/mnc" && $MAKE testclean && $MAKE templates ) > make_mnc.errors 2>&1 + RETVAL=$? + if test "x${RETVAL}" = x0 ; then + rm -f make_mnc.errors + else + 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 else - echo "Error: problem encountered while building source files in pkg/mnc:" - cat make_mnc.errors 1>&2 - exit 1 + DISABLE="$DISABLE mnc" fi fi fi # Check for package PROFILES: if NetCDF is not available, # then delete profiles from the list of available packages. -echo $PACKAGES | grep ' profiles ' > /dev/null 2>&1 -RETVAL=$? -if test "x$RETVAL" = x0 ; then - if test "x$HAVE_NETCDF" != xt ; then +if test "x$HAVE_NETCDF" != xt ; then + echo " $PACKAGES " | grep ' profiles ' > /dev/null 2>&1 + RETVAL=$? + if test "x$RETVAL" = x0 ; then cat <> F77srclist.tmp printf " $sf" >> F77srclist.tmp - if test "x$OPENAD" != x ; then + if test "x$OPENAD" != x ; then basename=${sf%%.F} isAD=`egrep ^$basename.f'[ ]*' adSrcFiles.tmp` - if test -z "$isAD" ; then + if test -z "$isAD" ; then toBeIgnored=`egrep ^$basename'[ ]*' ${OAD_DONT_COMPILE}` - if test -z "$toBeIgnored" ; then + if test -z "$toBeIgnored" ; then echo " \\" >> nonADF77srclist.tmp printf " $sf" >> nonADF77srclist.tmp - else + else echo " not to be compiled : $sf" fi - else # file is initially listed as an AD file we want to exclude it + else # file is initially listed as an AD file we want to exclude it # or we want to retain the untransformed version notToBeTransformed=`egrep ^$basename'[ ]*' ${OAD_DONT_TRANSFORM}` untransformedVersionToBeKept=`egrep ^$basename'[ ]*' ${OAD_KEEP_ORIGINAL}` - if test -n "$notToBeTransformed"; then + if test -n "$notToBeTransformed"; then echo " not to be transformed: $sf" fi if test -n "$untransformedVersionToBeKept" ; then echo " original to be kept : $sf" - fi + fi if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then echo " \\" >> nonADF77srclist.tmp printf " $sf" >> nonADF77srclist.tmp @@ -2520,8 +2501,14 @@ echo "" >> hsrclist.tmp echo "" >> ad_flow_files.tmp +CMDLINE=$0 +for xx in "$@" ; do nw=`echo $xx | wc -w` + if test $nw = '1' ; then CMDLINE="$CMDLINE $xx" + else CMDLINE="$CMDLINE '$xx'" ; fi +done + if test -f $MAKEFILE ; then - mv -f $MAKEFILE "$MAKEFILE.bak" + mv -f $MAKEFILE "$MAKEFILE.old" fi echo " Writing makefile: $MAKEFILE" echo "# Multithreaded + multi-processing makefile for:" > $MAKEFILE @@ -2529,7 +2516,7 @@ echo "# This makefile was generated automatically on" >> $MAKEFILE echo "# $THISDATE" >> $MAKEFILE echo "# by the command:" >> $MAKEFILE -echo "# $0 $G2ARGS" >> $MAKEFILE +echo "# $CMDLINE" >> $MAKEFILE echo "# executed by:" >> $MAKEFILE echo "# ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE @@ -2540,7 +2527,7 @@ cat >>$MAKEFILE <> $MAKEFILE -# add definitions for preprocessed sources -# and note that not all systems allow case sensitive extensions -# hence the $FS and $FS90 here. -# for fixed format f90 files we use ff90 or FF90 resp +# add definitions for preprocessed sources +# and note that not all systems allow case sensitive extensions +# hence the $FS and $FS90 here. +# for fixed format f90 files we use ff90 or FF90 resp # but these are not expected to be the original source files echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')' >> $MAKEFILE @@ -2685,13 +2672,13 @@ -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template -rm -rf *.o -rm -rf *.$FS *.flowdir - -rm -rf *.f$FS90 *_mod.h *_mod.F90 *.FF90 *.mod-whirl ad_input* - -rm -rf temp.sed + -rm -rf *.f$FS90 \$(AD_CLEAN) ad_input* Clean: @make clean @make cleanlinks -rm -f \$(SPECIAL_FILES) - -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log f90mkdepend.log *.bak + -rm -f genmake_state genmake_*optfile genmake_warnings genmake_errors + -rm -f make.log run.log f90mkdepend.log *.bak "$MAKEFILE.old" -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log CLEAN: @make Clean @@ -2733,7 +2720,7 @@ decode_files.o : EMBEDDED_FILES.h -## \$(F77_PP_SRC_FILES) +## \$(F77_PP_SRC_FILES) all_fF.tar.gz : \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile @echo Creating \$@ ... -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile @@ -2784,7 +2771,7 @@ #=== Automatic Differentiation Rules === #=== for TAMC/TAF ====================== -if test "x$OPENAD" = x ; then +if test "x$OPENAD" = x ; then cat >>$MAKEFILE < ad_input_code.$FS + cat \$(FLOFILES) \$(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 @@ -2844,18 +2831,18 @@ cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS \${EXE_AD}: ad_taf_output.o \$(OBJFILES) - \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) + \$(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 cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS ad_tamc: ad_tamc_output.o \$(OBJFILES) - \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) + \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) adonlyfwd: patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff - + adtrick: patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff @@ -2883,14 +2870,14 @@ 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) + \$(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 cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS ftl_tamc: ftl_tamc_output.o \$(OBJFILES) - \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS) + \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS) # ... SVD ... @@ -2919,17 +2906,17 @@ EOF -fi +fi #=== for OpenAD ======================== -if test "x$OPENAD" != x ; then +if test "x$OPENAD" != x ; then # ============ begin OpenAD specific section ============== cat >>$MAKEFILE <>$MAKEFILE < \$@ -f95_test.f90: all_mods.xb.x2w.w2f.pp.f$FS90 \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90 +f95_test.f90: all_mods.xb.x2w.w2f.pp.f$FS90 \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90 cat \$^ > \$@ f95_test.out: f95_test_mods.f90 f95_test.f90 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 -AD_OBJ_FILES=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) all_mods.xb.x2w.w2f.pp.o ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.o \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o) +# 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 + +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_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)) \$(AD_OBJ_FILES) - @echo Creating \$@ ... - \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES) \$(LIBS) +\$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.comp \$(AD_OBJ_FILES_S2) +ifeq (\$(MAKELEVEL),1) + \$(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 -%_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk +# create the module files +%_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk -# create the header files -%_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk +# create the header files +%_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: @@ -3049,33 +3056,33 @@ @./\$(EXE_AD) > \$@ CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90) -ad_input_code.f$FS90: ../OAD_support/maxMinDefs.f \$(CB2M_AD_FILES) +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 +# 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 +# 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 + ./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 -H -S \$< -o \$@ + ./preProcess.py --timing --r8 -H -S \$< -o \$@ # 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) +# 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 \$< @@ -3091,11 +3098,11 @@ # XAIF' -> WHIRL' ad_input_code_sf.w2f.pre.xb.x2w.B : ad_input_code_sf.w2f.pre.xb.xaif xaif2whirl - ./xaif2whirl --debug 1 -t OpenADTy_active --structured ad_input_code_sf.w2f.pre.B \$< + ./xaif2whirl --debug 1 ad_input_code_sf.w2f.pre.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 -openadType OpenADTy_active \$< + ./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 @@ -3103,40 +3110,29 @@ PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F # postprocess F' -ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 multi-pp.pl \$(PPEXTRAS:.F=.f) - perl multi-pp.pl -inline=../OAD_support/ad_inline.f \$< - # the postprocessor still gets the name wrong - cat \$<.pp | sed 's/RETURN//' > \$@ - -# extract all transformed modules -all_mods.xb.x2w.w2f.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90 - cat \$< | sed -n '/MODULE /,/END MODULE/p' > \$@ - -# remove the transformed globals module from the -# transformed ad_input_code file -# and remove for now the duplicate variables -# and fix 2 data statements -ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90 - cat \$< | sed '/MODULE /,/END MODULE/d' | sed '/^ INTEGER(w2f__i4) DOLOOP_UB/d' > \$@ +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 + 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 --outputFormat=fixed -m r -i ../OAD_support/ad_inline.f --width 4 \$< # setup some links %.xsd: \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ . -mfef90: +mfef90: \$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 . # link the support files: -\$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES): +\$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES): \$(LN) ../OAD_support/\$@ . -whirl2xaif xaif2whirl: - \$(LN) \${OPENADFORTTK}/bin/\$@ . - -%.pl: +whirl2xaif xaif2whirl: \$(LN) \${OPENADFORTTK}/bin/\$@ . -preProcess.py: +preProcess.py postProcess.py: \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ . whirl2f whirl2f_be: @@ -3145,6 +3141,8 @@ 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) + # ============ end OpenAD specific section ============== EOF @@ -3188,7 +3186,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 "Warning - this file is automatically generated - do NOT edit" -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