--- MITgcm/tools/genmake2 2003/10/22 18:00:49 1.21 +++ 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.21 2003/10/22 18:00:49 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 @@ -1041,8 +1041,8 @@ fi done -echo " Searching for CPP_OPTIONS.h in order to warn about the presence" -echo " of \"#define ALLOW_PKGNAME\"-type statements:" +echo " Searching for CPP_OPTIONS.h in order to warn about the presence" +echo " of \"#define ALLOW_PKGNAME\"-type statements:" CPP_OPTIONS= spaths=". $INCLUDEDIRS" for i in $spaths ; do @@ -1292,11 +1292,12 @@ @\$(EXECUTABLE) > \$@ 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 {} \; @@ -1363,15 +1364,20 @@ cat >>$MAKEFILE < ad_input_code.f +AD_CONFIG.h: + cat AD_CONFIG.template > AD_CONFIG.h # ... 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) \$(TAF_EXTRA) ad_input_code.f cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f @@ -1392,16 +1398,21 @@ ftl_taf_f: ftl_taf_output.f ftl_tamc_f: ftl_tamc_output.f -ftl_taf_output.f: ad_input_code.f - \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f - cat ad_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_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 ftl_taf: ftl_taf_output.o \$(OBJFILES) \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) -ftl_tamc_output.f: ad_input_code.f - \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f - cat ad_input_code_ftl.f | sed -f adjoint_sed > ftl_tamc_output.f +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) @@ -1411,9 +1422,14 @@ svd: svd_taf svd_taf_f: svd_taf_output.f -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_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) @@ -1457,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 <