--- MITgcm/tools/genmake2 2003/10/21 18:35:08 1.15 +++ MITgcm/tools/genmake2 2003/10/23 04:41:41 1.22 @@ -1,6 +1,6 @@ #!/bin/bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.15 2003/10/21 18:35:08 edhill Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.22 2003/10/23 04:41:41 edhill Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -121,6 +121,7 @@ p_FC="$p_FC $c" fi done + rm -f ./hello.f ./hello if test "x${p_FC}" = x ; then cat 1>&2 <> $MAKEFILE echo "# executed by:" >> $MAKEFILE echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE + +EXE_AD=$EXECUTABLE"_ad" +EXE_FTL=$EXECUTABLE"_ftl" +EXE_SVD=$EXECUTABLE"_svd" + cat >>$MAKEFILE < \$@ clean: + -cat AD_CONFIG.template > AD_CONFIG.h -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} Clean: @make clean @make cleanlinks - -rm -f Makefile.bak genmake_state genmake_optfile make.log + -rm -f Makefile.bak genmake_state genmake_*optfile make.log CLEAN: @make Clean -find \$(EXEDIR) -name "*.meta" -exec rm {} \; @@ -1274,7 +1305,7 @@ -find \$(EXEDIR) -name "fort.*" -exec rm {} \; -rm -f \$(EXECUTABLE) output.txt -Makefile: makefile +#eh3 Makefile: makefile makefile: ${0} $@ cleanlinks: @@ -1304,6 +1335,9 @@ TAMC = ${TAMC} TAF = ${TAF} +TAF_EXTRA = ${TAF_EXTRA} +TAMC_EXTRA = ${TAMC_EXTRA} + EOF ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS" @@ -1326,38 +1360,79 @@ echo -n " $i" >> $MAKEFILE done echo >> $MAKEFILE +rm -f ad_files cat >>$MAKEFILE < AD_CONFIG.h -ad_input_code.f: \$(F77FILES) +# ... AD ... +ad: ad_taf +ad_taf_f: ad_taf_output.f +ad_tamc_f: ad_tamc_output.f + +ad_input_code.f: \$(SRCFILES) + cat ad_config.template > AD_CONFIG.h + @make \$(F77FILES) @make \$(AD_FLOW_FILES) cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f - 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) - + \$(LINK) -o ${EXE_AD} \$(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) + \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) + + +# ... FTL ... +ftl: ftl_taf +ftl_taf_f: ftl_taf_output.f +ftl_tamc_f: ftl_tamc_output.f + +ftl_input_code.f: \$(SRCFILES) + cat ftl_config.template > AD_CONFIG.h + @make \$(AD_FLOW_FILES) + cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f +ftl_taf_output.f: ftl_input_code.f + \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f + cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f -flt_taf_output.f: ad_input_code.f - \$(TAF) \$(FTL_TAF_FLAGS) ad_input_code.f - cat ad_input_code_ad.f | sed -f adjoint_sed > flt_taf_output.f +ftl_taf: ftl_taf_output.o \$(OBJFILES) + \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) -flt_taf: flt_taf_output.o \$(OBJFILES) - \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) flt_taf_output.o \$(LIBS) +ftl_tamc_output.f: ftl_input_code.f + \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f + cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_tamc_output.f +ftl_tamc: ftl_tamc_output.o \$(OBJFILES) + \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS) + + +# ... SVD ... +svd: svd_taf +svd_taf_f: svd_taf_output.f + +svd_input_code.f: \$(SRCFILES) + cat svd_config.template > AD_CONFIG.h + @make \$(AD_FLOW_FILES) + cat \$(AD_FLOW_FILES) \$(AD_FILES) > svd_input_code.f + +svd_taf_output.f: svd_input_code.f + \$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) svd_input_code.f + cat svd_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f + +svd_taf: svd_taf_output.o \$(OBJFILES) + \$(LINK) -o ${EXE_SVD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS) #========================================= @@ -1398,6 +1473,45 @@ printf "\n=== Done ===\n" +# Write the "template" files for the adjoint builds +cat >>AD_CONFIG.template <>ad_config.template <>ftl_config.template <>svd_config.template <