/[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.176 by jmc, Fri Nov 7 04:34:19 2008 UTC revision 1.185 by jmc, Fri Mar 27 20:18:07 2009 UTC
# Line 1046  INCLUDES="-I. $INCLUDES" Line 1046  INCLUDES="-I. $INCLUDES"
1046  FFLAGS=  FFLAGS=
1047  FOPTIM=  FOPTIM=
1048  FEXTRAFLAGS=  FEXTRAFLAGS=
1049    USE_EXTENDED_SRC=
1050    EXTENDED_SRC_FLAG=
1051  CFLAGS=  CFLAGS=
1052  KFLAGS1=  KFLAGS1=
1053  KFLAGS2=  KFLAGS2=
# Line 1402  if test ! -d ${ROOTDIR} ; then Line 1404  if test ! -d ${ROOTDIR} ; then
1404  fi  fi
1405    
1406  #  Find the MITgcm ${THISVER}  #  Find the MITgcm ${THISVER}
1407  if test -f "${ROOTDIR}/doc/tag-index" ; then  version_file="${ROOTDIR}/doc/tag-index"
1408      THISVER=`grep '^checkpoint' ${ROOTDIR}/doc/tag-index | head -1`  if test -f $version_file ; then
1409        THISVER=`grep '^checkpoint' $version_file | head -1`
1410    #-  remove ./BUILD_INFO.h file if older than version_file
1411        if test -f ./BUILD_INFO.h -a ./BUILD_INFO.h -ot $version_file ; then
1412            echo "  remove ./BUILD_INFO.h (older than ${version_file})"
1413            rm -f ./BUILD_INFO.h
1414        fi
1415  fi  fi
1416    
1417  if test "x$MAKEFILE" = x ; then  if test "x$MAKEFILE" = x ; then
# Line 1640  if test ! "x$GSL" = x ; then Line 1648  if test ! "x$GSL" = x ; then
1648        INCLUDES="$INCLUDES $GSLINC"        INCLUDES="$INCLUDES $GSLINC"
1649        LIBS="$LIBS $GSLLIB"        LIBS="$LIBS $GSLLIB"
1650  fi  fi
1651    #- if USE_EXTENDED_SRC is set, add EXTENDED_SRC_FLAG to FFLAGS :
1652    if test ! "x$USE_EXTENDED_SRC" = x ; then
1653          FFLAGS="$FFLAGS $EXTENDED_SRC_FLAG"
1654          F90FIXEDFORMAT="$F90FIXEDFORMAT $EXTENDED_SRC_FLAG"
1655    fi
1656    
1657  printf "\n===  Checking system libraries  ===\n"  printf "\n===  Checking system libraries  ===\n"
1658  printf "  Do we have the system() command using $FC...  "  printf "  Do we have the system() command using $FC...  "
# Line 1762  fi Line 1775  fi
1775    
1776    
1777  printf "\n===  Setting defaults  ===\n"  printf "\n===  Setting defaults  ===\n"
1778  printf "  Adding MODS directories:  "  printf "  Adding MODS directories: "
1779    MPI_LNKF=
1780  for d in $MODS ; do  for d in $MODS ; do
1781      if test ! -d $d ; then      if test ! -d $d ; then
1782          echo          echo
1783          echo "Error: MODS directory \"$d\" not found!"          echo "Error: MODS directory \"$d\" not found!"
1784          exit 1          exit 1
1785      else      else
1786          printf " $d"          printf "$d "
1787          SOURCEDIRS="$SOURCEDIRS $d"          SOURCEDIRS="$SOURCEDIRS $d"
1788          INCLUDEDIRS="$INCLUDEDIRS $d"          INCLUDEDIRS="$INCLUDEDIRS $d"
1789            #-------------------------------------------------------
1790            # Put special links so that MPI specific files are used
1791            MPI_FILES=`(cd $d ; find . -name "*_mpi" -print)`
1792            for i in $MPI_FILES ; do
1793              ii=`echo $i | sed 's:^\./::'`
1794              name=`echo $ii | sed 's:_mpi::' `
1795              if test "x$MPI" = x ; then
1796              # NO: We undo an _mpi symbolically linked file
1797                if test -L $name ; then
1798                  cmp $name "$d/$ii" > /dev/null 2>&1
1799                  RETVAL=$?
1800                  if test "x$RETVAL" = x0 ; then
1801                    printf "Un-linking $name ; "
1802                    rm -f $name
1803                  fi
1804                fi
1805              else
1806              # YES: We symbolically link this file (with conditions if already there)
1807                if test -L $name ; then
1808                  cmp $d/$ii $name > /dev/null 2>&1
1809                  RETVAL=$?
1810                  xx=`echo $MPI_LNKF | grep -c $name`
1811                  if test "x$RETVAL" != x0 -a $xx == 0 ; then
1812                  # remove sym-link if different and has not just been linked
1813                    printf "Un-link + "
1814                    rm -f $name
1815                  fi
1816                  if test "x$RETVAL" = x0 ; then
1817                  # if identical, keep sym-link and keep record of it
1818                    MPI_LNKF="$MPI_LNKF $name"
1819                  fi
1820                fi
1821                if ! test -f $name ; then
1822                  # make sym-link and keep record of it
1823                    printf "Linking $ii to $name ; "
1824                    ln -s $d/$ii $name
1825                    MPI_LNKF="$MPI_LNKF $name"
1826                fi
1827              fi
1828            done
1829            #-------------------------------------------------------
1830      fi      fi
1831  done  done
1832  echo  echo
# Line 2616  clean: Line 2671  clean:
2671          -rm -rf *.o          -rm -rf *.o
2672          -rm -rf *.$FS *.flowdir          -rm -rf *.$FS *.flowdir
2673          -rm -rf *.f$FS90 *_mod.h *_mod.F90 *.FF90 *.mod-whirl ad_input*          -rm -rf *.f$FS90 *_mod.h *_mod.F90 *.FF90 *.mod-whirl ad_input*
2674          -rm -rf temp.sed reslice.dat          -rm -rf temp.sed
2675  Clean:  Clean:
2676          @make clean          @make clean
2677          @make cleanlinks          @make cleanlinks
# Line 2682  cat >>$MAKEFILE <<EOF Line 2737  cat >>$MAKEFILE <<EOF
2737  # The normal chain of rules is (  .F - .$FS - .o  )  # The normal chain of rules is (  .F - .$FS - .o  )
2738    
2739  ## This nullifies any default implicit rules concerning these two file types:  ## This nullifies any default implicit rules concerning these two file types:
2740  %.o : %.F  ## %.o : %.F
2741    
2742  .F.$FS:  .F.$FS:
2743          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
# Line 2938  timeRatio.c Line 2993  timeRatio.c
2993  f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)  f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)
2994          cat \$^ > \$@          cat \$^ > \$@
2995    
2996  f95_test.f90: all_mods.xb.x2w.w2f.pp.f$FS90 \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90  f95_test.f90: all_mods.xb.x2w.w2f.pp.f$FS90 \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
2997          cat \$^ > \$@          cat \$^ > \$@
2998    
2999  f95_test.out: f95_test_mods.f90 f95_test.f90  f95_test.out: f95_test_mods.f90 f95_test.f90
3000          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
3001          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
3002    
3003  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)  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)
3004    
3005  \$(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)) \$(AD_OBJ_FILES)
3006          @echo Creating \$@ ...          @echo Creating \$@ ...
3007          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES) \$(LIBS)
3008    
3009  # makefile debug rule  # makefile debug rule
3010  openad: ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90  openad: ad_input_code.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
3011  .PHONY: openad  .PHONY: openad
3012    
3013  # create the module files  # create the module files
# Line 2998  ad_input_code_sf.w2f.f$FS90: ad_input_co Line 3053  ad_input_code_sf.w2f.f$FS90: ad_input_co
3053          cat w2f__types.f90 \$(basename \$<).w2f.f > \$@          cat w2f__types.f90 \$(basename \$<).w2f.f > \$@
3054    
3055  # canonicalizer  # canonicalizer
3056  ad_input_code_sf.w2f.canon.f$FS90: ad_input_code_sf.w2f.f$FS90 canon.v1.py  ad_input_code_sf.w2f.pre.f$FS90: ad_input_code_sf.w2f.f$FS90 preProcess.py
3057          python canon.v1.py --r8 \$< > \$@          ./preProcess.py -H -S \$< -o \$@
3058    
3059  # F -> WHIRL  # F -> WHIRL
3060  # note that the canonicalized version cuts off at col 72  # note that the canonicalized version cuts off at col 72
# Line 3007  ad_input_code_sf.w2f.canon.f$FS90: ad_in Line 3062  ad_input_code_sf.w2f.canon.f$FS90: ad_in
3062  # as we are in fixed mode and cut of exactly there.  # as we are in fixed mode and cut of exactly there.
3063  # Otherwise mfef90 patches in spaces to fill up to 72 (or 132)  # Otherwise mfef90 patches in spaces to fill up to 72 (or 132)
3064  # characters respectively.  # characters respectively.
3065  ad_input_code_sf.w2f.canon.B: ad_input_code_sf.w2f.canon.f$FS90 mfef90  ad_input_code_sf.w2f.pre.B: ad_input_code_sf.w2f.pre.f$FS90 mfef90
3066          ./mfef90 -r8 -z -F \$<          ./mfef90 -r8 -z -F \$<
3067          mv \$<.B \$@          mv \$<.B \$@
3068    
3069  # WHIRL -> XAIF  # WHIRL -> XAIF
3070  ad_input_code_sf.w2f.canon.xaif : ad_input_code_sf.w2f.canon.B whirl2xaif  ad_input_code_sf.w2f.pre.xaif : ad_input_code_sf.w2f.pre.B whirl2xaif
3071          ./whirl2xaif -s -n --debug 1 -o \$@ \$<          ./whirl2xaif -s -n --debug 1 -o \$@ \$<
3072    
3073  # XAIF -> XAIF'  # XAIF -> XAIF'
3074  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.pre.xb.xaif : ad_input_code_sf.w2f.pre.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd oadDriver
3075          ./openad_adm -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r          ./oadDriver -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r
3076    
3077  # XAIF' -> WHIRL'  # XAIF' -> WHIRL'
3078  ad_input_code_sf.w2f.canon.xb.x2w.B : ad_input_code_sf.w2f.canon.xb.xaif xaif2whirl  ad_input_code_sf.w2f.pre.xb.x2w.B : ad_input_code_sf.w2f.pre.xb.xaif xaif2whirl
3079          ./xaif2whirl --debug 1 --structured ad_input_code_sf.w2f.canon.B \$<          ./xaif2whirl --debug 1 --structured ad_input_code_sf.w2f.pre.B \$<
3080    
3081  # WHIRL' -> F'  # WHIRL' -> F'
3082  ad_input_code_sf.w2f.canon.xb.x2w.w2f.f$FS90: ad_input_code_sf.w2f.canon.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
3083          ./whirl2f -FLIST:ftn_file=\$@ -openad \$<          ./whirl2f -FLIST:ftn_file=\$@ -openad \$<
3084    
 # undo slice hiding  
3085  # insert template directives  # insert template directives
3086  ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.w2f.f$FS90 reslicer.py ../OAD_support/insertTemplateDir.bash  ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.f$FS90 ../OAD_support/insertTemplateDir.bash
3087          python reslicer.py \$< > \$<.1          ../OAD_support/insertTemplateDir.bash \$< \$@
         ../OAD_support/insertTemplateDir.bash \$<.1  \$@  
         rm \$<.1  
3088    
3089    PPEXTRAS=\$(wildcard ../OAD_support/ad_template.*.F) ../OAD_support/ad_inline.F
3090  # postprocess F'  # postprocess F'
3091  ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.f$FS90 multi-pp.pl ../OAD_support/ad_inline.f \$(wildcard ../OAD_support/ad_template.*.f)  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)
3092          perl multi-pp.pl -inline=../OAD_support/ad_inline.f \$<          perl multi-pp.pl -inline=../OAD_support/ad_inline.f \$<
3093          # the postprocessor still gets the name wrong          # the postprocessor still gets the name wrong
3094          cat \$<.pp | sed 's/RETURN//' > \$@          cat \$<.pp | sed 's/RETURN//' > \$@
3095    
3096  # extract all transformed modules  # extract all transformed modules
3097  all_mods.xb.x2w.w2f.pp.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90  all_mods.xb.x2w.w2f.pp.f$FS90: ad_input_code_sf.w2f.pre.xb.x2w.w2f.td.pp.f$FS90
3098          cat \$< | sed -n '/MODULE /,/END MODULE/p' > \$@          cat \$< | sed -n '/MODULE /,/END MODULE/p' > \$@
3099    
3100  # remove the transformed globals module from the  # remove the transformed globals module from the
3101  # transformed ad_input_code file  # transformed ad_input_code file
3102  # and remove for now the duplicate variables  # and remove for now the duplicate variables
3103  # and fix 2 data statements  # and fix 2 data statements
3104  ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90  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
3105          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' > \$@
3106    
3107  # setup some links  # setup some links
# Line 3068  whirl2xaif xaif2whirl: Line 3121  whirl2xaif xaif2whirl:
3121  %.pl:  %.pl:
3122          \$(LN) \${OPENADFORTTK}/bin/\$@ .          \$(LN) \${OPENADFORTTK}/bin/\$@ .
3123    
3124  %.py:  preProcess.py:
3125          \$(LN) \${OPENADROOT}/OpenADFortTk/tools/canonicalize/\$@ .          \$(LN) \${OPENADFORTTK_BASE}/tools/SourceProcessing/\$@ .
3126    
3127  whirl2f whirl2f_be:  whirl2f whirl2f_be:
3128          \$(LN) \${OPEN64ROOT}/whirl2f/\$@ .          \$(LN) \${OPEN64ROOT}/whirl2f/\$@ .
3129    
3130  openad_adm:  oadDriver:
3131          \$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/test/t \$@          \$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/driver/oadDriver \$@
3132    
3133  # ============ end OpenAD specific section ==============  # ============ end OpenAD specific section ==============
3134    

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

  ViewVC Help
Powered by ViewVC 1.1.22