--- MITgcm/tools/genmake2 2014/01/06 16:49:10 1.263 +++ MITgcm/tools/genmake2 2017/03/30 18:06:38 1.282 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.263 2014/01/06 16:49:10 jahn Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.282 2017/03/30 18:06:38 jmc Exp $ # $Name: $ # # Makefile generator for MITgcm UV codes @@ -19,13 +19,20 @@ -help | --help | -h | --h Print this help message and exit. + -oad | --oad + Generate a Makefile for an OpenAD built + + -nocat4ad | -dog4ad | -ncad | -dad + do not concatenate (cat) source code sent to TAF + resulting in compilation of multiple files + -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_oad" (for OpenAD built) or "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 -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 @@ -138,7 +145,7 @@ from \$PATH/lib and use binaries from \$PATH/bin. -omp | --omp - Activate OpenMP code + use Compiler option OMPFLAG + Activate OpenMP code -omp=OMPFLAG | --omp=OMPFLAG Activate OpenMP code + use Compiler option OMPFLAG @@ -690,6 +697,7 @@ echo "Error: unable to parse package dependencies -- please check PKG_DEPEND=\"$1\"" exit 1 fi + #echo "---- content of tmp file '.pd_tmp' :" ; cat .pd_tmp ; echo "---- end of file" . ./.pd_tmp rm -f ./.pd_tmp } @@ -1079,9 +1087,7 @@ } check_lapack_libs() { - if test ! "x$SKIP_LAPACK_CHECK" = x ; then - return - fi + if test "x$CHECK_FOR_LAPACK" = xf ; then return ; fi echo >> $LOGFILE echo "running: check_lapack_libs()" >> $LOGFILE cat < genmake_tla.F @@ -1277,8 +1283,8 @@ DEVEL= HAVE_TEST_L= -# comment this line out to enable lapack test -SKIP_LAPACK_CHECK=t +# set this to "t" to enable lapack test +CHECK_FOR_LAPACK=f # DEFINES checked by test compilation or command-line HAVE_SYSTEM= @@ -1325,7 +1331,9 @@ FS90= AUTODIFF_PKG_USED=f +OPENAD= AD_OPTFILE= +CAT_SRC_FOR_TAF=1 TAF= AD_TAF_FLAGS= FTL_TAF_FLAGS= @@ -1355,7 +1363,7 @@ gm_s8="HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME HAVE_LAPACK HAVE_FLUSH" # 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" +gm_s10="AUTODIFF_PKG_USED AD_OPTFILE OPENAD TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS" gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS" gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES" @@ -1400,13 +1408,15 @@ -help | --help | -h | --h) usage ;; - -nooptfile | --nooptfile) - OPTFILE="NONE" ;; -optfile | --optfile | -of | --of) ac_prev=OPTFILE ;; -optfile=* | --optfile=* | -of=* | --of=*) OPTFILE=$ac_optarg ;; + -oad | --oad) + OPENAD="true" ; ALWAYS_USE_F90=1 ;; + -nocat4ad | -dog4ad | -ncad | -dad) + CAT_SRC_FOR_TAF=0 ;; -adoptfile | --adoptfile | -adof | --adof) ac_prev=AD_OPTFILE ;; -adoptfile=* | --adoptfile=* | -adof=* | --adof=*) @@ -1578,7 +1588,7 @@ #TMP=./genmk_$$ #- try to put temporary files in system-local /tmp dir -TMP=/tmp/genmk_$$ +TMP=/tmp/genmk_${USER}_$$ touch $TMP ; retVal=$? if [ $retVal -eq 0 ] ; then if test ! -r $TMP ; then TMP=./genmk_$$ ; fi @@ -1680,10 +1690,12 @@ echo " getting AD_OPTFILE information:" if test "x${AD_OPTFILE}" = x ; then - if test "x$MITGCM_AD_OF" = x ; then + if test "x$MITGCM_AD_OF" != x ; then + AD_OPTFILE=$MITGCM_AD_OF + elif test "x$OPENAD" = x ; then AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default else - AD_OPTFILE=$MITGCM_AD_OF + AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_oad fi fi if test "x${AD_OPTFILE}" != xNONE ; then @@ -1706,6 +1718,12 @@ fi #==================================================================== +# Initialize INCLUDEDIRSMK from and optfile INCLUDEDIRS +if test "x${INCLUDEDIRS}" != "x" ; then + INCLUDEDIRSMK=${INCLUDEDIRS} +fi + +#==================================================================== # Set default values if not set by the optfile # # Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined. If not, @@ -1950,26 +1968,56 @@ fi rm -f genmake_tcomp* -printf " Do we have the etime() command using $FC... " -cat > genmake_tcomp.$FS < genmake_tcomp_1.$FS < genmake_tcomp.log 2>&1 +$FC $FFLAGS -o genmake_tcomp_1 genmake_tcomp_1.$FS > genmake_tcomp.log 2>&1 RETVAL=$? if test "x$RETVAL" = x0 ; then - HAVE_ETIME=t - DEFINES="$DEFINES -DHAVE_ETIME" - echo "yes" + HAVE_ETIME='Fct' + DEFINES="$DEFINES -DHAVE_ETIME_FCT" + echo " yes (${HAVE_ETIME})" else + cat > genmake_tcomp_2.$FS <> genmake_tcomp.log 2>&1 + RETVAL=$? + if test "x$RETVAL" = x0 ; then + echo -n 'c,' + ./genmake_tcomp_2 > genmake_tcomp_2.out 2>&1 + RETVAL=$? + fi + if test "x$RETVAL" = x0 ; then + echo -n 'r:' + RETVAL=`cat genmake_tcomp_2.out | $AWK '{print $1}'` + fi + if test "x$RETVAL" = x0 ; then + HAVE_ETIME='SbR' + DEFINES="$DEFINES -DHAVE_ETIME_SBR" + echo " yes (${HAVE_ETIME})" + else HAVE_ETIME= - echo "no" + echo " no" + fi fi +#mkdir chk_etime ; cp -p -f genmake_tcomp* chk_etime rm -f genmake_tcomp* printf " Can we call simple C routines (here, \"cloc()\") using $FC... " @@ -2064,6 +2112,8 @@ printf "$d " SOURCEDIRS="$SOURCEDIRS $d" INCLUDEDIRS="$INCLUDEDIRS $d" + SOURCEDIRSMK="$SOURCEDIRSMK $d" + INCLUDEDIRSMK="$INCLUDEDIRSMK $d" fi done echo @@ -2087,6 +2137,9 @@ if test "x${TOOLSDIR}" = x ; then TOOLSDIR="$ROOTDIR/tools" + TOOLSDIRMK='$(ROOTDIR)'"/tools" +else + TOOLSDIRMK=${TOOLSDIR} fi if test ! -d ${TOOLSDIR} ; then echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!" @@ -2397,18 +2450,19 @@ if test "x$p" = "x$pname" ; then pin="t" ; fi done - # Is the DNAME entry a (+) or (-) rule ? + # Is the DNAME entry a (=), (+) or (-) rule ? tmp="dname=\"\$DNAME_$i\"" eval $tmp - plus="-" + plus="a" echo $dname | grep '^+' > /dev/null 2>&1 RETVAL=$? - if test "x$RETVAL" = x0 ; then - plus="+" - fi + if test "x$RETVAL" = x0 ; then plus="+" ; fi + echo $dname | grep '^-' > /dev/null 2>&1 + RETVAL=$? + if test "x$RETVAL" = x0 ; then plus="-" ; fi # Is $dname in the current $PACKAGES list? - dname=`echo $dname | sed -e 's/^[+-]//'` + dname=`echo $dname | sed -e 's/^[=+-]//'` din="f" for p in $PACKAGES ; do if test "x$p" = "x$dname" ; then @@ -2417,7 +2471,7 @@ done # 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 + if test "x$pin" = xt -a "x$plus" != "x-" -a "x$din" = xf ; then #echo " " $pname ": need to add :" $dname in_dis="f" for dis in $DISABLE ; do @@ -2426,10 +2480,17 @@ fi done if test "x$in_dis" = xt ; then - echo "Error: can't satisfy package dependencies:" - echo " \"$dname\" is required by the dependency rules" - echo " but is disallowed by the DISABLE settings" - exit 1 + if test "x$plus" = "x+" ; then + echo "Error: can't satisfy package dependencies:" + echo " \"$dname\" is required with pkg \"$pname\" (dependency rules)" + echo " but is disallowed by the DISABLE settings" + exit 1 + elif test "x$ck" = xt ; then + #- (=) is a weaker dependency rule: warning but no stop + echo "Warning: pkg \"$dname\" is set DISABLE (from: \"$PKG_LIST\")" + echo -n " but is recommended with pkg \"$pname\" (dependency rules)" + echo " <- ignores recommendation" + fi else PACKAGES="$PACKAGES $dname" ck= @@ -2439,12 +2500,12 @@ # Do we need to get rid of $dname according to the dependency rules? if test "x$pin" = xt -a "x$plus" = "x-" -a "x$din" = xt; then echo "Error: can't satisfy package dependencies:" - echo " \"$pname\" was requested but is disallowed by" - echo " the dependency rules for \"$dname\"" + echo " \"$dname\" was requested but is disallowed by" + echo " the dependency rules for \"$pname\"" exit 1 fi - i=`echo "$i + 1" | bc -l` - #i=$(( $i + 1 )) + i=`expr $i + 1` + #i=`echo "$i + 1" | bc -l` done ck=$ck"t" done @@ -2452,9 +2513,12 @@ fi for i in $PACKAGES ; do adr="$ROOTDIR/pkg/$i" + adrmk='$(ROOTDIR)'"/pkg/$i" if test -d $adr ; then SOURCEDIRS="$SOURCEDIRS $adr" INCLUDEDIRS="$INCLUDEDIRS $adr" + SOURCEDIRSMK="$SOURCEDIRSMK $adrmk" + INCLUDEDIRSMK="$INCLUDEDIRSMK $adrmk" if test "x$i" = xautodiff ; then AUTODIFF_PKG_USED=t fi @@ -2510,20 +2574,24 @@ if test "x$STANDARDDIRS" != x ; then for d in $STANDARDDIRS ; do adr="$ROOTDIR/$d/src" + adrmk='$(ROOTDIR)/'"$d/src" if test ! -d $adr ; then echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\"" echo " is correct and that you correctly specified the STANDARDDIRS option" exit 1 else SOURCEDIRS="$SOURCEDIRS $adr" + SOURCEDIRSMK="$SOURCEDIRSMK $adrmk" fi adr="$ROOTDIR/$d/inc" + adrmk='$(ROOTDIR)/'"$d/inc" if test ! -d $adr ; then echo "Error: directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\"" echo " is correct and that you correctly specified the STANDARDDIRS option" exit 1 else INCLUDEDIRS="$INCLUDEDIRS $adr" + INCLUDEDIRSMK="$INCLUDEDIRSMK $adrmk" fi done fi @@ -2623,8 +2691,9 @@ OAD_KEEP_ORIGINAL="/dev/null" OAD_CB2M_FILES="/dev/null" OADTOOLS="$TOOLSDIR/OAD_support" + OADTOOLSMK='$(TOOLSDIR)/OAD_support' echo " looking for dontCompile file: " - for i in "." $MODS ; do + for i in "." $MODS $OADTOOLS ; do if test -r $i"/dontCompile" ; then OAD_DONT_COMPILE=$i"/dontCompile" echo " found $OAD_DONT_COMPILE" @@ -2632,7 +2701,7 @@ fi done echo " looking for dontTransform file: " - for i in "." $MODS ; do + for i in "." $MODS $OADTOOLS ; do if test -r $i"/dontTransform" ; then OAD_DONT_TRANSFORM=$i"/dontTransform" echo " found $OAD_DONT_TRANSFORM" @@ -2640,7 +2709,7 @@ fi done echo " looking for keepOriginal file: " - for i in "." $MODS ; do + for i in "." $MODS $OADTOOLS ; do if test -r $i"/keepOriginal" ; then OAD_KEEP_ORIGINAL=$i"/keepOriginal" echo " found $OAD_KEEP_ORIGINAL" @@ -2648,7 +2717,7 @@ fi done echo " looking for cb2mFiles: " - for i in "." $MODS ; do + for i in "." $MODS $OADTOOLS ; do if test -r $i"/cb2mFiles" ; then OAD_CB2M_FILES=$i"/cb2mFiles" echo " found $OAD_CB2M_FILES" @@ -2667,7 +2736,11 @@ printf 'H_SRC_FILES = ' > $TMP.hsrclist printf 'AD_FLOW_FILES = ' > $TMP.ad_flow_files alldirs="$SOURCEDIRS $INCLUDEDIRS ." +alldirsmk=(${SOURCEDIRSMK} ${INCLUDEDIRSMK} ".") +nd=0 for d in $alldirs ; do + dmk=${alldirsmk[${nd}]} + nd=$((${nd}+1)) deplist= sfiles=`( cd $d; echo *.[h,c,F] *.flow )` sfiles=`( echo $sfiles; cd $d; echo *.F90 )` @@ -2770,12 +2843,12 @@ if test "x$deplist" != x ; then if test "$d" != "." ; then echo "" >> $TMP.srclinks - echo "# These files are linked from $d" >> $TMP.srclinks + echo "# These files are linked from $dmk ( aka $d )" >> $TMP.srclinks echo "$deplist :" >> $TMP.srclinks # We need to make sure that the link isn't already there. # This may happen when make thinks that a header file has to be "remade" # because a module it depends on has changed. In this case we do nothing. - printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> $TMP.srclinks + printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $dmk >> $TMP.srclinks fi fi done @@ -2832,15 +2905,15 @@ ROOTDIR = ${ROOTDIR} BUILDDIR = ${BUILDDIR} -SOURCEDIRS = ${SOURCEDIRS} -INCLUDEDIRS = ${INCLUDEDIRS} +SOURCEDIRS = ${SOURCEDIRSMK} +INCLUDEDIRS = ${INCLUDEDIRSMK} EXEDIR = ${EXEDIR} EXECUTABLE = \$(EXEDIR)/${EXECUTABLE} -TOOLSDIR = ${TOOLSDIR} -OADTOOLS = ${OADTOOLS} +TOOLSDIR = ${TOOLSDIRMK} +OADTOOLS = ${OADTOOLSMK} #eh3 new defines for the adjoint work -AUTODIFF = ${ROOTDIR}/pkg/autodiff +AUTODIFF = \$(ROOTDIR)/pkg/autodiff EXE_AD = ${EXE_AD} EXE_FTL = ${EXE_FTL} EXE_SVD = ${EXE_SVD} @@ -2887,8 +2960,8 @@ KFLAGS1 = ${KFLAGS1} KFLAGS2 = ${KFLAGS2} # Optim./debug for FC -FFLAGS = ${FFLAGS} ${FEXTRAFLAGS} -FOPTIM = ${FOPTIM} +FFLAGS = ${FFLAGS} +FOPTIM = ${FOPTIM} ${FEXTRAFLAGS} # Optim./debug for FC F90FLAGS = ${F90FLAGS} F90OPTIM = ${F90OPTIM} @@ -2954,7 +3027,7 @@ lib: libmitgcmuv.a -libmitgcmuv.a: \$(OBJFILES) +libmitgcmuv.a: \$(SPECIAL_FILES) \$(OBJFILES) ar rcv libmitgcmuv.a \$(OBJFILES) ar d libmitgcmuv.a main.o @@ -2964,10 +3037,6 @@ small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES) -output.txt: \$(EXECUTABLE) - @printf 'running ... ' - @\$(EXECUTABLE) > \$@ - # remove most of the files that "make" generates clean: -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template @@ -3119,6 +3188,24 @@ echo >> $MAKEFILE rm -f $TMP.adSrcFiles +if test $CAT_SRC_FOR_TAF = 0 ; then +cat >>$MAKEFILE <>$MAKEFILE < ad_input_code.$FS -ad_taf_output.$FS: ad_input_code.$FS - @-rm -f ad_input_code_ad.$FS ; echo '' +adtafonly: \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS ls -l ad_input_code_ad.$FS cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS -adtafonly: +EOF + +if test $CAT_SRC_FOR_TAF = 1 ; then +cat >>$MAKEFILE < ad_taf_output.$FS @@ -3155,20 +3247,48 @@ \$(EXE_AD): \$(SPECIAL_FILES) \$(H_SRC_FILES) ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES) \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.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 +adobj: ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) -ad_tamc: ad_tamc_output.o \$(OBJFILES) - \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) +EOF + +else +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) \$(F77_PP_SRC_FILES) + @\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES) + @-rm -f \$(AD_FILES:.$FS=_ad.$FS) \$(AD_FILES:.$FS=_ad.o); echo '' + \$(MAKE) -f \$(MAKEFILE) remove_comments + \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) \$(FLOWFILES) \$(AD_FILES) + \$(MAKE) -f \$(MAKEFILE) adj_sed + cat \$(AD_FILES:.$FS=_ad.$FS) > ad_taf_output.$FS + +\$(EXE_AD): \$(SPECIAL_FILES) \$(H_SRC_FILES) ad_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES) + \$(MAKE) -f \$(MAKEFILE) adobjfiles + \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(AD_FILES:.$FS=_ad.o) \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS) + +adobj: ad_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) + \$(MAKE) -f \$(MAKEFILE) adobjfiles + +EOF +fi +cat >>$MAKEFILE < ad_tamc_output.$FS + +ad_tamc: ad_tamc_output.o \$(OBJFILES) + \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) # ... FTL ... ftlall: ftl_exe_target @@ -3190,13 +3310,18 @@ @\$(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 - @-rm -f ftl_input_code_tl.$FS ; echo '' +ftltafonly: \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS ls -l ftl_input_code_tl.$FS cat ftl_input_code_tl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS -ftltafonly: +EOF + +if test $CAT_SRC_FOR_TAF = 1 ; then +cat >>$MAKEFILE < ftl_taf_output.$FS @@ -3204,6 +3329,31 @@ \$(EXE_FTL): \$(SPECIAL_FILES) \$(H_SRC_FILES) ftl_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES) \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) ftl_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS) +EOF + +else +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) \$(F77_PP_SRC_FILES) + @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES) + @-rm -f \$(AD_FILES:.$FS=_tl.$FS) \$(AD_FILES:.$FS=_tl.o); echo '' + \$(MAKE) -f \$(MAKEFILE) remove_comments + \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) \$(AD_FLOW_FILES) \$(AD_FILES) + \$(MAKE) -f \$(MAKEFILE) ftl_sed + cat \$(AD_FILES:.$FS=_tl.$FS) > ftl_taf_output.$FS + +\$(EXE_FTL): \$(SPECIAL_FILES) \$(H_SRC_FILES) ftl_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES) + \$(MAKE) -f \$(MAKEFILE) ftlobjfiles + \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(AD_FILES:.$FS=_tl.o) \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS) + +EOF +fi + +cat >>$MAKEFILE < ftl_tamc_output.$FS @@ -3246,6 +3396,7 @@ # ============ begin OpenAD specific section ============== cat >>$MAKEFILE <>$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) \$(EXE_AD) + CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES)) .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) @@ -3318,6 +3476,7 @@ OAD_cp.F90 \ OAD_rev.F90 \ OAD_tape.F90 \ +OAD_regular_cp.F90 \ revolve.F90 OPENAD_SUPPORT_C_SRC_FILES = \ @@ -3344,28 +3503,21 @@ \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS) # create sources files modules from header files containing common blocks -%_mod.FF90 : %.h \${OADTOOLS}/cb2mGetModules.csh \${OADTOOLS}/cb2mGetModules.awk - \${OADTOOLS}/cb2mGetModules.csh $< \${OADTOOLS}/cb2mGetModules.awk +%_mod.FF90 : %.h \$(OADTOOLS)/cb2mGetModules.csh \$(OADTOOLS)/cb2mGetModules.awk + \$(OADTOOLS)/cb2mGetModules.csh $< \$(OADTOOLS)/cb2mGetModules.awk # create new header files with USE statements for the new modules made above -%_mod.h : %.h \${OADTOOLS}/cb2mGetHeaders.csh \${OADTOOLS}/cb2mGetHeaders.awk - \${OADTOOLS}/cb2mGetHeaders.csh $< \${OADTOOLS}/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES) +%_mod.h : %.h \$(OADTOOLS)/cb2mGetHeaders.csh \$(OADTOOLS)/cb2mGetHeaders.awk + \$(OADTOOLS)/cb2mGetHeaders.csh $< \$(OADTOOLS)/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES) # change the include directives of everybody to refer to the new header files with the USE statements -%_cb2m.FF90 : %.F \${OADTOOLS}/cb2mUseModules.bash - \${OADTOOLS}/cb2mUseModules.bash $< ${MPI} +%_cb2m.FF90 : %.F \$(OADTOOLS)/cb2mUseModules.bash + \$(OADTOOLS)/cb2mUseModules.bash $< ${MPI} # makefile debug rule small_f: \$(CB2M_F90_PP_SRC_FILES) .PHONY: small_f -ad_output.txt: \$(EXE_AD) - @printf 'linking data files ... ' - \$(LN) -f ../input_ad/data* ../input_ad/eedata . - \$(LN) -f ../../global_ocean.90x40x15/input/*.bin . - @printf 'running ... ' - @./\$(EXE_AD) > \$@ - ad_input_code.f$FS90: \$(CB2M_AD_FILES) cat \$^ > \$@ @@ -3375,7 +3527,7 @@ # 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 \${OADTOOLS}/stop2print.sed > ad_input_code_sf.pre.s2p.f90 + cat \$< | sed -f \$(OADTOOLS)/stop2print.sed > ad_input_code_sf.pre.s2p.f90 # F -> WHIRL ad_input_code_sf.pre.s2p.B: ad_input_code_sf.pre.s2p.f90 @@ -3398,10 +3550,10 @@ \${OPEN64ROOT}/whirl2f/whirl2f -FLIST:ftn_file=\$@ -openad \$< # insert template directives -ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 \${OADTOOLS}/insertTemplateDir.bash - \${OADTOOLS}/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 \$(OADTOOLS)/insertTemplateDir.bash + \$(OADTOOLS)/insertTemplateDir.bash \$< \$@ -PPEXTRAS=\$(notdir \$(wildcard \${OADTOOLS}/ad_template.*.F)) ad_inline.F +PPEXTRAS=\$(notdir \$(wildcard \$(OADTOOLS)/ad_template.*.F)) ad_inline.F # postprocess F' 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 ad_inline.f \$< @@ -3416,7 +3568,7 @@ # link the support files: \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES) \$(PPEXTRAS): - \$(LN) \${OADTOOLS}/\$@ . + \$(LN) \$(OADTOOLS)/\$@ . AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag