/[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.14 by edhill, Tue Oct 21 15:29:20 2003 UTC revision 1.35 by edhill, Thu Nov 13 22:03:39 2003 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/sh
2  #  #
3  # $Header$  # $Header$
4  #  #
# 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 103  find_possible_configs()  { Line 104  find_possible_configs()  {
104          CPP="cpp -traditional -P"          CPP="cpp -traditional -P"
105      fi      fi
106    
107        # makedepend is not always available
108        if test "x${MAKEDEPEND}" = x ; then
109          which makedepend >& /dev/null
110          RETVAL=$?
111          if test "x${RETVAL}" = x1 ; then
112             echo "    makedepend was not found. Using xmakedpend instead."
113             MAKEDEPEND='$(TOOLSDIR)/xmakedepend'
114          fi
115        fi
116    
117      # look for possible fortran compilers      # look for possible fortran compilers
118      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"
119      p_FC=      p_FC=
120      for c in $tmp ; do      for c in $tmp ; do
121          rm -f ./hello.f ./hello          rm -f ./hello.f ./hello
# Line 121  EOF Line 132  EOF
132              p_FC="$p_FC $c"              p_FC="$p_FC $c"
133          fi          fi
134      done      done
135        rm -f ./hello.f ./hello
136      if test "x${p_FC}" = x ; then      if test "x${p_FC}" = x ; then
137          cat 1>&2 <<EOF          cat 1>&2 <<EOF
138    
# Line 136  EOF Line 148  EOF
148          echo "  The possible FORTRAN compilers found in your path are:"          echo "  The possible FORTRAN compilers found in your path are:"
149          echo "   "$p_FC          echo "   "$p_FC
150          if test "x$FC" = x ; then          if test "x$FC" = x ; then
151              FC=`echo $p_FC | awk '{print $1}'`              FC=`echo $p_FC | $AWK '{print $1}'`
152          fi          fi
153      fi      fi
154    
# Line 202  get_pdepend_list()  { Line 214  get_pdepend_list()  {
214      #  strip the comments and then convert the dependency file into      #  strip the comments and then convert the dependency file into
215      #  two arrays: PNAME, DNAME      #  two arrays: PNAME, DNAME
216      cat $1 | sed -e 's/#.*$//g' \      cat $1 | sed -e 's/#.*$//g' \
217          | 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} }' \
218          > ./.pd_tmp          > ./.pd_tmp
219      source ./.pd_tmp      . ./.pd_tmp
220      rm -f ./.pd_tmp      rm -f ./.pd_tmp
221    
222      echo -n "PNAME = "${}      echo -n "PNAME = "${}
# Line 262  usage()  { Line 274  usage()  {
274      exit 1      exit 1
275  }  }
276    
277  #eh3 # This is the generic configuration.  #  Build a CPP macro to automate calling C routines from FORTRAN
278  #eh3 set LN         = ( 'ln -s' )  get_fortran_c_namemangling()  {
279  #eh3 set CPP        = ( '/lib/cpp -P' )      default_nm="#define FC_NAMEMANGLE(X) X ## _"
280  #eh3 set S64        = ( '$(TOOLSDIR)/set64bitConst.sh' )      
281  #eh3 set KPP        = (  )      cat > genmake_test.c <<EOF
282  #eh3 set FC         = ( 'f77' )  void tcall( char * string ) { tsub( string ); }
283  #eh3 set LINK       = $FC  EOF
284  #eh3 set MAKEDEPEND = ( 'makedepend' )      $MAKE genmake_test.o > genmake_test.log 2>&1
285  #eh3 set INCLUDES   = ( -I. )      RETVAL=$?
286  #eh3 set FFLAGS     = (  )      if test "x$RETVAL" != x0 ; then
287  #eh3 set FOPTIM     = (  )          cat genmake_test.log >> genmake_errors
288  #eh3 set CFLAGS     = (  )          FC_NAMEMANGLE=$default_nm
289  #eh3 set KFLAGS1    = (  )          echo
290  #eh3 set KFLAGS2    = (  )          echo "WARNING: C test compile fails -- please see \"genmake_errors\""
291  #eh3 set LIBS       = (  )          echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'"
292  #eh3 set KPPFILES   = (  )          echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here."
293  #eh3 if (! $?NOOPTFILES ) set NOOPTFILES = (  )          return 1
294  #eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = (  )      fi
295        c_tcall=`nm genmake_test.o | grep tcall | cut -d ' ' -f 3`
296        RETVAL=$?
297        if test "x$RETVAL" != x0 ; then
298            FC_NAMEMANGLE=$default_nm
299            echo
300            echo "WARNING: The \"nm\" command failed."
301            echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'"
302            echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here."
303            return 1
304        fi
305        cat > genmake_tcomp.f <<EOF
306          subroutine tcall( string )
307          character*(*) string
308          call tsub( string )
309          end
310    EOF
311        $FC $FFLAGS $DEFINES -c genmake_tcomp.f > genmake_tcomp.log 2>&1
312        RETVAL=$?
313        if test "x$RETVAL" != x0 ; then
314            cat genmake_tcomp.log >> genmake_errors
315            FC_NAMEMANGLE=$default_nm
316            echo
317            echo "WARNING: FORTRAN test compile fails -- please see \"genmake_errors\""
318            echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'"
319            echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here."
320            return 1
321        fi
322        f_tcall=`nm genmake_tcomp.o | grep tcall | cut -d ' ' -f 3`
323        RETVAL=$?
324        if test "x$RETVAL" != x0 ; then
325            FC_NAMEMANGLE=$default_nm
326            echo
327            echo "WARNING: The \"nm\" command failed."
328            echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'"
329            echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here."
330            return 1
331        fi
332    
333        c_a=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
334        f_a=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'`
335        c_b=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
336        f_b=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'`
337    
338        nmangle="X"
339        if test "x$c_a" != "x$f_a" ; then
340            comm="echo x$f_a | sed -e 's|x$c_a||'"
341            a=`eval $comm`
342            nmangle="$a ## $nmangle"
343        fi
344        if test "x$c_b" != "x$f_b" ; then
345            comm="echo x$f_b | sed -e 's|x$c_b||'"
346            b=`eval $comm`
347            nmangle="$nmangle ## $b"
348        fi
349    
350        FC_NAMEMANGLE="#define FC_NAMEMANGLE(X)  $nmangle"
351    
352        #  cleanup the testing files
353        rm -f genmake_tcomp.* genmake_test.*
354    }
355    
356  #  Set defaults here  #  Set defaults here
357  COMMANDL="$0 $@"  COMMANDL="$0 $@"
# Line 290  S64= Line 362  S64=
362  KPP=  KPP=
363  FC=  FC=
364  LINK=  LINK=
365  DEFINES="-DWORDLENGTH=4"  # DEFINES="-DWORDLENGTH=4"
366    DEFINES=
367  PACKAGES=  PACKAGES=
368  ENABLE=  ENABLE=
369  DISABLE=  DISABLE=
# Line 311  KPPFILES= Line 384  KPPFILES=
384  NOOPTFILES=  NOOPTFILES=
385  NOOPTFLAGS=  NOOPTFLAGS=
386    
387    # DEFINES checked by test compilation
388    HAVE_SYSTEM=
389    HAVE_FDATE=
390    FC_NAMEMANGLE=
391    
392  MODS=  MODS=
393  TOOLSDIR=  TOOLSDIR=
394  SOURCEDIRS=  SOURCEDIRS=
# Line 319  STANDARDDIRS= Line 397  STANDARDDIRS=
397    
398  PWD=`pwd`  PWD=`pwd`
399  MAKE=make  MAKE=make
400    AWK=awk
401  THISHOSTNAME=`hostname`  THISHOSTNAME=`hostname`
402  THISCWD=`pwd`  THISCWD=`pwd`
403  THISDATE=`date`  THISDATE=`date`
# Line 334  fi Line 413  fi
413    
414  AUTODIFF_PKG_USED=f  AUTODIFF_PKG_USED=f
415  AD_OPTFILE=  AD_OPTFILE=
416    TAF=
417    AD_TAF_FLAGS=
418    FTL_TAF_FLAGS=
419    SVD_TAF_FLAGS=
420    TAF_EXTRA=
421    TAMC=
422    AD_TAMC_FLAGS=
423    FTL_TAF_FLAGS=
424    SVD_TAMC_FLAGS=
425    TAMC_EXTRA=
426    
427    
428  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
429  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT"
# Line 344  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPE Line 434  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPE
434  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"  gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS"
435  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"  gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE"
436  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"  gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF"
437    gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE"
438    
439  #  The following are all related to adjoint/tangent-linear stuff  #  The following are all related to adjoint/tangent-linear stuff
440  gm_s7="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF DIFF_FLAGS AD_TAMC_FLAGS AD_TAF_FLAGS"  gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS"
441  gm_s8="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"  gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS"
442  gm_s9=""  gm_s12="TAF_EXTRA TAMC_EXTRA"
443    
444  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8"  gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7"
445    gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12"
446    
447    
448  echo  echo
# Line 358  echo "===  Processing options files and Line 450  echo "===  Processing options files and
450  gm_local="genmake_local"  gm_local="genmake_local"
451  for i in . $MODS ; do  for i in . $MODS ; do
452      if test -r $i/$gm_local ; then      if test -r $i/$gm_local ; then
453          source $i/$gm_local          . $i/$gm_local
454          break          break
455      fi      fi
456  done  done
457  echo -n "  getting local config information:  "  echo -n "  getting local config information:  "
458  if test -e $gm_local ; then  if test -e $gm_local ; then
459      echo "using $gm_local"      echo "using $gm_local"
460      source $gm_local      . $gm_local
461      # echo "DISABLE=$DISABLE"      # echo "DISABLE=$DISABLE"
462      # echo "ENABLE=$ENABLE"      # echo "ENABLE=$ENABLE"
463  else  else
# Line 495  for ac_option ; do Line 587  for ac_option ; do
587          -ds | --ds)          -ds | --ds)
588              DUMPSTATE=t ;;              DUMPSTATE=t ;;
589                    
590            -taf_extra | --taf_extra)
591                ac_prev=TAF_EXTRA ;;
592            -taf_extra=* | --taf_extra=*)
593                TAF_EXTRA=$ac_optarg ;;
594    
595            -tamc_extra | --tamc_extra)
596                ac_prev=TAMC_EXTRA ;;
597            -tamc_extra=* | --tamc_extra=*)
598                TAMC_EXTRA=$ac_optarg ;;
599    
600          -*)          -*)
601              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
602              usage              usage
# Line 559  fi Line 661  fi
661  if test "x$OPTFILE" != xNONE ; then  if test "x$OPTFILE" != xNONE ; then
662      if test -f "$OPTFILE" -a -r "$OPTFILE" ; then      if test -f "$OPTFILE" -a -r "$OPTFILE" ; then
663          echo "    using OPTFILE=\"$OPTFILE\""          echo "    using OPTFILE=\"$OPTFILE\""
664          source "$OPTFILE"          . "$OPTFILE"
665          RETVAL=$?          RETVAL=$?
666          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
667              echo -n "Error: failed to source OPTFILE \"$OPTFILE\""              echo -n "Error: failed to source OPTFILE \"$OPTFILE\""
# Line 586  fi Line 688  fi
688  if test "x${AD_OPTFILE}" != xNONE ; then  if test "x${AD_OPTFILE}" != xNONE ; then
689      if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then      if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then
690          echo "    using AD_OPTFILE=\"$AD_OPTFILE\""          echo "    using AD_OPTFILE=\"$AD_OPTFILE\""
691          source "$AD_OPTFILE"          . "$AD_OPTFILE"
692          RETVAL=$?          RETVAL=$?
693          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
694              echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""              echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\""
# Line 602  if test "x${AD_OPTFILE}" != xNONE ; then Line 704  if test "x${AD_OPTFILE}" != xNONE ; then
704      fi      fi
705  fi  fi
706    
707  #  Check that FC, LINK, CPP, and S64 are defined.  If not, complain  #  Check that FC, LINK, CPP, S64, and LN are defined.  If not,
708  #  and abort!  #  complain and abort!
709  if test "x$FC" = x ; then  if test "x$FC" = x ; then
710      cat <<EOF 1>&2      cat <<EOF 1>&2
711    
# Line 629  Error: C pre-processor "$CPP" failed the Line 731  Error: C pre-processor "$CPP" failed the
731    
732    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"    1) within the options file ("CPP=...") as specified by "-of=OPTFILE"
733    2) the "./genmake_local" file    2) the "./genmake_local" file
734      3) with the CPP environment variable
735    
736  EOF  EOF
737      exit 1      exit 1
# Line 638  fi Line 741  fi
741  if test "x$MAKEDEPEND" = x ; then  if test "x$MAKEDEPEND" = x ; then
742      MAKEDEPEND=makedepend      MAKEDEPEND=makedepend
743  fi  fi
744    if test "x$LN" = x ; then
745        LN="ln -s"
746    fi
747    echo "test" > genmake_test_ln
748    $LN genmake_test_ln genmake_tlink
749    RETVAL=$?
750    if test "x$RETVAL" != x0 ; then
751        cat <<EOF 1>&2
752    
753    Error: The command "ln -s" failed -- please specify a working soft-link
754      command in the optfile.
755    
756    EOF
757        exit 1
758    fi
759    rm -f genmake_test_ln genmake_tlink
760    
761    printf "\n===  Checking system libraries  ===\n"
762    echo -n "  Do we have the system() command using $FC...  "
763    cat > genmake_tcomp.f <<EOF
764          program hello
765          call system('echo hi')
766          end
767    EOF
768    $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1
769    RETVAL=$?
770    if test "x$RETVAL" = x0 ; then
771        HAVE_SYSTEM=t
772        DEFINES="$DEFINES -DHAVE_SYSTEM"
773        echo "yes"
774    else
775        HAVE_SYSTEM=
776        echo "no"
777    fi
778    rm -f genmake_tcomp*
779    
780    echo -n "  Do we have the fdate() command using $FC...  "
781    cat > genmake_tcomp.f <<EOF
782          program hello
783          CHARACTER(128) string
784          string = ' '
785          call fdate( string )
786          print *, string
787          end
788    EOF
789    $FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1
790    RETVAL=$?
791    if test "x$RETVAL" = x0 ; then
792        HAVE_FDATE=t
793        DEFINES="$DEFINES -DHAVE_FDATE"
794        echo "yes"
795    else
796        HAVE_FDATE=
797        echo "no"
798    fi
799    rm -f genmake_tcomp*
800    
801    echo "  The name mangling convention for $FC is...  "
802    #FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) X ## _"
803    if test "x$FC_NAMEMANGLE" = x ; then
804        get_fortran_c_namemangling
805    fi
806    echo "    '$FC_NAMEMANGLE'"
807    echo "$FC_NAMEMANGLE" > FC_NAMEMANGLE.h.template
808    cmp FC_NAMEMANGLE.h FC_NAMEMANGLE.h.template > /dev/null 2>&1
809    RETVAL=$?
810    if test "x$RETVAL" != x0 ; then
811        mv -f FC_NAMEMANGLE.h.template FC_NAMEMANGLE.h
812    fi
813    
814    
815  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
816  echo -n "  Adding MODS directories:  "  echo -n "  Adding MODS directories:  "
# Line 721  echo "  getting package dependency info Line 894  echo "  getting package dependency info
894  #  Strip the comments and then convert the dependency file into  #  Strip the comments and then convert the dependency file into
895  #  two arrays: PNAME, DNAME  #  two arrays: PNAME, DNAME
896  cat $PDEPEND | sed -e 's/#.*$//g' \  cat $PDEPEND | sed -e 's/#.*$//g' \
897      | 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}' \
898      > ./.pd_tmp      > ./.pd_tmp
899  RETVAL=$?  RETVAL=$?
900  if test ! "x${RETVAL}" = x0 ; then  if test ! "x${RETVAL}" = x0 ; then
901      echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""      echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\""
902      exit 1      exit 1
903  fi  fi
904  source ./.pd_tmp  . ./.pd_tmp
905  rm -f ./.pd_tmp  rm -f ./.pd_tmp
906    
907  #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"  #  Search for default packages.  Note that a "$ROOTDIR/pkg/pkg_groups"
# Line 755  else Line 928  else
928      else      else
929          echo "  using PDEFAULT=\"$PDEFAULT\""          echo "  using PDEFAULT=\"$PDEFAULT\""
930          #  Strip the comments and add all the names          #  Strip the comments and add all the names
931          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | awk '(NF>0){print $0}'`          def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'`
932          RETVAL=$?          RETVAL=$?
933          if test "x${RETVAL}" != x0 ; then          if test "x${RETVAL}" != x0 ; then
934              echo -n "Error: can't parse default package list "              echo -n "Error: can't parse default package list "
# Line 886  for i in $PACKAGES ; do Line 1059  for i in $PACKAGES ; do
1059      fi      fi
1060  done  done
1061    
 #  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  
1062    
1063  # Create a list of #define and #undef to enable/disable packages  # Create a list of #define and #undef to enable/disable packages
1064  PACKAGES_DOT_H=PACKAGES_CONFIG.h  PACKAGES_DOT_H=PACKAGES_CONFIG.h
# Line 935  for n in $names ; do Line 1090  for n in $names ; do
1090              fi              fi
1091          done          done
1092          if test "x$has_pack" = xf ; then          if test "x$has_pack" = xf ; then
1093              undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'`              undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'`
1094              echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"              echo "#undef $undef" >> $PACKAGES_DOT_H".tmp"
 #           DEFINES="$DEFINES -U$undef"  
   
 #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  
             case $n in  
                 mom_fluxform)  
                     DEFINES="$DEFINES -DDISABLE_MOM_FLUXFORM"  
                     ;;  
                 mom_vecinv)  
                     DEFINES="$DEFINES -DDISABLE_MOM_VECINV"  
                     ;;  
                 debug)  
                     DEFINES="$DEFINES -DDISABLE_DEBUGMODE"  
                     ;;  
             esac  
 #EH3  WARNING :  This is an UGLY HACK that needs to be removed!!!  
   
1095          fi          fi
1096      fi      fi
1097  done  done
# Line 961  cat <<EOF >>$PACKAGES_DOT_H".tmp" Line 1100  cat <<EOF >>$PACKAGES_DOT_H".tmp"
1100  C  Packages enabled by genmake:  C  Packages enabled by genmake:
1101  EOF  EOF
1102  for i in $PACKAGES ; do  for i in $PACKAGES ; do
1103      def=`echo "ALLOW_$i" | awk '{print toupper($0)}'`      def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'`
1104      echo "#define $def" >> $PACKAGES_DOT_H".tmp"      echo "#define $def" >> $PACKAGES_DOT_H".tmp"
1105  #eh3 DEFINES="$DEFINES -D$def"  #eh3 DEFINES="$DEFINES -D$def"
1106    
# Line 1018  for d in $STANDARDDIRS ; do Line 1157  for d in $STANDARDDIRS ; do
1157      fi      fi
1158  done  done
1159    
1160  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"
1161  echo " of \"#define ALLOW_PKGNAME\"-type statements:"  echo "    of \"#define ALLOW_PKGNAME\"-type statements:"
1162  CPP_OPTIONS=  CPP_OPTIONS=
1163  spaths=". $INCLUDEDIRS"  spaths=". $INCLUDEDIRS"
1164  for i in $spaths ; do  for i in $spaths ; do
# Line 1096  for d in $alldirs ; do Line 1235  for d in $alldirs ; do
1235      for sf in $sfiles ; do      for sf in $sfiles ; do
1236          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
1237              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
1238                  extn=`echo $sf | awk -F '.' '{print $NF}'`                  extn=`echo $sf | $AWK -F '.' '{print $NF}'`
1239                  touch .links.tmp/$sf                  touch .links.tmp/$sf
1240                  deplist="$deplist $sf"                  deplist="$deplist $sf"
1241                  case $extn in                  case $extn in
# Line 1150  echo "# by the command:" >> $MAKEFILE Line 1289  echo "# by the command:" >> $MAKEFILE
1289  echo "#    $0 $@" >> $MAKEFILE  echo "#    $0 $@" >> $MAKEFILE
1290  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
1291  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE  echo "#    $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE
1292    
1293    EXE_AD=$EXECUTABLE"_ad"
1294    EXE_FTL=$EXECUTABLE"_ftl"
1295    EXE_SVD=$EXECUTABLE"_svd"
1296    
1297  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1298  #  #
1299  # BUILDDIR     : Directory where object files are written  # BUILDDIR     : Directory where object files are written
# Line 1180  TOOLSDIR    = ${TOOLSDIR} Line 1324  TOOLSDIR    = ${TOOLSDIR}
1324    
1325  #eh3  new defines for the adjoint work  #eh3  new defines for the adjoint work
1326  AUTODIFF    = ${ROOTDIR}/pkg/autodiff  AUTODIFF    = ${ROOTDIR}/pkg/autodiff
1327    EXE_AD      = ${EXE_AD}
1328    EXE_FTL     = ${EXE_FTL}
1329    EXE_SVD     = ${EXE_SVD}
1330    
1331  EOF  EOF
1332    
# Line 1261  output.txt: \$(EXECUTABLE) Line 1408  output.txt: \$(EXECUTABLE)
1408          @\$(EXECUTABLE) > \$@          @\$(EXECUTABLE) > \$@
1409    
1410  clean:  clean:
1411            -cat AD_CONFIG.template > AD_CONFIG.h
1412          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl}          -rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl}
1413  Clean:  Clean:
1414          @make clean          @make clean
1415          @make cleanlinks          @make cleanlinks
1416          -rm -f Makefile.bak genmake_state genmake_optfile make.log          -rm -f Makefile.bak genmake_state genmake_*optfile make.log
1417  CLEAN:  CLEAN:
1418          @make Clean          @make Clean
1419          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;          -find \$(EXEDIR) -name "*.meta" -exec rm {} \;
# Line 1273  CLEAN: Line 1421  CLEAN:
1421          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;          -find \$(EXEDIR) -name "fort.*" -exec rm {} \;
1422          -rm -f \$(EXECUTABLE) output.txt          -rm -f \$(EXECUTABLE) output.txt
1423    
1424  Makefile: makefile  #eh3 Makefile: makefile
1425  makefile:  makefile:
1426          ${0} $@          ${0} $@
1427  cleanlinks:  cleanlinks:
# Line 1303  cleanlinks: Line 1451  cleanlinks:
1451  TAMC           = ${TAMC}  TAMC           = ${TAMC}
1452  TAF            = ${TAF}  TAF            = ${TAF}
1453    
1454    TAF_EXTRA      = ${TAF_EXTRA}
1455    TAMC_EXTRA     = ${TAMC_EXTRA}
1456    
1457  EOF  EOF
1458    
1459  ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS"  ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS"
# Line 1325  for i in $AD_FILES ; do Line 1476  for i in $AD_FILES ; do
1476      echo -n " $i" >> $MAKEFILE      echo -n " $i" >> $MAKEFILE
1477  done  done
1478  echo >> $MAKEFILE  echo >> $MAKEFILE
1479    rm -f ad_files
1480    
1481  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
1482    
1483    # ... AD ...
1484  ad_input_code.f: \$(F77FILES)  adall: ad_taf
1485    adtaf: ad_taf_output.f
1486    adtamc: ad_tamc_output.f
1487    
1488    ad_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1489            cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
1490            @make \$(F77FILES)
1491          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
1492          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f
1493    
   
1494  ad_taf_output.f: ad_input_code.f  ad_taf_output.f: ad_input_code.f
1495          \$(TAF) \$(AD_TAF_FLAGS) ad_input_code.f          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f
1496          cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f          cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f
1497    
1498  ad_taf: ad_taf_output.o \$(OBJFILES)  ad_taf: ad_taf_output.o \$(OBJFILES)
1499          \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS)
   
1500    
1501  ad_tamc_output.f: ad_input_code.f  ad_tamc_output.f: ad_input_code.f
1502          \$(TAMC) \$(AD_TAMC_FLAGS) ad_input_code.f          \$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f
1503          cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f          cat ad_input_code_ad.f | sed -f adjoint_sed > ad_tamc_output.f
1504    
1505  ad_tamc: ad_tamc_output.o \$(OBJFILES)  ad_tamc: ad_tamc_output.o \$(OBJFILES)
1506          \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)          \$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS)
1507    
1508    
1509    # ... FTL ...
1510    ftlall: ftl_taf
1511    ftltaf: ftl_taf_output.f
1512    ftltamc: ftl_tamc_output.f
1513    
1514    ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES)
1515            cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
1516            @make \$(F77FILES)
1517            @make \$(AD_FLOW_FILES)
1518            cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f
1519    
1520    ftl_taf_output.f: ftl_input_code.f
1521            \$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f
1522            cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f
1523    
1524  flt_taf_output.f: ad_input_code.f  ftl_taf: ftl_taf_output.o \$(OBJFILES)
1525          \$(TAF) \$(FTL_TAF_FLAGS) ad_input_code.f          \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS)
         cat ad_input_code_ad.f | sed -f adjoint_sed > flt_taf_output.f  
1526    
1527  flt_taf: flt_taf_output.o \$(OBJFILES)  ftl_tamc_output.f: ftl_input_code.f
1528          \$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) flt_taf_output.o \$(LIBS)          \$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f
1529            cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_tamc_output.f
1530    
1531    ftl_tamc: ftl_tamc_output.o \$(OBJFILES)
1532            \$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS)
1533    
1534    
1535    # ... SVD ...
1536    svd: svd_taf
1537    svd_taf_f: svd_taf_output.f
1538    
1539    svd_input_code.f: \$(SRCFILES)
1540            cmp svd_config.template AD_CONFIG.h || cat svd_config.template > AD_CONFIG.h
1541            @make \$(F77FILES)
1542            @make \$(AD_FLOW_FILES)
1543            cat \$(AD_FLOW_FILES) \$(AD_FILES) > svd_input_code.f
1544    
1545    svd_taf_output.f: svd_input_code.f
1546            \$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) svd_input_code.f
1547            cat svd_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f
1548    
1549    svd_taf: svd_taf_output.o \$(OBJFILES)
1550            \$(LINK) -o ${EXE_SVD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS)
1551    
1552    
1553  #=========================================  #=========================================
# Line 1397  printf "\n\n# DO NOT DELETE\n" >> $MAKEF Line 1588  printf "\n\n# DO NOT DELETE\n" >> $MAKEF
1588    
1589  printf "\n===  Done  ===\n"  printf "\n===  Done  ===\n"
1590    
1591    #  Write the "template" files for the adjoint builds
1592    cat >AD_CONFIG.template <<EOF
1593    C  WARNING: This file is automatically generated by genmake2 and
1594    C    used by the Makefile rules.  Please DO NOT EDIT this file
1595    C    unless you are CERTAIN that you know what you are doing.
1596    
1597    #undef ALLOW_ADJOINT_RUN
1598    #undef ALLOW_TANGENTLINEAR_RUN
1599    #undef ALLOW_ECCO_OPTIMIZATION
1600    EOF
1601    cat >ad_config.template <<EOF
1602    C  WARNING: This file is automatically generated by genmake2 and
1603    C    used by the Makefile rules.  Please DO NOT EDIT this file
1604    C    unless you are CERTAIN that you know what you are doing.
1605    
1606    #define ALLOW_ADJOINT_RUN
1607    #undef ALLOW_TANGENTLINEAR_RUN
1608    #undef ALLOW_ECCO_OPTIMIZATION
1609    EOF
1610    cat >ftl_config.template <<EOF
1611    C  WARNING: This file is automatically generated by genmake2 and
1612    C    used by the Makefile rules.  Please DO NOT EDIT this file
1613    C    unless you are CERTAIN that you know what you are doing.
1614    
1615    #undef ALLOW_ADJOINT_RUN
1616    #define ALLOW_TANGENTLINEAR_RUN
1617    #undef ALLOW_ECCO_OPTIMIZATION
1618    EOF
1619    cat >svd_config.template <<EOF
1620    C  WARNING: This file is automatically generated by genmake2 and
1621    C    used by the Makefile rules.  Please DO NOT EDIT this file
1622    C    unless you are CERTAIN that you know what you are doing.
1623    
1624    #undef ALLOW_ADJOINT_RUN
1625    #undef ALLOW_TANGENTLINEAR_RUN
1626    #undef ALLOW_ECCO_OPTIMIZATION
1627    EOF
1628    cp AD_CONFIG.template AD_CONFIG.h
1629    
1630    
1631  #  Write the "state" for future records  #  Write the "state" for future records
1632  if test "x$DUMPSTATE" != xf ; then  if test "x$DUMPSTATE" != xf ; then

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.35

  ViewVC Help
Powered by ViewVC 1.1.22