/[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.173 by jmc, Sun Jul 20 18:01:05 2008 UTC revision 1.174 by cnh, Thu Nov 6 03:55:50 2008 UTC
# Line 2216  fi Line 2216  fi
2216    
2217  #  Here, we build the list of files to be "run through" the adjoint  #  Here, we build the list of files to be "run through" the adjoint
2218  #  compiler.  #  compiler.
2219  if test -f ./ad_files ; then  if test -f ./adSrcFiles.tmp ; then
2220      rm -f ./ad_files      rm -f ./adSrcFiles.tmp
2221  fi  fi
2222  echo "  Creating the list of files for the adjoint compiler."  echo "  Creating the list of files for the adjoint compiler."
2223  for i in $SOURCEDIRS ; do  for i in $SOURCEDIRS ; do
2224      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`      list_files=`( cd $i && ls -1 *.list 2>/dev/null )`
2225      for j in $list_files ; do      for j in $list_files ; do
2226          cat $i/$j >> ad_files          cat $i/$j >> adSrcFiles.tmp
2227      done      done
2228  done  done
2229  if test ! "x"$FS = "x.f" ; then  if test ! "x"$FS = "x.f" ; then
2230      cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f      cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f
2231      mv -f ad_files_f ad_files      mv -f adSrcFiles.tmp_f adSrcFiles.tmp
2232  fi  fi
2233    
2234  echo  echo
# Line 2286  if test ! -r ".links.tmp/foo" ; then Line 2286  if test ! -r ".links.tmp/foo" ; then
2286      exit 1      exit 1
2287  fi  fi
2288  rm -f .links.tmp/foo  rm -f .links.tmp/foo
2289    
2290    if test "x$OPENAD" != x ; then
2291        OAD_DONT_COMPILE="/dev/null"
2292        OAD_DONT_TRANSFORM="/dev/null"
2293        OAD_KEEP_ORIGINAL="/dev/null"
2294        OAD_CB2M_FILES="/dev/null"
2295        echo "  looking for dontCompile file:  "
2296        for i in "." $MODS ; do
2297            if test -r $i"/dontCompile" ; then
2298                OAD_DONT_COMPILE=$i"/dontCompile"
2299                echo "     found $OAD_DONT_COMPILE"
2300                break
2301            fi
2302        done
2303        echo "  looking for dontTransform file:  "
2304        for i in "." $MODS ; do
2305            if test -r $i"/dontTransform" ; then
2306                OAD_DONT_TRANSFORM=$i"/dontTransform"
2307                echo "     found $OAD_DONT_TRANSFORM"
2308                break
2309            fi
2310        done
2311        echo "  looking for keepOriginal file:  "
2312        for i in "." $MODS ; do
2313            if test -r $i"/keepOriginal" ; then
2314                OAD_KEEP_ORIGINAL=$i"/keepOriginal"
2315                echo "     found $OAD_KEEP_ORIGINAL"
2316                break
2317            fi
2318        done
2319        echo "  looking for cb2mFiles:  "
2320        for i in "." $MODS ; do
2321            if test -r $i"/cb2mFiles" ; then
2322                OAD_CB2M_FILES=$i"/cb2mFiles"
2323                echo "     found $OAD_CB2M_FILES"
2324                break
2325            fi
2326        done
2327        echo "   OpenAD exceptions:  "
2328    fi
2329    
2330  echo "# This section creates symbolic links" > srclinks.tmp  echo "# This section creates symbolic links" > srclinks.tmp
2331  echo "" >> srclinks.tmp  echo "" >> srclinks.tmp
2332  printf 'SRCFILES = '    > srclist.inc  printf 'F77_SRC_FILES = ' > F77srclist.tmp
2333  printf 'CSRCFILES = '   > csrclist.inc  printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp
2334  printf 'F90SRCFILES = ' > f90srclist.inc  printf 'C_SRC_FILES = '   > csrclist.tmp
2335  printf 'HEADERFILES = ' > hlist.inc  printf 'F90_SRC_FILES = ' > F90srclist.tmp
2336  printf 'AD_FLOW_FILES = ' > ad_flow_files.inc  printf 'H_SRC_FILES = '   > hsrclist.tmp
2337    printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp
2338  alldirs="$SOURCEDIRS $INCLUDEDIRS ."  alldirs="$SOURCEDIRS $INCLUDEDIRS ."
2339  for d in $alldirs ; do  for d in $alldirs ; do
2340      deplist=      deplist=
2341      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`      sfiles=`( cd $d; echo *.[h,c,F] *.flow )`
2342      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`      sfiles=`( echo $sfiles; cd $d; echo *.F90 )`
2343        if test "x$OPENAD" != x ; then
2344            sfiles=`( echo $sfiles | grep -v _cb2m\. )`
2345        fi
2346      for sf in $sfiles ; do      for sf in $sfiles ; do
2347          if test ! -r ".links.tmp/$sf" ; then          if test ! -r ".links.tmp/$sf" ; then
2348              if test -f "$d/$sf" ; then              if test -f "$d/$sf" ; then
# Line 2332  for d in $alldirs ; do Line 2377  for d in $alldirs ; do
2377                  if test "x$ignore_f" = xf ; then                  if test "x$ignore_f" = xf ; then
2378                      extn=`echo $sf | $AWK -F. '{print $NF}'`                      extn=`echo $sf | $AWK -F. '{print $NF}'`
2379                      case $extn in                      case $extn in
2380                          F)                        F)
2381                              echo    " \\"  >> srclist.inc                          echo    " \\"  >> F77srclist.tmp
2382                              printf " $sf" >> srclist.inc                          printf " $sf" >> F77srclist.tmp
2383                              ;;                          if test "x$OPENAD" != x ; then
2384                          F90)                              basename=${sf%%.F}
2385                              echo    " \\"  >> f90srclist.inc                              isAD=`egrep ^$basename.f'[  ]*' adSrcFiles.tmp`
2386                              printf " $sf" >> f90srclist.inc                              if test -z "$isAD" ; then
2387                              ;;                                  toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE}`
2388                          c)                                  if test -z "$toBeIgnored" ; then
2389                              echo    " \\"  >> csrclist.inc                                      echo    " \\"  >> nonADF77srclist.tmp
2390                              printf " $sf" >> csrclist.inc                                      printf " $sf" >> nonADF77srclist.tmp
2391                              ;;                                  else
2392                          h)                                      echo "    not to be compiled   :  $sf"
2393                              echo    " \\"  >> hlist.inc                                  fi
2394                              printf " $sf" >> hlist.inc                              else # file is initially listed as an AD file we want to exclude it
2395                              ;;                                   # or we want to retain the untransformed version
2396                          flow)                                  notToBeTransformed=`egrep ^$basename'[      ]*' ${OAD_DONT_TRANSFORM}`
2397                              echo    " \\"  >> ad_flow_files.inc                                  untransformedVersionToBeKept=`egrep ^$basename'[      ]*' ${OAD_KEEP_ORIGINAL}`
2398                              printf " $sf" >> ad_flow_files.inc                                  if test -n "$notToBeTransformed"; then
2399                              ;;                                      echo "    not to be transformed:  $sf"
2400                      esac                                  fi
2401                  fi                                  if test -n "$untransformedVersionToBeKept" ; then
2402                                        echo "    original to be kept  :  $sf"
2403                                    fi    
2404                                    if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then
2405                                        echo    " \\"  >> nonADF77srclist.tmp
2406                                        printf " $sf" >> nonADF77srclist.tmp
2407                                    fi
2408                                fi
2409                            fi
2410                            ;;
2411                        F90)
2412                            echo    " \\"  >> F90srclist.tmp
2413                            printf " $sf" >> F90srclist.tmp
2414                            ;;
2415                        c)
2416                            echo    " \\"  >> csrclist.tmp
2417                            printf " $sf" >> csrclist.tmp
2418                            ;;
2419                        h)
2420                            echo    " \\"  >> hsrclist.tmp
2421                            printf " $sf" >> hsrclist.tmp
2422                            ;;
2423                        flow)
2424                            echo    " \\"  >> ad_flow_files.tmp
2425                            printf " $sf" >> ad_flow_files.tmp
2426                            ;;
2427                       esac
2428                    fi
2429              fi              fi
2430          fi          fi
2431      done      done
2432      if test "x$deplist" != x ; then      if test "x$deplist" != x ; then
2433          echo "" >> srclinks.tmp        if test "$d" != "." ; then
2434            echo "" >> srclinks.tmp
2435          echo "#  These files are linked from $d" >> srclinks.tmp          echo "#  These files are linked from $d" >> srclinks.tmp
2436          echo "$deplist :" >> srclinks.tmp          echo "$deplist :" >> srclinks.tmp
2437  # We need to make sure that the link isn't already there.  # We need to make sure that the link isn't already there.
2438  # 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"
2439  # 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.
2440          printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp          printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp
2441          fi
2442      fi      fi
2443  done  done
2444  rm -rf .links.tmp  rm -rf .links.tmp
2445  echo "" >> srclist.inc  echo "" >> F77srclist.tmp
2446  echo "" >> csrclist.inc  echo "" >> nonADF77srclist.tmp
2447  echo "" >> f90srclist.inc  echo "" >> csrclist.tmp
2448  echo "" >> hlist.inc  echo "" >> F90srclist.tmp
2449  echo "" >> ad_flow_files.inc  echo "" >> hsrclist.tmp
2450    echo "" >> ad_flow_files.tmp
2451    
2452  if test -f $MAKEFILE ; then  if test -f $MAKEFILE ; then
2453      mv -f $MAKEFILE "$MAKEFILE.bak"      mv -f $MAKEFILE "$MAKEFILE.bak"
# Line 2472  FOPTIM = ${FOPTIM} Line 2547  FOPTIM = ${FOPTIM}
2547  # Optim./debug for FC  # Optim./debug for FC
2548  F90FLAGS = ${F90FLAGS}  F90FLAGS = ${F90FLAGS}
2549  F90OPTIM = ${F90OPTIM}  F90OPTIM = ${F90OPTIM}
2550    F90FIXEDFORMAT = ${F90FIXEDFORMAT}
2551  # Flags for CC  # Flags for CC
2552  CFLAGS = ${CFLAGS}  CFLAGS = ${CFLAGS}
2553  # Files that should not be optimized  # Files that should not be optimized
# Line 2484  MAKEFILE=${MAKEFILE} Line 2560  MAKEFILE=${MAKEFILE}
2560    
2561  EOF  EOF
2562    
2563  cat srclist.inc       >> $MAKEFILE  cat F77srclist.tmp      >> $MAKEFILE
2564  cat csrclist.inc      >> $MAKEFILE  cat nonADF77srclist.tmp >> $MAKEFILE
2565  cat f90srclist.inc    >> $MAKEFILE  cat csrclist.tmp        >> $MAKEFILE
2566  cat hlist.inc         >> $MAKEFILE  cat F90srclist.tmp      >> $MAKEFILE
2567  cat ad_flow_files.inc >> $MAKEFILE  cat hsrclist.tmp        >> $MAKEFILE
2568    cat ad_flow_files.tmp   >> $MAKEFILE
2569    
2570    rm -f F77srclist.tmp nonADF77srclist.tmp csrclist.tmp F90srclist.tmp hsrclist.tmp ad_flow_files.tmp
2571    
2572  echo >> $MAKEFILE  echo >> $MAKEFILE
2573  echo 'F77FILES =  $(SRCFILES:.F=.'$FS')'      >> $MAKEFILE  
2574  echo 'F90FILES =  $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE  # add definitions for preprocessed sources
2575  echo 'OBJFILES =  $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE  # and note that not all systems allow case sensitive extensions
2576    # hence the $FS and $FS90 here.
2577    # for fixed format f90 files we use ff90 or FF90 resp
2578    # but these are not expected to be the original source files
2579    
2580    echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')'      >> $MAKEFILE
2581    echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE
2582    echo 'OBJFILES= $(F77_SRC_FILES:.F=.o) $(C_SRC_FILES:.c=.o) $(F90_SRC_FILES:.F90=.o)' >> $MAKEFILE
2583  echo 'FLOFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE  echo 'FLOFILES =  $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE
2584  echo >> $MAKEFILE  echo >> $MAKEFILE
2585  echo '.SUFFIXES:' >> $MAKEFILE  echo '.SUFFIXES:' >> $MAKEFILE
2586  echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90 .flowdir .flow' >> $MAKEFILE  echo '.SUFFIXES: .o .'$FS' .p .F .c .f'$FS90' .'$FS90' .FF90 .F90 .flowdir .flow' >> $MAKEFILE
 rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc  
 rm -f ad_flow_files.inc  
2587    
2588  cat >>$MAKEFILE <<EOF  cat >>$MAKEFILE <<EOF
2589    
2590  all: \$(EXECUTABLE)  all: \$(EXECUTABLE)
2591  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES) \$(EMBEDDED_FILES)  \$(EXECUTABLE): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(EMBEDDED_FILES)
2592          @echo Creating \$@ ...          @echo Creating \$@ ...
2593          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)          \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
2594  depend:  depend:
2595          @make links          @make links
2596          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES)          \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
2597          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)          \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2598          -rm -f makedepend.out          -rm -f makedepend.out
2599    
# Line 2518  libmitgcmuv.a: \$(OBJFILES) Line 2603  libmitgcmuv.a: \$(OBJFILES)
2603          ar rcv libmitgcmuv.a \$(OBJFILES)          ar rcv libmitgcmuv.a \$(OBJFILES)
2604          ar d   libmitgcmuv.a main.o          ar d   libmitgcmuv.a main.o
2605    
2606  links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES)  links: \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(SPECIAL_FILES)
2607    
2608  small_f: \$(F77FILES) \$(F90FILES)  small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES)
2609    
2610  output.txt: \$(EXECUTABLE)  output.txt: \$(EXECUTABLE)
2611          @printf 'running ... '          @printf 'running ... '
# Line 2530  clean: Line 2615  clean:
2615          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template          -rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template
2616          -rm -rf *.o          -rm -rf *.o
2617          -rm -rf *.$FS *.flowdir          -rm -rf *.$FS *.flowdir
2618            -rm -rf *.f$FS90 *_mod.h *_mod.F90 *.FF90 *.mod-whirl ad_input*
2619            -rm -rf temp.sed reslice.dat
2620  Clean:  Clean:
2621          @make clean          @make clean
2622          @make cleanlinks          @make cleanlinks
# Line 2551  makefile: Line 2638  makefile:
2638  cleanlinks:  cleanlinks:
2639          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
2640    
2641  # Special targets (SPECIAL_FILES) which are create by make  # Special targets (SPECIAL_FILES) which are created by make
2642  ${PACKAGES_DOT_H}:  ${PACKAGES_DOT_H}:
2643          @echo Creating \$@ ...          @echo Creating \$@ ...
2644          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@
# Line 2576  if test "x$EMBED_SRC" = xt ; then Line 2663  if test "x$EMBED_SRC" = xt ; then
2663    
2664  decode_files.o : EMBEDDED_FILES.h  decode_files.o : EMBEDDED_FILES.h
2665    
2666  ##  \$(F77FILES)  ##  \$(F77_PP_SRC_FILES)
2667  all_fF.tar.gz : \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(F77FILES) Makefile  all_fF.tar.gz : \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2668          @echo Creating \$@ ...          @echo Creating \$@ ...
2669          -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(F77FILES) Makefile          -tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile
2670          -rm -f all_fF.tar.gz          -rm -f all_fF.tar.gz
2671          -gzip all_fF.tar          -gzip all_fF.tar
2672    
# Line 2595  cat >>$MAKEFILE <<EOF Line 2682  cat >>$MAKEFILE <<EOF
2682  # The normal chain of rules is (  .F - .$FS - .o  )  # The normal chain of rules is (  .F - .$FS - .o  )
2683    
2684  ## This nullifies any default implicit rules concerning these two file types:  ## This nullifies any default implicit rules concerning these two file types:
2685  ## %.o : %.F  %.o : %.F
2686    
2687  .F.$FS:  .F.$FS:
2688          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2689  .$FS.o:  .$FS.o:
2690          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<
2691  .F.o:  .F90.$FS90:
2692          \$(FC) \$(FFLAGS) \$(FOPTIM) -c \$<          \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2693  .F90.o:    .FF90.f$FS90:
2694            \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@
2695    .$FS90.o:
2696          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<          \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$<
2697    .f$FS90.o:
2698            cp \$< \$(basename  \$<).f90
2699            \$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$(F90FIXEDFORMAT) \$(basename  \$<).f90
2700  .c.o:  .c.o:
2701          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<          \$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$<
2702  .flow.flowdir:  .flow.flowdir:
# Line 2616  cat >>$MAKEFILE <<EOF Line 2708  cat >>$MAKEFILE <<EOF
2708  .p.$FS:  .p.$FS:
2709          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<          \$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$<
2710    
2711    EOF
2712    
2713  #=========================================  #=========================================
2714  #===  Automatic Differentiation Rules  ===  #===  Automatic Differentiation Rules  ===
2715    #===  for TAMC/TAF  ======================
2716    
2717    if test "x$OPENAD" == x ; then
2718    
2719    cat >>$MAKEFILE <<EOF
2720    
2721  TAMC           = ${TAMC}  TAMC           = ${TAMC}
2722  TAF            = ${TAF}  TAF            = ${TAF}
# Line 2656  adall: \$(EXE_AD) Line 2755  adall: \$(EXE_AD)
2755  adtaf: ad_taf_output.$FS  adtaf: ad_taf_output.$FS
2756  adtamc: ad_tamc_output.$FS  adtamc: ad_tamc_output.$FS
2757    
2758  ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)  ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)
2759          @$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
2760          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
2761          -rm -f ad_config.template          -rm -f ad_config.template
2762          @make \$(F77FILES)          @make \$(F77_PP_SRC_FILES)
2763          @make \$(FLOFILES)          @make \$(FLOFILES)
2764          cat \$(FLOFILES) \$(AD_FILES) > ad_input_code.$FS          cat \$(FLOFILES) \$(AD_FILES) > ad_input_code.$FS
2765    
# Line 2695  ftlall: ftl_taf Line 2794  ftlall: ftl_taf
2794  ftltaf: ftl_taf_output.$FS  ftltaf: ftl_taf_output.$FS
2795  ftltamc: ftl_tamc_output.$FS  ftltamc: ftl_tamc_output.$FS
2796    
2797  ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES)  ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES)
2798          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template          @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template
2799          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2800          -rm -f ftl_config.template          -rm -f ftl_config.template
2801          @make \$(F77FILES)          @make \$(F77_PP_SRC_FILES)
2802          @make \$(AD_FLOW_FILES)          @make \$(AD_FLOW_FILES)
2803          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS          cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS
2804    
# Line 2748  svd_touch: Line 2847  svd_touch:
2847          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h          cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h
2848          -rm -f ftl_config.template          -rm -f ftl_config.template
2849    
2850  #=========================================  EOF
2851    
2852    fi
2853    
2854    #===  for OpenAD  ========================
2855    
2856    if test "x$OPENAD" != x ; then
2857    
2858    # ============ begin OpenAD specific section ==============
2859    
2860    cat >>$MAKEFILE <<EOF
2861    
2862    # all the source files linked from the various locations:
2863    ALL_LINKED_FILES= \
2864    \$(F77_SRC_FILES) \
2865    \$(C_SRC_FILES) \
2866    \$(H_SRC_FILES) \
2867    \$(F90_SRC_FILES) \
2868    \$(SPECIAL_FILES)
2869    
2870    ifndef OPENADROOT
2871      \$(error "Error:  environment variable OPENADROOT not defined!")
2872    endif
2873    
2874    ifndef XAIFSCHEMAROOT
2875      \$(error "Error:  environment variable XAIFSCHEMAROOT not defined!")
2876    endif
2877    
2878    ifndef XAIFBOOSTERROOT
2879      \$(error "Error:  environment variable XAIFBOOSTERROOT not defined!")
2880    endif
2881    
2882  EOF  EOF
2883    
2884    echo "  Add the source list for common block to module conversion "
2885    echo >> $MAKEFILE
2886    printf "CB2M_F90_SRC_NAMES = " >> $MAKEFILE
2887    for i in `cat ${OAD_CB2M_FILES}` ; do
2888      echo    " \\" >> $MAKEFILE
2889      printf " $i" >> $MAKEFILE
2890    done
2891    echo >> $MAKEFILE
2892    
2893    echo "  Add the source list for AD code generation"
2894    echo >> $MAKEFILE
2895    printf "AD_FILES = " >> $MAKEFILE
2896    for i in `cat ${OAD_CB2M_FILES}` ; do
2897      echo    " \\" >> $MAKEFILE
2898      printf " ${i}_mod.f$FS90" >> $MAKEFILE
2899    done
2900    AD_FILES=`cat adSrcFiles.tmp`
2901    for i in $AD_FILES ; do
2902      basename=${i%%.f}
2903      toBeIgnored=`egrep ^$basename'[      ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}`
2904      if test -z "$toBeIgnored" ; then
2905        echo    " \\" >> $MAKEFILE
2906        printf " $i" >> $MAKEFILE
2907      fi
2908    done
2909    echo >> $MAKEFILE
2910    rm -f adSrcFiles.tmp
2911    
2912    cat >>$MAKEFILE <<EOF
2913    
2914    adAll: \$(EXE_AD)
2915    .PHONY: adAll
2916    
2917    CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES))
2918    
2919    .PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90)
2920    
2921    .PHONY: adDepend
2922    adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90)
2923            \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
2924            \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
2925            -rm -f makedepend.out
2926    
2927    OPENAD_SUPPORT_F90_SRC_FILES = \
2928    w2f__types.F90 \
2929    OAD_active.F90 \
2930    OAD_cp.F90 \
2931    OAD_rev.F90 \
2932    OAD_tape.F90        
2933    
2934    OPENAD_SUPPORT_C_SRC_FILES = \
2935    iaddr.c \
2936    timeRatio.c
2937    
2938    f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90)
2939            cat \$^ > \$@
2940    
2941    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
2942            cat \$^ > \$@
2943    
2944    f95_test.out: f95_test_mods.f90 f95_test.f90
2945            f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1
2946            f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1
2947    
2948    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)
2949    
2950    \$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(AD_OBJ_FILES)
2951            @echo Creating \$@ ...
2952            \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES) \$(LIBS)
2953    
2954    # makefile debug rule
2955    openad: ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90
2956    .PHONY: openad
2957    
2958    # create the module files
2959    %_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk
2960            ../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk
2961    
2962    # create the header files
2963    %_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk
2964            ../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES)
2965    
2966    # change everybody else to use the new module files:
2967    %_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash
2968            ../OAD_support/cb2mUseModules.bash $< ${MPI}
2969    
2970    # makefile debug rule
2971    small_f: \$(CB2M_F90_PP_SRC_FILES)
2972    .PHONY: small_f
2973    
2974    ad_output.txt: \$(EXE_AD)
2975            @printf 'linking data files ... '
2976            \$(LN) -f ../input_ad/data* ../input_ad/eedata .
2977            \$(LN) -f ../../global_ocean.90x40x15/input/*.bin .
2978            @printf 'running ... '
2979            @./\$(EXE_AD) > \$@
2980    
2981    CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90)
2982    ad_input_code.f$FS90: ../OAD_support/maxMinDefs.f \$(CB2M_AD_FILES)
2983            cat \$^ > \$@
2984    
2985    # strip all comments and blanks to reduce
2986    # the file size in order to reduce perl's memory requirements
2987    ad_input_code_sf.f$FS90 : ad_input_code.f$FS90
2988            cat \$^ | sed -f ../OAD_support/strip.sed | sed -f ../OAD_support/stop2print.sed > \$@
2989    
2990    # mfef90 preprocessing
2991    # expand statement functions
2992    # expose mfef90 specific substring handling
2993    # add the w2f__types module
2994    ad_input_code_sf.w2f.f$FS90: ad_input_code_sf.f$FS90 mfef90 whirl2f whirl2f_be w2f__types.f90
2995            ./mfef90 -r8 -z -F -N132 \$<
2996            mv \$<.B \$(basename \$<).B
2997            ./whirl2f -openad \$(basename \$<).B
2998            cat w2f__types.f90 \$(basename \$<).w2f.f > \$@
2999    
3000    # canonicalizer
3001    ad_input_code_sf.w2f.canon.f$FS90: ad_input_code_sf.w2f.f$FS90 canon.v1.py
3002            python canon.v1.py --r8 \$< > \$@
3003    
3004    # F -> WHIRL
3005    # note that the canonicalized version cuts off at col 72
3006    # doing this also for string constants which is ok as long
3007    # as we are in fixed mode and cut of exactly there.
3008    # Otherwise mfef90 patches in spaces to fill up to 72 (or 132)
3009    # characters respectively.
3010    ad_input_code_sf.w2f.canon.B: ad_input_code_sf.w2f.canon.f$FS90 mfef90
3011            ./mfef90 -r8 -z -F \$<
3012            mv \$<.B \$@
3013    
3014    # WHIRL -> XAIF
3015    ad_input_code_sf.w2f.canon.xaif : ad_input_code_sf.w2f.canon.B whirl2xaif
3016            ./whirl2xaif -s -n --debug 1 -o \$@ \$<
3017    
3018    # XAIF -> XAIF'
3019    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
3020            ./openad_adm -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r
3021    
3022    # XAIF' -> WHIRL'
3023    ad_input_code_sf.w2f.canon.xb.x2w.B : ad_input_code_sf.w2f.canon.xb.xaif xaif2whirl
3024            ./xaif2whirl --debug 1 --structured ad_input_code_sf.w2f.canon.B \$<
3025    
3026    # WHIRL' -> F'
3027    ad_input_code_sf.w2f.canon.xb.x2w.w2f.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.B whirl2f whirl2f_be
3028            ./whirl2f -FLIST:ftn_file=\$@ -openad \$<
3029    
3030    # undo slice hiding
3031    # insert template directives
3032    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
3033            python reslicer.py \$< > \$<.1
3034            ../OAD_support/insertTemplateDir.bash \$<.1  \$@
3035            rm \$<.1
3036    
3037    # postprocess F'
3038    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)
3039            perl multi-pp.pl -inline=../OAD_support/ad_inline.f \$<
3040            # the postprocessor still gets the name wrong
3041            cat \$<.pp | sed 's/RETURN//' > \$@
3042    
3043    # extract all transformed modules
3044    all_mods.xb.x2w.w2f.pp.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90
3045            cat \$< | sed -n '/MODULE /,/END MODULE/p' > \$@
3046    
3047    # remove the transformed globals module from the
3048    # transformed ad_input_code file
3049    # and remove for now the duplicate variables
3050    # and fix 2 data statements
3051    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
3052            cat \$< | sed '/MODULE /,/END MODULE/d' | sed '/^      INTEGER(w2f__i4) DOLOOP_UB/d' > \$@
3053    
3054    # setup some links
3055    %.xsd:
3056            \$(LN) \${XAIFSCHEMAROOT}/schema/\$@ .
3057    
3058    mfef90:
3059            \$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 .
3060    
3061    # link the support files:
3062    \$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES):
3063            \$(LN) ../OAD_support/\$@ .
3064    
3065    whirl2xaif xaif2whirl:
3066            \$(LN) \${OPENADFORTTK}/bin/\$@ .
3067    
3068    %.pl:
3069            \$(LN) \${OPENADFORTTK}/bin/\$@ .
3070    
3071    %.py:
3072            \$(LN) \${OPENADROOT}/OpenADFortTk/tools/canonicalize/\$@ .
3073    
3074    whirl2f whirl2f_be:
3075            \$(LN) \${OPEN64ROOT}/whirl2f/\$@ .
3076    
3077    openad_adm:
3078            \$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/test/t \$@
3079    
3080    # ============ end OpenAD specific section ==============
3081    
3082    EOF
3083    
3084    fi
3085    
3086    #=========================================
3087    
3088  if test "x$EXEHOOK" != x ; then  if test "x$EXEHOOK" != x ; then
3089      printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE      printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE
3090  fi  fi

Legend:
Removed from v.1.173  
changed lines
  Added in v.1.174

  ViewVC Help
Powered by ViewVC 1.1.22