--- MITgcm/tools/genmake2 2012/08/28 21:11:22 1.238 +++ MITgcm/tools/genmake2 2012/09/19 20:46:03 1.241 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.238 2012/08/28 21:11:22 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.241 2012/09/19 20:46:03 utke Exp $ # $Name: $ # # Makefile generator for MITgcm UV codes @@ -174,28 +174,18 @@ test_for_package_in_cpp_options() { cpp_options=$1 pkg=$2 - test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg[ ]" - test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg[ ]" - test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg[ ]" - test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg[ ]" - test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg$" - test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg$" - test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg$" - test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg$" + test_for_string_in_file $cpp_options "^ *# *define *\" + test_for_string_in_file $cpp_options "^ *# *undef *\" + test_for_string_in_file $cpp_options "^ *# *define *\" + test_for_string_in_file $cpp_options "^ *# *undef *\" } # Search for particular CPP #cmds associated with MPI # usage: test_for_mpi_in_cpp_eeoptions CPP_file test_for_mpi_in_cpp_eeoptions() { cpp_options=$1 - test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI[ ]" - test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI[ ]" - test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI[ ]" - test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI[ ]" - test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI$" - test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI$" - test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI$" - test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI$" + test_for_string_in_file $cpp_options "^ *# *define *\" + test_for_string_in_file $cpp_options "^ *# *undef *\" } # Search for particular string in a file. Return 1 if detected, 0 if not @@ -203,7 +193,7 @@ test_for_string_in_file() { file=$1 strng=$2 - grep -i "$strng" $file > /dev/null 2>&1 + grep "$strng" $file > /dev/null 2>&1 RETVAL=$? if test "x${RETVAL}" = x0 ; then printf "Error: In $file there is an illegal line: " @@ -1668,7 +1658,7 @@ if test ! "x$MPI" = x ; then echo " Turning on MPI cpp macros" - DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI" + DEFINES="$DEFINES -DALLOW_USE_MPI" fi if test ! "x$OMP" = x ; then echo " Add OMPFLAG and turn on OpenMP cpp macros" @@ -2722,8 +2712,6 @@ cat >>$MAKEFILE < \$@ + \$(CPPCMD) > \$@ .$FS.o: \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< .F.o: \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< .F90.$FS90: - \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ + \$(CPPCMD) > \$@ .FF90.f$FS90: - \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ + \$(CPPCMD) > \$@ .$FS90.o: \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$< .f$FS90.o: @@ -2924,11 +2915,11 @@ .c.o: \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$< .flow.flowdir: - \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ + \$(CPPCMD) > \$@ # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain .F.p: - \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ + \$(CPPCMD) > \$@ .p.$FS: \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< @@ -2986,7 +2977,7 @@ @-rm -f ad_config.template \$(MAKE) -f \$(MAKEFILE) \$(EXE_AD) -ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES) +ad_input_code.$FS: \$(AD_FILES) \$(AD_FLOW_FILES) @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h @-rm -f ad_config.template @@ -3004,7 +2995,7 @@ ls -l ad_input_code_ad.$FS cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS -\${EXE_AD}: ad_taf_output.o \$(OBJFILES) +\$(EXE_AD): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) ad_taf_output.o \$(OBJFILES) \$(EMBEDDED_FILES) \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) ad_tamc_output.$FS: ad_input_code.$FS @@ -3034,7 +3025,7 @@ @-rm -f ad_config.template \$(MAKE) -f \$(MAKEFILE) \$(EXE_FTL) -ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) +ftl_input_code.$FS: \$(AD_FILES) @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h @-rm -f ad_config.template @@ -3052,7 +3043,7 @@ ls -l ftl_input_code_ftl.$FS cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS -\${EXE_FTL}: ftl_taf_output.o \$(OBJFILES) +\$(EXE_FTL): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) ftl_taf_output.o \$(OBJFILES) \$(EMBEDDED_FILES) \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) ftl_tamc_output.$FS: ftl_input_code.$FS