/[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.157 by heimbach, Sat Nov 4 21:01:37 2006 UTC revision 1.187 by jmc, Wed Apr 15 22:21:03 2009 UTC
# Line 325  find_possible_configs()  { Line 325  find_possible_configs()  {
325    
326      #================================================================      #================================================================
327      #  look for possible C compilers      #  look for possible C compilers
328      tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc"      tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc icc"
329      p_CC=      p_CC=
330      for c in $tmp ; do      for c in $tmp ; do
331          rm -f ./genmake_hello.c  ./genmake_hello          rm -f ./genmake_hello.c  ./genmake_hello
# Line 364  EOF Line 364  EOF
364    
365      #================================================================      #================================================================
366      #  look for possible FORTRAN compilers      #  look for possible FORTRAN compilers
367      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 gfortran"      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc ifort f90 f95 mpif77 mpf77 mpxlf95 gfortran g95"
368      p_FC=      p_FC=
369      for c in $tmp ; do      for c in $tmp ; do
370          rm -f ./hello.f ./hello          rm -f ./hello.f ./hello
# Line 601  Usage: "$0" [OPTIONS] Line 601  Usage: "$0" [OPTIONS]
601    
602      -gsl | --gsl      -gsl | --gsl
603            Use GSL to control floating point rounding and precision            Use GSL to control floating point rounding and precision
604        -devel | --devel
605              Add additional warning and debugging flags for development
606    
607      -mpi | --mpi      -mpi | --mpi
608            Include MPI header files and link to MPI libraries            Include MPI header files and link to MPI libraries
# Line 609  Usage: "$0" [OPTIONS] Line 611  Usage: "$0" [OPTIONS]
611            set to PATH. i.e. Include files from \$PATH/include, link to libraries            set to PATH. i.e. Include files from \$PATH/include, link to libraries
612            from \$PATH/lib and use binaries from \$PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
613    
614        -omp | --omp
615              Activate OpenMP code + use Compiler option OMPFLAG
616        -omp=OMPFLAG | --omp=OMPFLAG
617              Activate OpenMP code + use Compiler option OMPFLAG
618    
619      -es | --es | -embed-source | --embed-source      -es | --es | -embed-source | --embed-source
620            Embed a tarball containing the full source code            Embed a tarball containing the full source code
621            (including the Makefile, etc.) used to build the            (including the Makefile, etc.) used to build the
# Line 744  void FC_NAMEMANGLE(cloc) ( double *curti Line 751  void FC_NAMEMANGLE(cloc) ( double *curti
751   *curtim = *curtim/1.E6;   *curtim = *curtim/1.E6;
752  }  }
753  EOF  EOF
754      make genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
755        echo $COMM >> genmake_warnings
756        $COMM >> genmake_warnings 2>&1
757      RET_C=$?      RET_C=$?
758      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
759        program hello        program hello
# Line 754  EOF Line 763  EOF
763        print *," HELLO WORLD", wtime        print *," HELLO WORLD", wtime
764        end        end
765  EOF  EOF
766      $FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o"
767        echo $COMM >> genmake_warnings
768        $COMM >> genmake_warnings 2>&1
769      RET_F=$?      RET_F=$?
770      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1      test -x ./genmake_tc  &&  ./genmake_tc >> genmake_warnings 2>&1
771      RETVAL=$?      RETVAL=$?
# Line 801  void FC_NAMEMANGLE(sigreg) (int * aip) Line 812  void FC_NAMEMANGLE(sigreg) (int * aip)
812      return;      return;
813  }  }
814  EOF  EOF
815      make genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
816        echo $COMM >> genmake_warnings
817        $COMM >> genmake_warnings 2>&1
818      RET_C=$?      RET_C=$?
819      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
820        program hello        program hello
# Line 849  void FC_NAMEMANGLE(setrlstk) () Line 862  void FC_NAMEMANGLE(setrlstk) ()
862      return;      return;
863  }  }
864  EOF  EOF
865      make genmake_tc_1.o >> genmake_warnings 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
866        echo $COMM >> genmake_warnings
867        $COMM >> genmake_warnings 2>&1
868      RET_C=$?      RET_C=$?
869      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
870        program hello        program hello
# Line 893  void FC_NAMEMANGLE(tfsize) ( int *nbyte Line 908  void FC_NAMEMANGLE(tfsize) ( int *nbyte
908          *nbyte = -1;          *nbyte = -1;
909  }  }
910  EOF  EOF
911      make genmake_tc_1.o >> genmake_tc.log 2>&1      COMM="$CC $CFLAGS -c genmake_tc_1.c"
912        echo $COMM >> genmake_warnings
913        $COMM >> genmake_tc.log 2>&1
914      RET_C=$?      RET_C=$?
915      cat <<EOF > genmake_tc_2.$FS      cat <<EOF > genmake_tc_2.$FS
916        program hello        program hello
# Line 983  EOF Line 1000  EOF
1000          if test "x$RET_COMPILE" = x0 ; then          if test "x$RET_COMPILE" = x0 ; then
1001              LIBS="$LIBS -lnetcdf"              LIBS="$LIBS -lnetcdf"
1002              HAVE_NETCDF=t              HAVE_NETCDF=t
1003            else
1004            # try again with "-lnetcdff" added to the libs
1005                echo "try again with added '-lnetcdff -lnetcdf'" > genmake_tnc.log
1006                echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log
1007                echo " &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log
1008                echo " &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log
1009                cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null  \
1010                    &&  $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1  \
1011                    &&  $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdff -lnetcdf >> genmake_tnc.log 2>&1
1012                RET_COMPILE=$?
1013                cat genmake_tnc.log >> genmake_warnings
1014                if test "x$RET_COMPILE" = x0 ; then
1015                    LIBS="$LIBS -lnetcdff -lnetcdf"
1016                    HAVE_NETCDF=t
1017                fi
1018          fi          fi
1019      fi      fi
1020      rm -f genmake_tnc*      rm -f genmake_tnc*
# Line 1018  OPTFILE= Line 1050  OPTFILE=
1050  INCLUDES="-I. $INCLUDES"  INCLUDES="-I. $INCLUDES"
1051  FFLAGS=  FFLAGS=
1052  FOPTIM=  FOPTIM=
1053    FEXTRAFLAGS=
1054    USE_EXTENDED_SRC=
1055    EXTENDED_SRC_FLAG=
1056  CFLAGS=  CFLAGS=
1057  KFLAGS1=  KFLAGS1=
1058  KFLAGS2=  KFLAGS2=
# Line 1028  NOOPTFILES= Line 1063  NOOPTFILES=
1063  NOOPTFLAGS=  NOOPTFLAGS=
1064  MPI=  MPI=
1065  MPIPATH=  MPIPATH=
1066    OMP=
1067    OMPFLAG=
1068  TS=  TS=
1069  PAPIS=  PAPIS=
1070  PCLS=  PCLS=
# Line 1036  PAPI= Line 1073  PAPI=
1073  PCL=  PCL=
1074  HPMT=  HPMT=
1075  GSL=  GSL=
1076    DEVEL=
1077  HAVE_TEST_L=  HAVE_TEST_L=
1078    
1079  # DEFINES checked by test compilation or command-line  # DEFINES checked by test compilation or command-line
# Line 1094  TAMC_EXTRA= Line 1132  TAMC_EXTRA=
1132    
1133  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1134  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
1135  gm_s2="FC CPP IEEE TS PAPIS PCLS PAPI PCL HPMT GSL MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI OMP DUMPSTATE STANDARDDIRS"
1136    
1137  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1138  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM "  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM FEXTRAFLAGS"
1139  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
1140  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE"
1141  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
# Line 1124  EOF Line 1162  EOF
1162    
1163  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
1164  gm_local="genmake_local"  gm_local="genmake_local"
 for i in . $MODS ; do  
     if test -r $i/$gm_local ; then  
         . $i/$gm_local  
         break  
     fi  
 done  
1165  printf "  getting local config information:  "  printf "  getting local config information:  "
1166  if test -f $gm_local ; then  if test -f $gm_local ; then
1167      echo "using $gm_local"      echo "using $gm_local"
# Line 1292  for ac_option in "$@" ; do Line 1324  for ac_option in "$@" ; do
1324          -gsl | --gsl)          -gsl | --gsl)
1325              GSL=true ;;              GSL=true ;;
1326    
1327            -devel | --devel)
1328                DEVEL=true ;;
1329    
1330          -mpi | --mpi)          -mpi | --mpi)
1331              MPI=true ;;              MPI=true ;;
1332          -mpi=* | --mpi=*)          -mpi=* | --mpi=*)
1333              MPIPATH=$ac_optarg              MPIPATH=$ac_optarg
1334              MPI=true ;;              MPI=true ;;
1335                    
1336  #       -jam | --jam)          -omp | --omp)
1337  #           JAM=1 ;;              OMP=true ;;
1338  #       -nojam | --nojam)          -omp=* | --omp=*)
1339  #           JAM=0 ;;              OMPFLAG=$ac_optarg
1340                OMP=true ;;
1341                    
1342          -ds | --ds)          -ds | --ds)
1343              DUMPSTATE=t ;;              DUMPSTATE=t ;;
# Line 1340  done Line 1376  done
1376  if test -f ./.genmakerc ; then  if test -f ./.genmakerc ; then
1377      echo      echo
1378      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""      echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
1379      echo "  file.  This file format is no longer supported.  Please see:"      echo "  file.  This file format is no longer supported.  For directions on"
1380      echo      echo "  how to setup and use the new \"genmake2\" script, please see:"
1381      echo "    http://mitgcm.org/devel_HOWTO/"      echo "    http://mitgcm.org/devel_HOWTO/"
1382      echo      echo "  and send an email to MITgcm-support@mitgcm.org if you need help."
1383      echo "  for directions on how to setup and use the new \"genmake2\" input"      echo "WARNING: ignore \"./.genmakerc\" and continue."
     echo "  files and send an email to MITgcm-support@mitgcm.org if you want help."  
1384      echo      echo
1385  fi  fi
1386    
# Line 1377  if test ! -d ${ROOTDIR} ; then Line 1412  if test ! -d ${ROOTDIR} ; then
1412  fi  fi
1413    
1414  #  Find the MITgcm ${THISVER}  #  Find the MITgcm ${THISVER}
1415  if test -f "${ROOTDIR}/doc/tag-index" ; then  version_file="${ROOTDIR}/doc/tag-index"
1416      THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`  if test -f $version_file ; then
1417        THISVER=`grep '^checkpoint' $version_file | head -1`
1418    #-  remove ./BUILD_INFO.h file if older than version_file
1419        if test -f ./BUILD_INFO.h -a ./BUILD_INFO.h -ot $version_file ; then
1420            echo "  remove ./BUILD_INFO.h (older than ${version_file})"
1421            rm -f ./BUILD_INFO.h
1422        fi
1423  fi  fi
1424    
1425  if test "x$MAKEFILE" = x ; then  if test "x$MAKEFILE" = x ; then
# Line 1534  if test ! "x$MPI" = x ; then Line 1575  if test ! "x$MPI" = x ; then
1575        echo "  Turning on MPI cpp macros"        echo "  Turning on MPI cpp macros"
1576        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1577  fi  fi
1578    if test ! "x$OMP" = x ; then
1579          echo "  Add OMPFLAG and turn on OpenMP cpp macros"
1580          FFLAGS="$FFLAGS $OMPFLAG"
1581          F90FLAGS="$F90FLAGS $OMPFLAG"
1582          DEFINES="$DEFINES -DUSE_OMP_THREADING"
1583    fi
1584    
1585  if test ! "x$TS" = x ; then  if test ! "x$TS" = x ; then
1586        echo "  Turning on timing per timestep"        echo "  Turning on timing per timestep"
# Line 1542  if test ! "x$TS" = x ; then Line 1589  if test ! "x$TS" = x ; then
1589        else        else
1590              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"              DEFINES="$DEFINES -DTIME_PER_TIMESTEP"
1591        fi        fi
1592          PACKAGES="$PACKAGES showflops"
1593  fi  fi
1594  if test ! "x$PAPIS" = x ; then  if test ! "x$PAPIS" = x ; then
1595        echo "  Turning on PAPI flop summary per timestep"        echo "  Turning on PAPI flop summary per timestep"
# Line 1553  if test ! "x$PAPIS" = x ; then Line 1601  if test ! "x$PAPIS" = x ; then
1601        fi        fi
1602        INCLUDES="$INCLUDES $PAPIINC"        INCLUDES="$INCLUDES $PAPIINC"
1603        LIBS="$LIBS $PAPILIB"        LIBS="$LIBS $PAPILIB"
1604          PACKAGES="$PACKAGES showflops"
1605  fi  fi
1606  if test ! "x$PCLS" = x ; then  if test ! "x$PCLS" = x ; then
1607        echo "  Turning on PCL counter summary per timestep"        echo "  Turning on PCL counter summary per timestep"
# Line 1564  if test ! "x$PCLS" = x ; then Line 1613  if test ! "x$PCLS" = x ; then
1613        fi        fi
1614        INCLUDES="$INCLUDES $PCLINC"        INCLUDES="$INCLUDES $PCLINC"
1615        LIBS="$LIBS $PCLLIB"        LIBS="$LIBS $PCLLIB"
1616          PACKAGES="$PACKAGES showflops"
1617  fi  fi
1618  if test ! "x$PAPI" = x ; then  if test ! "x$PAPI" = x ; then
1619        if test ! "x$PAPIS" = x ; then        if test ! "x$PAPIS" = x ; then
# Line 1612  if test ! "x$GSL" = x ; then Line 1662  if test ! "x$GSL" = x ; then
1662        INCLUDES="$INCLUDES $GSLINC"        INCLUDES="$INCLUDES $GSLINC"
1663        LIBS="$LIBS $GSLLIB"        LIBS="$LIBS $GSLLIB"
1664  fi  fi
1665    #- if USE_EXTENDED_SRC is set, add EXTENDED_SRC_FLAG to FFLAGS :
1666    if test ! "x$USE_EXTENDED_SRC" = x ; then
1667          FFLAGS="$FFLAGS $EXTENDED_SRC_FLAG"
1668          F90FIXEDFORMAT="$F90FIXEDFORMAT $EXTENDED_SRC_FLAG"
1669    fi
1670    
1671  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1672  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
# Line 1734  fi Line 1789  fi
1789    
1790    
1791  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1792  printf "  Adding MODS directories:  "  printf "  Adding MODS directories: "
1793    MPI_LNKF=
1794  for d in $MODS ; do  for d in $MODS ; do
1795      if test ! -d $d ; then      if test ! -d $d ; then
1796          echo          echo
1797          echo "Error: MODS directory \"$d\" not found!"          echo "Error: MODS directory \"$d\" not found!"
1798          exit 1          exit 1
1799      else      else
1800          printf " $d"          printf "$d "
1801          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1802          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
1803            #-------------------------------------------------------
1804            # Put special links so that MPI specific files are used
1805            MPI_FILES=`(cd $d ; find . -name "*_mpi" -print)`
1806            for i in $MPI_FILES ; do
1807              ii=`echo $i | sed 's:^\./::'`
1808              name=`echo $ii | sed 's:_mpi::' `
1809              if test "x$MPI" = x ; then
1810              # NO: We undo an _mpi symbolically linked file
1811                if test -L $name ; then
1812                  cmp $name "$d/$ii" > /dev/null 2>&1
1813                  RETVAL=$?
1814                  if test "x$RETVAL" = x0 ; then
1815                    printf "Un-linking $name ; "
1816                    rm -f $name
1817                  fi
1818                fi
1819              else
1820              # YES: We symbolically link this file (with conditions if already there)
1821                if test -L $name ; then
1822                  cmp $d/$ii $name > /dev/null 2>&1
1823                  RETVAL=$?
1824                  yy=0 ;
1825                  for xx in $MPI_LNKF ; do if test $xx = $name ; then yy=1 ; fi ; done
1826                  if test "x$RETVAL" != x0 -a $yy = 0 ; then
1827                  # remove sym-link if different and has not just been linked
1828                    printf "Un-link + "
1829                    rm -f $name
1830                  fi
1831                  if test "x$RETVAL" = x0 ; then
1832                  # if identical, keep sym-link and keep record of it
1833                    MPI_LNKF="$MPI_LNKF $name"
1834                  fi
1835                fi
1836                if ! test -f $name ; then
1837                  # make sym-link and keep record of it
1838                    printf "Linking $ii to $name ; "
1839                    ln -sf $d/$ii $name
1840                    MPI_LNKF="$MPI_LNKF $name"
1841                fi
1842              fi
1843            done
1844            #-------------------------------------------------------
1845      fi      fi
1846  done  done
1847  echo  echo
1848    #echo "MPI_LNKF='$MPI_LNKF'"
1849    
1850  if test "x${PLATFORM}" = x ; then  if test "x${PLATFORM}" = x ; then
1851      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
# Line 1943  done Line 2042  done
2042  rm -f ./.tmp_pack  rm -f ./.tmp_pack
2043  echo "    packages are:  $PACKAGES"  echo "    packages are:  $PACKAGES"
2044    
2045  #  Check availability of NetCDF and then either build the MNC template  #  Check for package MNC: if NetCDF is available, then build the MNC
2046  #  files or delete mnc from the list of available packages.  #  template files ; otherwise, delete mnc from the list of packages.
2047  echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1  echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1
2048  RETVAL=$?  RETVAL=$?
2049  if test "x$RETVAL" = x0 ; then  if test "x$RETVAL" = x0 ; then
# Line 1978  EOF Line 2077  EOF
2077      fi      fi
2078  fi  fi
2079    
2080    #  Check for package PROFILES: if NetCDF is not available,
2081    #  then delete profiles from the list of available packages.
2082    echo $PACKAGES | grep ' profiles ' > /dev/null 2>&1
2083    RETVAL=$?
2084    if test "x$RETVAL" = x0 ; then
2085        if test "x$HAVE_NETCDF" != xt ; then
2086            cat <<EOF
2087    
2088    *********************************************************************
2089    WARNING: the "profiles" package was enabled but tests failed to
2090      compile NetCDF applications.  Please check that:
2091    
2092      1) NetCDF is correctly installed for this compiler and
2093      2) the LIBS variable (within the "optfile") specifies the correct
2094           NetCDF library to link against.
2095    
2096      Due to this failure, the "profiles" package is now DISABLED.
2097    *********************************************************************
2098    
2099    EOF
2100            PACKAGES=`echo $PACKAGES | sed -e 's/profiles//g'`
2101            DISABLE="$DISABLE profiles"
2102        fi
2103    fi
2104    
2105  echo "  applying package dependency rules"  echo "  applying package dependency rules"
2106  ck=  ck=
2107  while test "x$ck" != xtt ; do  while test "x$ck" != xtt ; do
2108      i=0      i=0
2109      # rtot=${#PNAME[@]}      # rtot=${#PNAME[@]}
2110      rtot=$nname      rtot=$nname
2111      while test $i -lt $rtot ; do      while test $i -le $rtot ; do
2112    
2113          #  Is $pname in the current $PACKAGES list?          #  Is $pname in the current $PACKAGES list?
2114          #  pname=${PNAME[$i]}          #  pname=${PNAME[$i]}
# Line 2018  while test "x$ck" != xtt ; do Line 2142  while test "x$ck" != xtt ; do
2142    
2143          #  Do we need to add $dname according to the dependency rules?          #  Do we need to add $dname according to the dependency rules?
2144          if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then          if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then
2145                #echo "   " $pname ": need to add :" $dname
2146              in_dis="f"              in_dis="f"
2147              for dis in $DISABLE ; do              for dis in $DISABLE ; do
2148                  if test "x$dis" = "x$dname" ; then                  if test "x$dis" = "x$dname" ; then
# Line 2162  fi Line 2287  fi
2287    
2288  #  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
2289  #  compiler.  #  compiler.
2290  if test -f ./ad_files ; then  if test -f ./adSrcFiles.tmp ; then
2291      rm -f ./ad_files      rm -f ./adSrcFiles.tmp
2292  fi  fi
2293  echo "  Creating the list of files for the adjoint compiler."  echo "  Creating the list of files for the adjoint compiler."
2294  for i in $SOURCEDIRS ; do  for i in $SOURCEDIRS ; do
2295      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2296      for j in $list_files ; do      for j in $list_files ; do
2297          cat $i/$j >> ad_files          cat $i/$j >> adSrcFiles.tmp
2298      done      done
2299  done  done
2300  if test ! "x"$FS = "x.f" ; then  if test ! "x"$FS = "x.f" ; then
2301      cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f      cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f
2302      mv -f ad_files_f ad_files      mv -f adSrcFiles.tmp_f adSrcFiles.tmp
2303  fi  fi
2304    
2305  echo  echo
# Line 2232  if test ! -r ".links.tmp/foo" ; then Line 2357  if test ! -r ".links.tmp/foo" ; then
2357      exit 1      exit 1
2358  fi  fi
2359  rm -f .links.tmp/foo  rm -f .links.tmp/foo
2360    
2361    if test "x$OPENAD" != x ; then
2362        OAD_DONT_COMPILE="/dev/null"
2363        OAD_DONT_TRANSFORM="/dev/null"
2364        OAD_KEEP_ORIGINAL="/dev/null"
2365        OAD_CB2M_FILES="/dev/null"
2366        echo "  looking for dontCompile file:  "
2367        for i in "." $MODS ; do
2368            if test -r $i"/dontCompile" ; then
2369                OAD_DONT_COMPILE=$i"/dontCompile"
2370                echo "     found $OAD_DONT_COMPILE"
2371                break
2372            fi
2373        done
2374        echo "  looking for dontTransform file:  "
2375        for i in "." $MODS ; do
2376            if test -r $i"/dontTransform" ; then
2377                OAD_DONT_TRANSFORM=$i"/dontTransform"
2378                echo "     found $OAD_DONT_TRANSFORM"
2379                break
2380            fi
2381        done
2382        echo "  looking for keepOriginal file:  "
2383        for i in "." $MODS ; do
2384            if test -r $i"/keepOriginal" ; then
2385                OAD_KEEP_ORIGINAL=$i"/keepOriginal"
2386                echo "     found $OAD_KEEP_ORIGINAL"
2387                break
2388            fi
2389        done
2390        echo "  looking for cb2mFiles:  "
2391        for i in "." $MODS ; do
2392            if test -r $i"/cb2mFiles" ; then
2393                OAD_CB2M_FILES=$i"/cb2mFiles"
2394                echo "     found $OAD_CB2M_FILES"
2395                break
2396            fi
2397        done
2398        echo "   OpenAD exceptions:  "
2399    fi
2400    
2401  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
2402  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
2403  printf 'SRCFILES = '    > srclist.inc  printf 'F77_SRC_FILES = ' > F77srclist.tmp
2404  printf 'CSRCFILES = '   > csrclist.inc  printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp
2405  printf 'F90SRCFILES = ' > f90srclist.inc  printf 'C_SRC_FILES = '   > csrclist.tmp
2406  printf 'HEADERFILES = ' > hlist.inc  printf 'F90_SRC_FILES = ' > F90srclist.tmp
2407  printf 'AD_FLOW_FILES = ' > ad_flow_files.inc  printf 'H_SRC_FILES = '   > hsrclist.tmp
2408    printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp
2409  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2410  for d in $alldirs ; do  for d in $alldirs ; do
2411      deplist=      deplist=
2412      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
2413      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
2414        if test "x$OPENAD" != x ; then
2415            sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2416        fi
2417      for sf in $sfiles ; do      for sf in $sfiles ; do
2418          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
2419              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
# Line 2278  for d in $alldirs ; do Line 2448  for d in $alldirs ; do
2448                  if test "x$ignore_f" = xf ; then                  if test "x$ignore_f" = xf ; then
2449                      extn=`echo $sf | $AWK -F. '{print $NF}'`                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2450                      case $extn in                      case $extn in
2451                          F)                        F)
2452                              echo    " \\"  >> srclist.inc                          echo    " \\"  >> F77srclist.tmp
2453                              printf " $sf" >> srclist.inc                          printf " $sf" >> F77srclist.tmp
2454                              ;;                          if test "x$OPENAD" != x ; then
2455                          F90)                              basename=${sf%%.F}
2456                              echo    " \\"  >> f90srclist.inc                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`
2457                              printf " $sf" >> f90srclist.inc                              if test -z "$isAD" ; then
2458                              ;;                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`
2459                          c)                                  if test -z "$toBeIgnored" ; then
2460                              echo    " \\"  >> csrclist.inc                                      echo    " \\"  >> nonADF77srclist.tmp
2461                              printf " $sf" >> csrclist.inc                                      printf " $sf" >> nonADF77srclist.tmp
2462                              ;;                                  else
2463                          h)                                      echo "    not to be compiled   :  $sf"
2464                              echo    " \\"  >> hlist.inc                                  fi
2465                              printf " $sf" >> hlist.inc                              else # file is initially listed as an AD file we want to exclude it
2466                              ;;                                   # or we want to retain the untransformed version
2467                          flow)                                  notToBeTransformed=`egrep ^$basename'[      ]*' ${OAD_DONT_TRANSFORM}`
2468                              echo    " \\"  >> ad_flow_files.inc                                  untransformedVersionToBeKept=`egrep ^$basename'[      ]*' ${OAD_KEEP_ORIGINAL}`
2469                              printf " $sf" >> ad_flow_files.inc                                  if test -n "$notToBeTransformed"; then
2470                              ;;                                      echo "    not to be transformed:  $sf"
2471                      esac                                  fi
2472                  fi                                  if test -n "$untransformedVersionToBeKept" ; then
2473                                        echo "    original to be kept  :  $sf"
2474                                    fi    
2475                                    if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2476                                        echo    " \\"  >> nonADF77srclist.tmp
2477                                        printf " $sf" >> nonADF77srclist.tmp
2478                                    fi
2479                                fi
2480                            fi
2481                            ;;
2482                        F90)
2483                            echo    " \\"  >> F90srclist.tmp
2484                            printf " $sf" >> F90srclist.tmp
2485                            ;;
2486                        c)
2487                            echo    " \\"  >> csrclist.tmp
2488                            printf " $sf" >> csrclist.tmp
2489                            ;;
2490                        h)
2491                            echo    " \\"  >> hsrclist.tmp
2492                            printf " $sf" >> hsrclist.tmp
2493                            ;;
2494                        flow)
2495                            echo    " \\"  >> ad_flow_files.tmp
2496                            printf " $sf" >> ad_flow_files.tmp
2497                            ;;
2498                       esac
2499                    fi
2500              fi              fi
2501          fi          fi
2502      done      done
2503      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2504          echo "" >> srclinks.tmp        if test "$d" != "." ; then
2505            echo "" >> srclinks.tmp
2506          echo "#  These files are linked from $d" >> srclinks.tmp          echo "#  These files are linked from $d" >> srclinks.tmp
2507          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> srclinks.tmp
2508          printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp  # We need to make sure that the link isn't already there.
2509    # This may happen when make thinks that a header file has to be "remade"
2510    # because a module it depends on has changed.  In this case we do nothing.
2511            printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp
2512          fi
2513      fi      fi
2514  done  done
2515  rm -rf .links.tmp  rm -rf .links.tmp
2516  echo "" >> srclist.inc  echo "" >> F77srclist.tmp
2517  echo "" >> csrclist.inc  echo "" >> nonADF77srclist.tmp
2518  echo "" >> f90srclist.inc  echo "" >> csrclist.tmp
2519  echo "" >> hlist.inc  echo "" >> F90srclist.tmp
2520  echo "" >> ad_flow_files.inc  echo "" >> hsrclist.tmp
2521    echo "" >> ad_flow_files.tmp
2522    
2523  if test -f $MAKEFILE ; then  if test -f $MAKEFILE ; then
2524      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
# Line 2383  else Line 2586  else
2586      echo "EMBEDDED_FILES = " >>$MAKEFILE      echo "EMBEDDED_FILES = " >>$MAKEFILE
2587  fi  fi
2588    
 #  Note: figure out some way to add Hyades JAM libraries here  
2589  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2590  # Unix ln (link)  # Unix ln (link)
2591  LN = ${LN}  LN = ${LN}
# Line 2410  INCLUDES = ${INCLUDES} Line 2612  INCLUDES = ${INCLUDES}
2612  KFLAGS1 = ${KFLAGS1}  KFLAGS1 = ${KFLAGS1}
2613  KFLAGS2 = ${KFLAGS2}  KFLAGS2 = ${KFLAGS2}
2614  # Optim./debug for FC  # Optim./debug for FC
2615  FFLAGS = ${FFLAGS}  FFLAGS = ${FFLAGS} ${FEXTRAFLAGS}
2616  FOPTIM = ${FOPTIM}  FOPTIM = ${FOPTIM}
2617  # Optim./debug for FC  # Optim./debug for FC
2618  F90FLAGS = ${F90FLAGS}  F90FLAGS = ${F90FLAGS}
2619  F90OPTIM = ${F90OPTIM}  F90OPTIM = ${F90OPTIM}
2620    F90FIXEDFORMAT = ${F90FIXEDFORMAT}
2621  # Flags for CC  # Flags for CC
2622  CFLAGS = ${CFLAGS}  CFLAGS = ${CFLAGS}
2623  # Files that should not be optimized  # Files that should not be optimized
# Line 2427  MAKEFILE=${MAKEFILE} Line 2630  MAKEFILE=${MAKEFILE}
2630    
2631  EOF  EOF
2632    
2633  cat srclist.inc       >> $MAKEFILE  cat F77srclist.tmp      >> $MAKEFILE
2634  cat csrclist.inc      >> $MAKEFILE  cat nonADF77srclist.tmp >> $MAKEFILE
2635  cat f90srclist.inc    >> $MAKEFILE  cat csrclist.tmp        >> $MAKEFILE
2636  cat hlist.inc         >> $MAKEFILE  cat F90srclist.tmp      >> $MAKEFILE
2637  cat ad_flow_files.inc >> $MAKEFILE  cat hsrclist.tmp        >> $MAKEFILE
2638    cat ad_flow_files.tmp   >> $MAKEFILE
2639    
2640    rm -f F77srclist.tmp nonADF77srclist.tmp csrclist.tmp F90srclist.tmp hsrclist.tmp ad_flow_files.tmp
2641    
2642  echo >> $MAKEFILE  echo >> $MAKEFILE
2643  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE  
2644  echo 'F90FILES =  $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE  # add definitions for preprocessed sources
2645  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  # and note that not all systems allow case sensitive extensions
2646    # hence the $FS and $FS90 here.
2647    # for fixed format f90 files we use ff90 or FF90 resp
2648    # but these are not expected to be the original source files
2649    
2650    echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE
2651    echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE
2652    echo 'OBJFILES= $(F77_SRC_FILES:.F=.o) $(C_SRC_FILES:.c=.o) $(F90_SRC_FILES:.F90=.o)' >> $MAKEFILE
2653    echo 'FLOFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE
2654  echo >> $MAKEFILE  echo >> $MAKEFILE
2655  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
2656  echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE  echo '.SUFFIXES: .o .'$FS' .p .F .c .f'$FS90' .'$FS90' .FF90 .F90 .flowdir .flow' >> $MAKEFILE
 rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc  
 rm -f ad_flow_files.inc  
2657    
2658  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2659    
2660  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
2661  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES) \$(EMBEDDED_FILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(EMBEDDED_FILES)
2662          @echo Creating \$@ ...          @echo Creating \$@ ...
2663          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2664  depend:  depend:
2665          @make links          @make links
2666          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
2667          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2668          -rm -f makedepend.out          -rm -f makedepend.out
2669    
# Line 2458  lib: libmitgcmuv.a Line 2671  lib: libmitgcmuv.a
2671    
2672  libmitgcmuv.a: \$(OBJFILES)  libmitgcmuv.a: \$(OBJFILES)
2673          ar rcv libmitgcmuv.a \$(OBJFILES)          ar rcv libmitgcmuv.a \$(OBJFILES)
2674            ar d   libmitgcmuv.a main.o
2675    
2676  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  links: \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(SPECIAL_FILES)
2677    
2678  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
2679    
2680  output.txt: \$(EXECUTABLE)  output.txt: \$(EXECUTABLE)
2681          @printf 'running ... '          @printf 'running ... '
# Line 2470  output.txt: \$(EXECUTABLE) Line 2684  output.txt: \$(EXECUTABLE)
2684  clean:  clean:
2685          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2686          -rm -rf *.o          -rm -rf *.o
2687          -rm -rf *.$FS          -rm -rf *.$FS *.flowdir
2688            -rm -rf *.f$FS90 *_mod.h *_mod.F90 *.FF90 *.mod-whirl ad_input*
2689            -rm -rf temp.sed
2690  Clean:  Clean:
2691          @make clean          @make clean
2692          @make cleanlinks          @make cleanlinks
2693          -rm -f \$(SPECIAL_FILES)          -rm -f \$(SPECIAL_FILES)
2694          -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak          -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log f90mkdepend.log *.bak
2695            -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log
2696  CLEAN:  CLEAN:
2697          @make Clean          @make Clean
2698          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
2699          -find \$(EXEDIR) -name "*.data" -exec rm {} \;          -find \$(EXEDIR) -name "*.data" -exec rm {} \;
2700          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
2701          -rm -f \$(EXECUTABLE) \$(EXE_AD) *.txt STD* *diagnostics.log datetime          -rm -f \$(EXECUTABLE) \$(EXE_AD) *.txt STD* *diagnostics.log datetime
2702            -rm -f *_MIT_CE_000.opt0000 costfunction*0000
2703          -rm -rf mnc_test_*          -rm -rf mnc_test_*
2704    
2705  #eh3 Makefile: makefile  #eh3 Makefile: makefile
# Line 2490  makefile: Line 2708  makefile:
2708  cleanlinks:  cleanlinks:
2709          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2710    
2711  # Special targets (SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are created by make
2712  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2713          @echo Creating \$@ ...          @echo Creating \$@ ...
2714          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@
# Line 2515  if test "x$EMBED_SRC" = xt ; then Line 2733  if test "x$EMBED_SRC" = xt ; then
2733    
2734  decode_files.o : EMBEDDED_FILES.h  decode_files.o : EMBEDDED_FILES.h
2735    
2736  ##  \$(F77FILES)  ##  \$(F77_PP_SRC_FILES)
2737  all_fF.tar.gz : \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(F77FILES) Makefile  all_fF.tar.gz : \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2738          @echo Creating \$@ ...          @echo Creating \$@ ...
2739          -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(F77FILES) Makefile          -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2740          -rm -f all_fF.tar.gz          -rm -f all_fF.tar.gz
2741          -gzip all_fF.tar          -gzip all_fF.tar
2742    
# Line 2542  cat >>$MAKEFILE <<EOF Line 2760  cat >>$MAKEFILE <<EOF
2760          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2761  .F90.$FS90:  .F90.$FS90:
2762          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2763    .FF90.f$FS90:
2764            \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2765  .$FS90.o:  .$FS90.o:
2766          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2767    .f$FS90.o:
2768            cp \$< \$(basename  \$<).f90
2769            \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$(F90FIXEDFORMAT) \$(basename  \$<).f90
2770  .c.o:  .c.o:
2771          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
2772    .flow.flowdir:
2773            \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2774    
2775  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain  # Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain
2776  .F.p:  .F.p:
# Line 2553  cat >>$MAKEFILE <<EOF Line 2778  cat >>$MAKEFILE <<EOF
2778  .p.$FS:  .p.$FS:
2779          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
2780    
2781    EOF
2782    
2783  #=========================================  #=========================================
2784  #===  Automatic Differentiation Rules  ===  #===  Automatic Differentiation Rules  ===
2785    #===  for TAMC/TAF  ======================
2786    
2787    if test "x$OPENAD" = x ; then
2788    
2789    cat >>$MAKEFILE <<EOF
2790    
2791  TAMC           = ${TAMC}  TAMC           = ${TAMC}
2792  TAF            = ${TAF}  TAF            = ${TAF}
# Line 2578  done Line 2810  done
2810  echo "  Add the source list for AD code generation"  echo "  Add the source list for AD code generation"
2811  echo >> $MAKEFILE  echo >> $MAKEFILE
2812  printf "AD_FILES = " >> $MAKEFILE  printf "AD_FILES = " >> $MAKEFILE
2813  AD_FILES=`cat ad_files`  AD_FILES=`cat adSrcFiles.tmp`
2814  for i in $AD_FILES ; do  for i in $AD_FILES ; do
2815      echo    " \\" >> $MAKEFILE      echo    " \\" >> $MAKEFILE
2816      printf " $i" >> $MAKEFILE      printf " $i" >> $MAKEFILE
2817  done  done
2818  echo >> $MAKEFILE  echo >> $MAKEFILE
2819  rm -f ad_files  rm -f adSrcFiles.tmp
2820    
2821  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2822    
# Line 2593  adall: \$(EXE_AD) Line 2825  adall: \$(EXE_AD)
2825  adtaf: ad_taf_output.$FS  adtaf: ad_taf_output.$FS
2826  adtamc: ad_tamc_output.$FS  adtamc: ad_tamc_output.$FS
2827    
2828  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)
2829          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template
2830          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2831          -rm -f ad_config.template          -rm -f ad_config.template
2832          @make \$(F77FILES)          @make \$(F77_PP_SRC_FILES)
2833          @make \$(AD_FLOW_FILES)          @make \$(FLOFILES)
2834          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS          cat \$(FLOFILES) \$(AD_FILES) > ad_input_code.$FS
2835    
2836  ad_taf_output.$FS: ad_input_code.$FS  ad_taf_output.$FS: ad_input_code.$FS
2837          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2838            ls -l ad_input_code_ad.$FS
2839          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
2840    
2841  adtafonly:  adtafonly:
2842          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
2843            ls -l ad_input_code_ad.$FS
2844          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
2845    
2846  \${EXE_AD}: ad_taf_output.o \$(OBJFILES)  \${EXE_AD}: ad_taf_output.o \$(OBJFILES)
# Line 2630  ftlall: ftl_taf Line 2864  ftlall: ftl_taf
2864  ftltaf: ftl_taf_output.$FS  ftltaf: ftl_taf_output.$FS
2865  ftltamc: ftl_tamc_output.$FS  ftltamc: ftl_tamc_output.$FS
2866    
2867  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)
2868          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template
2869          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2870          -rm -f ftl_config.template          -rm -f ftl_config.template
2871          @make \$(F77FILES)          @make \$(F77_PP_SRC_FILES)
2872          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2873          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2874    
2875  ftl_taf_output.$FS: ftl_input_code.$FS  ftl_taf_output.$FS: ftl_input_code.$FS
2876          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2877            ls -l ftl_input_code_ftl.$FS
2878          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2879    
2880  ftltafonly:  ftltafonly:
2881          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS          \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS
2882            ls -l ftl_input_code_ftl.$FS
2883          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS          cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS
2884    
2885  ftl_taf: ftl_taf_output.o \$(OBJFILES)  ftl_taf: ftl_taf_output.o \$(OBJFILES)
# Line 2681  svd_touch: Line 2917  svd_touch:
2917          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2918          -rm -f ftl_config.template          -rm -f ftl_config.template
2919    
2920  #=========================================  EOF
2921    
2922    fi
2923    
2924    #===  for OpenAD  ========================
2925    
2926    if test "x$OPENAD" != x ; then
2927    
2928    # ============ begin OpenAD specific section ==============
2929    
2930    cat >>$MAKEFILE <<EOF
2931    
2932    # all the source files linked from the various locations:
2933    ALL_LINKED_FILES= \
2934    \$(F77_SRC_FILES) \
2935    \$(C_SRC_FILES) \
2936    \$(H_SRC_FILES) \
2937    \$(F90_SRC_FILES) \
2938    \$(SPECIAL_FILES)
2939    
2940    ifndef OPENADROOT
2941      \$(error "Error:  environment variable OPENADROOT not defined!")
2942    endif
2943    
2944    ifndef XAIFSCHEMAROOT
2945      \$(error "Error:  environment variable XAIFSCHEMAROOT not defined!")
2946    endif
2947    
2948    ifndef XAIFBOOSTERROOT
2949      \$(error "Error:  environment variable XAIFBOOSTERROOT not defined!")
2950    endif
2951    
2952    EOF
2953    
2954    echo "  Add the source list for common block to module conversion "
2955    echo >> $MAKEFILE
2956    printf "CB2M_F90_SRC_NAMES = " >> $MAKEFILE
2957    for i in `cat ${OAD_CB2M_FILES}` ; do
2958      echo    " \\" >> $MAKEFILE
2959      printf " $i" >> $MAKEFILE
2960    done
2961    echo >> $MAKEFILE
2962    
2963    echo "  Add the source list for AD code generation"
2964    echo >> $MAKEFILE
2965    printf "AD_FILES = " >> $MAKEFILE
2966    for i in `cat ${OAD_CB2M_FILES}` ; do
2967      echo    " \\" >> $MAKEFILE
2968      printf " ${i}_mod.f$FS90" >> $MAKEFILE
2969    done
2970    AD_FILES=`cat adSrcFiles.tmp`
2971    for i in $AD_FILES ; do
2972      basename=${i%%.f}
2973      toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`
2974      if test -z "$toBeIgnored" ; then
2975        echo    " \\" >> $MAKEFILE
2976        printf " $i" >> $MAKEFILE
2977      fi
2978    done
2979    echo >> $MAKEFILE
2980    rm -f adSrcFiles.tmp
2981    
2982    cat >>$MAKEFILE <<EOF
2983    
2984    adAll: \$(EXE_AD)
2985    .PHONY: adAll
2986    
2987    CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))
2988    
2989    .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90)
2990    
2991    .PHONY: adDepend
2992    adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90)
2993            \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
2994            \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2995            -rm -f makedepend.out
2996    
2997    OPENAD_SUPPORT_F90_SRC_FILES = \
2998    w2f__types.F90 \
2999    OAD_active.F90 \
3000    OAD_cp.F90 \
3001    OAD_rev.F90 \
3002    OAD_tape.F90        
3003    
3004    OPENAD_SUPPORT_C_SRC_FILES = \
3005    iaddr.c \
3006    timeRatio.c
3007    
3008    f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)
3009            cat \$^ > \$@
3010    
3011    f95_test.f90: all_mods.xb.x2w.w2f.pp.f$FS90 \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
3012            cat \$^ > \$@
3013    
3014    f95_test.out: f95_test_mods.f90 f95_test.f90
3015            f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1
3016            f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1
3017    
3018    AD_OBJ_FILES=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) all_mods.xb.x2w.w2f.pp.o  ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.o \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o)
3019    
3020    \$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(AD_OBJ_FILES)
3021            @echo Creating \$@ ...
3022            \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES) \$(LIBS)
3023    
3024    # makefile debug rule
3025    openad: ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
3026    .PHONY: openad
3027    
3028    # create the module files
3029    %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk
3030            ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk
3031    
3032    # create the header files
3033    %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk
3034            ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
3035    
3036    # change everybody else to use the new module files:
3037    %_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash
3038            ../OAD_support/cb2mUseModules.bash $< ${MPI}
3039    
3040    # makefile debug rule
3041    small_f: \$(CB2M_F90_PP_SRC_FILES)
3042    .PHONY: small_f
3043    
3044    ad_output.txt: \$(EXE_AD)
3045            @printf 'linking data files ... '
3046            \$(LN) -f ../input_ad/data* ../input_ad/eedata .
3047            \$(LN) -f ../../global_ocean.90x40x15/input/*.bin .
3048            @printf 'running ... '
3049            @./\$(EXE_AD) > \$@
3050    
3051    CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)
3052    ad_input_code.f$FS90: ../OAD_support/maxMinDefs.f \$(CB2M_AD_FILES)
3053            cat \$^ > \$@
3054    
3055    # strip all comments and blanks to reduce
3056    # the file size in order to reduce perl's memory requirements
3057    ad_input_code_sf.f$FS90 : ad_input_code.f$FS90
3058            cat \$^ | sed -f ../OAD_support/strip.sed | sed -f ../OAD_support/stop2print.sed > \$@
3059    
3060    # mfef90 preprocessing
3061    # expand statement functions
3062    # expose mfef90 specific substring handling
3063    # add the w2f__types module
3064    ad_input_code_sf.w2f.f$FS90: ad_input_code_sf.f$FS90 mfef90 whirl2f whirl2f_be w2f__types.f90
3065            ./mfef90 -r8 -z -F -N132 \$<
3066            mv \$<.B \$(basename \$<).B
3067            ./whirl2f -openad \$(basename \$<).B
3068            cat w2f__types.f90 \$(basename \$<).w2f.f > \$@
3069    
3070    # canonicalizer
3071    ad_input_code_sf.w2f.pre.f$FS90: ad_input_code_sf.w2f.f$FS90 preProcess.py
3072            ./preProcess.py -H -S \$< -o \$@
3073    
3074    # F -> WHIRL
3075    # note that the canonicalized version cuts off at col 72
3076    # doing this also for string constants which is ok as long
3077    # as we are in fixed mode and cut of exactly there.
3078    # Otherwise mfef90 patches in spaces to fill up to 72 (or 132)
3079    # characters respectively.
3080    ad_input_code_sf.w2f.pre.B: ad_input_code_sf.w2f.pre.f$FS90 mfef90
3081            ./mfef90 -r8 -z -F \$<
3082            mv \$<.B \$@
3083    
3084    # WHIRL -> XAIF
3085    ad_input_code_sf.w2f.pre.xaif : ad_input_code_sf.w2f.pre.B whirl2xaif
3086            ./whirl2xaif -s -n --debug 1 -o \$@ \$<
3087    
3088    # XAIF -> XAIF'
3089    ad_input_code_sf.w2f.pre.xb.xaif : ad_input_code_sf.w2f.pre.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd oadDriver
3090            ./oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r
3091    
3092    # XAIF' -> WHIRL'
3093    ad_input_code_sf.w2f.pre.xb.x2w.B : ad_input_code_sf.w2f.pre.xb.xaif xaif2whirl
3094            ./xaif2whirl --debug 1 --structured ad_input_code_sf.w2f.pre.B \$<
3095    
3096    # WHIRL' -> F'
3097    ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.B whirl2f whirl2f_be
3098            ./whirl2f -FLIST:ftn_file=\$@ -openad \$<
3099    
3100    # insert template directives
3101    ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90 ../OAD_support/insertTemplateDir.bash
3102            ../OAD_support/insertTemplateDir.bash \$< \$@
3103    
3104    PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F
3105    # postprocess F'
3106    ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 multi-pp.pl \$(PPEXTRAS:.F=.f)
3107            perl multi-pp.pl -inline=../OAD_support/ad_inline.f \$<
3108            # the postprocessor still gets the name wrong
3109            cat \$<.pp | sed 's/RETURN//' > \$@
3110    
3111    # extract all transformed modules
3112    all_mods.xb.x2w.w2f.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
3113            cat \$< | sed -n '/MODULE /,/END MODULE/p' > \$@
3114    
3115    # remove the transformed globals module from the
3116    # transformed ad_input_code file
3117    # and remove for now the duplicate variables
3118    # and fix 2 data statements
3119    ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
3120            cat \$< | sed '/MODULE /,/END MODULE/d' | sed '/^      INTEGER(w2f__i4) DOLOOP_UB/d' > \$@
3121    
3122    # setup some links
3123    %.xsd:
3124            \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3125    
3126    mfef90:
3127            \$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 .
3128    
3129    # link the support files:
3130    \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):
3131            \$(LN) ../OAD_support/\$@ .
3132    
3133    whirl2xaif xaif2whirl:
3134            \$(LN) \${OPENADFORTTK}/bin/\$@ .
3135    
3136    %.pl:
3137            \$(LN) \${OPENADFORTTK}/bin/\$@ .
3138    
3139    preProcess.py:
3140            \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ .
3141    
3142    whirl2f whirl2f_be:
3143            \$(LN) \${OPEN64ROOT}/whirl2f/\$@ .
3144    
3145    oadDriver:
3146            \$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver \$@
3147    
3148    # ============ end OpenAD specific section ==============
3149    
3150  EOF  EOF
3151    
3152    fi
3153    
3154    #=========================================
3155    
3156  if test "x$EXEHOOK" != x ; then  if test "x$EXEHOOK" != x ; then
3157      printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE      printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
3158  fi  fi

Legend:
Removed from v.1.157  
changed lines
  Added in v.1.187

  ViewVC Help
Powered by ViewVC 1.1.22