/[MITgcm]/MITgcm_contrib/heimbach/OpenAD/code_shallow_openad/genmake2
ViewVC logotype

Diff of /MITgcm_contrib/heimbach/OpenAD/code_shallow_openad/genmake2

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2 by utke, Wed Dec 14 19:54:42 2005 UTC revision 1.13 by utke, Thu Apr 12 04:49:21 2007 UTC
# Line 1  Line 1 
1    
2  #! /usr/bin/env bash  #! /usr/bin/env bash
3  #  #
4  # $Header$  # $Header$
# Line 923  EOF Line 924  EOF
924    
925  echo "===  Processing options files and arguments  ==="  echo "===  Processing options files and arguments  ==="
926  gm_local="genmake_local"  gm_local="genmake_local"
927    modsCount=0
928  for i in . $MODS ; do  for i in . $MODS ; do
929      if test -r $i/$gm_local ; then      if test -r $i/$gm_local ; then
930          . $i/$gm_local          . $i/$gm_local
931          break          break
932      fi      fi
933        let modsCount=modsCount+1
934  done  done
935    if test $modsCount -gt 1 ; then
936      echo "ERROR: some uses of MODS break with more than one directory specified"
937      exit -1;
938    fi
939  printf "  getting local config information:  "  printf "  getting local config information:  "
940  if test -f $gm_local ; then  if test -f $gm_local ; then
941      echo "using $gm_local"      echo "using $gm_local"
# Line 1897  for d in $alldirs ; do Line 1904  for d in $alldirs ; do
1904                          basename=${sf%%.F}                          basename=${sf%%.F}
1905                          isAD=`egrep ^$basename.f'[      ]*' adSrcFiles.tmp`                          isAD=`egrep ^$basename.f'[      ]*' adSrcFiles.tmp`
1906                          if test -z "$isAD" ; then                          if test -z "$isAD" ; then
1907                            echo    " \\"  >> nonADF77srclist.tmp                            toBeIgnored=`egrep ^$basename'[      ]*' ${MODS}/dontCompile`
1908                            printf " $sf" >> nonADF77srclist.tmp                            if test -z "$toBeIgnored" ; then
1909                                echo    " \\"  >> nonADF77srclist.tmp
1910                                printf " $sf" >> nonADF77srclist.tmp
1911                              else
1912                                echo "Ignoring $sf"
1913                              fi
1914                          fi                          fi
1915                          ;;                          ;;
1916                      F90)                      F90)
# Line 1928  for d in $alldirs ; do Line 1940  for d in $alldirs ; do
1940  done  done
1941  rm -rf .links.tmp  rm -rf .links.tmp
1942  echo "" >> F77srclist.tmp  echo "" >> F77srclist.tmp
1943    for i in `cat ${MODS}/keepOriginal`
1944    do
1945      echo   " \\" >> nonADF77srclist.tmp
1946      printf " $i" >> nonADF77srclist.tmp
1947    done  
1948  echo "" >> nonADF77srclist.tmp  echo "" >> nonADF77srclist.tmp
1949  echo "" >> csrclist.tmp  echo "" >> csrclist.tmp
1950  echo "" >> F90srclist.tmp  echo "" >> F90srclist.tmp
# Line 2221  EEPARAMS \ Line 2238  EEPARAMS \
2238  PARAMS \  PARAMS \
2239  BAR2 \  BAR2 \
2240  BARRIER \  BARRIER \
 CD_CODE_VARS \  
2241  CG2D \  CG2D \
2242  CG3D \  CG3D \
2243  DFILE \  DFILE \
# Line 2254  grdchk Line 2270  grdchk
2270  .PHONY: adAll  .PHONY: adAll
2271  adAll: \$(EXE_AD)  adAll: \$(EXE_AD)
2272    
 # these are all fixed format:  
 CB2M_F77_TO_FF90_SRC_FILES=\$(F77_SRC_FILES:.F=_cb2m.FF90)  
 CB2M_F90_SRC_FILES=\$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES))  
2273  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))  CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))
2274    
2275  .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.ff90)  .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.ff90)
2276    
2277  .PHONY: adDepend  .PHONY: adDepend
2278  #this file is included at the bottom  adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90)
 adDepend: \$(ALL_LINKED_FILES) \$(CB2M_F90_SRC_FILES) \$(CB2M_F77_TO_FF90_SRC_FILES)  
2279          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
2280          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2281          -rm -f makedepend.out          -rm -f makedepend.out
2282    
   
2283  OPENAD_SUPPORT_F90_SRC_FILES = \  OPENAD_SUPPORT_F90_SRC_FILES = \
2284  w2f__types.f90 \  w2f__types.f90 \
2285  active_module.f90 \  active_module.f90 \
# Line 2278  OpenAD_rev.f90 \ Line 2289  OpenAD_rev.f90 \
2289  OpenAD_tape.f90          OpenAD_tape.f90        
2290    
2291  OPENAD_SUPPORT_C_SRC_FILES = \  OPENAD_SUPPORT_C_SRC_FILES = \
2292  iaddr.c  iaddr.c \
2293    timeRatio.c
2294    
2295    f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES)
2296            cat \$^ > \$@
2297    
2298  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.canon.xb.x2w.w2f.rs.pp.o \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o)  f95_test.f90: all_mods.xb.x2w.w2f.pp.f \$(NON_AD_F77_SRC_FILES:.F=_cb2m.ff90) ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f
2299            cat \$^ > \$@
2300    
2301  \$(EXE_AD): \$(AD_OBJ_FILES)  f95_test.out: f95_test_mods.f90 f95_test.f90
2302            f95 -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1
2303            f95 -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1
2304    
2305    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.canon.xb.x2w.w2f.rs.pp.o \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o)
2306    
2307    \$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(AD_OBJ_FILES)
2308          @echo Creating \$@ ...          @echo Creating \$@ ...
2309          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$^ \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES) \$(LIBS)
2310    
2311  # makefile debug rule  # makefile debug rule
2312  openad: ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f  openad: ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f
2313  .PHONY: openad  .PHONY: openad
2314    
2315  CB2MFILES= cb2m1.csh cb2m1.awk cb2m2.bash  # create the module files
2316  # create the module files and change the header files  %_mod.FF90 : %.h ${MODS}/cb2mGetModules.csh ${MODS}/cb2mGetModules.awk
2317  \$(CB2M_F90_SRC_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) : \$(ALL_LINKED_FILES) \$(CB2MFILES)          ${MODS}/cb2mGetModules.csh $< ${MODS}/cb2mGetModules.awk
2318          ./cb2m1.csh \$(CB2M_F90_SRC_NAMES)  
2319    # create the header files
2320  # change everybody else to use the module files:  %_mod.h : %.h ${MODS}/cb2mGetHeaders.csh ${MODS}/cb2mGetHeaders.awk
2321  \$(CB2M_F77_TO_FF90_SRC_FILES): \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(CB2M_F90_SRC_FILES)          ${MODS}/cb2mGetHeaders.csh $< ${MODS}/cb2mGetHeaders.awk
2322          ./cb2m2.bash  
2323    # change everybody else to use the new module files:
2324    %_cb2m.FF90 : %.F ${MODS}/cb2mUseModules.bash
2325            ${MODS}/cb2mUseModules.bash $<
2326    
2327  # makefile debug rule  # makefile debug rule
2328  small_f: \$(CB2M_F77_PP_SRC_FILES) \$(CB2M_F90_PP_SRC_FILES)  small_f: \$(CB2M_F90_PP_SRC_FILES)
2329  .PHONY: small_f  .PHONY: small_f
2330    
2331  ad_output.txt: \$(EXE_AD)  ad_output.txt: \$(EXE_AD)
# Line 2311  ad_output.txt: \$(EXE_AD) Line 2336  ad_output.txt: \$(EXE_AD)
2336          @./\$(EXE_AD) > \$@          @./\$(EXE_AD) > \$@
2337    
2338  CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.ff90)  CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.ff90)
2339  ad_input_code.$FS: \$(CB2M_AD_FILES)  ad_input_code.$FS: ${MODS}/maxMinDefs.f \$(CB2M_AD_FILES)
2340  #       @$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          cat \$^ > \$@
 #       cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h  
 #       -rm -f ad_config.template  
         cat ../code_ad/maxMinDefs.f \$(CB2M_AD_FILES) > ad_input_code.$FS  
   
 \$(CB2MFILES):  
         \$(LN) \$(addprefix ../code_ad/, \$(CB2MFILES)) .  
2341    
2342  # strip all comments and blanks to reduce  # strip all comments and blanks to reduce
2343  # the file size in order to reduce perl's memory requirements  # the file size in order to reduce perl's memory requirements
2344  ad_input_code_sf.f : ad_input_code.f  ad_input_code_sf.f : ad_input_code.f
2345          cat \$^ | sed -f ../code_ad/strip.sed | sed -f ../code_ad/stop2print.sed > \$@          cat \$^ | sed -f ${MODS}/strip.sed | sed -f ${MODS}/stop2print.sed > \$@
2346    
2347  # mfef90 preprocessing  # mfef90 preprocessing
2348  # expand statement functions  # expand statement functions
# Line 2354  ad_input_code_sf.w2f.canon.xaif : ad_inp Line 2373  ad_input_code_sf.w2f.canon.xaif : ad_inp
2373    
2374  # XAIF -> XAIF'  # XAIF -> XAIF'
2375  ad_input_code_sf.w2f.canon.xb.xaif : ad_input_code_sf.w2f.canon.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd openad_adm  ad_input_code_sf.w2f.canon.xb.xaif : ad_input_code_sf.w2f.canon.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd openad_adm
2376          ./openad_adm -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I          ./openad_adm -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r -p "recip_hFacC recip_rA"
2377    
2378  # XAIF' -> WHIRL'  # XAIF' -> WHIRL'
2379  ad_input_code_sf.w2f.canon.xb.x2w.B : ad_input_code_sf.w2f.canon.xb.xaif xaif2whirl  ad_input_code_sf.w2f.canon.xb.x2w.B : ad_input_code_sf.w2f.canon.xb.xaif xaif2whirl
2380          ./xaif2whirl --structured ad_input_code_sf.w2f.canon.B \$<          ./xaif2whirl --debug 1 --structured ad_input_code_sf.w2f.canon.B \$<
2381    
2382  # WHIRL' -> F'  # WHIRL' -> F'
2383  ad_input_code_sf.w2f.canon.xb.x2w.w2f.f: ad_input_code_sf.w2f.canon.xb.x2w.B whirl2f whirl2f_be  ad_input_code_sf.w2f.canon.xb.x2w.w2f.f: ad_input_code_sf.w2f.canon.xb.x2w.B whirl2f whirl2f_be
# Line 2366  ad_input_code_sf.w2f.canon.xb.x2w.w2f.f: Line 2385  ad_input_code_sf.w2f.canon.xb.x2w.w2f.f:
2385    
2386  # undo slice hiding  # undo slice hiding
2387  # insert template directives  # insert template directives
2388  ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.f: ad_input_code_sf.w2f.canon.xb.x2w.w2f.f reslicer.py ../code_ad/insertTemplateDir.bash  ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.f: ad_input_code_sf.w2f.canon.xb.x2w.w2f.f reslicer.py ${MODS}/insertTemplateDir.bash
2389          python reslicer.py \$< > \$<.1          python reslicer.py \$< > \$<.1
2390          ../code_ad/insertTemplateDir.bash \$<.1  \$@          ${MODS}/insertTemplateDir.bash \$<.1  \$@
2391          rm \$<.1          rm \$<.1
2392    
2393  # postprocess F'  # postprocess F'
2394  ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.f multi-pp.pl ../code_ad/ad_inline.f ../code_ad/ad_template.checkpoint.f ../code_ad/ad_template.plain.f ../code_ad/ad_template.split.f  ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.f multi-pp.pl ${MODS}/ad_inline.f ${MODS}/ad_template.checkpoint.f ${MODS}/ad_template.plain.f ${MODS}/ad_template.split.f ${MODS}/ad_template.sa_cg2d.f
2395          perl multi-pp.pl -inline=../code_ad/ad_inline.f \$<          perl multi-pp.pl -inline=${MODS}/ad_inline.f \$<
2396          cat \$@ | sed 's/RETURN//' > \$@.1          cat \$@ | sed 's/RETURN//' > \$@.1
2397          mv \$@.1 \$@          mv \$@.1 \$@
2398    
# Line 2384  all_mods.xb.x2w.w2f.pp.f: ad_input_code_ Line 2403  all_mods.xb.x2w.w2f.pp.f: ad_input_code_
2403  # remove the transformed globals module from the  # remove the transformed globals module from the
2404  # transformed ad_input_code file  # transformed ad_input_code file
2405  # and remove for now the duplicate variables  # and remove for now the duplicate variables
2406  ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f  # and fix 2 data statements
2407    ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f ${MODS}/fixData.sed
2408    #       cat \$< | sed '/MODULE /,/END MODULE/d' | sed '/^      INTEGER(w2f__i4) DOLOOP_UB/d' | sed -f ${MODS}/fixData.sed > \$@
2409          cat \$< | sed '/MODULE /,/END MODULE/d' | sed '/^      INTEGER(w2f__i4) DOLOOP_UB/d' > \$@          cat \$< | sed '/MODULE /,/END MODULE/d' | sed '/^      INTEGER(w2f__i4) DOLOOP_UB/d' > \$@
2410    
2411  # setup some links  # setup some links
# Line 2396  mfef90: Line 2417  mfef90:
2417    
2418  # link the support files:  # link the support files:
2419  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES) :  \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES) :
2420          \$(LN) ../code_ad/\$@ .          \$(LN) ${MODS}/\$@ .
2421    
2422  whirl2xaif xaif2whirl:  whirl2xaif xaif2whirl:
2423          \$(LN) \${OPENADROOT}/OpenADFortTk/OpenADFortTk-i686-Linux/bin/\$@ .          \$(LN) \${OPENADROOT}/OpenADFortTk/OpenADFortTk-x86-Linux/bin/\$@ .
2424    
2425  %.pl:  %.pl:
2426          \$(LN) \${OPENADROOT}/OpenADFortTk/OpenADFortTk-i686-Linux/bin/\$@ .          \$(LN) \${OPENADROOT}/OpenADFortTk/OpenADFortTk-x86-Linux/bin/\$@ .
2427    
2428  %.py:  %.py:
2429          \$(LN) \${OPENADROOT}/OpenADFortTk/tools/canonicalize/\$@ .          \$(LN) \${OPENADROOT}/OpenADFortTk/tools/canonicalize/\$@ .

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.22