/[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.190 by utke, Wed Apr 22 18:35:00 2009 UTC revision 1.204 by jmc, Wed Mar 10 15:49:54 2010 UTC
# Line 519  Usage: "$0" [OPTIONS] Line 519  Usage: "$0" [OPTIONS]
519        -pdefault=NAME | --pdefault=NAME        -pdefault=NAME | --pdefault=NAME
520            Get the default package list from "NAME".            Get the default package list from "NAME".
521    
522        -bash NAME
523              Explicitly specify the Bourne or BASH shell to use
524    
525      -make NAME | -m NAME      -make NAME | -m NAME
526        --make=NAME | -m=NAME        --make=NAME | -m=NAME
527            Use "NAME" for the MAKE program. The default is "make" but            Use "NAME" for the MAKE program. The default is "make" but
# Line 578  Usage: "$0" [OPTIONS] Line 581  Usage: "$0" [OPTIONS]
581            *only* works if it is supported by the OPTFILE that            *only* works if it is supported by the OPTFILE that
582            is being used.            is being used.
583    
584        -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4
585              Use "real*4" type for _RS variable (#undef REAL4_IS_SLOW)
586              *only* works if CPP_EEOPTIONS.h allows this.
587    
588      -ignoretime | -ignore_time | --ignoretime | --ignore_time      -ignoretime | -ignore_time | --ignoretime | --ignore_time
589            Ignore all the "wall clock" routines entirely.  This will            Ignore all the "wall clock" routines entirely.  This will
590            not in any way hurt the model results -- it simply means            not in any way hurt the model results -- it simply means
# Line 621  Usage: "$0" [OPTIONS] Line 628  Usage: "$0" [OPTIONS]
628            (including the Makefile, etc.) used to build the            (including the Makefile, etc.) used to build the
629            executable [off by default]            executable [off by default]
630    
     -bash NAME  
           Explicitly specify the Bourne or BASH shell to use  
   
631    While it is most often a single word, the "NAME" variables specified    While it is most often a single word, the "NAME" variables specified
632    above can in many cases be a space-delimited string such as:    above can in many cases be a space-delimited string such as:
633    
# Line 635  Usage: "$0" [OPTIONS] Line 639  Usage: "$0" [OPTIONS]
639    
640    For more detailed genmake documentation, please see:    For more detailed genmake documentation, please see:
641    
642      http://mitgcm.org/devel_HOWTO/      http://mitgcm.org/public/devel_HOWTO/
643    
644  EOF  EOF
645    
# Line 1065  MPI= Line 1069  MPI=
1069  MPIPATH=  MPIPATH=
1070  OMP=  OMP=
1071  OMPFLAG=  OMPFLAG=
1072    USE_R4=
1073  TS=  TS=
1074  PAPIS=  PAPIS=
1075  PCLS=  PCLS=
# Line 1132  TAMC_EXTRA= Line 1137  TAMC_EXTRA=
1137    
1138  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1139  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
1140  gm_s2="FC CPP IEEE TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI OMP DUMPSTATE STANDARDDIRS"  gm_s2="FC IEEE USE_R4 TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI OMP DUMPSTATE STANDARDDIRS"
1141    
1142  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1143  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM FEXTRAFLAGS"  gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM FEXTRAFLAGS"
# Line 1173  else Line 1178  else
1178  fi  fi
1179    
1180  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"  #echo "$0::$1:$2:$3:$4:$5:$6:$7:"
 #OPTIONS=  
 #n=0  
 #for i ; do  
 #   echo "$i  $n"  
 #   setvar="OPTIONS[$n]='$i'"  
 #   #  echo "  $setvar"  
 #   eval "$setvar"  
 #   n=$(( $n + 1 ))  
 #done  
1181  #parse_options  #parse_options
1182  ac_prev=  ac_prev=
1183  for ac_option in "$@" ; do  for ac_option in "$@" ; do
# Line 1306  for ac_option in "$@" ; do Line 1302  for ac_option in "$@" ; do
1302          -noieee | --noieee)          -noieee | --noieee)
1303              IEEE= ;;              IEEE= ;;
1304    
1305            -use_real4 | -use_r4 | -ur4 | --use_real4 | --use_r4 | --ur4 )
1306                USE_R4=true ;;
1307    
1308          -ts | --ts)          -ts | --ts)
1309              TS=true ;;              TS=true ;;
1310          -papis | --papis)          -papis | --papis)
# Line 1414  fi Line 1413  fi
1413  #  Find the MITgcm ${THISVER}  #  Find the MITgcm ${THISVER}
1414  version_file="${ROOTDIR}/doc/tag-index"  version_file="${ROOTDIR}/doc/tag-index"
1415  if test -f $version_file ; then  if test -f $version_file ; then
1416      THISVER=`grep '^checkpoint' $version_file | head -1`      THISVER=`$AWK '/^checkpoint/{print $1; exit}' $version_file`
1417  #-  remove ./BUILD_INFO.h file if older than version_file  #-  remove ./BUILD_INFO.h file if older than version_file
1418      if test -f ./BUILD_INFO.h -a ./BUILD_INFO.h -ot $version_file ; then      if test -f ./BUILD_INFO.h -a ./BUILD_INFO.h -ot $version_file ; then
1419          echo "  remove ./BUILD_INFO.h (older than ${version_file})"          echo "  remove ./BUILD_INFO.h (older than ${version_file})"
# Line 1582  if test ! "x$OMP" = x ; then Line 1581  if test ! "x$OMP" = x ; then
1581        DEFINES="$DEFINES -DUSE_OMP_THREADING"        DEFINES="$DEFINES -DUSE_OMP_THREADING"
1582  fi  fi
1583    
1584    if test ! "x$USE_R4" = x ; then
1585          echo "  Turning on LET_RS_BE_REAL4 cpp flag"
1586          DEFINES="$DEFINES -DLET_RS_BE_REAL4"
1587    fi
1588    
1589  if test ! "x$TS" = x ; then  if test ! "x$TS" = x ; then
1590        echo "  Turning on timing per timestep"        echo "  Turning on timing per timestep"
1591        if test ! "x$FOOLAD" = x ; then        if test ! "x$FOOLAD" = x ; then
# Line 1790  fi Line 1794  fi
1794    
1795  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1796  printf "  Adding MODS directories: "  printf "  Adding MODS directories: "
 MPI_LNKF=  
1797  for d in $MODS ; do  for d in $MODS ; do
1798      if test ! -d $d ; then      if test ! -d $d ; then
1799          echo          echo
# Line 1800  for d in $MODS ; do Line 1803  for d in $MODS ; do
1803          printf "$d "          printf "$d "
1804          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1805          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
         #-------------------------------------------------------  
         # Put special links so that MPI specific files are used  
         MPI_FILES=`(cd $d ; find . -name "*_mpi" -print)`  
         for i in $MPI_FILES ; do  
           ii=`echo $i | sed 's:^\./::'`  
           name=`echo $ii | sed 's:_mpi::' `  
           if test "x$MPI" = x ; then  
           # NO: We undo an _mpi symbolically linked file  
             if test -L $name ; then  
               cmp $name "$d/$ii" > /dev/null 2>&1  
               RETVAL=$?  
               if test "x$RETVAL" = x0 ; then  
                 printf "Un-linking $name ; "  
                 rm -f $name  
               fi  
             fi  
           else  
           # YES: We symbolically link this file (with conditions if already there)  
             if test -L $name ; then  
               cmp $d/$ii $name > /dev/null 2>&1  
               RETVAL=$?  
               yy=0 ;  
               for xx in $MPI_LNKF ; do if test $xx = $name ; then yy=1 ; fi ; done  
               if test "x$RETVAL" != x0 -a $yy = 0 ; then  
               # remove sym-link if different and has not just been linked  
                 printf "Un-link + "  
                 rm -f $name  
               fi  
               if test "x$RETVAL" = x0 ; then  
               # if identical, keep sym-link and keep record of it  
                 MPI_LNKF="$MPI_LNKF $name"  
               fi  
             fi  
             if ! test -f $name ; then  
               # make sym-link and keep record of it  
                 printf "Linking $ii to $name ; "  
                 ln -sf $d/$ii $name  
                 MPI_LNKF="$MPI_LNKF $name"  
             fi  
           fi  
         done  
         #-------------------------------------------------------  
1806      fi      fi
1807  done  done
1808  echo  echo
 #echo "MPI_LNKF='$MPI_LNKF'"  
1809    
1810  if test "x${PLATFORM}" = x ; then  if test "x${PLATFORM}" = x ; then
1811      PLATFORM=$p_PLATFORM      PLATFORM=$p_PLATFORM
# Line 2520  echo "" >> F90srclist.tmp Line 2480  echo "" >> F90srclist.tmp
2480  echo "" >> hsrclist.tmp  echo "" >> hsrclist.tmp
2481  echo "" >> ad_flow_files.tmp  echo "" >> ad_flow_files.tmp
2482    
2483    CMDLINE=$0
2484    for xx in "$@" ; do nw=`echo $xx | wc -w`
2485        if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
2486                            else CMDLINE="$CMDLINE '$xx'" ; fi
2487    done
2488    
2489  if test -f $MAKEFILE ; then  if test -f $MAKEFILE ; then
2490      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
2491  fi  fi
# Line 2529  echo "#    $MACHINE" >> $MAKEFILE Line 2495  echo "#    $MACHINE" >> $MAKEFILE
2495  echo "# This makefile was generated automatically on" >> $MAKEFILE  echo "# This makefile was generated automatically on" >> $MAKEFILE
2496  echo "#    $THISDATE" >> $MAKEFILE  echo "#    $THISDATE" >> $MAKEFILE
2497  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2498  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $CMDLINE"  >> $MAKEFILE
2499  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2500  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2501    
# Line 2685  clean: Line 2651  clean:
2651          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2652          -rm -rf *.o          -rm -rf *.o
2653          -rm -rf *.$FS *.flowdir          -rm -rf *.$FS *.flowdir
2654          -rm -rf *.f$FS90 *_mod.h *_mod.F90 *.FF90 *.mod-whirl ad_input*          -rm -rf *.f$FS90 \$(AD_CLEAN) ad_input*
         -rm -rf temp.sed  
2655  Clean:  Clean:
2656          @make clean          @make clean
2657          @make cleanlinks          @make cleanlinks
2658          -rm -f \$(SPECIAL_FILES)          -rm -f \$(SPECIAL_FILES)
2659          -rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log f90mkdepend.log *.bak          -rm -f genmake_state genmake_*optfile genmake_warnings genmake_errors
2660            -rm -f make.log run.log f90mkdepend.log *.bak
2661          -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log          -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log
2662  CLEAN:  CLEAN:
2663          @make Clean          @make Clean
# Line 2831  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC Line 2797  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC
2797          -rm -f ad_config.template          -rm -f ad_config.template
2798          @make \$(F77_PP_SRC_FILES)          @make \$(F77_PP_SRC_FILES)
2799          @make \$(FLOFILES)          @make \$(FLOFILES)
2800          cat \$(FLOFILES) \$(AD_FILES) > ad_input_code.$FS          cat \$(FLOFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS
2801    
2802  ad_taf_output.$FS: ad_input_code.$FS  ad_taf_output.$FS: ad_input_code.$FS
2803          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS          \$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS
# Line 3015  f95_test.out: f95_test_mods.f90 f95_test Line 2981  f95_test.out: f95_test_mods.f90 f95_test
2981          f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1          f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1
2982          f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1          f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1
2983    
2984  AD_OBJ_FILES=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) all_mods.xb.x2w.w2f.pp.o  ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.o \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o)  # the file included below is created by the
2985    # postProcessor and its inclusion sets the
2986    # variable POSTPROCESSEDFILES
2987    # used below. Because the file is made during
2988    # make it won't be read until the second (recursive)
2989    # invocation in the rule below
2990    -include postProcess.make
2991    
2992    AD_OBJ_FILES_S1=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) \$(POSTPROCESSEDFILES:.f$FS90=.o)
2993    
2994    AD_OBJ_FILES_S2=\$(AD_OBJ_FILES_S1) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o)
2995    
2996    postProcess.comp: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.tag \$(AD_OBJ_FILES_S1)
2997    ifeq (\$(MAKELEVEL),0)
2998            \$(MAKE) adAll
2999    else
3000            touch \$@
3001    endif
3002    
3003  \$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(AD_OBJ_FILES)  \$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.comp \$(AD_OBJ_FILES_S2)
3004          @echo Creating \$@ ...  ifeq (\$(MAKELEVEL),1)
3005          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)
3006    else
3007            touch \$@
3008    endif
3009    
3010  # makefile debug rule  # makefile debug rule
3011  openad: ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90  openad: ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
# Line 3049  ad_output.txt: \$(EXE_AD) Line 3035  ad_output.txt: \$(EXE_AD)
3035          @./\$(EXE_AD) > \$@          @./\$(EXE_AD) > \$@
3036    
3037  CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)  CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)
3038  ad_input_code.f$FS90: ../OAD_support/maxMinDefs.f \$(CB2M_AD_FILES)  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3039          cat \$^ > \$@          cat \$^ > \$@
3040    
3041  # strip all comments and blanks to reduce  # strip all comments and blanks to reduce
# Line 3069  ad_input_code_sf.w2f.f$FS90: ad_input_co Line 3055  ad_input_code_sf.w2f.f$FS90: ad_input_co
3055    
3056  # canonicalizer  # canonicalizer
3057  ad_input_code_sf.w2f.pre.f$FS90: ad_input_code_sf.w2f.f$FS90 preProcess.py  ad_input_code_sf.w2f.pre.f$FS90: ad_input_code_sf.w2f.f$FS90 preProcess.py
3058          ./preProcess.py -H -S \$< -o \$@          ./preProcess.py --timing --r8 -H -S \$< -o \$@
3059    
3060  # F -> WHIRL  # F -> WHIRL
3061  # note that the canonicalized version cuts off at col 72  # note that the canonicalized version cuts off at col 72
# Line 3091  ad_input_code_sf.w2f.pre.xb.xaif : ad_in Line 3077  ad_input_code_sf.w2f.pre.xb.xaif : ad_in
3077    
3078  # XAIF' -> WHIRL'  # XAIF' -> WHIRL'
3079  ad_input_code_sf.w2f.pre.xb.x2w.B : ad_input_code_sf.w2f.pre.xb.xaif xaif2whirl  ad_input_code_sf.w2f.pre.xb.x2w.B : ad_input_code_sf.w2f.pre.xb.xaif xaif2whirl
3080          ./xaif2whirl --debug 1 --structured ad_input_code_sf.w2f.pre.B \$<          ./xaif2whirl --debug 1 ad_input_code_sf.w2f.pre.B \$<
3081    
3082  # WHIRL' -> F'  # WHIRL' -> F'
3083  ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.B whirl2f whirl2f_be  ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.B whirl2f whirl2f_be
# Line 3103  ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f Line 3089  ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f
3089    
3090  PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F  PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F
3091  # postprocess F'  # postprocess F'
3092  ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 postProcess.py \$(PPEXTRAS:.F=.f)  postProcess.tag: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 postProcess.py \$(PPEXTRAS:.F=.f)
3093          ./postProcess.py -m r -i ../OAD_support/ad_inline.f -o \$@ \$<          # the target is a placeholder to signal execution of the rule
3094            touch \$@
3095  # extract all transformed modules          # this step also creates the file postProcess.make but we cannot
3096  all_mods.xb.x2w.w2f.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90          # name it as the target or else make will try to remake it for
3097          cat \$< | sed -n '/MODULE /,/END MODULE/p' > \$@          # the include directive above for any rule, e.g. make clean
3098            ./postProcess.py --progress --timing --outputFormat=fixed -m r -i ../OAD_support/ad_inline.f --width 4 \$<
 # remove the transformed globals module from the  
 # transformed ad_input_code file  
 # and remove for now the duplicate variables  
 # and fix 2 data statements  
 ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90  
         cat \$< | sed '/MODULE /,/END MODULE/d' | sed '/^      INTEGER(w2f__i4) DOLOOP_UB/d' > \$@  
3099    
3100  # setup some links  # setup some links
3101  %.xsd:  %.xsd:
# Line 3140  whirl2f whirl2f_be: Line 3120  whirl2f whirl2f_be:
3120  oadDriver:  oadDriver:
3121          \$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver \$@          \$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver \$@
3122    
3123    AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.make postProcess.tag postProcess.comp \$(PPEXTRAS:.F=.f)
3124    
3125  # ============ end OpenAD specific section ==============  # ============ end OpenAD specific section ==============
3126    
3127  EOF  EOF

Legend:
Removed from v.1.190  
changed lines
  Added in v.1.204

  ViewVC Help
Powered by ViewVC 1.1.22