--- MITgcm/tools/genmake2 2009/04/15 22:21:03 1.187 +++ MITgcm/tools/genmake2 2009/04/28 18:46:06 1.193 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.187 2009/04/15 22:21:03 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.193 2009/04/28 18:46:06 utke Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -1173,15 +1173,6 @@ fi #echo "$0::$1:$2:$3:$4:$5:$6:$7:" -#OPTIONS= -#n=0 -#for i ; do -# echo "$i $n" -# setvar="OPTIONS[$n]='$i'" -# # echo " $setvar" -# eval "$setvar" -# n=$(( $n + 1 )) -#done #parse_options ac_prev= for ac_option in "$@" ; do @@ -1790,7 +1781,6 @@ printf "\n=== Setting defaults ===\n" printf " Adding MODS directories: " -MPI_LNKF= for d in $MODS ; do if test ! -d $d ; then echo @@ -1800,52 +1790,9 @@ printf "$d " SOURCEDIRS="$SOURCEDIRS $d" INCLUDEDIRS="$INCLUDEDIRS $d" - #------------------------------------------------------- - # Put special links so that MPI specific files are used - MPI_FILES=`(cd $d ; find . -name "*_mpi" -print)` - for i in $MPI_FILES ; do - ii=`echo $i | sed 's:^\./::'` - name=`echo $ii | sed 's:_mpi::' ` - if test "x$MPI" = x ; then - # NO: We undo an _mpi symbolically linked file - if test -L $name ; then - cmp $name "$d/$ii" > /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 @@ -2520,6 +2467,12 @@ 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" fi @@ -2529,7 +2482,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 @@ -2685,8 +2638,7 @@ -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 @@ -2825,7 +2777,7 @@ adtaf: ad_taf_output.$FS adtamc: ad_tamc_output.$FS -ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) +ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES) @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h -rm -f ad_config.template @@ -3015,11 +2967,31 @@ 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 @@ -3049,7 +3021,7 @@ @./\$(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) ../OAD_support/maxMinDefs.f cat \$^ > \$@ # strip all comments and blanks to reduce @@ -3103,21 +3075,13 @@ 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 -m r -i ../OAD_support/ad_inline.f --width 4 \$< # setup some links %.xsd: @@ -3133,10 +3097,7 @@ whirl2xaif xaif2whirl: \$(LN) \${OPENADFORTTK}/bin/\$@ . -%.pl: - \$(LN) \${OPENADFORTTK}/bin/\$@ . - -preProcess.py: +preProcess.py postProcess.py: \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ . whirl2f whirl2f_be: @@ -3145,6 +3106,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 + # ============ end OpenAD specific section ============== EOF