--- MITgcm/tools/genmake2 2003/10/21 15:29:20 1.14 +++ MITgcm/tools/genmake2 2003/10/21 20:42:16 1.18 @@ -1,6 +1,6 @@ #!/bin/bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.14 2003/10/21 15:29:20 edhill Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.18 2003/10/21 20:42:16 edhill Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -46,14 +46,14 @@ PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups" if test -r $PKG_GROUPS ; then cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp - cat ./p1.tmp | awk '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp + cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp matched=0 for i in $PACKAGES ; do line=`grep "^ *$i" ./p2.tmp` RETVAL=$? if test "x$RETVAL" = x0 ; then matched=1 - replace=`echo $line | awk '{ $1=""; $2=""; print $0 }'` + replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'` echo " replacing \"$i\" with: $replace" new_packages="$new_packages $replace" else @@ -136,7 +136,7 @@ echo " The possible FORTRAN compilers found in your path are:" echo " "$p_FC if test "x$FC" = x ; then - FC=`echo $p_FC | awk '{print $1}'` + FC=`echo $p_FC | $AWK '{print $1}'` fi fi @@ -202,7 +202,7 @@ # 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=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \ > ./.pd_tmp source ./.pd_tmp rm -f ./.pd_tmp @@ -319,6 +319,7 @@ PWD=`pwd` MAKE=make +AWK=awk THISHOSTNAME=`hostname` THISCWD=`pwd` THISDATE=`date` @@ -334,6 +335,17 @@ AUTODIFF_PKG_USED=f AD_OPTFILE= +TAF= +AD_TAF_FLAGS= +FTL_TAF_FLAGS= +SVD_TAF_FLAGS= +TAF_EXTRA= +TAMC= +AD_TAMC_FLAGS= +FTL_TAF_FLAGS= +SVD_TAMC_FLAGS= +TAMC_EXTRA= + # The following state can be set directly by command-line switches gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT" @@ -346,11 +358,11 @@ gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF" # The following are all related to adjoint/tangent-linear stuff -gm_s7="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF DIFF_FLAGS AD_TAMC_FLAGS AD_TAF_FLAGS" +gm_s7="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS" gm_s8="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS" -gm_s9="" +gm_s9="TAF_EXTRA TAMC_EXTRA" -gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8" +gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8 $gm_s9" echo @@ -495,6 +507,16 @@ -ds | --ds) DUMPSTATE=t ;; + -taf_extra | --taf_extra) + ac_prev=TAF_EXTRA ;; + -taf_extra=* | --taf_extra=*) + TAF_EXTRA=$ac_optarg ;; + + -tamc_extra | --tamc_extra) + ac_prev=TAMC_EXTRA ;; + -tamc_extra=* | --tamc_extra=*) + TAMC_EXTRA=$ac_optarg ;; + -*) echo "Error: unrecognized option: "$ac_option usage @@ -721,7 +743,7 @@ # 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}' \ + | $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 @@ -755,7 +777,7 @@ else echo " using PDEFAULT=\"$PDEFAULT\"" # Strip the comments and add all the names - def=`cat $PDEFAULT | sed -e 's/#.*$//g' | awk '(NF>0){print $0}'` + def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'` RETVAL=$? if test "x${RETVAL}" != x0 ; then echo -n "Error: can't parse default package list " @@ -935,7 +957,7 @@ fi done if test "x$has_pack" = xf ; then - undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'` + undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'` echo "#undef $undef" >> $PACKAGES_DOT_H".tmp" # DEFINES="$DEFINES -U$undef" @@ -961,7 +983,7 @@ C Packages enabled by genmake: EOF for i in $PACKAGES ; do - def=`echo "ALLOW_$i" | awk '{print toupper($0)}'` + def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'` echo "#define $def" >> $PACKAGES_DOT_H".tmp" #eh3 DEFINES="$DEFINES -D$def" @@ -1096,7 +1118,7 @@ for sf in $sfiles ; do if test ! -r ".links.tmp/$sf" ; then if test -f "$d/$sf" ; then - extn=`echo $sf | awk -F '.' '{print $NF}'` + extn=`echo $sf | $AWK -F '.' '{print $NF}'` touch .links.tmp/$sf deplist="$deplist $sf" case $extn in @@ -1273,7 +1295,7 @@ -find \$(EXEDIR) -name "fort.*" -exec rm {} \; -rm -f \$(EXECUTABLE) output.txt -Makefile: makefile +#eh3 Makefile: makefile makefile: ${0} $@ cleanlinks: @@ -1303,6 +1325,9 @@ TAMC = ${TAMC} TAF = ${TAF} +TAF_EXTRA = ${TAF_EXTRA} +TAMC_EXTRA = ${TAMC_EXTRA} + EOF ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS" @@ -1328,35 +1353,49 @@ cat >>$MAKEFILE < ad_input_code.f - +# ... AD ... ad_taf_output.f: ad_input_code.f - \$(TAF) \$(AD_TAF_FLAGS) ad_input_code.f + \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f ad_taf: ad_taf_output.o \$(OBJFILES) \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) - ad_tamc_output.f: ad_input_code.f - \$(TAMC) \$(AD_TAMC_FLAGS) ad_input_code.f - cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f + \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f + cat ad_input_code_ad.f | sed -f adjoint_sed > ad_tamc_output.f ad_tamc: ad_tamc_output.o \$(OBJFILES) \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) +# ... FLT ... flt_taf_output.f: ad_input_code.f - \$(TAF) \$(FTL_TAF_FLAGS) ad_input_code.f + \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f cat ad_input_code_ad.f | sed -f adjoint_sed > flt_taf_output.f flt_taf: flt_taf_output.o \$(OBJFILES) \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) flt_taf_output.o \$(LIBS) +flt_tamc_output.f: ad_input_code.f + \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f + cat ad_input_code_ad.f | sed -f adjoint_sed > flt_tamc_output.f + +flt_tamc: flt_tamc_output.o \$(OBJFILES) + \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) flt_tamc_output.o \$(LIBS) + + +# ... SVD ... +svd_taf_output.f: ad_input_code.f + \$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f + cat ad_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f + +svd_taf: svd_taf_output.o \$(OBJFILES) + \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS) #=========================================