/[MITgcm]/MITgcm/tools/genmake2
ViewVC logotype

Diff of /MITgcm/tools/genmake2

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.261 by jahn, Thu Aug 22 16:04:18 2013 UTC revision 1.278 by jmc, Fri Jan 15 22:08:17 2016 UTC
# Line 19  Usage: "$0" [OPTIONS] Line 19  Usage: "$0" [OPTIONS]
19      -help | --help | -h | --h      -help | --help | -h | --h
20            Print this help message and exit.            Print this help message and exit.
21    
22        -oad | --oad
23              Generate a Makefile for an OpenAD built
24    
25        -nocat4ad | -dog4ad | -ncad | -dad
26              do not concatenate (cat) source code sent to TAF
27              resulting in compilation of multiple files
28    
29      -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME      -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
30        -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME        -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
31            Use "NAME" as the adoptfile.  By default, the file at            Use "NAME" as the adoptfile.  By default, the file at
32              "tools/adjoint_options/adjoint_oad" (for OpenAD built) or
33            "tools/adjoint_options/adjoint_default" will be used.            "tools/adjoint_options/adjoint_default" will be used.
34    
35      -nooptfile | --nooptfile      -optfile NAME | --optfile NAME | -of NAME | --of NAME
       -optfile NAME | --optfile NAME | -of NAME | --of NAME  
36        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
37            Use "NAME" as the optfile.  By default, an attempt will be            Use "NAME" as the optfile.  By default, an attempt will be
38            made to find an appropriate "standard" optfile in the            made to find an appropriate "standard" optfile in the
# Line 1079  EOF Line 1086  EOF
1086  }  }
1087    
1088  check_lapack_libs()  {  check_lapack_libs()  {
1089      if test ! "x$SKIP_LAPACK_CHECK" = x ; then      if test "x$CHECK_FOR_LAPACK" = xf ; then return ; fi
         return  
     fi  
1090      echo >> $LOGFILE      echo >> $LOGFILE
1091      echo "running: check_lapack_libs()" >> $LOGFILE      echo "running: check_lapack_libs()" >> $LOGFILE
1092      cat <<EOF > genmake_tla.F      cat <<EOF > genmake_tla.F
# Line 1277  GSL= Line 1282  GSL=
1282  DEVEL=  DEVEL=
1283  HAVE_TEST_L=  HAVE_TEST_L=
1284    
1285  # comment this line out to enable lapack test  # set this to "t" to enable lapack test
1286  SKIP_LAPACK_CHECK=t  CHECK_FOR_LAPACK=f
1287    
1288  # DEFINES checked by test compilation or command-line  # DEFINES checked by test compilation or command-line
1289  HAVE_SYSTEM=  HAVE_SYSTEM=
# Line 1325  FS= Line 1330  FS=
1330  FS90=  FS90=
1331    
1332  AUTODIFF_PKG_USED=f  AUTODIFF_PKG_USED=f
1333    OPENAD=
1334  AD_OPTFILE=  AD_OPTFILE=
1335    CAT_SRC_FOR_TAF=1
1336  TAF=  TAF=
1337  AD_TAF_FLAGS=  AD_TAF_FLAGS=
1338  FTL_TAF_FLAGS=  FTL_TAF_FLAGS=
# Line 1355  gm_s7="TMP THISHOST THISUSER THISDATE TH Line 1362  gm_s7="TMP THISHOST THISUSER THISDATE TH
1362  gm_s8="HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME HAVE_LAPACK HAVE_FLUSH"  gm_s8="HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME HAVE_LAPACK HAVE_FLUSH"
1363    
1364  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1365  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE OPENAD TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
1366  gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"  gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
1367  gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES"  gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES"
1368    
# Line 1400  for ac_option in "$@" ; do Line 1407  for ac_option in "$@" ; do
1407          -help | --help | -h | --h)          -help | --help | -h | --h)
1408              usage ;;              usage ;;
1409    
         -nooptfile | --nooptfile)  
             OPTFILE="NONE" ;;  
1410          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
1411              ac_prev=OPTFILE ;;              ac_prev=OPTFILE ;;
1412          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
1413              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
1414    
1415            -oad | --oad)
1416                OPENAD="true" ; ALWAYS_USE_F90=1 ;;
1417            -nocat4ad | -dog4ad | -ncad | -dad)
1418                CAT_SRC_FOR_TAF=0 ;;
1419          -adoptfile | --adoptfile | -adof | --adof)          -adoptfile | --adoptfile | -adof | --adof)
1420              ac_prev=AD_OPTFILE ;;              ac_prev=AD_OPTFILE ;;
1421          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
# Line 1576  for ac_option in "$@" ; do Line 1585  for ac_option in "$@" ; do
1585    
1586  done  done
1587    
1588  TMP=./genmk_$$  #TMP=./genmk_$$
1589  #- try to put temporary files in system-local /tmp dir  #- try to put temporary files in system-local /tmp dir
1590  #TMP=/tmp/genmk_$$  TMP=/tmp/genmk_${USER}_$$
1591  #touch $TMP ; retVal=$?  touch $TMP ; retVal=$?
1592  #if [ $retVal -eq 0 ] ; then  if [ $retVal -eq 0 ] ; then
1593  #  if test ! -r $TMP ; then TMP=./genmk_$$ ; fi    if test ! -r $TMP ; then TMP=./genmk_$$ ; fi
1594  #else  else
1595  #  TMP=./genmk_$$    TMP=./genmk_$$
1596  #fi  fi
1597  #rm -f $TMP  rm -f $TMP
1598  ##echo "  temp files: $TMP.*"  #echo "  temp files: $TMP.*"
1599    
1600  printf "  getting local config information:  "  printf "  getting local config information:  "
1601  if test -f $gm_local ; then  if test -f $gm_local ; then
# Line 1680  fi Line 1689  fi
1689    
1690  echo "  getting AD_OPTFILE information:"  echo "  getting AD_OPTFILE information:"
1691  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1692      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" != x ; then
1693            AD_OPTFILE=$MITGCM_AD_OF
1694        elif test "x$OPENAD" = x ; then
1695          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
1696      else      else
1697          AD_OPTFILE=$MITGCM_AD_OF          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_oad
1698      fi      fi
1699  fi  fi
1700  if test "x${AD_OPTFILE}" != xNONE ; then  if test "x${AD_OPTFILE}" != xNONE ; then
# Line 1950  else Line 1961  else
1961  fi  fi
1962  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1963    
1964  printf "  Do we have the etime() command using $FC...  "  printf "  Do we have the etime() command using $FC... "
1965  cat > genmake_tcomp.$FS <<EOF  cat > genmake_tcomp_1.$FS <<EOF
1966        program hello        program hello
1967        REAL*4 ACTUAL, TARRAY(2)        REAL*4 actual, tarray(2)
1968        EXTERNAL ETIME        EXTERNAL ETIME
1969        REAL*4 ETIME        REAL*4 ETIME
1970        actual = etime( tarray )        actual = ETIME( tarray )
1971        print *, tarray        print *, tarray
1972        end        end
1973  EOF  EOF
1974  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1  $FC $FFLAGS -o genmake_tcomp_1 genmake_tcomp_1.$FS > genmake_tcomp.log 2>&1
1975  RETVAL=$?  RETVAL=$?
1976  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
1977      HAVE_ETIME=t      HAVE_ETIME='Fct'
1978      DEFINES="$DEFINES -DHAVE_ETIME"      DEFINES="$DEFINES -DHAVE_ETIME_FCT"
1979      echo "yes"      echo " yes (${HAVE_ETIME})"
1980  else  else
1981      cat > genmake_tcomp_2.$FS <<EOF
1982          program hello
1983          REAL*4 actual, tarray(2)
1984          actual = -999.
1985          call ETIME( tarray, actual )
1986          if ( actual.ge.0. ) then
1987            print *, 0, tarray, actual
1988          else
1989            print *, 1, tarray, actual
1990          endif
1991          end
1992    EOF
1993      $FC $FFLAGS -o genmake_tcomp_2 genmake_tcomp_2.$FS >> genmake_tcomp.log 2>&1
1994      RETVAL=$?
1995      if test "x$RETVAL" = x0 ; then
1996        echo -n 'c,'
1997        ./genmake_tcomp_2 > genmake_tcomp_2.out 2>&1
1998        RETVAL=$?
1999      fi
2000      if test "x$RETVAL" = x0 ; then
2001        echo -n 'r:'
2002        RETVAL=`cat genmake_tcomp_2.out | $AWK '{print $1}'`
2003      fi
2004      if test "x$RETVAL" = x0 ; then
2005        HAVE_ETIME='SbR'
2006        DEFINES="$DEFINES -DHAVE_ETIME_SBR"
2007        echo " yes (${HAVE_ETIME})"
2008      else
2009      HAVE_ETIME=      HAVE_ETIME=
2010      echo "no"      echo " no"
2011      fi
2012  fi  fi
2013    #mkdir chk_etime ; cp -p -f genmake_tcomp* chk_etime
2014  rm -f genmake_tcomp*  rm -f genmake_tcomp*
2015    
2016  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "  printf "  Can we call simple C routines (here, \"cloc()\") using $FC...  "
# Line 2356  EOF Line 2397  EOF
2397      fi      fi
2398  fi  fi
2399    
 #  Check for package RADTRANS: if LAPACK is not available,  
 #  then issue a warning that the direct radtrans solver is not available.  
 if test "x$HAVE_LAPACK" != xt ; then  
     echo " $PACKAGES " | grep ' radtrans ' > /dev/null 2>&1  
     RETVAL=$?  
     if test "x$RETVAL" = x0 ; then  
         cat <<EOF  
 *********************************************************************  
 WARNING: the "radtrans" package was enabled but tests failed to  
   compile LAPACK applications.  This means that the direct radtrans  
   solver is not available and compilation will fail if it is enabled.  
   If you want to use the direct solver, please check that:  
   
   1) LAPACK is correctly installed for this compiler and  
   2) the LIBS variable (within the "optfile") specifies the correct  
      LAPACK library to link against.  
 *********************************************************************  
 EOF  
     fi  
 fi  
   
2400  #  Make sure the openad package is enabled if using OpenAD  #  Make sure the openad package is enabled if using OpenAD
2401  if test "x$OPENAD" != x ; then  if test "x$OPENAD" != x ; then
2402      echo " $PACKAGES " | grep ' openad ' > /dev/null 2>&1      echo " $PACKAGES " | grep ' openad ' > /dev/null 2>&1
# Line 2645  if test "x$OPENAD" != x ; then Line 2665  if test "x$OPENAD" != x ; then
2665      OAD_CB2M_FILES="/dev/null"      OAD_CB2M_FILES="/dev/null"
2666      OADTOOLS="$TOOLSDIR/OAD_support"      OADTOOLS="$TOOLSDIR/OAD_support"
2667      echo "  looking for dontCompile file:  "      echo "  looking for dontCompile file:  "
2668      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2669          if test -r $i"/dontCompile" ; then          if test -r $i"/dontCompile" ; then
2670              OAD_DONT_COMPILE=$i"/dontCompile"              OAD_DONT_COMPILE=$i"/dontCompile"
2671              echo "     found $OAD_DONT_COMPILE"              echo "     found $OAD_DONT_COMPILE"
# Line 2653  if test "x$OPENAD" != x ; then Line 2673  if test "x$OPENAD" != x ; then
2673          fi          fi
2674      done      done
2675      echo "  looking for dontTransform file:  "      echo "  looking for dontTransform file:  "
2676      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2677          if test -r $i"/dontTransform" ; then          if test -r $i"/dontTransform" ; then
2678              OAD_DONT_TRANSFORM=$i"/dontTransform"              OAD_DONT_TRANSFORM=$i"/dontTransform"
2679              echo "     found $OAD_DONT_TRANSFORM"              echo "     found $OAD_DONT_TRANSFORM"
# Line 2661  if test "x$OPENAD" != x ; then Line 2681  if test "x$OPENAD" != x ; then
2681          fi          fi
2682      done      done
2683      echo "  looking for keepOriginal file:  "      echo "  looking for keepOriginal file:  "
2684      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2685          if test -r $i"/keepOriginal" ; then          if test -r $i"/keepOriginal" ; then
2686              OAD_KEEP_ORIGINAL=$i"/keepOriginal"              OAD_KEEP_ORIGINAL=$i"/keepOriginal"
2687              echo "     found $OAD_KEEP_ORIGINAL"              echo "     found $OAD_KEEP_ORIGINAL"
# Line 2669  if test "x$OPENAD" != x ; then Line 2689  if test "x$OPENAD" != x ; then
2689          fi          fi
2690      done      done
2691      echo "  looking for cb2mFiles:  "      echo "  looking for cb2mFiles:  "
2692      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2693          if test -r $i"/cb2mFiles" ; then          if test -r $i"/cb2mFiles" ; then
2694              OAD_CB2M_FILES=$i"/cb2mFiles"              OAD_CB2M_FILES=$i"/cb2mFiles"
2695              echo "     found $OAD_CB2M_FILES"              echo "     found $OAD_CB2M_FILES"
# Line 2908  CPPINCLUDES = ${CPPINCLUDES} Line 2928  CPPINCLUDES = ${CPPINCLUDES}
2928  KFLAGS1 = ${KFLAGS1}  KFLAGS1 = ${KFLAGS1}
2929  KFLAGS2 = ${KFLAGS2}  KFLAGS2 = ${KFLAGS2}
2930  # Optim./debug for FC  # Optim./debug for FC
2931  FFLAGS = ${FFLAGS} ${FEXTRAFLAGS}  FFLAGS = ${FFLAGS}
2932  FOPTIM = ${FOPTIM}  FOPTIM = ${FOPTIM} ${FEXTRAFLAGS}
2933  # Optim./debug for FC  # Optim./debug for FC
2934  F90FLAGS = ${F90FLAGS}  F90FLAGS = ${F90FLAGS}
2935  F90OPTIM = ${F90OPTIM}  F90OPTIM = ${F90OPTIM}
# Line 2985  links: \$(F77_SRC_FILES) \$(C_SRC_FILES) Line 3005  links: \$(F77_SRC_FILES) \$(C_SRC_FILES)
3005    
3006  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
3007    
 output.txt: \$(EXECUTABLE)  
         @printf 'running ... '  
         @\$(EXECUTABLE) > \$@  
   
3008  # remove most of the files that "make" generates  # remove most of the files that "make" generates
3009  clean:  clean:
3010          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
# Line 3140  done Line 3156  done
3156  echo >> $MAKEFILE  echo >> $MAKEFILE
3157  rm -f $TMP.adSrcFiles  rm -f $TMP.adSrcFiles
3158    
3159    if test $CAT_SRC_FOR_TAF = 0 ; then
3160    cat >>$MAKEFILE <<EOF
3161    
3162    # ... Utilities ...
3163    remove_comments:
3164            sed -i.bak -f \$(TOOLSDIR)/remove_comments_sed \$(AD_FILES)
3165            @-rm -f \$(AD_FILES:.$FS=.$FS.bak)
3166    adj_sed:
3167            sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_ad.$FS)
3168            @-rm -f \$(AD_FILES:.$FS=_ad.$FS.bak)
3169    ftl_sed:
3170            sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_tl.$FS)
3171            @-rm -f \$(AD_FILES:.$FS=_tl.$FS.bak)
3172    adobjfiles: \$(AD_FILES:.$FS=_ad.o)
3173    ftlobjfiles: \$(AD_FILES:.$FS=_tl.o)
3174    EOF
3175    fi
3176    
3177  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3178    
3179  # ... AD ...  # ... AD ...
# Line 3162  ad_input_code.$FS: \$(AD_FILES) \$(AD_FL Line 3196  ad_input_code.$FS: \$(AD_FILES) \$(AD_FL
3196          @\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)          @\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)
3197          cat \$(FLOWFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS          cat \$(FLOWFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS
3198    
3199  ad_taf_output.$FS: ad_input_code.$FS  adtafonly:
         @-rm -f ad_input_code_ad.$FS ; echo ''  
3200          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3201          ls -l ad_input_code_ad.$FS          ls -l ad_input_code_ad.$FS
3202          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
3203    
3204  adtafonly:  EOF
3205    
3206    if test $CAT_SRC_FOR_TAF = 1 ; then
3207    cat >>$MAKEFILE <<EOF
3208    # ... send 1 file to TAF ...
3209    ad_taf_output.$FS: ad_input_code.$FS
3210            @-rm -f ad_input_code_ad.$FS ; echo ''
3211          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3212          ls -l ad_input_code_ad.$FS          ls -l ad_input_code_ad.$FS
3213          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
# Line 3176  adtafonly: Line 3215  adtafonly:
3215  \$(EXE_AD): \$(SPECIAL_FILES) \$(H_SRC_FILES) ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)  \$(EXE_AD): \$(SPECIAL_FILES) \$(H_SRC_FILES) ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)
3216          \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)          \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)
3217    
3218  ad_tamc_output.$FS: ad_input_code.$FS  adobj: ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o)
         \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS  
         cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS  
3219    
3220  ad_tamc: ad_tamc_output.o \$(OBJFILES)  EOF
3221          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)  
3222    else
3223    cat >>$MAKEFILE <<EOF
3224    # ... send multiple files to TAF ...
3225    ad_taf_output.$FS: \$(AD_FLOW_FILES) \$(AD_FILES)
3226            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3227            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3228            @-rm -f ad_config.template
3229            @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3230            @\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)
3231            @-rm -f \$(AD_FILES:.$FS=_ad.$FS) \$(AD_FILES:.$FS=_ad.o); echo ''
3232            \$(MAKE) -f \$(MAKEFILE) remove_comments
3233            \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) \$(FLOWFILES) \$(AD_FILES)
3234            \$(MAKE) -f \$(MAKEFILE) adj_sed
3235            cat \$(AD_FILES:.$FS=_ad.$FS) > ad_taf_output.$FS
3236    
3237    \$(EXE_AD): \$(SPECIAL_FILES) \$(H_SRC_FILES) ad_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)
3238            \$(MAKE) -f \$(MAKEFILE) adobjfiles
3239            \$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(AD_FILES:.$FS=_ad.o) \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)
3240    
3241    adobj: ad_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o)
3242            \$(MAKE) -f \$(MAKEFILE) adobjfiles
3243    
3244    EOF
3245    fi
3246    
3247    cat >>$MAKEFILE <<EOF
3248  adonlyfwd:  adonlyfwd:
3249          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
3250    
3251  adtrick:  adtrick:
3252          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
3253    
3254  adobj: ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o)  ad_tamc_output.$FS: ad_input_code.$FS
3255            \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
3256            cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
3257    
3258    ad_tamc: ad_tamc_output.o \$(OBJFILES)
3259            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
3260    
3261  # ... FTL ...  # ... FTL ...
3262  ftlall: ftl_exe_target  ftlall: ftl_exe_target
# Line 3211  ftl_input_code.$FS: \$(AD_FILES) Line 3278  ftl_input_code.$FS: \$(AD_FILES)
3278          @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES)          @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3279          cat \$(AD_FLOW_FILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ftl_input_code.$FS          cat \$(AD_FLOW_FILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ftl_input_code.$FS
3280    
3281  ftl_taf_output.$FS: ftl_input_code.$FS  ftltafonly:
         @-rm -f ftl_input_code_tl.$FS ; echo ''  
3282          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3283          ls -l ftl_input_code_tl.$FS          ls -l ftl_input_code_tl.$FS
3284          cat ftl_input_code_tl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS          cat ftl_input_code_tl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
3285    
3286  ftltafonly:  EOF
3287    
3288    if test $CAT_SRC_FOR_TAF = 1 ; then
3289    cat >>$MAKEFILE <<EOF
3290    # ... send 1 file to TAF ...
3291    ftl_taf_output.$FS: ftl_input_code.$FS
3292            @-rm -f ftl_input_code_tl.$FS ; echo ''
3293          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3294          ls -l ftl_input_code_tl.$FS          ls -l ftl_input_code_tl.$FS
3295          cat ftl_input_code_tl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS          cat ftl_input_code_tl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
# Line 3225  ftltafonly: Line 3297  ftltafonly:
3297  \$(EXE_FTL): \$(SPECIAL_FILES) \$(H_SRC_FILES) ftl_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)  \$(EXE_FTL): \$(SPECIAL_FILES) \$(H_SRC_FILES) ftl_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)
3298          \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) ftl_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)          \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) ftl_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)
3299    
3300    EOF
3301    
3302    else
3303    cat >>$MAKEFILE <<EOF
3304    # ... send multiple files to TAF ...
3305    ftl_taf_output.$FS: \$(AD_FLOW_FILES) \$(AD_FILES)
3306            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3307            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3308            @-rm -f ad_config.template
3309            @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3310            @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3311            @-rm -f \$(AD_FILES:.$FS=_tl.$FS) \$(AD_FILES:.$FS=_tl.o); echo ''
3312            \$(MAKE) -f \$(MAKEFILE) remove_comments
3313            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) \$(AD_FLOW_FILES) \$(AD_FILES)
3314            \$(MAKE) -f \$(MAKEFILE) ftl_sed
3315            cat \$(AD_FILES:.$FS=_tl.$FS) > ftl_taf_output.$FS
3316    
3317    \$(EXE_FTL): \$(SPECIAL_FILES) \$(H_SRC_FILES) ftl_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)
3318            \$(MAKE) -f \$(MAKEFILE) ftlobjfiles
3319            \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(AD_FILES:.$FS=_tl.o) \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)
3320    
3321    EOF
3322    fi
3323    
3324    cat >>$MAKEFILE <<EOF
3325  ftl_tamc_output.$FS: ftl_input_code.$FS  ftl_tamc_output.$FS: ftl_input_code.$FS
3326          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
3327          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS
# Line 3267  if test "x$OPENAD" != x ; then Line 3364  if test "x$OPENAD" != x ; then
3364  # ============ begin OpenAD specific section ==============  # ============ begin OpenAD specific section ==============
3365    
3366  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3367    # ... OpenAD ...
3368    
3369  # all the source files linked from the various locations:  # all the source files linked from the various locations:
3370  ALL_LINKED_FILES= \  ALL_LINKED_FILES= \
# Line 3320  rm -f $TMP.adSrcFiles Line 3418  rm -f $TMP.adSrcFiles
3418    
3419  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3420    
3421  adAll: \$(EXE_AD)  adAll: ad_exe_target
3422  .PHONY: adAll  .PHONY: adAll
3423    
3424    ad_exe_target:
3425            @echo Update AD_CONFIG.h and make \$(EXE_AD)
3426            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3427            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3428            @-rm -f ad_config.template
3429            \$(MAKE) -f \$(MAKEFILE) \$(EXE_AD)
3430    
3431  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))
3432    
3433  .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90)  .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90)
# Line 3339  OAD_active.F90 \ Line 3444  OAD_active.F90 \
3444  OAD_cp.F90 \  OAD_cp.F90 \
3445  OAD_rev.F90 \  OAD_rev.F90 \
3446  OAD_tape.F90 \  OAD_tape.F90 \
3447    OAD_regular_cp.F90 \
3448  revolve.F90  revolve.F90
3449    
3450  OPENAD_SUPPORT_C_SRC_FILES = \  OPENAD_SUPPORT_C_SRC_FILES = \
# Line 3380  AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(N Line 3486  AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(N
3486  small_f: \$(CB2M_F90_PP_SRC_FILES)  small_f: \$(CB2M_F90_PP_SRC_FILES)
3487  .PHONY: small_f  .PHONY: small_f
3488    
 ad_output.txt: \$(EXE_AD)  
         @printf 'linking data files ... '  
         \$(LN) -f ../input_ad/data* ../input_ad/eedata .  
         \$(LN) -f ../../global_ocean.90x40x15/input/*.bin .  
         @printf 'running ... '  
         @./\$(EXE_AD) > \$@  
   
3489  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3490          cat \$^ > \$@          cat \$^ > \$@
3491    

Legend:
Removed from v.1.261  
changed lines
  Added in v.1.278

  ViewVC Help
Powered by ViewVC 1.1.22