/[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.276 by jmc, Thu Jan 7 20:21:42 2016 UTC revision 1.279 by jmc, Sat Jan 28 18:37:21 2017 UTC
# Line 32  Usage: "$0" [OPTIONS] Line 32  Usage: "$0" [OPTIONS]
32            "tools/adjoint_options/adjoint_oad" (for OpenAD built) or            "tools/adjoint_options/adjoint_oad" (for OpenAD built) or
33            "tools/adjoint_options/adjoint_default" will be used.            "tools/adjoint_options/adjoint_default" will be used.
34    
35      -nooptfile | --nooptfile      -optfile NAME | --optfile NAME | -of NAME | --of NAME
       -optfile NAME | --optfile NAME | -of NAME | --of NAME  
36        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME        -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME
37            Use "NAME" as the optfile.  By default, an attempt will be            Use "NAME" as the optfile.  By default, an attempt will be
38            made to find an appropriate "standard" optfile in the            made to find an appropriate "standard" optfile in the
# Line 1408  for ac_option in "$@" ; do Line 1407  for ac_option in "$@" ; do
1407          -help | --help | -h | --h)          -help | --help | -h | --h)
1408              usage ;;              usage ;;
1409    
         -nooptfile | --nooptfile)  
             OPTFILE="NONE" ;;  
1410          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
1411              ac_prev=OPTFILE ;;              ac_prev=OPTFILE ;;
1412          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
# Line 1720  if test "x${AD_OPTFILE}" != xNONE ; then Line 1717  if test "x${AD_OPTFILE}" != xNONE ; then
1717  fi  fi
1718    
1719  #====================================================================  #====================================================================
1720    # Initialize INCLUDEDIRSMK from and optfile INCLUDEDIRS
1721    if test "x${INCLUDEDIRS}" != "x" ; then
1722     INCLUDEDIRSMK=${INCLUDEDIRS}
1723    fi
1724    
1725    #====================================================================
1726  #  Set default values if not set by the optfile  #  Set default values if not set by the optfile
1727  #  #
1728  #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,  #  Check that FC, CC, LINK, CPP, S64, LN, and MAKE are defined.  If not,
# Line 1965  fi Line 1968  fi
1968  rm -f genmake_tcomp*  rm -f genmake_tcomp*
1969    
1970  printf "  Do we have the etime() command using $FC... "  printf "  Do we have the etime() command using $FC... "
1971  cat > genmake_tcomp.$FS <<EOF  cat > genmake_tcomp_1.$FS <<EOF
1972          program hello
1973          REAL*4 actual, tarray(2)
1974          EXTERNAL ETIME
1975          REAL*4 ETIME
1976          actual = ETIME( tarray )
1977          print *, tarray
1978          end
1979    EOF
1980    $FC $FFLAGS -o genmake_tcomp_1 genmake_tcomp_1.$FS > genmake_tcomp.log 2>&1
1981    RETVAL=$?
1982    if test "x$RETVAL" = x0 ; then
1983        HAVE_ETIME='Fct'
1984        DEFINES="$DEFINES -DHAVE_ETIME_FCT"
1985        echo " yes (${HAVE_ETIME})"
1986    else
1987      cat > genmake_tcomp_2.$FS <<EOF
1988        program hello        program hello
1989        REAL*4 actual, tarray(2)        REAL*4 actual, tarray(2)
1990        actual = -999.        actual = -999.
# Line 1977  cat > genmake_tcomp.$FS <<EOF Line 1996  cat > genmake_tcomp.$FS <<EOF
1996        endif        endif
1997        end        end
1998  EOF  EOF
1999  $FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1    $FC $FFLAGS -o genmake_tcomp_2 genmake_tcomp_2.$FS >> genmake_tcomp.log 2>&1
2000  RETVAL=$?    RETVAL=$?
2001  if test "x$RETVAL" = x0 ; then    if test "x$RETVAL" = x0 ; then
2002      echo -n 'c,'      echo -n 'c,'
2003      ./genmake_tcomp > genmake_tcomp.out 2>&1      ./genmake_tcomp_2 > genmake_tcomp_2.out 2>&1
2004      RETVAL=$?      RETVAL=$?
2005  fi    fi
2006  if test "x$RETVAL" = x0 ; then    if test "x$RETVAL" = x0 ; then
2007      echo -n 'r:'      echo -n 'r:'
2008      RETVAL=`cat genmake_tcomp.out | $AWK '{print $1}'`      RETVAL=`cat genmake_tcomp_2.out | $AWK '{print $1}'`
2009  fi    fi
2010  if test "x$RETVAL" = x0 ; then    if test "x$RETVAL" = x0 ; then
2011      HAVE_ETIME=t      HAVE_ETIME='SbR'
2012      DEFINES="$DEFINES -DHAVE_ETIME"      DEFINES="$DEFINES -DHAVE_ETIME_SBR"
2013      echo " yes"      echo " yes (${HAVE_ETIME})"
2014  else    else
2015      HAVE_ETIME=      HAVE_ETIME=
2016      echo " no"      echo " no"
2017      fi
2018  fi  fi
2019  #mkdir chk_etime ; cp -p -f genmake_tcomp* chk_etime  #mkdir chk_etime ; cp -p -f genmake_tcomp* chk_etime
2020  rm -f genmake_tcomp*  rm -f genmake_tcomp*
# Line 2091  for d in $MODS ; do Line 2111  for d in $MODS ; do
2111          printf "$d "          printf "$d "
2112          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
2113          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
2114            SOURCEDIRSMK="$SOURCEDIRSMK $d"
2115            INCLUDEDIRSMK="$INCLUDEDIRSMK $d"
2116      fi      fi
2117  done  done
2118  echo  echo
# Line 2114  fi Line 2136  fi
2136    
2137  if test "x${TOOLSDIR}" = x ; then  if test "x${TOOLSDIR}" = x ; then
2138      TOOLSDIR="$ROOTDIR/tools"      TOOLSDIR="$ROOTDIR/tools"
2139        TOOLSDIRMK='$(ROOTDIR)'"/tools"
2140    else
2141        TOOLSDIRMK=${TOOLSDIR}
2142  fi  fi
2143  if test ! -d ${TOOLSDIR} ; then  if test ! -d ${TOOLSDIR} ; then
2144      echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"      echo "Error: the specified TOOLSDIR (\"$TOOLSDIR\") does not exist!"
# Line 2479  if  test "x${PKG_DEPEND}" != x ; then Line 2504  if  test "x${PKG_DEPEND}" != x ; then
2504  fi  fi
2505  for i in $PACKAGES ; do  for i in $PACKAGES ; do
2506      adr="$ROOTDIR/pkg/$i"      adr="$ROOTDIR/pkg/$i"
2507        adrmk='$(ROOTDIR)'"/pkg/$i"
2508      if test -d $adr ; then      if test -d $adr ; then
2509          SOURCEDIRS="$SOURCEDIRS $adr"          SOURCEDIRS="$SOURCEDIRS $adr"
2510          INCLUDEDIRS="$INCLUDEDIRS $adr"          INCLUDEDIRS="$INCLUDEDIRS $adr"
2511            SOURCEDIRSMK="$SOURCEDIRSMK $adrmk"
2512            INCLUDEDIRSMK="$INCLUDEDIRSMK $adrmk"
2513          if test "x$i" = xautodiff ; then          if test "x$i" = xautodiff ; then
2514              AUTODIFF_PKG_USED=t              AUTODIFF_PKG_USED=t
2515          fi          fi
# Line 2537  BUILDDIR=${BUILDDIR:-.} Line 2565  BUILDDIR=${BUILDDIR:-.}
2565  if test "x$STANDARDDIRS" != x ; then  if test "x$STANDARDDIRS" != x ; then
2566      for d in $STANDARDDIRS ; do      for d in $STANDARDDIRS ; do
2567          adr="$ROOTDIR/$d/src"          adr="$ROOTDIR/$d/src"
2568            adrmk='$(ROOTDIR)/'"$d/src"
2569          if test ! -d $adr ; then          if test ! -d $adr ; then
2570              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
2571              echo "  is correct and that you correctly specified the STANDARDDIRS option"              echo "  is correct and that you correctly specified the STANDARDDIRS option"
2572              exit 1              exit 1
2573          else          else
2574              SOURCEDIRS="$SOURCEDIRS $adr"              SOURCEDIRS="$SOURCEDIRS $adr"
2575                SOURCEDIRSMK="$SOURCEDIRSMK $adrmk"
2576          fi          fi
2577          adr="$ROOTDIR/$d/inc"          adr="$ROOTDIR/$d/inc"
2578            adrmk='$(ROOTDIR)/'"$d/inc"
2579          if test ! -d $adr ; then          if test ! -d $adr ; then
2580              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""              echo "Error:  directory $adr not found -- please check that ROOTDIR=\"$ROOTDIR\""
2581              echo "  is correct and that you correctly specified the STANDARDDIRS option"              echo "  is correct and that you correctly specified the STANDARDDIRS option"
2582              exit 1              exit 1
2583          else          else
2584              INCLUDEDIRS="$INCLUDEDIRS $adr"              INCLUDEDIRS="$INCLUDEDIRS $adr"
2585                INCLUDEDIRSMK="$INCLUDEDIRSMK $adrmk"
2586          fi          fi
2587      done      done
2588  fi  fi
# Line 2650  if test "x$OPENAD" != x ; then Line 2682  if test "x$OPENAD" != x ; then
2682      OAD_KEEP_ORIGINAL="/dev/null"      OAD_KEEP_ORIGINAL="/dev/null"
2683      OAD_CB2M_FILES="/dev/null"      OAD_CB2M_FILES="/dev/null"
2684      OADTOOLS="$TOOLSDIR/OAD_support"      OADTOOLS="$TOOLSDIR/OAD_support"
2685        OADTOOLSMK='$(TOOLSDIR)/OAD_support'
2686      echo "  looking for dontCompile file:  "      echo "  looking for dontCompile file:  "
2687      for i in "." $MODS $OADTOOLS ; do      for i in "." $MODS $OADTOOLS ; do
2688          if test -r $i"/dontCompile" ; then          if test -r $i"/dontCompile" ; then
# Line 2694  printf 'F90_SRC_FILES = ' > $TMP.F90srcl Line 2727  printf 'F90_SRC_FILES = ' > $TMP.F90srcl
2727  printf 'H_SRC_FILES = '   > $TMP.hsrclist  printf 'H_SRC_FILES = '   > $TMP.hsrclist
2728  printf 'AD_FLOW_FILES = ' > $TMP.ad_flow_files  printf 'AD_FLOW_FILES = ' > $TMP.ad_flow_files
2729  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2730    alldirsmk=(${SOURCEDIRSMK} ${INCLUDEDIRSMK} ".")
2731    nd=0
2732  for d in $alldirs ; do  for d in $alldirs ; do
2733        dmk=${alldirsmk[${nd}]}
2734        nd=$((${nd}+1))
2735      deplist=      deplist=
2736      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
2737      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
# Line 2797  for d in $alldirs ; do Line 2834  for d in $alldirs ; do
2834      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2835        if test "$d" != "." ; then        if test "$d" != "." ; then
2836          echo "" >> $TMP.srclinks          echo "" >> $TMP.srclinks
2837          echo "#  These files are linked from $d" >> $TMP.srclinks          echo "#  These files are linked from $dmk ( aka $d )" >> $TMP.srclinks
2838          echo "$deplist :" >> $TMP.srclinks          echo "$deplist :" >> $TMP.srclinks
2839  # We need to make sure that the link isn't already there.  # We need to make sure that the link isn't already there.
2840  # This may happen when make thinks that a header file has to be "remade"  # This may happen when make thinks that a header file has to be "remade"
2841  # because a module it depends on has changed.  In this case we do nothing.  # because a module it depends on has changed.  In this case we do nothing.
2842          printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> $TMP.srclinks          printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $dmk >> $TMP.srclinks
2843        fi        fi
2844      fi      fi
2845  done  done
# Line 2859  cat >>$MAKEFILE <<EOF Line 2896  cat >>$MAKEFILE <<EOF
2896    
2897  ROOTDIR     = ${ROOTDIR}  ROOTDIR     = ${ROOTDIR}
2898  BUILDDIR    = ${BUILDDIR}  BUILDDIR    = ${BUILDDIR}
2899  SOURCEDIRS  = ${SOURCEDIRS}  SOURCEDIRS  = ${SOURCEDIRSMK}
2900  INCLUDEDIRS = ${INCLUDEDIRS}  INCLUDEDIRS = ${INCLUDEDIRSMK}
2901  EXEDIR      = ${EXEDIR}  EXEDIR      = ${EXEDIR}
2902  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
2903  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIRMK}
2904  OADTOOLS    = ${OADTOOLS}  OADTOOLS    = ${OADTOOLSMK}
2905    
2906  #eh3  new defines for the adjoint work  #eh3  new defines for the adjoint work
2907  AUTODIFF    = ${ROOTDIR}/pkg/autodiff  AUTODIFF    = \$(ROOTDIR)/pkg/autodiff
2908  EXE_AD      = ${EXE_AD}  EXE_AD      = ${EXE_AD}
2909  EXE_FTL     = ${EXE_FTL}  EXE_FTL     = ${EXE_FTL}
2910  EXE_SVD     = ${EXE_SVD}  EXE_SVD     = ${EXE_SVD}
# Line 2981  depend: Line 3018  depend:
3018    
3019  lib: libmitgcmuv.a  lib: libmitgcmuv.a
3020    
3021  libmitgcmuv.a: \$(OBJFILES)  libmitgcmuv.a: \$(SPECIAL_FILES) \$(OBJFILES)
3022          ar rcv libmitgcmuv.a \$(OBJFILES)          ar rcv libmitgcmuv.a \$(OBJFILES)
3023          ar d   libmitgcmuv.a main.o          ar d   libmitgcmuv.a main.o
3024    
# Line 3457  AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(N Line 3494  AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(N
3494          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)
3495    
3496  # create sources files modules from header files containing common blocks  # create sources files modules from header files containing common blocks
3497  %_mod.FF90 : %.h \${OADTOOLS}/cb2mGetModules.csh \${OADTOOLS}/cb2mGetModules.awk  %_mod.FF90 : %.h \$(OADTOOLS)/cb2mGetModules.csh \$(OADTOOLS)/cb2mGetModules.awk
3498          \${OADTOOLS}/cb2mGetModules.csh $< \${OADTOOLS}/cb2mGetModules.awk          \$(OADTOOLS)/cb2mGetModules.csh $< \$(OADTOOLS)/cb2mGetModules.awk
3499    
3500  # create new header files with USE statements for the new modules made above  # create new header files with USE statements for the new modules made above
3501  %_mod.h : %.h \${OADTOOLS}/cb2mGetHeaders.csh \${OADTOOLS}/cb2mGetHeaders.awk  %_mod.h : %.h \$(OADTOOLS)/cb2mGetHeaders.csh \$(OADTOOLS)/cb2mGetHeaders.awk
3502          \${OADTOOLS}/cb2mGetHeaders.csh $< \${OADTOOLS}/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)          \$(OADTOOLS)/cb2mGetHeaders.csh $< \$(OADTOOLS)/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
3503    
3504  # change the include directives of everybody to refer to  the new header files with the USE statements  # change the include directives of everybody to refer to  the new header files with the USE statements
3505  %_cb2m.FF90 : %.F \${OADTOOLS}/cb2mUseModules.bash  %_cb2m.FF90 : %.F \$(OADTOOLS)/cb2mUseModules.bash
3506          \${OADTOOLS}/cb2mUseModules.bash $< ${MPI}          \$(OADTOOLS)/cb2mUseModules.bash $< ${MPI}
3507    
3508  # makefile debug rule  # makefile debug rule
3509  small_f: \$(CB2M_F90_PP_SRC_FILES)  small_f: \$(CB2M_F90_PP_SRC_FILES)
# Line 3481  ad_input_code_sf.pre.f90 : \$(CB2M_AD_FI Line 3518  ad_input_code_sf.pre.f90 : \$(CB2M_AD_FI
3518    
3519  # replace stop statements (to avoid the implied unstructured control flow)  with print statements  # replace stop statements (to avoid the implied unstructured control flow)  with print statements
3520  ad_input_code_sf.pre.s2p.f90 : ad_input_code_sf.pre.f90  ad_input_code_sf.pre.s2p.f90 : ad_input_code_sf.pre.f90
3521          cat \$< | sed -f \${OADTOOLS}/stop2print.sed > ad_input_code_sf.pre.s2p.f90          cat \$< | sed -f \$(OADTOOLS)/stop2print.sed > ad_input_code_sf.pre.s2p.f90
3522    
3523  # F -> WHIRL  # F -> WHIRL
3524  ad_input_code_sf.pre.s2p.B: ad_input_code_sf.pre.s2p.f90  ad_input_code_sf.pre.s2p.B: ad_input_code_sf.pre.s2p.f90
# Line 3504  ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS Line 3541  ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS
3541          \${OPEN64ROOT}/whirl2f/whirl2f -FLIST:ftn_file=\$@ -openad \$<          \${OPEN64ROOT}/whirl2f/whirl2f -FLIST:ftn_file=\$@ -openad \$<
3542    
3543  # insert template directives  # insert template directives
3544  ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 \${OADTOOLS}/insertTemplateDir.bash  ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 \$(OADTOOLS)/insertTemplateDir.bash
3545          \${OADTOOLS}/insertTemplateDir.bash \$< \$@          \$(OADTOOLS)/insertTemplateDir.bash \$< \$@
3546    
3547  PPEXTRAS=\$(notdir \$(wildcard \${OADTOOLS}/ad_template.*.F)) ad_inline.F  PPEXTRAS=\$(notdir \$(wildcard \$(OADTOOLS)/ad_template.*.F)) ad_inline.F
3548  # postprocess F'  # postprocess F'
3549  postProcess.tag: ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90 \$(PPEXTRAS:.F=.f) | w2f__types.f90  postProcess.tag: ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90 \$(PPEXTRAS:.F=.f) | w2f__types.f90
3550          \${OPENADFORTTK_BASE}/tools/SourceProcessing/postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed --separateOutput --pathSuffix "" --filenameSuffix "_oad" -m r -i ad_inline.f \$<          \${OPENADFORTTK_BASE}/tools/SourceProcessing/postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed --separateOutput --pathSuffix "" --filenameSuffix "_oad" -m r -i ad_inline.f \$<
# Line 3522  OAD_intrinsics_oad.f \$(CB2M_AD_FILES:.f Line 3559  OAD_intrinsics_oad.f \$(CB2M_AD_FILES:.f
3559    
3560  # link the support files:  # link the support files:
3561  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES) \$(PPEXTRAS):  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES) \$(PPEXTRAS):
3562          \$(LN) \${OADTOOLS}/\$@ .          \$(LN) \$(OADTOOLS)/\$@ .
3563    
3564  AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag  AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag
3565    

Legend:
Removed from v.1.276  
changed lines
  Added in v.1.279

  ViewVC Help
Powered by ViewVC 1.1.22