/[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.11.2.11 by edhill, Sat Oct 4 13:56:40 2003 UTC revision 1.27 by edhill, Tue Nov 4 18:40:58 2003 UTC
# Line 46  expand_pkg_groups() { Line 46  expand_pkg_groups() {
46      PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"      PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"
47      if test -r $PKG_GROUPS ; then      if test -r $PKG_GROUPS ; then
48          cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp          cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp
49          cat ./p1.tmp | awk '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp          cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp
50          matched=0          matched=0
51          for i in $PACKAGES ; do          for i in $PACKAGES ; do
52              line=`grep $i ./p2.tmp`              line=`grep "^ *$i" ./p2.tmp`
53              RETVAL=$?              RETVAL=$?
54              if test "x$RETVAL" = x0 ; then              if test "x$RETVAL" = x0 ; then
55                  matched=1                  matched=1
56                  replace=`echo $line | awk '{ $1=""; $2=""; print $0 }'`                  replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
57                  echo "    replacing \"$i\" with: $replace"                  echo "    replacing \"$i\" with: $replace"
58                  new_packages="$new_packages $replace"                  new_packages="$new_packages $replace"
59              else              else
# Line 72  find_possible_configs()  { Line 72  find_possible_configs()  {
72    
73      tmp1=`uname`"_"`uname -m`      tmp1=`uname`"_"`uname -m`
74      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`      tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
75      PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`      tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'`
76        PLATFORM=`echo $tmp3 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
77      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
78      echo "  The platform appears to be:  $PLATFORM"      echo "  The platform appears to be:  $PLATFORM"
79  #     if test "x$OFLIST" = x ; then  #     if test "x$OFLIST" = x ; then
# Line 104  find_possible_configs()  { Line 105  find_possible_configs()  {
105      fi      fi
106    
107      # look for possible fortran compilers      # look for possible fortran compilers
108      tmp="$MITGCM_FC $FC g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"      tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95"
109      p_FC=      p_FC=
110      for c in $tmp ; do      for c in $tmp ; do
111          rm -f ./hello.f ./hello          rm -f ./hello.f ./hello
# Line 121  EOF Line 122  EOF
122              p_FC="$p_FC $c"              p_FC="$p_FC $c"
123          fi          fi
124      done      done
125        rm -f ./hello.f ./hello
126      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
127          cat 1>&2 <<EOF          cat 1>&2 <<EOF
128    
# Line 136  EOF Line 138  EOF
138          echo "  The possible FORTRAN compilers found in your path are:"          echo "  The possible FORTRAN compilers found in your path are:"
139          echo "   "$p_FC          echo "   "$p_FC
140          if test "x$FC" = x ; then          if test "x$FC" = x ; then
141              FC=`echo $p_FC | awk '{print $1}'`              FC=`echo $p_FC | $AWK '{print $1}'`
142          fi          fi
143      fi      fi
144    
# Line 202  get_pdepend_list()  { Line 204  get_pdepend_list()  {
204      #  strip the comments and then convert the dependency file into      #  strip the comments and then convert the dependency file into
205      #  two arrays: PNAME, DNAME      #  two arrays: PNAME, DNAME
206      cat $1 | sed -e 's/#.*$//g' \      cat $1 | sed -e 's/#.*$//g' \
207          | awk 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \          | $AWK 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \
208          > ./.pd_tmp          > ./.pd_tmp
209      source ./.pd_tmp      source ./.pd_tmp
210      rm -f ./.pd_tmp      rm -f ./.pd_tmp
# Line 319  STANDARDDIRS= Line 321  STANDARDDIRS=
321    
322  PWD=`pwd`  PWD=`pwd`
323  MAKE=make  MAKE=make
324    AWK=awk
325  THISHOSTNAME=`hostname`  THISHOSTNAME=`hostname`
326  THISCWD=`pwd`  THISCWD=`pwd`
327  THISDATE=`date`  THISDATE=`date`
# Line 327  EXECUTABLE= Line 330  EXECUTABLE=
330  EXEHOOK=  EXEHOOK=
331  EXEDIR=  EXEDIR=
332  PACKAGES_CONF=  PACKAGES_CONF=
333    IEEE=
334  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
335      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
336  fi  fi
337    
338    AUTODIFF_PKG_USED=f
339    AD_OPTFILE=
340    TAF=
341    AD_TAF_FLAGS=
342    FTL_TAF_FLAGS=
343    SVD_TAF_FLAGS=
344    TAF_EXTRA=
345    TAMC=
346    AD_TAMC_FLAGS=
347    FTL_TAF_FLAGS=
348    SVD_TAMC_FLAGS=
349    TAMC_EXTRA=
350    
351    
352  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
353  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"
354  gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS"
# Line 341  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFI Line 359  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFI
359  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"
360  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
361    
362  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6"  #  The following are all related to adjoint/tangent-linear stuff
363    gm_s7="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
364    gm_s8="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
365    gm_s9="TAF_EXTRA TAMC_EXTRA"
366    
367    gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8 $gm_s9"
368    
369    
370  echo  echo
# Line 374  fi Line 397  fi
397  #   n=$(( $n + 1 ))  #   n=$(( $n + 1 ))
398  #done  #done
399  #parse_options  #parse_options
   
400  ac_prev=  ac_prev=
401  for ac_option ; do  for ac_option ; do
402    
# Line 399  for ac_option ; do Line 421  for ac_option ; do
421          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
422              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
423                    
424            -adoptfile | --adoptfile | -ad | --ad)
425                ac_prev=AD_OPTFILE ;;
426            -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
427                AD_OPTFILE=$ac_optarg ;;
428            
429          -pdepend | --pdepend)          -pdepend | --pdepend)
430              ac_prev=PDEPEND ;;              ac_prev=PDEPEND ;;
431          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
# Line 482  for ac_option ; do Line 509  for ac_option ; do
509          -ds | --ds)          -ds | --ds)
510              DUMPSTATE=t ;;              DUMPSTATE=t ;;
511                    
512            -taf_extra | --taf_extra)
513                ac_prev=TAF_EXTRA ;;
514            -taf_extra=* | --taf_extra=*)
515                TAF_EXTRA=$ac_optarg ;;
516    
517            -tamc_extra | --tamc_extra)
518                ac_prev=TAMC_EXTRA ;;
519            -tamc_extra=* | --tamc_extra=*)
520                TAMC_EXTRA=$ac_optarg ;;
521    
522          -*)          -*)
523              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
524              usage              usage
# Line 496  for ac_option ; do Line 533  for ac_option ; do
533            
534  done  done
535    
536    if test -f ./.genmakerc ; then
537        echo
538        echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
539        echo "  file.  This file format is no longer supported.  Please see:"
540        echo
541        echo "    http://mitgcm.org/devel_HOWTO/"
542        echo
543        echo "  for directions on how to setup and use the new \"genmake2\" input"
544        echo "  files and send an email to MITgcm-support@mitgcm.org if you want help."
545        echo
546    fi
547    
548  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
549      if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then      if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then
550          ROOTDIR=".."          ROOTDIR=".."
# Line 550  if test "x$OPTFILE" != xNONE ; then Line 599  if test "x$OPTFILE" != xNONE ; then
599      fi      fi
600  fi  fi
601    
602    echo "  getting AD_OPTFILE information:  "
603    if test "x${AD_OPTFILE}" = x ; then
604        if test "x$MITGCM_AD_OF" = x ; then
605            AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
606        else
607            AD_OPTFILE=$MITGCM_AD_OF
608        fi
609    fi
610    if test "x${AD_OPTFILE}" != xNONE ; then
611        if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then
612            echo "    using AD_OPTFILE=\"$AD_OPTFILE\""
613            source "$AD_OPTFILE"
614            RETVAL=$?
615            if test "x$RETVAL" != x0 ; then
616                echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
617                echo "--please check that variable syntax is bash-compatible"
618                exit 1
619            fi
620            if test "x$DUMPSTATE" != xf ; then
621                cp -f $AD_OPTFILE "genmake_ad_optfile"
622            fi
623        else
624            echo "Error: can't read AD_OPTFILE=\"$AD_OPTFILE\""
625            exit 1
626        fi
627    fi
628    
629  #  Check that FC, LINK, CPP, and S64 are defined.  If not, complain  #  Check that FC, LINK, CPP, and S64 are defined.  If not, complain
630  #  and abort!  #  and abort!
631  if test "x$FC" = x ; then  if test "x$FC" = x ; then
# Line 568  fi Line 644  fi
644  if test "x$CPP" = x ; then  if test "x$CPP" = x ; then
645      CPP="cpp"      CPP="cpp"
646  fi  fi
647  echo "#define A a" | cpp > test_cpp 2>&1  echo "#define A a" | $CPP > test_cpp 2>&1
648  RETVAL=$?  RETVAL=$?
649  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
650      cat <<EOF 1>&2      cat <<EOF 1>&2
# Line 669  echo "  getting package dependency info Line 745  echo "  getting package dependency info
745  #  Strip the comments and then convert the dependency file into  #  Strip the comments and then convert the dependency file into
746  #  two arrays: PNAME, DNAME  #  two arrays: PNAME, DNAME
747  cat $PDEPEND | sed -e 's/#.*$//g' \  cat $PDEPEND | sed -e 's/#.*$//g' \
748      | awk 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \      | $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \
749      > ./.pd_tmp      > ./.pd_tmp
750  RETVAL=$?  RETVAL=$?
751  if test ! "x${RETVAL}" = x0 ; then  if test ! "x${RETVAL}" = x0 ; then
# Line 703  else Line 779  else
779      else      else
780          echo "  using PDEFAULT=\"$PDEFAULT\""          echo "  using PDEFAULT=\"$PDEFAULT\""
781          #  Strip the comments and add all the names          #  Strip the comments and add all the names
782          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | awk '(NF>0){print $0}'`          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
783          RETVAL=$?          RETVAL=$?
784          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
785              echo -n "Error: can't parse default package list "              echo -n "Error: can't parse default package list "
# Line 825  for i in $PACKAGES ; do Line 901  for i in $PACKAGES ; do
901      if test -d $adr ; then      if test -d $adr ; then
902          SOURCEDIRS="$SOURCEDIRS $adr"          SOURCEDIRS="$SOURCEDIRS $adr"
903          INCLUDEDIRS="$INCLUDEDIRS $adr"          INCLUDEDIRS="$INCLUDEDIRS $adr"
904            if test "x$i" = xautodiff ; then
905                AUTODIFF_PKG_USED=t
906            fi
907      else      else
908          echo "Error: the directory \"$adr\" for package $i doesn't exist"          echo "Error: the directory \"$adr\" for package $i doesn't exist"
909          exit 1          exit 1
910      fi      fi
911  done  done
912    
 #  This is compatible with the old genmake.  The "DISABLE_*" flags  
 #  need to be replaced by the "ALLOW_*" flags set below.  
 #  
 # echo -n "  Setting package-specific CPP flags:  "  
 # pkrm=( mom_fluxform mom_vecinv generic_advdiff )  
 # pkrmdef=( -DDISABLE_MOM_FLUXFORM -DDISABLE_MOM_VECINV -DDISABLE_GENERIC_ADVDIFF -DDISABLE_DEBUGMODE )  
 # echo -n "  "  
 # i=0  
 # while test $i -lt "${#pkrm[@]}" ; do  
 #     echo "$PACKAGES" | grep "${pk[$i]}" > /dev/null 2>&1  
 #     RETVAL=$?  
 #     if test "x$RETVAL" = x1 ; then  
 #       DEFINES="$DEFINES ${pkdef[$i]}"  
 #       echo -n " ${pkdef[$i]}"  
 #     fi  
 #     i=$(( $i + 1 ))  
 # done  
 # echo  
913    
914  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
915  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
# Line 880  for n in $names ; do Line 941  for n in $names ; do
941              fi              fi
942          done          done
943          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
944              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`
945              echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"              echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"
946  #           DEFINES="$DEFINES -U$undef"  #           DEFINES="$DEFINES -U$undef"
947    
# Line 892  for n in $names ; do Line 953  for n in $names ; do
953                  mom_vecinv)                  mom_vecinv)
954                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"                      DEFINES="$DEFINES -DDISABLE_MOM_VECINV"
955                      ;;                      ;;
                 debug)  
                     DEFINES="$DEFINES -DDISABLE_DEBUGMODE"  
                     ;;  
956              esac              esac
957  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
958    
# Line 906  cat <<EOF >>$PACKAGES_DOT_H".tmp" Line 964  cat <<EOF >>$PACKAGES_DOT_H".tmp"
964  C  Packages enabled by genmake:  C  Packages enabled by genmake:
965  EOF  EOF
966  for i in $PACKAGES ; do  for i in $PACKAGES ; do
967      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`
968      echo "#define $def" >> $PACKAGES_DOT_H".tmp"      echo "#define $def" >> $PACKAGES_DOT_H".tmp"
969  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
970    
# Line 963  for d in $STANDARDDIRS ; do Line 1021  for d in $STANDARDDIRS ; do
1021      fi      fi
1022  done  done
1023    
1024  echo " Searching for CPP_OPTIONS.h in order to warn about the presence"  echo "  Searching for CPP_OPTIONS.h in order to warn about the presence"
1025  echo " of \"#define ALLOW_PKGNAME\"-type statements:"  echo "    of \"#define ALLOW_PKGNAME\"-type statements:"
1026  CPP_OPTIONS=  CPP_OPTIONS=
1027  spaths=". $INCLUDEDIRS"  spaths=". $INCLUDEDIRS"
1028  for i in $spaths ; do  for i in $spaths ; do
# Line 987  for n in $names ; do Line 1045  for n in $names ; do
1045  done  done
1046    
1047    
1048    #  Here, we build the list of files to be "run through" the adjoint
1049    #  compiler.
1050    if test -f ./ad_files ; then
1051        rm -f ./ad_files
1052    fi
1053    echo "  Creating the list of files for the adjoint compiler."
1054    for i in $SOURCEDIRS ; do
1055        list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
1056        for j in $list_files ; do
1057            cat $i/$j >> ad_files
1058        done
1059    done
1060    
1061    cat <<EOF > adjoint_sed
1062    s/call adopen(/call adopen ( mythid,\\
1063         \&           /g
1064    s/call adclose(/call adclose( mythid,\\
1065         \&           /g
1066    s/call adread(/call adread ( mythid,\\
1067         \&           /g
1068    s/call adwrite(/call adwrite( mythid,\\
1069         \&           /g
1070    
1071    EOF
1072    
1073  echo  echo
1074  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
1075  echo "  setting INCLUDES"  echo "  setting INCLUDES"
# Line 1007  echo -n 'SRCFILES = '    > srclist.inc Line 1090  echo -n 'SRCFILES = '    > srclist.inc
1090  echo -n 'CSRCFILES = '   > csrclist.inc  echo -n 'CSRCFILES = '   > csrclist.inc
1091  echo -n 'F90SRCFILES = ' > f90srclist.inc  echo -n 'F90SRCFILES = ' > f90srclist.inc
1092  echo -n 'HEADERFILES = ' > hlist.inc  echo -n 'HEADERFILES = ' > hlist.inc
1093    echo -n 'AD_FLOW_FILES = ' > ad_flow_files.inc
1094  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
1095  for d in $alldirs ; do  for d in $alldirs ; do
1096      deplist=      deplist=
1097      sfiles=`( cd $d; echo *.[h,c,F] )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
1098      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
1099      for sf in $sfiles ; do      for sf in $sfiles ; do
1100          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
1101              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
1102                  extn=`echo $sf | awk -F '.' '{print $NF}'`                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`
1103                  touch .links.tmp/$sf                  touch .links.tmp/$sf
1104                  deplist="$deplist $sf"                  deplist="$deplist $sf"
1105                  case $extn in                  case $extn in
# Line 1035  for d in $alldirs ; do Line 1119  for d in $alldirs ; do
1119                          echo    " \\"  >> hlist.inc                          echo    " \\"  >> hlist.inc
1120                          echo -n " $sf" >> hlist.inc                          echo -n " $sf" >> hlist.inc
1121                          ;;                          ;;
1122                        flow)
1123                            echo    " \\"  >> ad_flow_files.inc
1124                            echo -n " $sf" >> ad_flow_files.inc
1125                            ;;
1126                  esac                  esac
1127              fi              fi
1128          fi          fi
# Line 1051  echo "" >> srclist.inc Line 1139  echo "" >> srclist.inc
1139  echo "" >> csrclist.inc  echo "" >> csrclist.inc
1140  echo "" >> f90srclist.inc  echo "" >> f90srclist.inc
1141  echo "" >> hlist.inc  echo "" >> hlist.inc
1142    echo "" >> ad_flow_files.inc
1143    
1144  if test -e $MAKEFILE ; then  if test -e $MAKEFILE ; then
1145      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
# Line 1064  echo "# by the command:" >> $MAKEFILE Line 1153  echo "# by the command:" >> $MAKEFILE
1153  echo "#    $0 $@" >> $MAKEFILE  echo "#    $0 $@" >> $MAKEFILE
1154  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
1155  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE
1156    
1157    EXE_AD=$EXECUTABLE"_ad"
1158    EXE_FTL=$EXECUTABLE"_ftl"
1159    EXE_SVD=$EXECUTABLE"_svd"
1160    
1161  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1162  #  #
1163  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
# Line 1092  EXEDIR      = ${EXEDIR} Line 1186  EXEDIR      = ${EXEDIR}
1186  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
1187  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIR}
1188    
1189    #eh3  new defines for the adjoint work
1190    AUTODIFF    = ${ROOTDIR}/pkg/autodiff
1191    EXE_AD      = ${EXE_AD}
1192    EXE_FTL     = ${EXE_FTL}
1193    EXE_SVD     = ${EXE_SVD}
1194    
1195  EOF  EOF
1196    
1197  #  Note: figure out some way to add Hyades JAM libraries here  #  Note: figure out some way to add Hyades JAM libraries here
# Line 1137  MAKEFILE=${MAKEFILE} Line 1237  MAKEFILE=${MAKEFILE}
1237    
1238  EOF  EOF
1239    
1240  cat srclist.inc    >> $MAKEFILE  cat srclist.inc       >> $MAKEFILE
1241  cat csrclist.inc   >> $MAKEFILE  cat csrclist.inc      >> $MAKEFILE
1242  cat f90srclist.inc >> $MAKEFILE  cat f90srclist.inc    >> $MAKEFILE
1243  cat hlist.inc      >> $MAKEFILE  cat hlist.inc         >> $MAKEFILE
1244    cat ad_flow_files.inc >> $MAKEFILE
1245    echo               >> $MAKEFILE
1246  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE
1247  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE
1248  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
1249    
1250  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc  rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc
1251    rm -f ad_flow_files.inc
1252    
1253  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1254    
# Line 1169  output.txt: \$(EXECUTABLE) Line 1272  output.txt: \$(EXECUTABLE)
1272          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
1273    
1274  clean:  clean:
1275            -cat AD_CONFIG.template > AD_CONFIG.h
1276          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl}          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl}
1277  Clean:  Clean:
1278          @make clean          @make clean
1279          @make cleanlinks          @make cleanlinks
1280          -rm -f Makefile.bak genmake_state genmake_optfile make.log          -rm -f Makefile.bak genmake_state genmake_*optfile make.log
1281  CLEAN:  CLEAN:
1282          @make Clean          @make Clean
1283          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
# Line 1181  CLEAN: Line 1285  CLEAN:
1285          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1286          -rm -f \$(EXECUTABLE) output.txt          -rm -f \$(EXECUTABLE) output.txt
1287    
1288    #eh3 Makefile: makefile
1289  makefile:  makefile:
1290          ${0} $@          ${0} $@
1291  cleanlinks:  cleanlinks:
# Line 1204  cleanlinks: Line 1309  cleanlinks:
1309  .p.f:  .p.f:
1310          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
1311    
1312    #=========================================
1313    #===  Automatic Differentiation Rules  ===
1314    
1315    TAMC           = ${TAMC}
1316    TAF            = ${TAF}
1317    
1318    TAF_EXTRA      = ${TAF_EXTRA}
1319    TAMC_EXTRA     = ${TAMC_EXTRA}
1320    
1321    EOF
1322    
1323    ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS"
1324    ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF_FLAGS"
1325    ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
1326    for i in $ad_vars ; do
1327        name=$i
1328        t1="t2=\$"`echo $i`
1329        eval $t1
1330        printf "%-20s = " $name >> $MAKEFILE
1331        echo $t2 >> $MAKEFILE
1332    done
1333    
1334    echo "  Add the source list for AD code generation"
1335    echo >> $MAKEFILE
1336    echo -n "AD_FILES = " >> $MAKEFILE
1337    AD_FILES=`cat ad_files`
1338    for i in $AD_FILES ; do
1339        echo    " \\" >> $MAKEFILE
1340        echo -n " $i" >> $MAKEFILE
1341    done
1342    echo >> $MAKEFILE
1343    rm -f ad_files
1344    
1345    cat >>$MAKEFILE <<EOF
1346    
1347    # ... AD ...
1348    adall: ad_taf
1349    adtaf: ad_taf_output.f
1350    adtamc: ad_tamc_output.f
1351    
1352    ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1353            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
1354            @make \$(F77FILES)
1355            @make \$(AD_FLOW_FILES)
1356            cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f
1357    
1358    ad_taf_output.f: ad_input_code.f
1359            \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f
1360            cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f
1361    
1362    ad_taf: ad_taf_output.o \$(OBJFILES)
1363            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
1364    
1365    ad_tamc_output.f: ad_input_code.f
1366            \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f
1367            cat ad_input_code_ad.f | sed -f adjoint_sed > ad_tamc_output.f
1368    
1369    ad_tamc: ad_tamc_output.o \$(OBJFILES)
1370            \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
1371    
1372    
1373    # ... FTL ...
1374    ftlall: ftl_taf
1375    ftltaf: ftl_taf_output.f
1376    ftltamc: ftl_tamc_output.f
1377    
1378    ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1379            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
1380            @make \$(F77FILES)
1381            @make \$(AD_FLOW_FILES)
1382            cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f
1383    
1384    ftl_taf_output.f: ftl_input_code.f
1385            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f
1386            cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f
1387    
1388    ftl_taf: ftl_taf_output.o \$(OBJFILES)
1389            \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
1390    
1391    ftl_tamc_output.f: ftl_input_code.f
1392            \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f
1393            cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_tamc_output.f
1394    
1395    ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
1396            \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
1397    
1398    
1399    # ... SVD ...
1400    svd: svd_taf
1401    svd_taf_f: svd_taf_output.f
1402    
1403    svd_input_code.f: \$(SRCFILES)
1404            cmp svd_config.template AD_CONFIG.h || cat svd_config.template > AD_CONFIG.h
1405            @make \$(F77FILES)
1406            @make \$(AD_FLOW_FILES)
1407            cat \$(AD_FLOW_FILES) \$(AD_FILES) > svd_input_code.f
1408    
1409    svd_taf_output.f: svd_input_code.f
1410            \$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) svd_input_code.f
1411            cat svd_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f
1412    
1413    svd_taf: svd_taf_output.o \$(OBJFILES)
1414            \$(LINK) -o ${EXE_SVD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS)
1415    
1416    
1417    #=========================================
1418    
1419  EOF  EOF
1420    
1421  if test "x$EXEHOOK" != x ; then  if test "x$EXEHOOK" != x ; then
# Line 1240  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 1452  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
1452    
1453  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
1454    
1455    #  Write the "template" files for the adjoint builds
1456    cat >AD_CONFIG.template <<EOF
1457    C  WARNING: This file is automatically generated by genmake2 and
1458    C    used by the Makefile rules.  Please DO NOT EDIT this file
1459    C    unless you are CERTAIN that you know what you are doing.
1460    
1461    #undef ALLOW_ADJOINT_RUN
1462    #undef ALLOW_TANGENTLINEAR_RUN
1463    #undef ALLOW_ECCO_OPTIMIZATION
1464    EOF
1465    cat >ad_config.template <<EOF
1466    C  WARNING: This file is automatically generated by genmake2 and
1467    C    used by the Makefile rules.  Please DO NOT EDIT this file
1468    C    unless you are CERTAIN that you know what you are doing.
1469    
1470    #define ALLOW_ADJOINT_RUN
1471    #undef ALLOW_TANGENTLINEAR_RUN
1472    #undef ALLOW_ECCO_OPTIMIZATION
1473    EOF
1474    cat >ftl_config.template <<EOF
1475    C  WARNING: This file is automatically generated by genmake2 and
1476    C    used by the Makefile rules.  Please DO NOT EDIT this file
1477    C    unless you are CERTAIN that you know what you are doing.
1478    
1479    #undef ALLOW_ADJOINT_RUN
1480    #define ALLOW_TANGENTLINEAR_RUN
1481    #undef ALLOW_ECCO_OPTIMIZATION
1482    EOF
1483    cat >svd_config.template <<EOF
1484    C  WARNING: This file is automatically generated by genmake2 and
1485    C    used by the Makefile rules.  Please DO NOT EDIT this file
1486    C    unless you are CERTAIN that you know what you are doing.
1487    
1488    #undef ALLOW_ADJOINT_RUN
1489    #undef ALLOW_TANGENTLINEAR_RUN
1490    #undef ALLOW_ECCO_OPTIMIZATION
1491    EOF
1492    cp AD_CONFIG.template AD_CONFIG.h
1493    
1494    
1495  #  Write the "state" for future records  #  Write the "state" for future records
1496  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" != xf ; then

Legend:
Removed from v.1.11.2.11  
changed lines
  Added in v.1.27

  ViewVC Help
Powered by ViewVC 1.1.22