/[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.253 by jmc, Wed Jul 24 00:33:53 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 208  test_for_string_in_file() { Line 215  test_for_string_in_file() {
215  expand_pkg_groups() {  expand_pkg_groups() {
216      new_packages=      new_packages=
217      if test -r $PKG_GROUPS ; then      if test -r $PKG_GROUPS ; then
218          cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp          cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > $TMP.p1
219          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp          cat $TMP.p1 | $AWK '(NF>2 && $2==":"){ print $0 }' > $TMP.p2
220          matched=0          matched=0
221          for i in $PACKAGES ; do          for i in $PACKAGES ; do
222              line=`grep "^ *$i" ./p2.tmp`              line=`grep "^ *$i" $TMP.p2`
223              RETVAL=$?              RETVAL=$?
224              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
225                  matched=1                  matched=1
# Line 224  expand_pkg_groups() { Line 231  expand_pkg_groups() {
231              fi              fi
232          done          done
233          PACKAGES=$new_packages          PACKAGES=$new_packages
234          rm -f ./p[1,2].tmp          rm -f $TMP.p[1,2]
235          return $matched          return $matched
236      else      else
237          echo "Warning: can't read package groups definition file: $PKG_GROUPS"          echo "Warning: can't read package groups definition file: $PKG_GROUPS"
# 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 1351  gm_s3="FEXTRAFLAGS IEEE DEVEL GSL TS PAP Line 1358  gm_s3="FEXTRAFLAGS IEEE DEVEL GSL TS PAP
1358  gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM"  gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM"
1359  gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
1360  gm_s6="PWD TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"  gm_s6="PWD TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"
1361  gm_s7="THISHOST THISUSER THISDATE THISVER MACHINE FC_NAMEMANGLE"  gm_s7="TMP THISHOST THISUSER THISDATE THISVER MACHINE FC_NAMEMANGLE"
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_$$
1589    #- try to put temporary files in system-local /tmp dir
1590    TMP=/tmp/genmk_${USER}_$$
1591    touch $TMP ; retVal=$?
1592    if [ $retVal -eq 0 ] ; then
1593      if test ! -r $TMP ; then TMP=./genmk_$$ ; fi
1594    else
1595      TMP=./genmk_$$
1596    fi
1597    rm -f $TMP
1598    #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
1602      echo "using $gm_local"      echo "using $gm_local"
# Line 1668  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 1938  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 2237  if test "x${PKG_GROUPS}" != x ; then Line 2290  if test "x${PKG_GROUPS}" != x ; then
2290  fi  fi
2291    
2292  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
2293  echo "" > ./.tmp_pack  echo "" > $TMP.pack
2294  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2295      echo $i >> ./.tmp_pack      echo $i >> $TMP.pack
2296  done  done
2297  for i in `grep  "-" ./.tmp_pack` ; do  for i in `grep  "-" $TMP.pack` ; do
2298      j=`echo $i | sed 's/[-]//'`      j=`echo $i | sed 's/[-]//'`
2299      DISABLE="$DISABLE $j"      DISABLE="$DISABLE $j"
2300  done  done
# Line 2259  for p in $PACKAGES ; do Line 2312  for p in $PACKAGES ; do
2312  done  done
2313  PACKAGES="$pack"  PACKAGES="$pack"
2314  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
2315  echo "" > ./.tmp_pack  echo "" > $TMP.pack
2316  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
2317  # Test if each explicitly referenced package exists  # Test if each explicitly referenced package exists
2318  for i in $PACKAGES ; do  for i in $PACKAGES ; do
# Line 2268  for i in $PACKAGES ; do Line 2321  for i in $PACKAGES ; do
2321          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
2322          exit 1          exit 1
2323      fi      fi
2324      echo $i >> ./.tmp_pack      echo $i >> $TMP.pack
2325  done  done
2326  PACKAGES=  PACKAGES=
2327  for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do  for i in `grep -v "-" $TMP.pack | sort | uniq` ; do
2328      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
2329  done  done
2330  rm -f ./.tmp_pack  rm -f $TMP.pack
2331  echo "    packages are: $PACKAGES"  echo "    packages are: $PACKAGES"
2332    
2333  #  Check for package MNC: if NetCDF is available, then build the MNC  #  Check for package MNC: if NetCDF is available, then build the MNC
# Line 2344  EOF Line 2397  EOF
2397      fi      fi
2398  fi  fi
2399    
2400  #  Check for package RADTRANS: if LAPACK is not available,  #  Make sure the openad package is enabled if using OpenAD
2401  #  then issue a warning that the direct radtrans solver is not available.  if test "x$OPENAD" != x ; then
2402  if test "x$HAVE_LAPACK" != xt ; then      echo " $PACKAGES " | grep ' openad ' > /dev/null 2>&1
     echo " $PACKAGES " | grep ' radtrans ' > /dev/null 2>&1  
2403      RETVAL=$?      RETVAL=$?
2404      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" != x0 ; then
2405          cat <<EOF          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:  
2406    
   1) LAPACK is correctly installed for this compiler and  
   2) the LIBS variable (within the "optfile") specifies the correct  
      LAPACK library to link against.  
2407  *********************************************************************  *********************************************************************
2408    ERROR: when generating an adjoint with OpenAD, the openad package
2409      must be enabled.  Please add it to packages.conf.
2410    *********************************************************************
2411    
2412  EOF  EOF
2413            exit 1
2414      fi      fi
2415  fi  fi
2416    
# Line 2553  fi Line 2602  fi
2602    
2603  #  Here, we build the list of files to be "run through" the adjoint  #  Here, we build the list of files to be "run through" the adjoint
2604  #  compiler.  #  compiler.
2605  if test -f ./adSrcFiles.tmp ; then  if test -f $TMP.adSrcFiles ; then
2606      rm -f ./adSrcFiles.tmp      rm -f $TMP.adSrcFiles
2607  fi  fi
2608  echo "  Creating the list of files for the adjoint compiler."  echo "  Creating the list of files for the adjoint compiler."
2609  touch adSrcFiles.tmp  touch $TMP.adSrcFiles
2610  for i in $SOURCEDIRS ; do  for i in $SOURCEDIRS ; do
2611      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2612      for j in $list_files ; do      for j in $list_files ; do
2613          cat $i/$j >> adSrcFiles.tmp          cat $i/$j >> $TMP.adSrcFiles
2614      done      done
2615  done  done
2616  if test ! "x"$FS = "x.f" ; then  if test ! "x"$FS = "x.f" ; then
2617      cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f      cat $TMP.adSrcFiles | sed -e "s/\.f/.$FS/g" > $TMP.adSrcFiles_f
2618      mv -f adSrcFiles.tmp_f adSrcFiles.tmp      mv -f $TMP.adSrcFiles_f $TMP.adSrcFiles
2619  fi  fi
2620    
2621  echo  echo
# Line 2588  if test ! "x$DIVA" = x -a ! "x$MPI" = x Line 2637  if test ! "x$DIVA" = x -a ! "x$MPI" = x
2637  fi  fi
2638    
2639  echo "  Determining the list of source and include files"  echo "  Determining the list of source and include files"
2640  rm -rf .links.tmp  rm -rf $TMP.links
2641  mkdir .links.tmp  mkdir $TMP.links
2642  touch .links.tmp/foo  touch $TMP.links/foo
2643  if test ! -r ".links.tmp/foo" ; then  if test ! -r "$TMP.links/foo" ; then
2644      echo      echo
2645      echo "ERROR : something is wrong with your directory permissions or"      echo "ERROR : something is wrong with your directory permissions or"
2646      echo "   your user file-creation mask (\"umask\") since creating a"      echo "   your user file-creation mask (\"umask\") since creating a"
# Line 2607  if test ! -r ".links.tmp/foo" ; then Line 2656  if test ! -r ".links.tmp/foo" ; then
2656      echo      echo
2657      exit 1      exit 1
2658  fi  fi
2659  rm -f .links.tmp/foo  rm -f $TMP.links/foo
2660    
2661  if test "x$OPENAD" != x ; then  if test "x$OPENAD" != x ; then
2662      OAD_DONT_COMPILE="/dev/null"      OAD_DONT_COMPILE="/dev/null"
# Line 2616  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 2624  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 2632  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 2640  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 2650  if test "x$OPENAD" != x ; then Line 2699  if test "x$OPENAD" != x ; then
2699      echo "   OpenAD exceptions:  "      echo "   OpenAD exceptions:  "
2700  fi  fi
2701    
2702  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > $TMP.srclinks
2703  echo "" >> srclinks.tmp  echo "" >> $TMP.srclinks
2704  printf 'F77_SRC_FILES = ' > F77srclist.tmp  printf 'F77_SRC_FILES = ' > $TMP.F77srclist
2705  printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp  printf 'NON_AD_F77_SRC_FILES = ' > $TMP.nonADF77srclist
2706  printf 'C_SRC_FILES = '   > csrclist.tmp  printf 'C_SRC_FILES = '   > $TMP.csrclist
2707  printf 'F90_SRC_FILES = ' > F90srclist.tmp  printf 'F90_SRC_FILES = ' > $TMP.F90srclist
2708  printf 'H_SRC_FILES = '   > hsrclist.tmp  printf 'H_SRC_FILES = '   > $TMP.hsrclist
2709  printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp  printf 'AD_FLOW_FILES = ' > $TMP.ad_flow_files
2710  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2711  for d in $alldirs ; do  for d in $alldirs ; do
2712      deplist=      deplist=
# Line 2667  for d in $alldirs ; do Line 2716  for d in $alldirs ; do
2716          sfiles=`( echo $sfiles | grep -v _cb2m\. )`          sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2717      fi      fi
2718      for sf in $sfiles ; do      for sf in $sfiles ; do
2719          if test ! -r ".links.tmp/$sf" ; then          if test ! -r "$TMP.links/$sf" ; then
2720              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2721                  ignore_f=f                  ignore_f=f
2722                  case $d/$sf in                  case $d/$sf in
# Line 2692  for d in $alldirs ; do Line 2741  for d in $alldirs ; do
2741                          if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then                          if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then
2742                              ignore_f=t                              ignore_f=t
2743                          else                          else
2744                              touch .links.tmp/$sf                              touch $TMP.links/$sf
2745                              deplist="$deplist $sf"                              deplist="$deplist $sf"
2746                          fi                          fi
2747                          ;;                          ;;
# Line 2701  for d in $alldirs ; do Line 2750  for d in $alldirs ; do
2750                      extn=`echo $sf | $AWK -F. '{print $NF}'`                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2751                      case $extn in                      case $extn in
2752                        F)                        F)
2753                          echo    " \\"  >> F77srclist.tmp                          echo    " \\"  >> $TMP.F77srclist
2754                          printf " $sf" >> F77srclist.tmp                          printf " $sf" >> $TMP.F77srclist
2755                          if test "x$OPENAD" != x ; then                          if test "x$OPENAD" = x ; then
2756                              basename=${sf%%.F}                              basename=${sf%%.F}
2757                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`                              isAD=`egrep ^$basename.f'[  ]*' $TMP.adSrcFiles`
2758                                if test -z "$isAD" ; then
2759                                    echo    " \\"  >> $TMP.nonADF77srclist
2760                                    printf " $sf" >> $TMP.nonADF77srclist
2761                                fi
2762                            else #- OpenAD case:
2763                                basename=${sf%%.F}
2764                                isAD=`egrep ^$basename.f'[  ]*' $TMP.adSrcFiles`
2765                              if test -z "$isAD" ; then                              if test -z "$isAD" ; then
2766                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`
2767                                  if test -z "$toBeIgnored" ; then                                  if test -z "$toBeIgnored" ; then
2768                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> $TMP.nonADF77srclist
2769                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> $TMP.nonADF77srclist
2770                                  else                                  else
2771                                      echo "    not to be compiled   :  $sf"                                      echo "    not to be compiled   :  $sf"
2772                                  fi                                  fi
# Line 2725  for d in $alldirs ; do Line 2781  for d in $alldirs ; do
2781                                      echo "    original to be kept  :  $sf"                                      echo "    original to be kept  :  $sf"
2782                                  fi                                  fi
2783                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2784                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> $TMP.nonADF77srclist
2785                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> $TMP.nonADF77srclist
2786                                  fi                                  fi
2787                              fi                              fi
2788                          fi                          fi
2789                          ;;                          ;;
2790                      F90)                      F90)
2791                          echo    " \\"  >> F90srclist.tmp                          echo    " \\"  >> $TMP.F90srclist
2792                          printf " $sf" >> F90srclist.tmp                          printf " $sf" >> $TMP.F90srclist
2793                          ;;                          ;;
2794                      c)                      c)
2795                          echo    " \\"  >> csrclist.tmp                          echo    " \\"  >> $TMP.csrclist
2796                          printf " $sf" >> csrclist.tmp                          printf " $sf" >> $TMP.csrclist
2797                          ;;                          ;;
2798                      h)                      h)
2799                          echo    " \\"  >> hsrclist.tmp                          echo    " \\"  >> $TMP.hsrclist
2800                          printf " $sf" >> hsrclist.tmp                          printf " $sf" >> $TMP.hsrclist
2801                          ;;                          ;;
2802                      flow)                      flow)
2803                          echo    " \\"  >> ad_flow_files.tmp                          echo    " \\"  >> $TMP.ad_flow_files
2804                          printf " $sf" >> ad_flow_files.tmp                          printf " $sf" >> $TMP.ad_flow_files
2805                          ;;                          ;;
2806                     esac                     esac
2807                  fi                  fi
# Line 2754  for d in $alldirs ; do Line 2810  for d in $alldirs ; do
2810      done      done
2811      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2812        if test "$d" != "." ; then        if test "$d" != "." ; then
2813          echo "" >> srclinks.tmp          echo "" >> $TMP.srclinks
2814          echo "#  These files are linked from $d" >> srclinks.tmp          echo "#  These files are linked from $d" >> $TMP.srclinks
2815          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> $TMP.srclinks
2816  # We need to make sure that the link isn't already there.  # We need to make sure that the link isn't already there.
2817  # This may happen when make thinks that a header file has to be "remade"  # This may happen when make thinks that a header file has to be "remade"
2818  # because a module it depends on has changed.  In this case we do nothing.  # because a module it depends on has changed.  In this case we do nothing.
2819          printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp          printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> $TMP.srclinks
2820        fi        fi
2821      fi      fi
2822  done  done
2823  rm -rf .links.tmp  rm -rf $TMP.links
2824  echo "" >> F77srclist.tmp  echo "" >> $TMP.F77srclist
2825  echo "" >> nonADF77srclist.tmp  echo "" >> $TMP.nonADF77srclist
2826  echo "" >> csrclist.tmp  echo "" >> $TMP.csrclist
2827  echo "" >> F90srclist.tmp  echo "" >> $TMP.F90srclist
2828  echo "" >> hsrclist.tmp  echo "" >> $TMP.hsrclist
2829  echo "" >> ad_flow_files.tmp  echo "" >> $TMP.ad_flow_files
2830    
2831  CMDLINE=$0  CMDLINE=$0
2832  for xx in "$@" ; do nw=`echo $xx | wc -w`  for xx in "$@" ; do nw=`echo $xx | wc -w`
# Line 2872  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 2892  MAKE = ${MAKE} Line 2948  MAKE = ${MAKE}
2948    
2949  EOF  EOF
2950    
2951  cat F77srclist.tmp      >> $MAKEFILE  cat $TMP.F77srclist      >> $MAKEFILE
2952  cat nonADF77srclist.tmp >> $MAKEFILE  cat $TMP.nonADF77srclist >> $MAKEFILE
2953  cat csrclist.tmp        >> $MAKEFILE  cat $TMP.csrclist        >> $MAKEFILE
2954  cat F90srclist.tmp      >> $MAKEFILE  cat $TMP.F90srclist      >> $MAKEFILE
2955  cat hsrclist.tmp        >> $MAKEFILE  cat $TMP.hsrclist        >> $MAKEFILE
2956  cat ad_flow_files.tmp   >> $MAKEFILE  cat $TMP.ad_flow_files   >> $MAKEFILE
2957    
2958  rm -f F77srclist.tmp nonADF77srclist.tmp csrclist.tmp F90srclist.tmp hsrclist.tmp ad_flow_files.tmp  rm -f $TMP.F77srclist $TMP.nonADF77srclist $TMP.csrclist $TMP.F90srclist $TMP.hsrclist $TMP.ad_flow_files
2959    
2960  echo >> $MAKEFILE  echo >> $MAKEFILE
2961    
# Line 2949  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 3096  done Line 3148  done
3148  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
3149  echo >> $MAKEFILE  echo >> $MAKEFILE
3150  printf "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
3151  AD_FILES=`cat adSrcFiles.tmp`  AD_FILES=`cat $TMP.adSrcFiles`
3152  for i in $AD_FILES ; do  for i in $AD_FILES ; do
3153      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
3154      printf " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
3155  done  done
3156  echo >> $MAKEFILE  echo >> $MAKEFILE
3157  rm -f adSrcFiles.tmp  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    
# Line 3126  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:
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
3214    
3215  \$(EXE_AD): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) ad_taf_output.o \$(OBJFILES) \$(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) \$(OBJFILES) ad_taf_output.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 \$(OBJFILES)  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 3174  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:
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_ftl.$FS          ls -l ftl_input_code_tl.$FS
3284          cat ftl_input_code_ftl.$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_ftl.$FS          ls -l ftl_input_code_tl.$FS
3295          cat ftl_input_code_ftl.$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
3296    
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)
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)
3299    
3300  \$(EXE_FTL): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) ftl_taf_output.o \$(OBJFILES) \$(EMBEDDED_FILES)  EOF
3301          \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)  
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 3229  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 3268  for i in `cat ${OAD_CB2M_FILES}` ; do Line 3404  for i in `cat ${OAD_CB2M_FILES}` ; do
3404    echo    " \\" >> $MAKEFILE    echo    " \\" >> $MAKEFILE
3405    printf " ${i}_mod.f$FS90" >> $MAKEFILE    printf " ${i}_mod.f$FS90" >> $MAKEFILE
3406  done  done
3407  AD_FILES=`cat adSrcFiles.tmp`  AD_FILES=`cat $TMP.adSrcFiles`
3408  for i in $AD_FILES ; do  for i in $AD_FILES ; do
3409    basename=${i%%.f}    basename=${i%%.f}
3410    toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`    toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`
# Line 3278  for i in $AD_FILES ; do Line 3414  for i in $AD_FILES ; do
3414    fi    fi
3415  done  done
3416  echo >> $MAKEFILE  echo >> $MAKEFILE
3417  rm -f adSrcFiles.tmp  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 3301  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 3342  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    
# Line 3384  ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS Line 3521  ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS
3521  ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 \${OADTOOLS}/insertTemplateDir.bash  ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 \${OADTOOLS}/insertTemplateDir.bash
3522          \${OADTOOLS}/insertTemplateDir.bash \$< \$@          \${OADTOOLS}/insertTemplateDir.bash \$< \$@
3523    
3524  PPEXTRAS=\$(wildcard \${OADTOOLS}/ad_template.*.F) \${OADTOOLS}/ad_inline.F  PPEXTRAS=\$(notdir \$(wildcard \${OADTOOLS}/ad_template.*.F)) ad_inline.F
3525  # postprocess F'  # postprocess F'
3526  postProcess.tag: ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90 \$(PPEXTRAS:.F=.f) | w2f__types.f90  postProcess.tag: ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90 \$(PPEXTRAS:.F=.f) | w2f__types.f90
3527          \${OPENADFORTTK_BASE}/tools/SourceProcessing/postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed --separateOutput --pathSuffix "" --filenameSuffix "_oad" -m r -i \${OADTOOLS}/ad_inline.f \$<          \${OPENADFORTTK_BASE}/tools/SourceProcessing/postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed --separateOutput --pathSuffix "" --filenameSuffix "_oad" -m r -i ad_inline.f \$<
3528          # the target is a placeholder to trigger a single execution of the rule          # the target is a placeholder to trigger a single execution of the rule
3529          touch \$@          touch \$@
3530  # put this so make knows about the postprocessing output  # put this so make knows about the postprocessing output
# Line 3398  OAD_intrinsics_oad.f \$(CB2M_AD_FILES:.f Line 3535  OAD_intrinsics_oad.f \$(CB2M_AD_FILES:.f
3535          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3536    
3537  # link the support files:  # link the support files:
3538  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES) \$(PPEXTRAS):
3539          \$(LN) \${OADTOOLS}/\$@ .          \$(LN) \${OADTOOLS}/\$@ .
3540    
3541  AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag \$(PPEXTRAS:.F=.f)  AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag
3542    
3543  # ============ end OpenAD specific section ==============  # ============ end OpenAD specific section ==============
3544    
# Line 3437  for i in $NOOPTFILES ; do Line 3574  for i in $NOOPTFILES ; do
3574  done  done
3575    
3576  echo "  Add rules for links"  echo "  Add rules for links"
3577  cat srclinks.tmp >> $MAKEFILE  cat $TMP.srclinks >> $MAKEFILE
3578  rm -f srclinks.tmp  rm -f $TMP.srclinks
3579    
3580  echo "  Adding makedepend marker"  echo "  Adding makedepend marker"
3581  printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE  printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE

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

  ViewVC Help
Powered by ViewVC 1.1.22