/[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.266 by jmc, Wed May 7 19:36:22 2014 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      -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME      -adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME
26        -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME        -adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME
27            Use "NAME" as the adoptfile.  By default, the file at            Use "NAME" as the adoptfile.  By default, the file at
28              "tools/adjoint_options/adjoint_oad" (for OpenAD built) or
29            "tools/adjoint_options/adjoint_default" will be used.            "tools/adjoint_options/adjoint_default" will be used.
30    
31      -nooptfile | --nooptfile      -nooptfile | --nooptfile
# Line 208  test_for_string_in_file() { Line 212  test_for_string_in_file() {
212  expand_pkg_groups() {  expand_pkg_groups() {
213      new_packages=      new_packages=
214      if test -r $PKG_GROUPS ; then      if test -r $PKG_GROUPS ; then
215          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
216          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp          cat $TMP.p1 | $AWK '(NF>2 && $2==":"){ print $0 }' > $TMP.p2
217          matched=0          matched=0
218          for i in $PACKAGES ; do          for i in $PACKAGES ; do
219              line=`grep "^ *$i" ./p2.tmp`              line=`grep "^ *$i" $TMP.p2`
220              RETVAL=$?              RETVAL=$?
221              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
222                  matched=1                  matched=1
# Line 224  expand_pkg_groups() { Line 228  expand_pkg_groups() {
228              fi              fi
229          done          done
230          PACKAGES=$new_packages          PACKAGES=$new_packages
231          rm -f ./p[1,2].tmp          rm -f $TMP.p[1,2]
232          return $matched          return $matched
233      else      else
234          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 1083  EOF
1083  }  }
1084    
1085  check_lapack_libs()  {  check_lapack_libs()  {
1086      if test ! "x$SKIP_LAPACK_CHECK" = x ; then      if test "x$CHECK_FOR_LAPACK" = xf ; then return ; fi
         return  
     fi  
1087      echo >> $LOGFILE      echo >> $LOGFILE
1088      echo "running: check_lapack_libs()" >> $LOGFILE      echo "running: check_lapack_libs()" >> $LOGFILE
1089      cat <<EOF > genmake_tla.F      cat <<EOF > genmake_tla.F
# Line 1277  GSL= Line 1279  GSL=
1279  DEVEL=  DEVEL=
1280  HAVE_TEST_L=  HAVE_TEST_L=
1281    
1282  # comment this line out to enable lapack test  # set this to "t" to enable lapack test
1283  SKIP_LAPACK_CHECK=t  CHECK_FOR_LAPACK=f
1284    
1285  # DEFINES checked by test compilation or command-line  # DEFINES checked by test compilation or command-line
1286  HAVE_SYSTEM=  HAVE_SYSTEM=
# Line 1325  FS= Line 1327  FS=
1327  FS90=  FS90=
1328    
1329  AUTODIFF_PKG_USED=f  AUTODIFF_PKG_USED=f
1330    OPENAD=
1331  AD_OPTFILE=  AD_OPTFILE=
1332  TAF=  TAF=
1333  AD_TAF_FLAGS=  AD_TAF_FLAGS=
# Line 1351  gm_s3="FEXTRAFLAGS IEEE DEVEL GSL TS PAP Line 1354  gm_s3="FEXTRAFLAGS IEEE DEVEL GSL TS PAP
1354  gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM"  gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM"
1355  gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS"
1356  gm_s6="PWD TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"  gm_s6="PWD TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK"
1357  gm_s7="THISHOST THISUSER THISDATE THISVER MACHINE FC_NAMEMANGLE"  gm_s7="TMP THISHOST THISUSER THISDATE THISVER MACHINE FC_NAMEMANGLE"
1358  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"
1359    
1360  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
1361  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"
1362  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"
1363  gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES"  gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES"
1364    
# Line 1407  for ac_option in "$@" ; do Line 1410  for ac_option in "$@" ; do
1410          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
1411              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
1412    
1413            -oad | --oad)
1414                OPENAD="true" ;;
1415          -adoptfile | --adoptfile | -adof | --adof)          -adoptfile | --adoptfile | -adof | --adof)
1416              ac_prev=AD_OPTFILE ;;              ac_prev=AD_OPTFILE ;;
1417          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)          -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
# Line 1576  for ac_option in "$@" ; do Line 1581  for ac_option in "$@" ; do
1581    
1582  done  done
1583    
1584    #TMP=./genmk_$$
1585    #- try to put temporary files in system-local /tmp dir
1586    TMP=/tmp/genmk_$$
1587    touch $TMP ; retVal=$?
1588    if [ $retVal -eq 0 ] ; then
1589      if test ! -r $TMP ; then TMP=./genmk_$$ ; fi
1590    else
1591      TMP=./genmk_$$
1592    fi
1593    rm -f $TMP
1594    #echo "  temp files: $TMP.*"
1595    
1596  printf "  getting local config information:  "  printf "  getting local config information:  "
1597  if test -f $gm_local ; then  if test -f $gm_local ; then
1598      echo "using $gm_local"      echo "using $gm_local"
# Line 1668  fi Line 1685  fi
1685    
1686  echo "  getting AD_OPTFILE information:"  echo "  getting AD_OPTFILE information:"
1687  if test "x${AD_OPTFILE}" = x ; then  if test "x${AD_OPTFILE}" = x ; then
1688      if test "x$MITGCM_AD_OF" = x ; then      if test "x$MITGCM_AD_OF" != x ; then
1689            AD_OPTFILE=$MITGCM_AD_OF
1690        elif test "x$OPENAD" = x ; then
1691          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
1692      else      else
1693          AD_OPTFILE=$MITGCM_AD_OF          AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_oad
1694      fi      fi
1695  fi  fi
1696  if test "x${AD_OPTFILE}" != xNONE ; then  if test "x${AD_OPTFILE}" != xNONE ; then
# Line 2237  if test "x${PKG_GROUPS}" != x ; then Line 2256  if test "x${PKG_GROUPS}" != x ; then
2256  fi  fi
2257    
2258  echo "  applying DISABLE settings"  echo "  applying DISABLE settings"
2259  echo "" > ./.tmp_pack  echo "" > $TMP.pack
2260  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2261      echo $i >> ./.tmp_pack      echo $i >> $TMP.pack
2262  done  done
2263  for i in `grep  "-" ./.tmp_pack` ; do  for i in `grep  "-" $TMP.pack` ; do
2264      j=`echo $i | sed 's/[-]//'`      j=`echo $i | sed 's/[-]//'`
2265      DISABLE="$DISABLE $j"      DISABLE="$DISABLE $j"
2266  done  done
# Line 2259  for p in $PACKAGES ; do Line 2278  for p in $PACKAGES ; do
2278  done  done
2279  PACKAGES="$pack"  PACKAGES="$pack"
2280  echo "  applying ENABLE settings"  echo "  applying ENABLE settings"
2281  echo "" > ./.tmp_pack  echo "" > $TMP.pack
2282  PACKAGES="$PACKAGES $ENABLE"  PACKAGES="$PACKAGES $ENABLE"
2283  # Test if each explicitly referenced package exists  # Test if each explicitly referenced package exists
2284  for i in $PACKAGES ; do  for i in $PACKAGES ; do
# Line 2268  for i in $PACKAGES ; do Line 2287  for i in $PACKAGES ; do
2287          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"          echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'"
2288          exit 1          exit 1
2289      fi      fi
2290      echo $i >> ./.tmp_pack      echo $i >> $TMP.pack
2291  done  done
2292  PACKAGES=  PACKAGES=
2293  for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do  for i in `grep -v "-" $TMP.pack | sort | uniq` ; do
2294      PACKAGES="$PACKAGES $i"      PACKAGES="$PACKAGES $i"
2295  done  done
2296  rm -f ./.tmp_pack  rm -f $TMP.pack
2297  echo "    packages are: $PACKAGES"  echo "    packages are: $PACKAGES"
2298    
2299  #  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 2363  EOF
2363      fi      fi
2364  fi  fi
2365    
2366  #  Check for package RADTRANS: if LAPACK is not available,  #  Make sure the openad package is enabled if using OpenAD
2367  #  then issue a warning that the direct radtrans solver is not available.  if test "x$OPENAD" != x ; then
2368  if test "x$HAVE_LAPACK" != xt ; then      echo " $PACKAGES " | grep ' openad ' > /dev/null 2>&1
     echo " $PACKAGES " | grep ' radtrans ' > /dev/null 2>&1  
2369      RETVAL=$?      RETVAL=$?
2370      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" != x0 ; then
2371          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:  
2372    
   1) LAPACK is correctly installed for this compiler and  
   2) the LIBS variable (within the "optfile") specifies the correct  
      LAPACK library to link against.  
2373  *********************************************************************  *********************************************************************
2374    ERROR: when generating an adjoint with OpenAD, the openad package
2375      must be enabled.  Please add it to packages.conf.
2376    *********************************************************************
2377    
2378  EOF  EOF
2379            exit 1
2380      fi      fi
2381  fi  fi
2382    
# Line 2553  fi Line 2568  fi
2568    
2569  #  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
2570  #  compiler.  #  compiler.
2571  if test -f ./adSrcFiles.tmp ; then  if test -f $TMP.adSrcFiles ; then
2572      rm -f ./adSrcFiles.tmp      rm -f $TMP.adSrcFiles
2573  fi  fi
2574  echo "  Creating the list of files for the adjoint compiler."  echo "  Creating the list of files for the adjoint compiler."
2575  touch adSrcFiles.tmp  touch $TMP.adSrcFiles
2576  for i in $SOURCEDIRS ; do  for i in $SOURCEDIRS ; do
2577      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2578      for j in $list_files ; do      for j in $list_files ; do
2579          cat $i/$j >> adSrcFiles.tmp          cat $i/$j >> $TMP.adSrcFiles
2580      done      done
2581  done  done
2582  if test ! "x"$FS = "x.f" ; then  if test ! "x"$FS = "x.f" ; then
2583      cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f      cat $TMP.adSrcFiles | sed -e "s/\.f/.$FS/g" > $TMP.adSrcFiles_f
2584      mv -f adSrcFiles.tmp_f adSrcFiles.tmp      mv -f $TMP.adSrcFiles_f $TMP.adSrcFiles
2585  fi  fi
2586    
2587  echo  echo
# Line 2588  if test ! "x$DIVA" = x -a ! "x$MPI" = x Line 2603  if test ! "x$DIVA" = x -a ! "x$MPI" = x
2603  fi  fi
2604    
2605  echo "  Determining the list of source and include files"  echo "  Determining the list of source and include files"
2606  rm -rf .links.tmp  rm -rf $TMP.links
2607  mkdir .links.tmp  mkdir $TMP.links
2608  touch .links.tmp/foo  touch $TMP.links/foo
2609  if test ! -r ".links.tmp/foo" ; then  if test ! -r "$TMP.links/foo" ; then
2610      echo      echo
2611      echo "ERROR : something is wrong with your directory permissions or"      echo "ERROR : something is wrong with your directory permissions or"
2612      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 2622  if test ! -r ".links.tmp/foo" ; then
2622      echo      echo
2623      exit 1      exit 1
2624  fi  fi
2625  rm -f .links.tmp/foo  rm -f $TMP.links/foo
2626    
2627  if test "x$OPENAD" != x ; then  if test "x$OPENAD" != x ; then
2628      OAD_DONT_COMPILE="/dev/null"      OAD_DONT_COMPILE="/dev/null"
# Line 2650  if test "x$OPENAD" != x ; then Line 2665  if test "x$OPENAD" != x ; then
2665      echo "   OpenAD exceptions:  "      echo "   OpenAD exceptions:  "
2666  fi  fi
2667    
2668  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > $TMP.srclinks
2669  echo "" >> srclinks.tmp  echo "" >> $TMP.srclinks
2670  printf 'F77_SRC_FILES = ' > F77srclist.tmp  printf 'F77_SRC_FILES = ' > $TMP.F77srclist
2671  printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp  printf 'NON_AD_F77_SRC_FILES = ' > $TMP.nonADF77srclist
2672  printf 'C_SRC_FILES = '   > csrclist.tmp  printf 'C_SRC_FILES = '   > $TMP.csrclist
2673  printf 'F90_SRC_FILES = ' > F90srclist.tmp  printf 'F90_SRC_FILES = ' > $TMP.F90srclist
2674  printf 'H_SRC_FILES = '   > hsrclist.tmp  printf 'H_SRC_FILES = '   > $TMP.hsrclist
2675  printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp  printf 'AD_FLOW_FILES = ' > $TMP.ad_flow_files
2676  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2677  for d in $alldirs ; do  for d in $alldirs ; do
2678      deplist=      deplist=
# Line 2667  for d in $alldirs ; do Line 2682  for d in $alldirs ; do
2682          sfiles=`( echo $sfiles | grep -v _cb2m\. )`          sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2683      fi      fi
2684      for sf in $sfiles ; do      for sf in $sfiles ; do
2685          if test ! -r ".links.tmp/$sf" ; then          if test ! -r "$TMP.links/$sf" ; then
2686              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
2687                  ignore_f=f                  ignore_f=f
2688                  case $d/$sf in                  case $d/$sf in
# Line 2692  for d in $alldirs ; do Line 2707  for d in $alldirs ; do
2707                          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
2708                              ignore_f=t                              ignore_f=t
2709                          else                          else
2710                              touch .links.tmp/$sf                              touch $TMP.links/$sf
2711                              deplist="$deplist $sf"                              deplist="$deplist $sf"
2712                          fi                          fi
2713                          ;;                          ;;
# Line 2701  for d in $alldirs ; do Line 2716  for d in $alldirs ; do
2716                      extn=`echo $sf | $AWK -F. '{print $NF}'`                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2717                      case $extn in                      case $extn in
2718                        F)                        F)
2719                          echo    " \\"  >> F77srclist.tmp                          echo    " \\"  >> $TMP.F77srclist
2720                          printf " $sf" >> F77srclist.tmp                          printf " $sf" >> $TMP.F77srclist
2721                          if test "x$OPENAD" != x ; then                          if test "x$OPENAD" = x ; then
2722                                basename=${sf%%.F}
2723                                isAD=`egrep ^$basename.f'[  ]*' $TMP.adSrcFiles`
2724                                if test -z "$isAD" ; then
2725                                    echo    " \\"  >> $TMP.nonADF77srclist
2726                                    printf " $sf" >> $TMP.nonADF77srclist
2727                                fi
2728                            else #- OpenAD case:
2729                              basename=${sf%%.F}                              basename=${sf%%.F}
2730                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`                              isAD=`egrep ^$basename.f'[  ]*' $TMP.adSrcFiles`
2731                              if test -z "$isAD" ; then                              if test -z "$isAD" ; then
2732                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`
2733                                  if test -z "$toBeIgnored" ; then                                  if test -z "$toBeIgnored" ; then
2734                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> $TMP.nonADF77srclist
2735                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> $TMP.nonADF77srclist
2736                                  else                                  else
2737                                      echo "    not to be compiled   :  $sf"                                      echo "    not to be compiled   :  $sf"
2738                                  fi                                  fi
# Line 2725  for d in $alldirs ; do Line 2747  for d in $alldirs ; do
2747                                      echo "    original to be kept  :  $sf"                                      echo "    original to be kept  :  $sf"
2748                                  fi                                  fi
2749                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then                                  if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2750                                      echo    " \\"  >> nonADF77srclist.tmp                                      echo    " \\"  >> $TMP.nonADF77srclist
2751                                      printf " $sf" >> nonADF77srclist.tmp                                      printf " $sf" >> $TMP.nonADF77srclist
2752                                  fi                                  fi
2753                              fi                              fi
2754                          fi                          fi
2755                          ;;                          ;;
2756                      F90)                      F90)
2757                          echo    " \\"  >> F90srclist.tmp                          echo    " \\"  >> $TMP.F90srclist
2758                          printf " $sf" >> F90srclist.tmp                          printf " $sf" >> $TMP.F90srclist
2759                          ;;                          ;;
2760                      c)                      c)
2761                          echo    " \\"  >> csrclist.tmp                          echo    " \\"  >> $TMP.csrclist
2762                          printf " $sf" >> csrclist.tmp                          printf " $sf" >> $TMP.csrclist
2763                          ;;                          ;;
2764                      h)                      h)
2765                          echo    " \\"  >> hsrclist.tmp                          echo    " \\"  >> $TMP.hsrclist
2766                          printf " $sf" >> hsrclist.tmp                          printf " $sf" >> $TMP.hsrclist
2767                          ;;                          ;;
2768                      flow)                      flow)
2769                          echo    " \\"  >> ad_flow_files.tmp                          echo    " \\"  >> $TMP.ad_flow_files
2770                          printf " $sf" >> ad_flow_files.tmp                          printf " $sf" >> $TMP.ad_flow_files
2771                          ;;                          ;;
2772                     esac                     esac
2773                  fi                  fi
# Line 2754  for d in $alldirs ; do Line 2776  for d in $alldirs ; do
2776      done      done
2777      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2778        if test "$d" != "." ; then        if test "$d" != "." ; then
2779          echo "" >> srclinks.tmp          echo "" >> $TMP.srclinks
2780          echo "#  These files are linked from $d" >> srclinks.tmp          echo "#  These files are linked from $d" >> $TMP.srclinks
2781          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> $TMP.srclinks
2782  # We need to make sure that the link isn't already there.  # We need to make sure that the link isn't already there.
2783  # 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"
2784  # 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.
2785          printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp          printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> $TMP.srclinks
2786        fi        fi
2787      fi      fi
2788  done  done
2789  rm -rf .links.tmp  rm -rf $TMP.links
2790  echo "" >> F77srclist.tmp  echo "" >> $TMP.F77srclist
2791  echo "" >> nonADF77srclist.tmp  echo "" >> $TMP.nonADF77srclist
2792  echo "" >> csrclist.tmp  echo "" >> $TMP.csrclist
2793  echo "" >> F90srclist.tmp  echo "" >> $TMP.F90srclist
2794  echo "" >> hsrclist.tmp  echo "" >> $TMP.hsrclist
2795  echo "" >> ad_flow_files.tmp  echo "" >> $TMP.ad_flow_files
2796    
2797  CMDLINE=$0  CMDLINE=$0
2798  for xx in "$@" ; do nw=`echo $xx | wc -w`  for xx in "$@" ; do nw=`echo $xx | wc -w`
# Line 2892  MAKE = ${MAKE} Line 2914  MAKE = ${MAKE}
2914    
2915  EOF  EOF
2916    
2917  cat F77srclist.tmp      >> $MAKEFILE  cat $TMP.F77srclist      >> $MAKEFILE
2918  cat nonADF77srclist.tmp >> $MAKEFILE  cat $TMP.nonADF77srclist >> $MAKEFILE
2919  cat csrclist.tmp        >> $MAKEFILE  cat $TMP.csrclist        >> $MAKEFILE
2920  cat F90srclist.tmp      >> $MAKEFILE  cat $TMP.F90srclist      >> $MAKEFILE
2921  cat hsrclist.tmp        >> $MAKEFILE  cat $TMP.hsrclist        >> $MAKEFILE
2922  cat ad_flow_files.tmp   >> $MAKEFILE  cat $TMP.ad_flow_files   >> $MAKEFILE
2923    
2924  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
2925    
2926  echo >> $MAKEFILE  echo >> $MAKEFILE
2927    
# Line 2949  links: \$(F77_SRC_FILES) \$(C_SRC_FILES) Line 2971  links: \$(F77_SRC_FILES) \$(C_SRC_FILES)
2971    
2972  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
2973    
 output.txt: \$(EXECUTABLE)  
         @printf 'running ... '  
         @\$(EXECUTABLE) > \$@  
   
2974  # remove most of the files that "make" generates  # remove most of the files that "make" generates
2975  clean:  clean:
2976          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
# Line 3096  done Line 3114  done
3114  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
3115  echo >> $MAKEFILE  echo >> $MAKEFILE
3116  printf "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
3117  AD_FILES=`cat adSrcFiles.tmp`  AD_FILES=`cat $TMP.adSrcFiles`
3118  for i in $AD_FILES ; do  for i in $AD_FILES ; do
3119      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
3120      printf " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
3121  done  done
3122  echo >> $MAKEFILE  echo >> $MAKEFILE
3123  rm -f adSrcFiles.tmp  rm -f $TMP.adSrcFiles
3124    
3125  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3126    
# Line 3127  ad_input_code.$FS: \$(AD_FILES) \$(AD_FL Line 3145  ad_input_code.$FS: \$(AD_FILES) \$(AD_FL
3145          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
3146    
3147  ad_taf_output.$FS: ad_input_code.$FS  ad_taf_output.$FS: ad_input_code.$FS
3148            @-rm -f ad_input_code_ad.$FS ; echo ''
3149          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
3150          ls -l ad_input_code_ad.$FS          ls -l ad_input_code_ad.$FS
3151          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS          cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS
# Line 3136  adtafonly: Line 3155  adtafonly:
3155          ls -l ad_input_code_ad.$FS          ls -l ad_input_code_ad.$FS
3156          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
3157    
3158  \$(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)
3159          \$(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)
3160    
3161  ad_tamc_output.$FS: ad_input_code.$FS  ad_tamc_output.$FS: ad_input_code.$FS
3162          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS
# Line 3152  adonlyfwd: Line 3171  adonlyfwd:
3171  adtrick:  adtrick:
3172          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff          patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff
3173    
3174  adobj: ad_taf_output.o \$(OBJFILES)  adobj: ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o)
3175    
3176  # ... FTL ...  # ... FTL ...
3177  ftlall: ftl_exe_target  ftlall: ftl_exe_target
# Line 3175  ftl_input_code.$FS: \$(AD_FILES) Line 3194  ftl_input_code.$FS: \$(AD_FILES)
3194          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
3195    
3196  ftl_taf_output.$FS: ftl_input_code.$FS  ftl_taf_output.$FS: ftl_input_code.$FS
3197            @-rm -f ftl_input_code_tl.$FS ; echo ''
3198          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3199          ls -l ftl_input_code_ftl.$FS          ls -l ftl_input_code_tl.$FS
3200          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
3201    
3202  ftltafonly:  ftltafonly:
3203          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
3204          ls -l ftl_input_code_ftl.$FS          ls -l ftl_input_code_tl.$FS
3205          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
3206    
3207  \$(EXE_FTL): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) ftl_taf_output.o \$(OBJFILES) \$(EMBEDDED_FILES)  \$(EXE_FTL): \$(SPECIAL_FILES) \$(H_SRC_FILES) ftl_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES)
3208          \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)          \$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) ftl_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS)
3209    
3210  ftl_tamc_output.$FS: ftl_input_code.$FS  ftl_tamc_output.$FS: ftl_input_code.$FS
3211          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS
# Line 3229  if test "x$OPENAD" != x ; then Line 3249  if test "x$OPENAD" != x ; then
3249  # ============ begin OpenAD specific section ==============  # ============ begin OpenAD specific section ==============
3250    
3251  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3252    # ... OpenAD ...
3253    
3254  # all the source files linked from the various locations:  # all the source files linked from the various locations:
3255  ALL_LINKED_FILES= \  ALL_LINKED_FILES= \
# Line 3268  for i in `cat ${OAD_CB2M_FILES}` ; do Line 3289  for i in `cat ${OAD_CB2M_FILES}` ; do
3289    echo    " \\" >> $MAKEFILE    echo    " \\" >> $MAKEFILE
3290    printf " ${i}_mod.f$FS90" >> $MAKEFILE    printf " ${i}_mod.f$FS90" >> $MAKEFILE
3291  done  done
3292  AD_FILES=`cat adSrcFiles.tmp`  AD_FILES=`cat $TMP.adSrcFiles`
3293  for i in $AD_FILES ; do  for i in $AD_FILES ; do
3294    basename=${i%%.f}    basename=${i%%.f}
3295    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 3299  for i in $AD_FILES ; do
3299    fi    fi
3300  done  done
3301  echo >> $MAKEFILE  echo >> $MAKEFILE
3302  rm -f adSrcFiles.tmp  rm -f $TMP.adSrcFiles
3303    
3304  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
3305    
3306  adAll: \$(EXE_AD)  adAll: ad_exe_target
3307  .PHONY: adAll  .PHONY: adAll
3308    
3309    ad_exe_target:
3310            @echo Update AD_CONFIG.h and make \$(EXE_AD)
3311            @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template
3312            @cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
3313            @-rm -f ad_config.template
3314            \$(MAKE) -f \$(MAKEFILE) \$(EXE_AD)
3315    
3316  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))
3317    
3318  .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 3342  AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(N Line 3370  AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(N
3370  small_f: \$(CB2M_F90_PP_SRC_FILES)  small_f: \$(CB2M_F90_PP_SRC_FILES)
3371  .PHONY: small_f  .PHONY: small_f
3372    
 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) > \$@  
   
3373  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3374          cat \$^ > \$@          cat \$^ > \$@
3375    
# Line 3384  ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS Line 3405  ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS
3405  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
3406          \${OADTOOLS}/insertTemplateDir.bash \$< \$@          \${OADTOOLS}/insertTemplateDir.bash \$< \$@
3407    
3408  PPEXTRAS=\$(wildcard \${OADTOOLS}/ad_template.*.F) \${OADTOOLS}/ad_inline.F  PPEXTRAS=\$(notdir \$(wildcard \${OADTOOLS}/ad_template.*.F)) ad_inline.F
3409  # postprocess F'  # postprocess F'
3410  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
3411          \${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 \$<
3412          # 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
3413          touch \$@          touch \$@
3414  # 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 3419  OAD_intrinsics_oad.f \$(CB2M_AD_FILES:.f
3419          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .          \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3420    
3421  # link the support files:  # link the support files:
3422  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES) \$(PPEXTRAS):
3423          \$(LN) \${OADTOOLS}/\$@ .          \$(LN) \${OADTOOLS}/\$@ .
3424    
3425  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
3426    
3427  # ============ end OpenAD specific section ==============  # ============ end OpenAD specific section ==============
3428    
# Line 3437  for i in $NOOPTFILES ; do Line 3458  for i in $NOOPTFILES ; do
3458  done  done
3459    
3460  echo "  Add rules for links"  echo "  Add rules for links"
3461  cat srclinks.tmp >> $MAKEFILE  cat $TMP.srclinks >> $MAKEFILE
3462  rm -f srclinks.tmp  rm -f $TMP.srclinks
3463    
3464  echo "  Adding makedepend marker"  echo "  Adding makedepend marker"
3465  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.266

  ViewVC Help
Powered by ViewVC 1.1.22