/[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.1 by adcroft, Wed Oct 1 18:44:48 2003 UTC revision 1.18 by edhill, Tue Oct 21 20:42:16 2003 UTC
# Line 11  Line 11 
11  # Search for particular CPP #cmds associated with packages  # Search for particular CPP #cmds associated with packages
12  # usage: test_for_package_in_cpp_options CPP_file package_name  # usage: test_for_package_in_cpp_options CPP_file package_name
13  test_for_package_in_cpp_options() {  test_for_package_in_cpp_options() {
14     cpp_options=$1      cpp_options=$1
15     pkg=$2      pkg=$2
16     grep -i "#define.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1      grep -i "#define.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1
17     RETVAL=$?      RETVAL=$?
18     if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
19        echo "Error: In $cpp_options there is an illegal line: #define ALLOW_$pkg"          echo "Error: In $cpp_options there is an illegal line: #define ALLOW_$pkg"
20        exit 99          exit 99
21     fi      fi
22     grep -i "#undef.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1      grep -i "#undef.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1
23     RETVAL=$?      RETVAL=$?
24     if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
25        echo "Error: In $cpp_options there is an illegal line: #undef ALLOW_$pkg"          echo "Error: In $cpp_options there is an illegal line: #undef ALLOW_$pkg"
26        exit 99          exit 99
27     fi      fi
28     grep -i "#define.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1      grep -i "#define.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1
29     RETVAL=$?      RETVAL=$?
30     if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
31        echo "Error: In $cpp_options there is an illegal line: #define DISABLE_$pkg"          echo "Error: In $cpp_options there is an illegal line: #define DISABLE_$pkg"
32        exit 99          exit 99
33     fi      fi
34     grep -i "#undef.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1      grep -i "#undef.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1
35     RETVAL=$?      RETVAL=$?
36     if test "x${RETVAL}" = x0 ; then      if test "x${RETVAL}" = x0 ; then
37        echo "Error: In $cpp_options there is an illegal line: #undef DISABLE_$pkg"          echo "Error: In $cpp_options there is an illegal line: #undef DISABLE_$pkg"
38        exit 99          exit 99
39     fi     fi
40  }  }
41    
42    # Read the $ROOTDIR/pkg/pkg_groups file and expand any references to
43    # the package list.
44    expand_pkg_groups() {
45        new_packages=
46        PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups"
47        if test -r $PKG_GROUPS ; then
48            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
50            matched=0
51            for i in $PACKAGES ; do
52                line=`grep "^ *$i" ./p2.tmp`
53                RETVAL=$?
54                if test "x$RETVAL" = x0 ; then
55                    matched=1
56                    replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'`
57                    echo "    replacing \"$i\" with: $replace"
58                    new_packages="$new_packages $replace"
59                else
60                    new_packages="$new_packages $i"
61                fi
62            done
63            PACKAGES=$new_packages
64            rm -f ./p[1,2].tmp
65        else
66            echo "Warning: can't read package groups definition file: $PKG_GROUPS"
67        fi
68    }
69    
70  # Guess possible config options for this host  # Guess possible config options for this host
71  find_possible_configs()  {  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/'`      PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'`
76      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`      OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")`
77      echo "  The platform appears to be:  $PLATFORM"      echo "  The platform appears to be:  $PLATFORM"
78  #     if test "x$OFLIST" = x ; then  #     if test "x$OFLIST" = x ; then
# Line 109  EOF Line 136  EOF
136          echo "  The possible FORTRAN compilers found in your path are:"          echo "  The possible FORTRAN compilers found in your path are:"
137          echo "   "$p_FC          echo "   "$p_FC
138          if test "x$FC" = x ; then          if test "x$FC" = x ; then
139              FC=`echo $p_FC | awk '{print $1}'`              FC=`echo $p_FC | $AWK '{print $1}'`
140          fi          fi
141      fi      fi
142    
# Line 175  get_pdepend_list()  { Line 202  get_pdepend_list()  {
202      #  strip the comments and then convert the dependency file into      #  strip the comments and then convert the dependency file into
203      #  two arrays: PNAME, DNAME      #  two arrays: PNAME, DNAME
204      cat $1 | sed -e 's/#.*$//g' \      cat $1 | sed -e 's/#.*$//g' \
205          | 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} }' \
206          > ./.pd_tmp          > ./.pd_tmp
207      source ./.pd_tmp      source ./.pd_tmp
208      rm -f ./.pd_tmp      rm -f ./.pd_tmp
# Line 212  usage()  { Line 239  usage()  {
239      echo "      -disable=NAME | --disable=NAME"      echo "      -disable=NAME | --disable=NAME"
240      echo "    -enable NAME | --enable NAME"      echo "    -enable NAME | --enable NAME"
241      echo "      -enable=NAME | --enable=NAME"      echo "      -enable=NAME | --enable=NAME"
242        echo "    -standarddirs NAME | --standarddirs NAME"
243        echo "      -standarddirs=NAME | --standarddirs=NAME"
244      echo "    -noopt NAME | --noopt NAME"      echo "    -noopt NAME | --noopt NAME"
245      echo "      -noopt=NAME | --noopt=NAME"      echo "      -noopt=NAME | --noopt=NAME"
246  #    echo "    -cpp NAME | --cpp NAME"  #    echo "    -cpp NAME | --cpp NAME"
# Line 286  MODS= Line 315  MODS=
315  TOOLSDIR=  TOOLSDIR=
316  SOURCEDIRS=  SOURCEDIRS=
317  INCLUDEDIRS=  INCLUDEDIRS=
318    STANDARDDIRS=
319    
320  PWD=`pwd`  PWD=`pwd`
321  MAKE=make  MAKE=make
322    AWK=awk
323  THISHOSTNAME=`hostname`  THISHOSTNAME=`hostname`
324  THISCWD=`pwd`  THISCWD=`pwd`
325  THISDATE=`date`  THISDATE=`date`
# Line 296  MACHINE=`uname -a` Line 327  MACHINE=`uname -a`
327  EXECUTABLE=  EXECUTABLE=
328  EXEHOOK=  EXEHOOK=
329  EXEDIR=  EXEDIR=
330    PACKAGES_CONF=
331    IEEE=
332    if test "x$MITGCM_IEEE" != x ; then
333        IEEE=$MITGCM_IEEE
334    fi
335    
336    AUTODIFF_PKG_USED=f
337    AD_OPTFILE=
338    TAF=
339    AD_TAF_FLAGS=
340    FTL_TAF_FLAGS=
341    SVD_TAF_FLAGS=
342    TAF_EXTRA=
343    TAMC=
344    AD_TAMC_FLAGS=
345    FTL_TAF_FLAGS=
346    SVD_TAMC_FLAGS=
347    TAMC_EXTRA=
348    
349    
350  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
351  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"
352  gm_s2="FC IEEE MPI JAM DUMPSTATE"  gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS"
353    
354  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
355  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 "
356  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
357  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"
358  gm_s6="EXECUTABLE EXEHOOK EXEDIR"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
359    
360    #  The following are all related to adjoint/tangent-linear stuff
361    gm_s7="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
362    gm_s8="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
363    gm_s9="TAF_EXTRA TAMC_EXTRA"
364    
365  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6"  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8 $gm_s9"
366    
367    
368  echo  echo
369  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
370  gm_local="./gm_local"  gm_local="genmake_local"
371    for i in . $MODS ; do
372        if test -r $i/$gm_local ; then
373            source $i/$gm_local
374            break
375        fi
376    done
377  echo -n "  getting local config information:  "  echo -n "  getting local config information:  "
378  if test -e $gm_local ; then  if test -e $gm_local ; then
379      echo "using $gm_local"      echo "using $gm_local"
# Line 334  fi Line 395  fi
395  #   n=$(( $n + 1 ))  #   n=$(( $n + 1 ))
396  #done  #done
397  #parse_options  #parse_options
   
398  ac_prev=  ac_prev=
399  for ac_option ; do  for ac_option ; do
400    
# Line 359  for ac_option ; do Line 419  for ac_option ; do
419          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
420              OPTFILE=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
421                    
422            -adoptfile | --adoptfile | -ad | --ad)
423                ac_prev=AD_OPTFILE ;;
424            -adoptfile=* | --adoptfile=* | -adof=* | --adof=*)
425                AD_OPTFILE=$ac_optarg ;;
426            
427          -pdepend | --pdepend)          -pdepend | --pdepend)
428              ac_prev=PDEPEND ;;              ac_prev=PDEPEND ;;
429          -pdepend=* | --pdepend=*)          -pdepend=* | --pdepend=*)
# Line 404  for ac_option ; do Line 469  for ac_option ; do
469          -enable=* | --enable=*)          -enable=* | --enable=*)
470              ENABLE=$ac_optarg ;;              ENABLE=$ac_optarg ;;
471                    
472            -standarddirs | --standarddirs)
473                ac_prev=STANDARDDIRS ;;
474            -standarddirs=* | --standarddirs=*)
475                STANDARDDIRS=$ac_optarg ;;
476    
477          -noopt | --noopt)          -noopt | --noopt)
478              ac_prev=NOOPT ;;              ac_prev=NOOPT ;;
479          -noopt=* | --noopt=*)          -noopt=* | --noopt=*)
# Line 420  for ac_option ; do Line 490  for ac_option ; do
490              FC=$ac_optarg ;;              FC=$ac_optarg ;;
491                    
492          -ieee | --ieee)          -ieee | --ieee)
493              IEEE=1 ;;              IEEE=true ;;
494          -noieee | --noieee)          -noieee | --noieee)
495              IEEE=0 ;;              IEEE= ;;
496                    
497          -mpi | --mpi)          -mpi | --mpi)
498              MPI=1 ;;              MPI=true ;;
499          -nompi | --nompi)          -nompi | --nompi)
500              MPI=0 ;;              MPI= ;;
501                    
502          -jam | --jam)          -jam | --jam)
503              JAM=1 ;;              JAM=1 ;;
# Line 437  for ac_option ; do Line 507  for ac_option ; do
507          -ds | --ds)          -ds | --ds)
508              DUMPSTATE=t ;;              DUMPSTATE=t ;;
509                    
510            -taf_extra | --taf_extra)
511                ac_prev=TAF_EXTRA ;;
512            -taf_extra=* | --taf_extra=*)
513                TAF_EXTRA=$ac_optarg ;;
514    
515            -tamc_extra | --tamc_extra)
516                ac_prev=TAMC_EXTRA ;;
517            -tamc_extra=* | --tamc_extra=*)
518                TAMC_EXTRA=$ac_optarg ;;
519    
520          -*)          -*)
521              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
522              usage              usage
# Line 451  for ac_option ; do Line 531  for ac_option ; do
531            
532  done  done
533    
534    if test -f ./.genmakerc ; then
535        echo
536        echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\""
537        echo "  file.  This file format is no longer supported.  Please see:"
538        echo
539        echo "    http://mitgcm.org/devel_HOWTO/"
540        echo
541        echo "  for directions on how to setup and use the new \"genmake2\" input"
542        echo "  files and send an email to MITgcm-support@mitgcm.org if you want help."
543        echo
544    fi
545    
546  if test "x${ROOTDIR}" = x ; then  if test "x${ROOTDIR}" = x ; then
547      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
548          ROOTDIR=".."          ROOTDIR=".."
# Line 497  if test "x$OPTFILE" != xNONE ; then Line 589  if test "x$OPTFILE" != xNONE ; then
589              exit 1              exit 1
590          fi          fi
591          if test "x$DUMPSTATE" != xf ; then          if test "x$DUMPSTATE" != xf ; then
592              cp -f $OPTFILE "gm_optfile"              cp -f $OPTFILE "genmake_optfile"
593          fi          fi
594      else      else
595          echo "Error: can't read OPTFILE=\"$OPTFILE\""          echo "Error: can't read OPTFILE=\"$OPTFILE\""
# Line 505  if test "x$OPTFILE" != xNONE ; then Line 597  if test "x$OPTFILE" != xNONE ; then
597      fi      fi
598  fi  fi
599    
600    echo "  getting AD_OPTFILE information:  "
601    if test "x${AD_OPTFILE}" = x ; then
602        if test "x$MITGCM_AD_OF" = x ; then
603            AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default
604        else
605            AD_OPTFILE=$MITGCM_AD_OF
606        fi
607    fi
608    if test "x${AD_OPTFILE}" != xNONE ; then
609        if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then
610            echo "    using AD_OPTFILE=\"$AD_OPTFILE\""
611            source "$AD_OPTFILE"
612            RETVAL=$?
613            if test "x$RETVAL" != x0 ; then
614                echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
615                echo "--please check that variable syntax is bash-compatible"
616                exit 1
617            fi
618            if test "x$DUMPSTATE" != xf ; then
619                cp -f $AD_OPTFILE "genmake_ad_optfile"
620            fi
621        else
622            echo "Error: can't read AD_OPTFILE=\"$AD_OPTFILE\""
623            exit 1
624        fi
625    fi
626    
627  #  Check that FC, LINK, CPP, and S64 are defined.  If not, complain  #  Check that FC, LINK, CPP, and S64 are defined.  If not, complain
628  #  and abort!  #  and abort!
629  if test "x$FC" = x ; then  if test "x$FC" = x ; then
# Line 513  if test "x$FC" = x ; then Line 632  if test "x$FC" = x ; then
632  Error: no Fortran compiler: please specify using one of the following:  Error: no Fortran compiler: please specify using one of the following:
633    1) within the options file ("FC=...") as specified by "-of=OPTFILE"    1) within the options file ("FC=...") as specified by "-of=OPTFILE"
634    2) the "-fc=XXX" command-line option    2) the "-fc=XXX" command-line option
635    3) the "./gm_local" file    3) the "./genmake_local" file
636  EOF  EOF
637      exit 1      exit 1
638  fi  fi
# Line 523  fi Line 642  fi
642  if test "x$CPP" = x ; then  if test "x$CPP" = x ; then
643      CPP="cpp"      CPP="cpp"
644  fi  fi
645  echo "#define A a" | cpp > test_cpp 2>&1  echo "#define A a" | $CPP > test_cpp 2>&1
646  RETVAL=$?  RETVAL=$?
647  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
648      cat <<EOF 1>&2      cat <<EOF 1>&2
# Line 531  if test "x$RETVAL" != x0 ; then Line 650  if test "x$RETVAL" != x0 ; then
650  Error: C pre-processor "$CPP" failed the test case: please specify using:  Error: C pre-processor "$CPP" failed the test case: please specify using:
651    
652    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
653    2) the "./gm_local" file    2) the "./genmake_local" file
654    
655  EOF  EOF
656      exit 1      exit 1
# Line 624  echo "  getting package dependency info Line 743  echo "  getting package dependency info
743  #  Strip the comments and then convert the dependency file into  #  Strip the comments and then convert the dependency file into
744  #  two arrays: PNAME, DNAME  #  two arrays: PNAME, DNAME
745  cat $PDEPEND | sed -e 's/#.*$//g' \  cat $PDEPEND | sed -e 's/#.*$//g' \
746      | 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}' \
747      > ./.pd_tmp      > ./.pd_tmp
748  RETVAL=$?  RETVAL=$?
749  if test ! "x${RETVAL}" = x0 ; then  if test ! "x${RETVAL}" = x0 ; then
# Line 634  fi Line 753  fi
753  source ./.pd_tmp  source ./.pd_tmp
754  rm -f ./.pd_tmp  rm -f ./.pd_tmp
755    
756    #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"
757    #  file should eventually be added so that, for convenience, one can
758    #  specify groups of packages using names like "ocean" and "atmosphere".
759  echo  -n "  checking default package list:  "  echo  -n "  checking default package list:  "
760  if test "x${PDEFAULT}" = x ; then  if test "x${PDEFAULT}" = x ; then
761        for i in "." $MODS ; do
762            if test -r $i"/packages.conf" ; then
763                    PDEFAULT=$i"/packages.conf"
764                    break
765            fi
766        done
767    fi
768    if test "x${PDEFAULT}" = x ; then
769      PDEFAULT="$ROOTDIR/pkg/pkg_default"      PDEFAULT="$ROOTDIR/pkg/pkg_default"
770  fi  fi
771  if test "x${PDEFAULT}" = xNONE ; then  if test "x${PDEFAULT}" = xNONE ; then
# Line 647  else Line 777  else
777      else      else
778          echo "  using PDEFAULT=\"$PDEFAULT\""          echo "  using PDEFAULT=\"$PDEFAULT\""
779          #  Strip the comments and add all the names          #  Strip the comments and add all the names
780          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | awk '(NF>0){print $0}'`          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
781          RETVAL=$?          RETVAL=$?
782          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
783              echo -n "Error: can't parse default package list "              echo -n "Error: can't parse default package list "
# Line 657  else Line 787  else
787          for i in $def ; do          for i in $def ; do
788              PACKAGES="$PACKAGES $i"              PACKAGES="$PACKAGES $i"
789          done          done
790          echo "    packages are:  $PACKAGES"          echo "    before group expansion packages are: $PACKAGES"
791            expand_pkg_groups
792            echo "    after group expansion packages are:  $PACKAGES"
793      fi      fi
794  fi  fi
795    
# Line 767  for i in $PACKAGES ; do Line 899  for i in $PACKAGES ; do
899      if test -d $adr ; then      if test -d $adr ; then
900          SOURCEDIRS="$SOURCEDIRS $adr"          SOURCEDIRS="$SOURCEDIRS $adr"
901          INCLUDEDIRS="$INCLUDEDIRS $adr"          INCLUDEDIRS="$INCLUDEDIRS $adr"
902            if test "x$i" = xautodiff ; then
903                AUTODIFF_PKG_USED=t
904            fi
905      else      else
906          echo "Error: the directory \"$adr\" for package $i doesn't exist"          echo "Error: the directory \"$adr\" for package $i doesn't exist"
907          exit 1          exit 1
# Line 793  done Line 928  done
928  # echo  # echo
929    
930  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
931  PACKAGES_DOT_H=PACKAGES.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
932  if test -e $PACKAGES_DOT_H ; then  cat <<EOF >$PACKAGES_DOT_H".tmp"
     if test ! -e $PACKAGES_DOT_H.bak ; then  
         cp -f $PACKAGES_DOT_H $PACKAGES_DOT_H.bak  
     fi  
     cat $PACKAGES_DOT_H \  
         | awk 'BEGIN{p=1;} ($1=="C===" && $2=="GENMAKE"){p=0;} {if (p==1) print $0}' \  
         > $PACKAGES_DOT_H.tmp  
 fi  
 cat <<EOF >>$PACKAGES_DOT_H.tmp  
933  C=== GENMAKE v2 ===  C=== GENMAKE v2 ===
934  C  The following defines have been set by GENMAKE, so please do not  C  The following defines have been set by GENMAKE, so please do not
935  C  edit anything below these comments.  In general, you should  C  edit anything below these comments.  In general, you should
936  C  add or remove packages by re-running genmake with different  C  add or remove packages by re-running genmake with different
937  C  "-enable" and/or "-disable" options.  C  "-enable" and/or "-disable" options.
938    
939    #ifndef PACKAGES_H
940    #define PACKAGES_H
941    
942  C  Packages disabled by genmake:  C  Packages disabled by genmake:
943  EOF  EOF
944  #  The following UGLY HACK sets multiple "#undef"s and it needs to go  #  The following UGLY HACK sets multiple "#undef"s and it needs to go
# Line 827  for n in $names ; do Line 957  for n in $names ; do
957              fi              fi
958          done          done
959          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
960              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`
961              echo "#undef $undef" >> $PACKAGES_DOT_H.tmp              echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"
962  #           DEFINES="$DEFINES -U$undef"  #           DEFINES="$DEFINES -U$undef"
963    
964  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
# Line 848  for n in $names ; do Line 978  for n in $names ; do
978          fi          fi
979      fi      fi
980  done  done
981  cat <<EOF >>$PACKAGES_DOT_H.tmp  cat <<EOF >>$PACKAGES_DOT_H".tmp"
982    
983  C  Packages enabled by genmake:  C  Packages enabled by genmake:
984  EOF  EOF
985  for i in $PACKAGES ; do  for i in $PACKAGES ; do
986      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`
987      echo "#define $def" >> $PACKAGES_DOT_H.tmp      echo "#define $def" >> $PACKAGES_DOT_H".tmp"
988      DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
989    
990  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
991      case $i in      case $i in
992          aim_v23)          aim_v23)
993              echo "#define   ALLOW_AIM" >> $PACKAGES_DOT_H.tmp              echo "#define   ALLOW_AIM" >> $PACKAGES_DOT_H".tmp"
994              DEFINES="$DEFINES -DALLOW_AIM"              DEFINES="$DEFINES -DALLOW_AIM"
995              echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"              echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)"
996              ;;              ;;
997      esac      esac
998  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!
999    
1000  done  done
1001  mv -f $PACKAGES_DOT_H.tmp $PACKAGES_DOT_H  cat <<EOF >>$PACKAGES_DOT_H".tmp"
1002    
1003    #endif /* PACKAGES_H */
1004    EOF
1005    
1006    if test ! -f $PACKAGES_DOT_H ; then
1007        mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1008    else
1009        cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1010        RETVAL=$?
1011        if test "x$RETVAL" = x0 ; then
1012            rm -f $PACKAGES_DOT_H".tmp"
1013        else
1014            mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak"
1015            mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H
1016        fi
1017    fi
1018    
1019  echo "  Adding STANDARDDIRS"  echo "  Adding STANDARDDIRS"
1020  BUILDDIR=${BUILDDIR:-.}  BUILDDIR=${BUILDDIR:-.}
1021  STANDARDDIRS=${STANDARDDIRS:-"eesupp model"}  if test "x$STANDARDDIRS" = x ; then
1022        STANDARDDIRS="eesupp model"
1023    fi
1024  for d in $STANDARDDIRS ; do  for d in $STANDARDDIRS ; do
1025      adr="$ROOTDIR/$d/src"      adr="$ROOTDIR/$d/src"
1026      if test ! -d $adr ; then      if test ! -d $adr ; then
# Line 892  for d in $STANDARDDIRS ; do Line 1040  for d in $STANDARDDIRS ; do
1040      fi      fi
1041  done  done
1042    
1043  echo "  Searching for CPP_OPTIONS.h (macros and flags for configuring the model):"  echo " Searching for CPP_OPTIONS.h in order to warn about the presence"
1044    echo " of \"#define ALLOW_PKGNAME\"-type statements:"
1045  CPP_OPTIONS=  CPP_OPTIONS=
1046  spaths=". $INCLUDEDIRS"  spaths=". $INCLUDEDIRS"
1047  for i in $spaths ; do  for i in $spaths ; do
# Line 901  for i in $spaths ; do Line 1050  for i in $spaths ; do
1050      if test -f $try -a -r $try ; then      if test -f $try -a -r $try ; then
1051          echo "    found CPP_OPTIONS=\"$try\""          echo "    found CPP_OPTIONS=\"$try\""
1052          CPP_OPTIONS="$try"          CPP_OPTIONS="$try"
 #aja    if test "x$i" != "x." ; then  
 #aja        cp -f $CPP_OPTIONS .  
 #aja    fi  
1053          break          break
1054      fi      fi
1055  done  done
# Line 918  for n in $names ; do Line 1064  for n in $names ; do
1064  done  done
1065    
1066    
1067    #  Here, we build the list of files to be "run through" the adjoint
1068    #  compiler.
1069    if test -f ./ad_files ; then
1070        rm -f ./ad_files
1071    fi
1072    echo "  Creating the list of files for the adjoint compiler."
1073    for i in $SOURCEDIRS ; do
1074        list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
1075        for j in $list_files ; do
1076            cat $i/$j >> ad_files
1077        done
1078    done
1079    
1080    cat <<EOF > adjoint_sed
1081    s/call adopen(/call adopen ( mythid,\\
1082         \&           /g
1083    s/call adclose(/call adclose( mythid,\\
1084         \&           /g
1085    s/call adread(/call adread ( mythid,\\
1086         \&           /g
1087    s/call adwrite(/call adwrite( mythid,\\
1088         \&           /g
1089    
1090    EOF
1091    
1092  echo  echo
1093  echo "===  Creating the Makefile  ==="  echo "===  Creating the Makefile  ==="
1094  echo "  setting INCLUDES"  echo "  setting INCLUDES"
# Line 938  echo -n 'SRCFILES = '    > srclist.inc Line 1109  echo -n 'SRCFILES = '    > srclist.inc
1109  echo -n 'CSRCFILES = '   > csrclist.inc  echo -n 'CSRCFILES = '   > csrclist.inc
1110  echo -n 'F90SRCFILES = ' > f90srclist.inc  echo -n 'F90SRCFILES = ' > f90srclist.inc
1111  echo -n 'HEADERFILES = ' > hlist.inc  echo -n 'HEADERFILES = ' > hlist.inc
1112    echo -n 'AD_FLOW_FILES = ' > ad_flow_files.inc
1113  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
1114  for d in $alldirs ; do  for d in $alldirs ; do
1115      deplist=      deplist=
1116      sfiles=`( cd $d; echo *.[h,c,F] )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
1117      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
1118      for sf in $sfiles ; do      for sf in $sfiles ; do
1119          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
1120              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
1121                  extn=`echo $sf | awk -F '.' '{print $NF}'`                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`
1122                  touch .links.tmp/$sf                  touch .links.tmp/$sf
1123                  deplist="$deplist $sf"                  deplist="$deplist $sf"
1124                  case $extn in                  case $extn in
# Line 966  for d in $alldirs ; do Line 1138  for d in $alldirs ; do
1138                          echo    " \\"  >> hlist.inc                          echo    " \\"  >> hlist.inc
1139                          echo -n " $sf" >> hlist.inc                          echo -n " $sf" >> hlist.inc
1140                          ;;                          ;;
1141                        flow)
1142                            echo    " \\"  >> ad_flow_files.inc
1143                            echo -n " $sf" >> ad_flow_files.inc
1144                            ;;
1145                  esac                  esac
1146              fi              fi
1147          fi          fi
# Line 982  echo "" >> srclist.inc Line 1158  echo "" >> srclist.inc
1158  echo "" >> csrclist.inc  echo "" >> csrclist.inc
1159  echo "" >> f90srclist.inc  echo "" >> f90srclist.inc
1160  echo "" >> hlist.inc  echo "" >> hlist.inc
1161    echo "" >> ad_flow_files.inc
 echo $DEFINES  
1162    
1163  if test -e $MAKEFILE ; then  if test -e $MAKEFILE ; then
1164      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
# Line 1025  EXEDIR      = ${EXEDIR} Line 1200  EXEDIR      = ${EXEDIR}
1200  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
1201  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIR}
1202    
1203    #eh3  new defines for the adjoint work
1204    AUTODIFF    = ${ROOTDIR}/pkg/autodiff
1205    
1206  EOF  EOF
1207    
1208  #  Note: figure out some way to add Hyades JAM libraries here  #  Note: figure out some way to add Hyades JAM libraries here
# Line 1070  MAKEFILE=${MAKEFILE} Line 1248  MAKEFILE=${MAKEFILE}
1248    
1249  EOF  EOF
1250    
1251  cat srclist.inc    >> $MAKEFILE  cat srclist.inc       >> $MAKEFILE
1252  cat csrclist.inc   >> $MAKEFILE  cat csrclist.inc      >> $MAKEFILE
1253  cat f90srclist.inc >> $MAKEFILE  cat f90srclist.inc    >> $MAKEFILE
1254  cat hlist.inc      >> $MAKEFILE  cat hlist.inc         >> $MAKEFILE
1255    cat ad_flow_files.inc >> $MAKEFILE
1256    echo               >> $MAKEFILE
1257  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE  echo 'F77FILES =  $(SRCFILES:.F=.f)'                                           >> $MAKEFILE
1258  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE  echo 'F90FILES =  $(F90SRCFILES:.F90=.f90)'                                    >> $MAKEFILE
1259  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE
1260    
1261  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
1262    rm -f ad_flow_files.inc
1263    
1264  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1265    
# Line 1106  clean: Line 1287  clean:
1287  Clean:  Clean:
1288          @make clean          @make clean
1289          @make cleanlinks          @make cleanlinks
1290          -rm -f Makefile.bak gm_state gm_optfile make.log PACKAGES.h*          -rm -f Makefile.bak genmake_state genmake_optfile make.log
1291  CLEAN:  CLEAN:
1292          @make Clean          @make Clean
1293          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
# Line 1114  CLEAN: Line 1295  CLEAN:
1295          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1296          -rm -f \$(EXECUTABLE) output.txt          -rm -f \$(EXECUTABLE) output.txt
1297    
1298    #eh3 Makefile: makefile
1299  makefile:  makefile:
1300          ${0} $@          ${0} $@
1301  cleanlinks:  cleanlinks:
# Line 1137  cleanlinks: Line 1319  cleanlinks:
1319  .p.f:  .p.f:
1320          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
1321    
1322    #=========================================
1323    #===  Automatic Differentiation Rules  ===
1324    
1325    TAMC           = ${TAMC}
1326    TAF            = ${TAF}
1327    
1328    TAF_EXTRA      = ${TAF_EXTRA}
1329    TAMC_EXTRA     = ${TAMC_EXTRA}
1330    
1331    EOF
1332    
1333    ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS"
1334    ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF_FLAGS"
1335    ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS"
1336    for i in $ad_vars ; do
1337        name=$i
1338        t1="t2=\$"`echo $i`
1339        eval $t1
1340        printf "%-20s = " $name >> $MAKEFILE
1341        echo $t2 >> $MAKEFILE
1342    done
1343    
1344    echo "  Add the source list for AD code generation"
1345    echo >> $MAKEFILE
1346    echo -n "AD_FILES = " >> $MAKEFILE
1347    AD_FILES=`cat ad_files`
1348    for i in $AD_FILES ; do
1349        echo    " \\" >> $MAKEFILE
1350        echo -n " $i" >> $MAKEFILE
1351    done
1352    echo >> $MAKEFILE
1353    
1354    cat >>$MAKEFILE <<EOF
1355    
1356    ad_input_code.f: \$(F77FILES)
1357            @make \$(AD_FLOW_FILES)
1358            cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f
1359    
1360    # ... AD ...
1361    ad_taf_output.f: ad_input_code.f
1362            \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f
1363            cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f
1364    
1365    ad_taf: ad_taf_output.o \$(OBJFILES)
1366            \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
1367    
1368    ad_tamc_output.f: ad_input_code.f
1369            \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f
1370            cat ad_input_code_ad.f | sed -f adjoint_sed > ad_tamc_output.f
1371    
1372    ad_tamc: ad_tamc_output.o \$(OBJFILES)
1373            \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
1374    
1375    
1376    # ... FLT ...
1377    flt_taf_output.f: ad_input_code.f
1378            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f
1379            cat ad_input_code_ad.f | sed -f adjoint_sed > flt_taf_output.f
1380    
1381    flt_taf: flt_taf_output.o \$(OBJFILES)
1382            \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) flt_taf_output.o \$(LIBS)
1383    
1384    flt_tamc_output.f: ad_input_code.f
1385            \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f
1386            cat ad_input_code_ad.f | sed -f adjoint_sed > flt_tamc_output.f
1387    
1388    flt_tamc: flt_tamc_output.o \$(OBJFILES)
1389            \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) flt_tamc_output.o \$(LIBS)
1390    
1391    
1392    # ... SVD ...
1393    svd_taf_output.f: ad_input_code.f
1394            \$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f
1395            cat ad_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f
1396    
1397    svd_taf: svd_taf_output.o \$(OBJFILES)
1398            \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS)
1399    
1400    
1401    #=========================================
1402    
1403  EOF  EOF
1404    
1405  if test "x$EXEHOOK" != x ; then  if test "x$EXEHOOK" != x ; then
# Line 1176  printf "\n===  Done  ===\n" Line 1439  printf "\n===  Done  ===\n"
1439    
1440  #  Write the "state" for future records  #  Write the "state" for future records
1441  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" != xf ; then
1442      echo -n "" > gm_state      echo -n "" > genmake_state
1443      for i in $gm_state ; do      for i in $gm_state ; do
1444          t1="t2=\$$i"          t1="t2=\$$i"
1445          eval $t1          eval $t1
1446          echo "$i='$t2'" >> gm_state          echo "$i='$t2'" >> genmake_state
1447      done      done
1448  fi  fi

Legend:
Removed from v.1.11.2.1  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.22