/[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.185 by jmc, Fri Mar 27 20:18:07 2009 UTC revision 1.194 by utke, Tue May 12 08:19:48 2009 UTC
# Line 611  Usage: "$0" [OPTIONS] Line 611  Usage: "$0" [OPTIONS]
611            set to PATH. i.e. Include files from \$PATH/include, link to libraries            set to PATH. i.e. Include files from \$PATH/include, link to libraries
612            from \$PATH/lib and use binaries from \$PATH/bin.            from \$PATH/lib and use binaries from \$PATH/bin.
613    
614        -omp | --omp
615              Activate OpenMP code + use Compiler option OMPFLAG
616        -omp=OMPFLAG | --omp=OMPFLAG
617              Activate OpenMP code + use Compiler option OMPFLAG
618    
619      -es | --es | -embed-source | --embed-source      -es | --es | -embed-source | --embed-source
620            Embed a tarball containing the full source code            Embed a tarball containing the full source code
621            (including the Makefile, etc.) used to build the            (including the Makefile, etc.) used to build the
# Line 1058  NOOPTFILES= Line 1063  NOOPTFILES=
1063  NOOPTFLAGS=  NOOPTFLAGS=
1064  MPI=  MPI=
1065  MPIPATH=  MPIPATH=
1066    OMP=
1067    OMPFLAG=
1068  TS=  TS=
1069  PAPIS=  PAPIS=
1070  PCLS=  PCLS=
# Line 1125  TAMC_EXTRA= Line 1132  TAMC_EXTRA=
1132    
1133  #  The following state can be set directly by command-line switches  #  The following state can be set directly by command-line switches
1134  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"  gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE"
1135  gm_s2="FC CPP IEEE TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI JAM DUMPSTATE STANDARDDIRS"  gm_s2="FC CPP IEEE TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI OMP DUMPSTATE STANDARDDIRS"
1136    
1137  #  The following state is not directly set by command-line switches  #  The following state is not directly set by command-line switches
1138  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 1166  else Line 1173  else
1173  fi  fi
1174    
1175  #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  
1176  #parse_options  #parse_options
1177  ac_prev=  ac_prev=
1178  for ac_option in "$@" ; do  for ac_option in "$@" ; do
# Line 1326  for ac_option in "$@" ; do Line 1324  for ac_option in "$@" ; do
1324              MPIPATH=$ac_optarg              MPIPATH=$ac_optarg
1325              MPI=true ;;              MPI=true ;;
1326                    
1327  #       -jam | --jam)          -omp | --omp)
1328  #           JAM=1 ;;              OMP=true ;;
1329  #       -nojam | --nojam)          -omp=* | --omp=*)
1330  #           JAM=0 ;;              OMPFLAG=$ac_optarg
1331                OMP=true ;;
1332                    
1333          -ds | --ds)          -ds | --ds)
1334              DUMPSTATE=t ;;              DUMPSTATE=t ;;
# Line 1567  if test ! "x$MPI" = x ; then Line 1566  if test ! "x$MPI" = x ; then
1566        echo "  Turning on MPI cpp macros"        echo "  Turning on MPI cpp macros"
1567        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"        DEFINES="$DEFINES -DALLOW_USE_MPI -DALWAYS_USE_MPI"
1568  fi  fi
1569    if test ! "x$OMP" = x ; then
1570          echo "  Add OMPFLAG and turn on OpenMP cpp macros"
1571          FFLAGS="$FFLAGS $OMPFLAG"
1572          F90FLAGS="$F90FLAGS $OMPFLAG"
1573          DEFINES="$DEFINES -DUSE_OMP_THREADING"
1574    fi
1575    
1576  if test ! "x$TS" = x ; then  if test ! "x$TS" = x ; then
1577        echo "  Turning on timing per timestep"        echo "  Turning on timing per timestep"
# Line 1776  fi Line 1781  fi
1781    
1782  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1783  printf "  Adding MODS directories: "  printf "  Adding MODS directories: "
 MPI_LNKF=  
1784  for d in $MODS ; do  for d in $MODS ; do
1785      if test ! -d $d ; then      if test ! -d $d ; then
1786          echo          echo
# Line 1786  for d in $MODS ; do Line 1790  for d in $MODS ; do
1790          printf "$d "          printf "$d "
1791          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1792          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=$?  
               xx=`echo $MPI_LNKF | grep -c $name`  
               if test "x$RETVAL" != x0 -a $xx == 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 -s $d/$ii $name  
                 MPI_LNKF="$MPI_LNKF $name"  
             fi  
           fi  
         done  
         #-------------------------------------------------------  
1793      fi      fi
1794  done  done
1795  echo  echo
# Line 2504  echo "" >> F90srclist.tmp Line 2467  echo "" >> F90srclist.tmp
2467  echo "" >> hsrclist.tmp  echo "" >> hsrclist.tmp
2468  echo "" >> ad_flow_files.tmp  echo "" >> ad_flow_files.tmp
2469    
2470    CMDLINE=$0
2471    for xx in "$@" ; do nw=`echo $xx | wc -w`
2472        if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
2473                            else CMDLINE="$CMDLINE '$xx'" ; fi
2474    done
2475    
2476  if test -f $MAKEFILE ; then  if test -f $MAKEFILE ; then
2477      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
2478  fi  fi
# Line 2513  echo "#    $MACHINE" >> $MAKEFILE Line 2482  echo "#    $MACHINE" >> $MAKEFILE
2482  echo "# This makefile was generated automatically on" >> $MAKEFILE  echo "# This makefile was generated automatically on" >> $MAKEFILE
2483  echo "#    $THISDATE" >> $MAKEFILE  echo "#    $THISDATE" >> $MAKEFILE
2484  echo "# by the command:" >> $MAKEFILE  echo "# by the command:" >> $MAKEFILE
2485  echo "#    $0 $G2ARGS" >> $MAKEFILE  echo "#    $CMDLINE"  >> $MAKEFILE
2486  echo "# executed by:" >> $MAKEFILE  echo "# executed by:" >> $MAKEFILE
2487  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE  echo "#    ${THISUSER}@${THISHOST}:${THISCWD}" >> $MAKEFILE
2488    
# Line 2570  else Line 2539  else
2539      echo "EMBEDDED_FILES = " >>$MAKEFILE      echo "EMBEDDED_FILES = " >>$MAKEFILE
2540  fi  fi
2541    
 #  Note: figure out some way to add Hyades JAM libraries here  
2542  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2543  # Unix ln (link)  # Unix ln (link)
2544  LN = ${LN}  LN = ${LN}
# Line 2670  clean: Line 2638  clean:
2638          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2639          -rm -rf *.o          -rm -rf *.o
2640          -rm -rf *.$FS *.flowdir          -rm -rf *.$FS *.flowdir
2641          -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  
2642  Clean:  Clean:
2643          @make clean          @make clean
2644          @make cleanlinks          @make cleanlinks
# Line 2769  EOF Line 2736  EOF
2736  #===  Automatic Differentiation Rules  ===  #===  Automatic Differentiation Rules  ===
2737  #===  for TAMC/TAF  ======================  #===  for TAMC/TAF  ======================
2738    
2739  if test "x$OPENAD" == x ; then  if test "x$OPENAD" = x ; then
2740    
2741  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2742    
# Line 2810  adall: \$(EXE_AD) Line 2777  adall: \$(EXE_AD)
2777  adtaf: ad_taf_output.$FS  adtaf: ad_taf_output.$FS
2778  adtamc: ad_tamc_output.$FS  adtamc: ad_tamc_output.$FS
2779    
2780  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES)
2781          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template
2782          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h          cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h
2783          -rm -f ad_config.template          -rm -f ad_config.template
# Line 3000  f95_test.out: f95_test_mods.f90 f95_test Line 2967  f95_test.out: f95_test_mods.f90 f95_test
2967          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
2968          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
2969    
2970  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
2971    # postProcessor and its inclusion sets the
2972    # variable POSTPROCESSEDFILES
2973    # used below. Because the file is made during
2974    # make it won't be read until the second (recursive)
2975    # invocation in the rule below
2976    -include postProcess.make
2977    
2978    AD_OBJ_FILES_S1=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) \$(POSTPROCESSEDFILES:.f$FS90=.o)
2979    
2980    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)
2981    
2982    postProcess.comp: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) postProcess.tag \$(AD_OBJ_FILES_S1)
2983    ifeq (\$(MAKELEVEL),0)
2984            \$(MAKE) adAll
2985    else
2986            touch \$@
2987    endif
2988    
2989  \$(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)
2990          @echo Creating \$@ ...  ifeq (\$(MAKELEVEL),1)
2991          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES_S2) \$(LIBS)
2992    else
2993            touch \$@
2994    endif
2995    
2996  # makefile debug rule  # makefile debug rule
2997  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 3034  ad_output.txt: \$(EXE_AD) Line 3021  ad_output.txt: \$(EXE_AD)
3021          @./\$(EXE_AD) > \$@          @./\$(EXE_AD) > \$@
3022    
3023  CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)  CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)
3024  ad_input_code.f$FS90: ../OAD_support/maxMinDefs.f \$(CB2M_AD_FILES)  ad_input_code.f$FS90:  \$(CB2M_AD_FILES)
3025          cat \$^ > \$@          cat \$^ > \$@
3026    
3027  # strip all comments and blanks to reduce  # strip all comments and blanks to reduce
# Line 3088  ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f Line 3075  ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f
3075    
3076  PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F  PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F
3077  # postprocess F'  # postprocess F'
3078  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 multi-pp.pl \$(PPEXTRAS:.F=.f)  postProcess.tag: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90 postProcess.py \$(PPEXTRAS:.F=.f)
3079          perl multi-pp.pl -inline=../OAD_support/ad_inline.f \$<          # the target is a placeholder to signal execution of the rule
3080          # the postprocessor still gets the name wrong          touch \$@
3081          cat \$<.pp | sed 's/RETURN//' > \$@          # this step also creates the file postProcess.make but we cannot
3082            # name it as the target or else make will try to remake it for
3083  # extract all transformed modules          # the include directive above for any rule, e.g. make clean
3084  all_mods.xb.x2w.w2f.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90          ./postProcess.py -m r -i ../OAD_support/ad_inline.f --width 4 \$<
         cat \$< | sed -n '/MODULE /,/END MODULE/p' > \$@  
   
 # 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' > \$@  
3085    
3086  # setup some links  # setup some links
3087  %.xsd:  %.xsd:
# Line 3118  mfef90: Line 3097  mfef90:
3097  whirl2xaif xaif2whirl:  whirl2xaif xaif2whirl:
3098          \$(LN) \${OPENADFORTTK}/bin/\$@ .          \$(LN) \${OPENADFORTTK}/bin/\$@ .
3099    
3100  %.pl:  preProcess.py postProcess.py:
         \$(LN) \${OPENADFORTTK}/bin/\$@ .  
   
 preProcess.py:  
3101          \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ .          \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ .
3102    
3103  whirl2f whirl2f_be:  whirl2f whirl2f_be:
# Line 3130  whirl2f whirl2f_be: Line 3106  whirl2f whirl2f_be:
3106  oadDriver:  oadDriver:
3107          \$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver \$@          \$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver \$@
3108    
3109    AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.make postProcess.tag postProcess.comp
3110    
3111  # ============ end OpenAD specific section ==============  # ============ end OpenAD specific section ==============
3112    
3113  EOF  EOF

Legend:
Removed from v.1.185  
changed lines
  Added in v.1.194

  ViewVC Help
Powered by ViewVC 1.1.22