/[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.252 by jmc, Mon Jul 22 19:11:31 2013 UTC revision 1.273 by jmc, Tue Sep 1 19:39:56 2015 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      -nooptfile | --nooptfile
# Line 208  test_for_string_in_file() { Line 216  test_for_string_in_file() {
216  expand_pkg_groups() {  expand_pkg_groups() {
217      new_packages=      new_packages=
218      if test -r $PKG_GROUPS ; then      if test -r $PKG_GROUPS ; then
219          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
220          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp          cat $TMP.p1 | $AWK '(NF>2 && $2==":"){ print $0 }' > $TMP.p2
221          matched=0          matched=0
222          for i in $PACKAGES ; do          for i in $PACKAGES ; do
223              line=`grep "^ *$i" ./p2.tmp`              line=`grep "^ *$i" $TMP.p2`
224              RETVAL=$?              RETVAL=$?
225              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
226                  matched=1                  matched=1
# Line 224  expand_pkg_groups() { Line 232  expand_pkg_groups() {
232              fi              fi
233          done          done
234          PACKAGES=$new_packages          PACKAGES=$new_packages
235          rm -f ./p[1,2].tmp          rm -f $TMP.p[1,2]
236          return $matched          return $matched
237      else      else
238          echo "Warning: can't read package groups definition file: $PKG_GROUPS"          echo "Warning: can't read package groups definition file: $PKG_GROUPS"
# Line 607  EOF Line 615  EOF
615  mpi_headers_do_local_copy() {  mpi_headers_do_local_copy() {
616    
617      dBug=0      dBug=0
618      #----- check for additional headers (chain of included headers)      rm -rf ./mpi_headers
619      listIni=$MPI_HEADER_FILES      if test -d $MPIINCLUDEDIR ; then
620      echo $listIni | grep "\<mpif.h\>" > /dev/null 2>&1  
621      outp=$?          #----- check for additional headers (chain of included headers)
622      #- always check mpif.h (the only mpi-header included in standard MITgcm code)          echo -n '  Check MPI headers ... '
623      if test $outp != 0 ; then listIni="mpif.h $listIni" ; fi          listIni=$MPI_HEADER_FILES
624      if test $dBug = 1 ; then echo "listIni='$listIni'" ; fi          echo $listIni | grep "\<mpif.h\>" > /dev/null 2>&1
625      doCheck=1 ; list2copy='' ; list2check=$listIni          outp=$?
626      while test $doCheck = 1 ; do          #- always check mpif.h (the only mpi-header included in standard MITgcm code)
627          newList=''          if test $outp != 0 ; then listIni="mpif.h $listIni" ; fi
628          for i in $list2check ; do          if test $dBug = 1 ; then echo "listIni='$listIni'" ; fi
629           if test -f $MPIINCLUDEDIR/$i ; then  
630              newInc=`grep '^ *include ' $MPIINCLUDEDIR/$i | \          doCheck=1 ; list2copy='' ; list2check=$listIni
631            while test $doCheck = 1 ; do
632              newList=''
633              for i in $list2check ; do
634                if test -f $MPIINCLUDEDIR/$i ; then
635                  newInc=`grep '^ *include ' $MPIINCLUDEDIR/$i | \
636                  sed -e 's/^ *include //' -e 's/\!.*$//' -e "s/'//g"  -e 's/\"//g'`                  sed -e 's/^ *include //' -e 's/\!.*$//' -e "s/'//g"  -e 's/\"//g'`
637             if test $dBug = 1 ; then echo -n "checking $i : newInc='$newInc'" ; fi                if test $dBug = 1 ; then echo -n "checking $i : newInc='$newInc'" ; fi
638             for j in $newInc ; do                for j in $newInc ; do
639               echo $listIni $list2copy $newList | grep "\<$j\>" > /dev/null 2>&1                  echo $listIni $list2copy $newList | grep "\<$j\>" > /dev/null 2>&1
640               outp=$?                  outp=$?
641               if test $outp != 0 ; then                  if test $outp != 0 ; then
642                  if test $dBug = 1 ; then echo -n " ; adding $j" ; fi                    if test $dBug = 1 ; then echo -n " ; adding $j" ; fi
643                  newList="$newList $j"                    newList="$newList $j"
644               fi                  fi
645             done                done
646             if test $dBug = 1 ; then echo "" ; fi                if test $dBug = 1 ; then echo "" ; fi
647           fi              fi
648              done
649              if test "x$newList" = x ; then doCheck=0
650              else list2check=$newList ; list2copy="$list2copy $newList"
651              fi
652          done          done
653          if test "x$newList" = x ; then doCheck=0          list2copy="$MPI_HEADER_FILES $list2copy"
654          else list2check=$newList ; list2copy="$list2copy $newList"          if test $dBug = 1 ; then echo "list2copy='$list2copy'" ; fi
655          fi  
656      done          #----- create local mpi_headers dir if we have files to copy
657      list2copy="$MPI_HEADER_FILES $list2copy"          mkListInc=`echo $list2copy | wc -w`
658      if test $dBug = 1 ; then echo "list2copy='$list2copy'" ; fi          if test $mkListInc != 0 ; then
659      #----- make local copy and update LOCAL_MPI_HEADERS (if not already set)            echo 'create local "./mpi_headers" dir'
660      mkListInc=0            mkdir -p ./mpi_headers
661      for i in $list2copy ; do            INCLUDES="-I./mpi_headers $INCLUDES"
662          if test -f $MPIINCLUDEDIR/$i ; then            mkListInc=1
663            fi
664            if test "x$LOCAL_MPI_HEADERS" != x ; then mkListInc=0 ; fi
665    
666            #----- make local copy and update LOCAL_MPI_HEADERS (if not already set)
667            for i in $list2copy ; do
668              if test -f $MPIINCLUDEDIR/$i ; then
669              cp -p $MPIINCLUDEDIR/$i ./mpi_headers              cp -p $MPIINCLUDEDIR/$i ./mpi_headers
670              if test $i = 'mpif.h' ; then              if test $i = 'mpif.h' ; then
671                  perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h                  perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h
672              fi              fi
673              if test $mkListInc = 1 ; then              if test $mkListInc = 2 ; then
674                  LOCAL_MPI_HEADERS="$LOCAL_MPI_HEADERS ./mpi_headers/$i"                  LOCAL_MPI_HEADERS="$LOCAL_MPI_HEADERS ./mpi_headers/$i"
675              fi              fi
676              if test "x$LOCAL_MPI_HEADERS" = x ; then              if test $mkListInc = 1 ; then
677                  LOCAL_MPI_HEADERS="./mpi_headers/$i" ; mkListInc=1                  LOCAL_MPI_HEADERS="./mpi_headers/$i" ; mkListInc=2
678              fi              fi
679          fi            fi
680      done          done
681        else
682            echo "WARNING: MPIINCLUDEDIR='$MPIINCLUDEDIR' is not a directory"
683            echo "WARNING: => skip checking for MPI headers (no ./mpi_headers dir)"
684    #       exit -1
685        fi
686  }  }
687    
688  #  Parse the package dependency information  #  Parse the package dependency information
# Line 1059  EOF Line 1087  EOF
1087  }  }
1088    
1089  check_lapack_libs()  {  check_lapack_libs()  {
1090      if test ! "x$SKIP_LAPACK_CHECK" = x ; then      if test "x$CHECK_FOR_LAPACK" = xf ; then return ; fi
         return  
     fi  
1091      echo >> $LOGFILE      echo >> $LOGFILE
1092      echo "running: check_lapack_libs()" >> $LOGFILE      echo "running: check_lapack_libs()" >> $LOGFILE
1093      cat <<EOF > genmake_tla.F      cat <<EOF > genmake_tla.F
# Line 1257  GSL= Line 1283  GSL=
1283  DEVEL=  DEVEL=
1284  HAVE_TEST_L=  HAVE_TEST_L=
1285    
1286  # comment this line out to enable lapack test  # set this to "t" to enable lapack test
1287  SKIP_LAPACK_CHECK=t  CHECK_FOR_LAPACK=f
1288    
1289  # DEFINES checked by test compilation or command-line  # DEFINES checked by test compilation or command-line
1290  HAVE_SYSTEM=  HAVE_SYSTEM=
# Line 1305  FS= Line 1331  FS=
1331  FS90=  FS90=
1332    
1333  AUTODIFF_PKG_USED=f  AUTODIFF_PKG_USED=f
1334    OPENAD=
1335  AD_OPTFILE=  AD_OPTFILE=
1336    CAT_SRC_FOR_TAF=1
1337  TAF=  TAF=
1338  AD_TAF_FLAGS=  AD_TAF_FLAGS=
1339  FTL_TAF_FLAGS=  FTL_TAF_FLAGS=
# Line 1331  gm_s3="FEXTRAFLAGS IEEE DEVEL GSL TS PAP Line 1359  gm_s3="FEXTRAFLAGS IEEE DEVEL GSL TS PAP
1359  gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM"  gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM"
1360  gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
1361  gm_s6="PWD TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"  gm_s6="PWD TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"
1362  gm_s7="THISHOST THISUSER THISDATE THISVER MACHINE FC_NAMEMANGLE"  gm_s7="TMP THISHOST THISUSER THISDATE THISVER MACHINE FC_NAMEMANGLE"
1363  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"
1364    
1365  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1366  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"
1367  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"
1368  gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES"  gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES"
1369    
# Line 1387  for ac_option in "$@" ; do Line 1415  for ac_option in "$@" ; do
1415          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
1416              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
1417    
1418            -oad | --oad)
1419                OPENAD="true" ; ALWAYS_USE_F90=1 ;;
1420            -nocat4ad | -dog4ad | -ncad | -dad)
1421                CAT_SRC_FOR_TAF=0 ;;
1422          -adoptfile | --adoptfile | -adof | --adof)          -adoptfile | --adoptfile | -adof | --adof)
1423              ac_prev=AD_OPTFILE ;;              ac_prev=AD_OPTFILE ;;
1424          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
# Line 1556  for ac_option in "$@" ; do Line 1588  for ac_option in "$@" ; do
1588    
1589  done  done
1590    
1591    #TMP=./genmk_$$
1592    #- try to put temporary files in system-local /tmp dir
1593    TMP=/tmp/genmk_${USER}_$$
1594    touch $TMP ; retVal=$?
1595    if [ $retVal -eq 0 ] ; then
1596      if test ! -r $TMP ; then TMP=./genmk_$$ ; fi
1597    else
1598      TMP=./genmk_$$
1599    fi
1600    rm -f $TMP
1601    #echo "  temp files: $TMP.*"
1602    
1603  printf "  getting local config information:  "  printf "  getting local config information:  "
1604  if test -f $gm_local ; then  if test -f $gm_local ; then
1605      echo "using $gm_local"      echo "using $gm_local"
# Line 1648  fi Line 1692  fi
1692    
1693  echo "  getting AD_OPTFILE information:"  echo "  getting AD_OPTFILE information:"
1694  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1695      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" != x ; then
1696            AD_OPTFILE=$MITGCM_AD_OF
1697        elif test "x$OPENAD" = x ; then
1698          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
1699      else      else
1700          AD_OPTFILE=$MITGCM_AD_OF          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_oad
1701      fi      fi
1702  fi  fi
1703  if test "x${AD_OPTFILE}" != xNONE ; then  if test "x${AD_OPTFILE}" != xNONE ; then
# Line 2217  if test "x${PKG_GROUPS}" != x ; then Line 2263  if test "x${PKG_GROUPS}" != x ; then
2263  fi  fi
2264    
2265  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
2266  echo "" > ./.tmp_pack  echo "" > $TMP.pack
2267  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2268      echo $i >> ./.tmp_pack      echo $i >> $TMP.pack
2269  done  done
2270  for i in `grep  "-" ./.tmp_pack` ; do  for i in `grep  "-" $TMP.pack` ; do
2271      j=`echo $i | sed 's/[-]//'`      j=`echo $i | sed 's/[-]//'`
2272      DISABLE="$DISABLE $j"      DISABLE="$DISABLE $j"
2273  done  done
# Line 2239  for p in $PACKAGES ; do Line 2285  for p in $PACKAGES ; do
2285  done  done
2286  PACKAGES="$pack"  PACKAGES="$pack"
2287  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
2288  echo "" > ./.tmp_pack  echo "" > $TMP.pack
2289  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
2290  # Test if each explicitly referenced package exists  # Test if each explicitly referenced package exists
2291  for i in $PACKAGES ; do  for i in $PACKAGES ; do
# Line 2248  for i in $PACKAGES ; do Line 2294  for i in $PACKAGES ; do
2294          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
2295          exit 1          exit 1
2296      fi      fi
2297      echo $i >> ./.tmp_pack      echo $i >> $TMP.pack
2298  done  done
2299  PACKAGES=  PACKAGES=
2300  for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do  for i in `grep -v "-" $TMP.pack | sort | uniq` ; do
2301      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
2302  done  done
2303  rm -f ./.tmp_pack  rm -f $TMP.pack
2304  echo "    packages are: $PACKAGES"  echo "    packages are: $PACKAGES"
2305    
2306  #  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 2324  EOF Line 2370  EOF
2370      fi      fi
2371  fi  fi
2372    
2373  #  Check for package RADTRANS: if LAPACK is not available,  #  Make sure the openad package is enabled if using OpenAD
2374  #  then issue a warning that the direct radtrans solver is not available.  if test "x$OPENAD" != x ; then
2375  if test "x$HAVE_LAPACK" != xt ; then      echo " $PACKAGES " | grep ' openad ' > /dev/null 2>&1
     echo " $PACKAGES " | grep ' radtrans ' > /dev/null 2>&1  
2376      RETVAL=$?      RETVAL=$?
2377      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" != x0 ; then
2378          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:  
2379    
   1) LAPACK is correctly installed for this compiler and  
   2) the LIBS variable (within the "optfile") specifies the correct  
      LAPACK library to link against.  
2380  *********************************************************************  *********************************************************************
2381    ERROR: when generating an adjoint with OpenAD, the openad package
2382      must be enabled.  Please add it to packages.conf.
2383    *********************************************************************
2384    
2385  EOF  EOF
2386            exit 1
2387      fi      fi
2388  fi  fi
2389    
# Line 2533  fi Line 2575  fi
2575    
2576  #  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
2577  #  compiler.  #  compiler.
2578  if test -f ./adSrcFiles.tmp ; then  if test -f $TMP.adSrcFiles ; then
2579      rm -f ./adSrcFiles.tmp      rm -f $TMP.adSrcFiles
2580  fi  fi
2581  echo "  Creating the list of files for the adjoint compiler."  echo "  Creating the list of files for the adjoint compiler."
2582  touch adSrcFiles.tmp  touch $TMP.adSrcFiles
2583  for i in $SOURCEDIRS ; do  for i in $SOURCEDIRS ; do
2584      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2585      for j in $list_files ; do      for j in $list_files ; do
2586          cat $i/$j >> adSrcFiles.tmp          cat $i/$j >> $TMP.adSrcFiles
2587      done      done
2588  done  done
2589  if test ! "x"$FS = "x.f" ; then  if test ! "x"$FS = "x.f" ; then
2590      cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f      cat $TMP.adSrcFiles | sed -e "s/\.f/.$FS/g" > $TMP.adSrcFiles_f
2591      mv -f adSrcFiles.tmp_f adSrcFiles.tmp      mv -f $TMP.adSrcFiles_f $TMP.adSrcFiles
2592  fi  fi
2593    
2594  echo  echo
# Line 2559  for i in $INCLUDEDIRS ; do Line 2601  for i in $INCLUDEDIRS ; do
2601  done  done
2602    
2603  if test ! "x$DIVA" = x -a ! "x$MPI" = x ; then  if test ! "x$DIVA" = x -a ! "x$MPI" = x ; then
2604    if test ! "x$MPIINCLUDEDIR" = x ; then      if test ! "x$MPIINCLUDEDIR" = x ; then
     if test -d $MPIINCLUDEDIR ; then  
         echo "  Creating the pseudo-MPI include directory"  
         INCLUDES="-I./mpi_headers $INCLUDES"  
         rm -rf ./mpi_headers  
         mkdir -p ./mpi_headers  
2605          #  Do a local copy of MPI headers files (in local dir ./mpi_headers/) after          #  Do a local copy of MPI headers files (in local dir ./mpi_headers/) after
2606          #   checking for additional included headers (in case of chain of included          #   checking for additional included headers (in case of chain of included
2607          #   header); also set LOCAL_MPI_HEADERS (if not already set)          #   header); also set LOCAL_MPI_HEADERS (if not already set)
2608          mpi_headers_do_local_copy          mpi_headers_do_local_copy
     else  
         echo "WARNING: MPIINCLUDEDIR='$MPIINCLUDEDIR' is not a dir"  
         echo "WARNING: ==> cannot create pseudo-MPI include directory"  
 #       exit -1  
2609      fi      fi
   fi  
2610  fi  fi
2611    
2612  echo "  Determining the list of source and include files"  echo "  Determining the list of source and include files"
2613  rm -rf .links.tmp  rm -rf $TMP.links
2614  mkdir .links.tmp  mkdir $TMP.links
2615  touch .links.tmp/foo  touch $TMP.links/foo
2616  if test ! -r ".links.tmp/foo" ; then  if test ! -r "$TMP.links/foo" ; then
2617      echo      echo
2618      echo "ERROR : something is wrong with your directory permissions or"      echo "ERROR : something is wrong with your directory permissions or"
2619      echo "   your user file-creation mask (\"umask\") since creating a"      echo "   your user file-creation mask (\"umask\") since creating a"
# Line 2597  if test ! -r ".links.tmp/foo" ; then Line 2629  if test ! -r ".links.tmp/foo" ; then
2629      echo      echo
2630      exit 1      exit 1
2631  fi  fi
2632  rm -f .links.tmp/foo  rm -f $TMP.links/foo
2633    
2634  if test "x$OPENAD" != x ; then  if test "x$OPENAD" != x ; then
2635      OAD_DONT_COMPILE="/dev/null"      OAD_DONT_COMPILE="/dev/null"
# Line 2606  if test "x$OPENAD" != x ; then Line 2638  if test "x$OPENAD" != x ; then
2638      OAD_CB2M_FILES="/dev/null"      OAD_CB2M_FILES="/dev/null"
2639      OADTOOLS="$TOOLSDIR/OAD_support"      OADTOOLS="$TOOLSDIR/OAD_support"
2640      echo "  looking for dontCompile file:  "      echo "  looking for dontCompile file:  "
2641      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2642          if test -r $i"/dontCompile" ; then          if test -r $i"/dontCompile" ; then
2643              OAD_DONT_COMPILE=$i"/dontCompile"              OAD_DONT_COMPILE=$i"/dontCompile"
2644              echo "     found $OAD_DONT_COMPILE"              echo "     found $OAD_DONT_COMPILE"
# Line 2614  if test "x$OPENAD" != x ; then Line 2646  if test "x$OPENAD" != x ; then
2646          fi          fi
2647      done      done
2648      echo "  looking for dontTransform file:  "      echo "  looking for dontTransform file:  "
2649      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2650          if test -r $i"/dontTransform" ; then          if test -r $i"/dontTransform" ; then
2651              OAD_DONT_TRANSFORM=$i"/dontTransform"              OAD_DONT_TRANSFORM=$i"/dontTransform"
2652              echo "     found $OAD_DONT_TRANSFORM"              echo "     found $OAD_DONT_TRANSFORM"
# Line 2622  if test "x$OPENAD" != x ; then Line 2654  if test "x$OPENAD" != x ; then
2654          fi          fi
2655      done      done
2656      echo "  looking for keepOriginal file:  "      echo "  looking for keepOriginal file:  "
2657      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2658          if test -r $i"/keepOriginal" ; then          if test -r $i"/keepOriginal" ; then
2659              OAD_KEEP_ORIGINAL=$i"/keepOriginal"              OAD_KEEP_ORIGINAL=$i"/keepOriginal"
2660              echo "     found $OAD_KEEP_ORIGINAL"              echo "     found $OAD_KEEP_ORIGINAL"
# Line 2630  if test "x$OPENAD" != x ; then Line 2662  if test "x$OPENAD" != x ; then
2662          fi          fi
2663      done      done
2664      echo "  looking for cb2mFiles:  "      echo "  looking for cb2mFiles:  "
2665      for i in "." $MODS ; do      for i in "." $MODS $OADTOOLS ; do
2666          if test -r $i"/cb2mFiles" ; then          if test -r $i"/cb2mFiles" ; then
2667              OAD_CB2M_FILES=$i"/cb2mFiles"              OAD_CB2M_FILES=$i"/cb2mFiles"
2668              echo "     found $OAD_CB2M_FILES"              echo "     found $OAD_CB2M_FILES"
# Line 2640  if test "x$OPENAD" != x ; then Line 2672  if test "x$OPENAD" != x ; then
2672      echo "   OpenAD exceptions:  "      echo "   OpenAD exceptions:  "
2673  fi  fi
2674    
2675  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > $TMP.srclinks
2676  echo "" >> srclinks.tmp  echo "" >> $TMP.srclinks
2677  printf 'F77_SRC_FILES = ' > F77srclist.tmp  printf 'F77_SRC_FILES = ' > $TMP.F77srclist
2678  printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp  printf 'NON_AD_F77_SRC_FILES = ' > $TMP.nonADF77srclist
2679  printf 'C_SRC_FILES = '   > csrclist.tmp  printf 'C_SRC_FILES = '   > $TMP.csrclist
2680  printf 'F90_SRC_FILES = ' > F90srclist.tmp  printf 'F90_SRC_FILES = ' > $TMP.F90srclist
2681  printf 'H_SRC_FILES = '   > hsrclist.tmp  printf 'H_SRC_FILES = '   > $TMP.hsrclist
2682  printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp  printf 'AD_FLOW_FILES = ' > $TMP.ad_flow_files
2683  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2684  for d in $alldirs ; do  for d in $alldirs ; do
2685      deplist=      deplist=
# Line 2657  for d in $alldirs ; do Line 2689  for d in $alldirs ; do
2689          sfiles=`( echo $sfiles | grep -v _cb2m\. )`          sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2690      fi      fi
2691      for sf in $sfiles ; do      for sf in $sfiles ; do
2692          if test ! -r ".links.tmp/$sf" ; then          if test ! -r "$TMP.links/$sf" ; then
2693              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2694                  ignore_f=f                  ignore_f=f
2695                  case $d/$sf in                  case $d/$sf in
# Line 2682  for d in $alldirs ; do Line 2714  for d in $alldirs ; do
2714                          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
2715                              ignore_f=t                              ignore_f=t
2716                          else                          else
2717                              touch .links.tmp/$sf                              touch $TMP.links/$sf
2718                              deplist="$deplist $sf"                              deplist="$deplist $sf"
2719                          fi                          fi
2720                          ;;                          ;;
# Line 2691  for d in $alldirs ; do Line 2723  for d in $alldirs ; do
2723                      extn=`echo $sf | $AWK -F. '{print $NF}'`                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2724                      case $extn in                      case $extn in
2725                        F)                        F)
2726                          echo    " \\"  >> F77srclist.tmp                          echo    " \\"  >> $TMP.F77srclist
2727                          printf " $sf" >> F77srclist.tmp                          printf " $sf" >> $TMP.F77srclist
2728                          if test "x$OPENAD" != x ; then                          if test "x$OPENAD" = x ; then
2729                                basename=${sf%%.F}
2730                                isAD=`egrep ^$basename.f'[  ]*' $TMP.adSrcFiles`
2731                                if test -z "$isAD" ; then
2732                                    echo    " \\"  >> $TMP.nonADF77srclist
2733                                    printf " $sf" >> $TMP.nonADF77srclist
2734                                fi
2735                            else #- OpenAD case:
2736                              basename=${sf%%.F}                              basename=${sf%%.F}
2737                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`                              isAD=`egrep ^$basename.f'[  ]*' $TMP.adSrcFiles`
2738                              if test -z "$isAD" ; then                              if test -z "$isAD" ; then
2739                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`
2740                                  if test -z "$toBeIgnored" ; then                                  if test -z "$toBeIgnored" ; then
2741                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> $TMP.nonADF77srclist
2742                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> $TMP.nonADF77srclist
2743                                  else                                  else
2744                                      echo "    not to be compiled   :  $sf"                                      echo "    not to be compiled   :  $sf"
2745                                  fi                                  fi
# Line 2715  for d in $alldirs ; do Line 2754  for d in $alldirs ; do
2754                                      echo "    original to be kept  :  $sf"                                      echo "    original to be kept  :  $sf"
2755                                  fi                                  fi
2756                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2757                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> $TMP.nonADF77srclist
2758                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> $TMP.nonADF77srclist
2759                                  fi                                  fi
2760                              fi                              fi
2761                          fi                          fi
2762                          ;;                          ;;
2763                      F90)                      F90)
2764                          echo    " \\"  >> F90srclist.tmp                          echo    " \\"  >> $TMP.F90srclist
2765                          printf " $sf" >> F90srclist.tmp                          printf " $sf" >> $TMP.F90srclist
2766                          ;;                          ;;
2767                      c)                      c)
2768                          echo    " \\"  >> csrclist.tmp                          echo    " \\"  >> $TMP.csrclist
2769                          printf " $sf" >> csrclist.tmp                          printf " $sf" >> $TMP.csrclist
2770                          ;;                          ;;
2771                      h)                      h)
2772                          echo    " \\"  >> hsrclist.tmp                          echo    " \\"  >> $TMP.hsrclist
2773                          printf " $sf" >> hsrclist.tmp                          printf " $sf" >> $TMP.hsrclist
2774                          ;;                          ;;
2775                      flow)                      flow)
2776                          echo    " \\"  >> ad_flow_files.tmp                          echo    " \\"  >> $TMP.ad_flow_files
2777                          printf " $sf" >> ad_flow_files.tmp                          printf " $sf" >> $TMP.ad_flow_files
2778                          ;;                          ;;
2779                     esac                     esac
2780                  fi                  fi
# Line 2744  for d in $alldirs ; do Line 2783  for d in $alldirs ; do
2783      done      done
2784      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2785        if test "$d" != "." ; then        if test "$d" != "." ; then
2786          echo "" >> srclinks.tmp          echo "" >> $TMP.srclinks
2787          echo "#  These files are linked from $d" >> srclinks.tmp          echo "#  These files are linked from $d" >> $TMP.srclinks
2788          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> $TMP.srclinks
2789  # We need to make sure that the link isn't already there.  # We need to make sure that the link isn't already there.
2790  # 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"
2791  # 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.
2792          printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp          printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> $TMP.srclinks
2793        fi        fi
2794      fi      fi
2795  done  done
2796  rm -rf .links.tmp  rm -rf $TMP.links
2797  echo "" >> F77srclist.tmp  echo "" >> $TMP.F77srclist
2798  echo "" >> nonADF77srclist.tmp  echo "" >> $TMP.nonADF77srclist
2799  echo "" >> csrclist.tmp  echo "" >> $TMP.csrclist
2800  echo "" >> F90srclist.tmp  echo "" >> $TMP.F90srclist
2801  echo "" >> hsrclist.tmp  echo "" >> $TMP.hsrclist
2802  echo "" >> ad_flow_files.tmp  echo "" >> $TMP.ad_flow_files
2803    
2804  CMDLINE=$0  CMDLINE=$0
2805  for xx in "$@" ; do nw=`echo $xx | wc -w`  for xx in "$@" ; do nw=`echo $xx | wc -w`
# Line 2862  CPPINCLUDES = ${CPPINCLUDES} Line 2901  CPPINCLUDES = ${CPPINCLUDES}
2901  KFLAGS1 = ${KFLAGS1}  KFLAGS1 = ${KFLAGS1}
2902  KFLAGS2 = ${KFLAGS2}  KFLAGS2 = ${KFLAGS2}
2903  # Optim./debug for FC  # Optim./debug for FC
2904  FFLAGS = ${FFLAGS} ${FEXTRAFLAGS}  FFLAGS = ${FFLAGS}
2905  FOPTIM = ${FOPTIM}  FOPTIM = ${FOPTIM} ${FEXTRAFLAGS}
2906  # Optim./debug for FC  # Optim./debug for FC
2907  F90FLAGS = ${F90FLAGS}  F90FLAGS = ${F90FLAGS}
2908  F90OPTIM = ${F90OPTIM}  F90OPTIM = ${F90OPTIM}
# Line 2882  MAKE = ${MAKE} Line 2921  MAKE = ${MAKE}
2921    
2922  EOF  EOF
2923    
2924  cat F77srclist.tmp      >> $MAKEFILE  cat $TMP.F77srclist      >> $MAKEFILE
2925  cat nonADF77srclist.tmp >> $MAKEFILE  cat $TMP.nonADF77srclist >> $MAKEFILE
2926  cat csrclist.tmp        >> $MAKEFILE  cat $TMP.csrclist        >> $MAKEFILE
2927  cat F90srclist.tmp      >> $MAKEFILE  cat $TMP.F90srclist      >> $MAKEFILE
2928  cat hsrclist.tmp        >> $MAKEFILE  cat $TMP.hsrclist        >> $MAKEFILE
2929  cat ad_flow_files.tmp   >> $MAKEFILE  cat $TMP.ad_flow_files   >> $MAKEFILE
2930    
2931  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
2932    
2933  echo >> $MAKEFILE  echo >> $MAKEFILE
2934    
# Line 2939  links: \$(F77_SRC_FILES) \$(C_SRC_FILES) Line 2978  links: \$(F77_SRC_FILES) \$(C_SRC_FILES)
2978    
2979  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
2980    
 output.txt: \$(EXECUTABLE)  
         @printf 'running ... '  
         @\$(EXECUTABLE) > \$@  
   
2981  # remove most of the files that "make" generates  # remove most of the files that "make" generates
2982  clean:  clean:
2983          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
# Line 2971  CLEAN: Line 3006  CLEAN:
3006          -rm -f *.txt STDOUT.* STDERR.* *diagnostics.log *.[0-9][0-9][0-9][0-9].log          -rm -f *.txt STDOUT.* STDERR.* *diagnostics.log *.[0-9][0-9][0-9][0-9].log
3007          -rm -f datetime costfinal divided.ctrl snapshot* output_adm.txt.diva_*          -rm -f datetime costfinal divided.ctrl snapshot* output_adm.txt.diva_*
3008          -rm -f *_MIT_CE_000.opt0000 costfunction*0000          -rm -f *_MIT_CE_000.opt0000 costfunction*0000
3009          -rm -f oad_cp.000.[0-9][0-9][0-9][0-9][0-9]          -rm -f oad_cp.[0-9][0-9][0-9].?????
3010    
3011  makefile:  makefile:
3012          $THIS_SCRIPT $G2ARGS          $THIS_SCRIPT $G2ARGS
# Line 3086  done Line 3121  done
3121  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
3122  echo >> $MAKEFILE  echo >> $MAKEFILE
3123  printf "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
3124  AD_FILES=`cat adSrcFiles.tmp`  AD_FILES=`cat $TMP.adSrcFiles`
3125  for i in $AD_FILES ; do  for i in $AD_FILES ; do
3126      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
3127      printf " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
3128  done  done
3129  echo >> $MAKEFILE  echo >> $MAKEFILE
3130  rm -f adSrcFiles.tmp  rm -f $TMP.adSrcFiles
3131    
3132    if test $CAT_SRC_FOR_TAF = 0 ; then
3133    cat >>$MAKEFILE <<EOF
3134    
3135    # ... Utilities ...
3136    remove_comments:
3137            sed -i.bak -f \$(TOOLSDIR)/remove_comments_sed \$(AD_FILES)
3138            @-rm -f \$(AD_FILES:.$FS=.$FS.bak)
3139    adj_sed:
3140            sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_ad.$FS)
3141            @-rm -f \$(AD_FILES:.$FS=_ad.$FS.bak)
3142    ftl_sed:
3143            sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_tl.$FS)
3144            @-rm -f \$(AD_FILES:.$FS=_tl.$FS.bak)
3145    adobjfiles: \$(AD_FILES:.$FS=_ad.o)
3146    ftlobjfiles: \$(AD_FILES:.$FS=_tl.o)
3147    EOF
3148    fi
3149    
3150  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3151    
# Line 3116  ad_input_code.$FS: \$(AD_FILES) \$(AD_FL Line 3169  ad_input_code.$FS: \$(AD_FILES) \$(AD_FL
3169          @\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)          @\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)
3170          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
3171    
3172  ad_taf_output.$FS: ad_input_code.$FS  adtafonly:
3173          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3174          ls -l ad_input_code_ad.$FS          ls -l ad_input_code_ad.$FS
3175          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
3176    
3177  adtafonly:  EOF
3178    
3179    if test $CAT_SRC_FOR_TAF = 1 ; then
3180    cat >>$MAKEFILE <<EOF
3181    # ... send 1 file to TAF ...
3182    ad_taf_output.$FS: ad_input_code.$FS
3183            @-rm -f ad_input_code_ad.$FS ; echo ''
3184          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3185          ls -l ad_input_code_ad.$FS          ls -l ad_input_code_ad.$FS
3186          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
3187    
3188  \$(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)
3189          \$(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)
3190    
3191  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  
3192    
3193  ad_tamc: ad_tamc_output.o \$(OBJFILES)  EOF
3194          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)  
3195    else
3196    cat >>$MAKEFILE <<EOF
3197    # ... send multiple files to TAF ...
3198    ad_taf_output.$FS: \$(AD_FLOW_FILES) \$(AD_FILES)
3199            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3200            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3201            @-rm -f ad_config.template
3202            @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3203            @\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES)
3204            @-rm -f \$(AD_FILES:.$FS=_ad.$FS) \$(AD_FILES:.$FS=_ad.o); echo ''
3205            \$(MAKE) -f \$(MAKEFILE) remove_comments
3206            \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) \$(FLOWFILES) \$(AD_FILES)
3207            \$(MAKE) -f \$(MAKEFILE) adj_sed
3208            cat \$(AD_FILES:.$FS=_ad.$FS) > ad_taf_output.$FS
3209    
3210    \$(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)
3211            \$(MAKE) -f \$(MAKEFILE) adobjfiles
3212            \$(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)
3213    
3214    adobj: ad_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o)
3215            \$(MAKE) -f \$(MAKEFILE) adobjfiles
3216    
3217    EOF
3218    fi
3219    
3220    cat >>$MAKEFILE <<EOF
3221  adonlyfwd:  adonlyfwd:
3222          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff
3223    
3224  adtrick:  adtrick:
3225          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
3226    
3227  adobj: ad_taf_output.o \$(OBJFILES)  ad_tamc_output.$FS: ad_input_code.$FS
3228            \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
3229            cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS
3230    
3231    ad_tamc: ad_tamc_output.o \$(OBJFILES)
3232            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
3233    
3234  # ... FTL ...  # ... FTL ...
3235  ftlall: ftl_exe_target  ftlall: ftl_exe_target
# Line 3164  ftl_input_code.$FS: \$(AD_FILES) Line 3251  ftl_input_code.$FS: \$(AD_FILES)
3251          @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES)          @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3252          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
3253    
3254  ftl_taf_output.$FS: ftl_input_code.$FS  ftltafonly:
3255          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3256          ls -l ftl_input_code_ftl.$FS          ls -l ftl_input_code_tl.$FS
3257          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
3258    
3259  ftltafonly:  EOF
3260    
3261    if test $CAT_SRC_FOR_TAF = 1 ; then
3262    cat >>$MAKEFILE <<EOF
3263    # ... send 1 file to TAF ...
3264    ftl_taf_output.$FS: ftl_input_code.$FS
3265            @-rm -f ftl_input_code_tl.$FS ; echo ''
3266          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3267          ls -l ftl_input_code_ftl.$FS          ls -l ftl_input_code_tl.$FS
3268          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
3269    
3270    \$(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)
3271            \$(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)
3272    
3273  \$(EXE_FTL): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) ftl_taf_output.o \$(OBJFILES) \$(EMBEDDED_FILES)  EOF
         \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)  
3274    
3275    else
3276    cat >>$MAKEFILE <<EOF
3277    # ... send multiple files to TAF ...
3278    ftl_taf_output.$FS: \$(AD_FLOW_FILES) \$(AD_FILES)
3279            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template
3280            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3281            @-rm -f ad_config.template
3282            @\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES)
3283            @\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES)
3284            @-rm -f \$(AD_FILES:.$FS=_tl.$FS) \$(AD_FILES:.$FS=_tl.o); echo ''
3285            \$(MAKE) -f \$(MAKEFILE) remove_comments
3286            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) \$(AD_FLOW_FILES) \$(AD_FILES)
3287            \$(MAKE) -f \$(MAKEFILE) ftl_sed
3288            cat \$(AD_FILES:.$FS=_tl.$FS) > ftl_taf_output.$FS
3289    
3290    \$(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)
3291            \$(MAKE) -f \$(MAKEFILE) ftlobjfiles
3292            \$(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)
3293    
3294    EOF
3295    fi
3296    
3297    cat >>$MAKEFILE <<EOF
3298  ftl_tamc_output.$FS: ftl_input_code.$FS  ftl_tamc_output.$FS: ftl_input_code.$FS
3299          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
3300          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 3219  if test "x$OPENAD" != x ; then Line 3337  if test "x$OPENAD" != x ; then
3337  # ============ begin OpenAD specific section ==============  # ============ begin OpenAD specific section ==============
3338    
3339  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3340    # ... OpenAD ...
3341    
3342  # all the source files linked from the various locations:  # all the source files linked from the various locations:
3343  ALL_LINKED_FILES= \  ALL_LINKED_FILES= \
# Line 3258  for i in `cat ${OAD_CB2M_FILES}` ; do Line 3377  for i in `cat ${OAD_CB2M_FILES}` ; do
3377    echo    " \\" >> $MAKEFILE    echo    " \\" >> $MAKEFILE
3378    printf " ${i}_mod.f$FS90" >> $MAKEFILE    printf " ${i}_mod.f$FS90" >> $MAKEFILE
3379  done  done
3380  AD_FILES=`cat adSrcFiles.tmp`  AD_FILES=`cat $TMP.adSrcFiles`
3381  for i in $AD_FILES ; do  for i in $AD_FILES ; do
3382    basename=${i%%.f}    basename=${i%%.f}
3383    toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`    toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`
# Line 3268  for i in $AD_FILES ; do Line 3387  for i in $AD_FILES ; do
3387    fi    fi
3388  done  done
3389  echo >> $MAKEFILE  echo >> $MAKEFILE
3390  rm -f adSrcFiles.tmp  rm -f $TMP.adSrcFiles
3391    
3392  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3393    
3394  adAll: \$(EXE_AD)  adAll: ad_exe_target
3395  .PHONY: adAll  .PHONY: adAll
3396    
3397    ad_exe_target:
3398            @echo Update AD_CONFIG.h and make \$(EXE_AD)
3399            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3400            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3401            @-rm -f ad_config.template
3402            \$(MAKE) -f \$(MAKEFILE) \$(EXE_AD)
3403    
3404  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))
3405    
3406  .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 3291  OAD_active.F90 \ Line 3417  OAD_active.F90 \
3417  OAD_cp.F90 \  OAD_cp.F90 \
3418  OAD_rev.F90 \  OAD_rev.F90 \
3419  OAD_tape.F90 \  OAD_tape.F90 \
3420    OAD_regular_cp.F90 \
3421  revolve.F90  revolve.F90
3422    
3423  OPENAD_SUPPORT_C_SRC_FILES = \  OPENAD_SUPPORT_C_SRC_FILES = \
# Line 3332  AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(N Line 3459  AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(N
3459  small_f: \$(CB2M_F90_PP_SRC_FILES)  small_f: \$(CB2M_F90_PP_SRC_FILES)
3460  .PHONY: small_f  .PHONY: small_f
3461    
 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) > \$@  
   
3462  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3463          cat \$^ > \$@          cat \$^ > \$@
3464    
# Line 3374  ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS Line 3494  ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS
3494  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
3495          \${OADTOOLS}/insertTemplateDir.bash \$< \$@          \${OADTOOLS}/insertTemplateDir.bash \$< \$@
3496    
3497  PPEXTRAS=\$(wildcard \${OADTOOLS}/ad_template.*.F) \${OADTOOLS}/ad_inline.F  PPEXTRAS=\$(notdir \$(wildcard \${OADTOOLS}/ad_template.*.F)) ad_inline.F
3498  # postprocess F'  # postprocess F'
3499  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
3500          \${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 \$<
3501          # 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
3502          touch \$@          touch \$@
3503  # put this so make knows about the postprocessing output  # put this so make knows about the postprocessing output
# Line 3388  OAD_intrinsics_oad.f \$(CB2M_AD_FILES:.f Line 3508  OAD_intrinsics_oad.f \$(CB2M_AD_FILES:.f
3508          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3509    
3510  # link the support files:  # link the support files:
3511  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES) \$(PPEXTRAS):
3512          \$(LN) \${OADTOOLS}/\$@ .          \$(LN) \${OADTOOLS}/\$@ .
3513    
3514  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
3515    
3516  # ============ end OpenAD specific section ==============  # ============ end OpenAD specific section ==============
3517    
# Line 3427  for i in $NOOPTFILES ; do Line 3547  for i in $NOOPTFILES ; do
3547  done  done
3548    
3549  echo "  Add rules for links"  echo "  Add rules for links"
3550  cat srclinks.tmp >> $MAKEFILE  cat $TMP.srclinks >> $MAKEFILE
3551  rm -f srclinks.tmp  rm -f $TMP.srclinks
3552    
3553  echo "  Adding makedepend marker"  echo "  Adding makedepend marker"
3554  printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE  printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE

Legend:
Removed from v.1.252  
changed lines
  Added in v.1.273

  ViewVC Help
Powered by ViewVC 1.1.22