19 |
-help | --help | -h | --h |
-help | --help | -h | --h |
20 |
Print this help message and exit. |
Print this help message and exit. |
21 |
|
|
22 |
|
-oad | --oad |
23 |
|
Generate a Makefile for an OpenAD built |
24 |
|
|
25 |
-adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME |
-adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME |
26 |
-adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME |
-adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME |
27 |
Use "NAME" as the adoptfile. By default, the file at |
Use "NAME" as the adoptfile. By default, the file at |
28 |
|
"tools/adjoint_options/adjoint_oad" (for OpenAD built) or |
29 |
"tools/adjoint_options/adjoint_default" will be used. |
"tools/adjoint_options/adjoint_default" will be used. |
30 |
|
|
31 |
-nooptfile | --nooptfile |
-nooptfile | --nooptfile |
212 |
expand_pkg_groups() { |
expand_pkg_groups() { |
213 |
new_packages= |
new_packages= |
214 |
if test -r $PKG_GROUPS ; then |
if test -r $PKG_GROUPS ; then |
215 |
cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp |
cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > $TMP.p1 |
216 |
cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp |
cat $TMP.p1 | $AWK '(NF>2 && $2==":"){ print $0 }' > $TMP.p2 |
217 |
matched=0 |
matched=0 |
218 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
219 |
line=`grep "^ *$i" ./p2.tmp` |
line=`grep "^ *$i" $TMP.p2` |
220 |
RETVAL=$? |
RETVAL=$? |
221 |
if test "x$RETVAL" = x0 ; then |
if test "x$RETVAL" = x0 ; then |
222 |
matched=1 |
matched=1 |
228 |
fi |
fi |
229 |
done |
done |
230 |
PACKAGES=$new_packages |
PACKAGES=$new_packages |
231 |
rm -f ./p[1,2].tmp |
rm -f $TMP.p[1,2] |
232 |
return $matched |
return $matched |
233 |
else |
else |
234 |
echo "Warning: can't read package groups definition file: $PKG_GROUPS" |
echo "Warning: can't read package groups definition file: $PKG_GROUPS" |
1329 |
FS90= |
FS90= |
1330 |
|
|
1331 |
AUTODIFF_PKG_USED=f |
AUTODIFF_PKG_USED=f |
1332 |
|
OPENAD= |
1333 |
AD_OPTFILE= |
AD_OPTFILE= |
1334 |
TAF= |
TAF= |
1335 |
AD_TAF_FLAGS= |
AD_TAF_FLAGS= |
1356 |
gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM" |
gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM" |
1357 |
gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS" |
gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS" |
1358 |
gm_s6="PWD TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK" |
gm_s6="PWD TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK" |
1359 |
gm_s7="THISHOST THISUSER THISDATE THISVER MACHINE FC_NAMEMANGLE" |
gm_s7="TMP THISHOST THISUSER THISDATE THISVER MACHINE FC_NAMEMANGLE" |
1360 |
gm_s8="HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME HAVE_LAPACK HAVE_FLUSH" |
gm_s8="HAVE_NETCDF HAVE_SYSTEM HAVE_FDATE HAVE_ETIME HAVE_LAPACK HAVE_FLUSH" |
1361 |
|
|
1362 |
# The following are all related to adjoint/tangent-linear stuff |
# The following are all related to adjoint/tangent-linear stuff |
1363 |
gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS" |
gm_s10="AUTODIFF_PKG_USED AD_OPTFILE OPENAD TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS" |
1364 |
gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS" |
gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS" |
1365 |
gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES" |
gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES" |
1366 |
|
|
1412 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
1413 |
OPTFILE=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
1414 |
|
|
1415 |
|
-oad | --oad) |
1416 |
|
OPENAD="true" ;; |
1417 |
-adoptfile | --adoptfile | -adof | --adof) |
-adoptfile | --adoptfile | -adof | --adof) |
1418 |
ac_prev=AD_OPTFILE ;; |
ac_prev=AD_OPTFILE ;; |
1419 |
-adoptfile=* | --adoptfile=* | -adof=* | --adof=*) |
-adoptfile=* | --adoptfile=* | -adof=* | --adof=*) |
1583 |
|
|
1584 |
done |
done |
1585 |
|
|
1586 |
|
#TMP=./genmk_$$ |
1587 |
|
#- try to put temporary files in system-local /tmp dir |
1588 |
|
TMP=/tmp/genmk_$$ |
1589 |
|
touch $TMP ; retVal=$? |
1590 |
|
if [ $retVal -eq 0 ] ; then |
1591 |
|
if test ! -r $TMP ; then TMP=./genmk_$$ ; fi |
1592 |
|
else |
1593 |
|
TMP=./genmk_$$ |
1594 |
|
fi |
1595 |
|
rm -f $TMP |
1596 |
|
#echo " temp files: $TMP.*" |
1597 |
|
|
1598 |
printf " getting local config information: " |
printf " getting local config information: " |
1599 |
if test -f $gm_local ; then |
if test -f $gm_local ; then |
1600 |
echo "using $gm_local" |
echo "using $gm_local" |
1687 |
|
|
1688 |
echo " getting AD_OPTFILE information:" |
echo " getting AD_OPTFILE information:" |
1689 |
if test "x${AD_OPTFILE}" = x ; then |
if test "x${AD_OPTFILE}" = x ; then |
1690 |
if test "x$MITGCM_AD_OF" = x ; then |
if test "x$MITGCM_AD_OF" != x ; then |
1691 |
|
AD_OPTFILE=$MITGCM_AD_OF |
1692 |
|
elif test "x$OPENAD" = x ; then |
1693 |
AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default |
AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default |
1694 |
else |
else |
1695 |
AD_OPTFILE=$MITGCM_AD_OF |
AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_oad |
1696 |
fi |
fi |
1697 |
fi |
fi |
1698 |
if test "x${AD_OPTFILE}" != xNONE ; then |
if test "x${AD_OPTFILE}" != xNONE ; then |
2258 |
fi |
fi |
2259 |
|
|
2260 |
echo " applying DISABLE settings" |
echo " applying DISABLE settings" |
2261 |
echo "" > ./.tmp_pack |
echo "" > $TMP.pack |
2262 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
2263 |
echo $i >> ./.tmp_pack |
echo $i >> $TMP.pack |
2264 |
done |
done |
2265 |
for i in `grep "-" ./.tmp_pack` ; do |
for i in `grep "-" $TMP.pack` ; do |
2266 |
j=`echo $i | sed 's/[-]//'` |
j=`echo $i | sed 's/[-]//'` |
2267 |
DISABLE="$DISABLE $j" |
DISABLE="$DISABLE $j" |
2268 |
done |
done |
2280 |
done |
done |
2281 |
PACKAGES="$pack" |
PACKAGES="$pack" |
2282 |
echo " applying ENABLE settings" |
echo " applying ENABLE settings" |
2283 |
echo "" > ./.tmp_pack |
echo "" > $TMP.pack |
2284 |
PACKAGES="$PACKAGES $ENABLE" |
PACKAGES="$PACKAGES $ENABLE" |
2285 |
# Test if each explicitly referenced package exists |
# Test if each explicitly referenced package exists |
2286 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
2289 |
echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'" |
echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'" |
2290 |
exit 1 |
exit 1 |
2291 |
fi |
fi |
2292 |
echo $i >> ./.tmp_pack |
echo $i >> $TMP.pack |
2293 |
done |
done |
2294 |
PACKAGES= |
PACKAGES= |
2295 |
for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do |
for i in `grep -v "-" $TMP.pack | sort | uniq` ; do |
2296 |
PACKAGES="$PACKAGES $i" |
PACKAGES="$PACKAGES $i" |
2297 |
done |
done |
2298 |
rm -f ./.tmp_pack |
rm -f $TMP.pack |
2299 |
echo " packages are: $PACKAGES" |
echo " packages are: $PACKAGES" |
2300 |
|
|
2301 |
# Check for package MNC: if NetCDF is available, then build the MNC |
# Check for package MNC: if NetCDF is available, then build the MNC |
2365 |
fi |
fi |
2366 |
fi |
fi |
2367 |
|
|
2368 |
# Check for package RADTRANS: if LAPACK is not available, |
# Make sure the openad package is enabled if using OpenAD |
2369 |
# then issue a warning that the direct radtrans solver is not available. |
if test "x$OPENAD" != x ; then |
2370 |
if test "x$HAVE_LAPACK" != xt ; then |
echo " $PACKAGES " | grep ' openad ' > /dev/null 2>&1 |
|
echo " $PACKAGES " | grep ' radtrans ' > /dev/null 2>&1 |
|
2371 |
RETVAL=$? |
RETVAL=$? |
2372 |
if test "x$RETVAL" = x0 ; then |
if test "x$RETVAL" != x0 ; then |
2373 |
cat <<EOF |
cat <<EOF |
|
********************************************************************* |
|
|
WARNING: the "radtrans" package was enabled but tests failed to |
|
|
compile LAPACK applications. This means that the direct radtrans |
|
|
solver is not available and compilation will fail if it is enabled. |
|
|
If you want to use the direct solver, please check that: |
|
2374 |
|
|
|
1) LAPACK is correctly installed for this compiler and |
|
|
2) the LIBS variable (within the "optfile") specifies the correct |
|
|
LAPACK library to link against. |
|
2375 |
********************************************************************* |
********************************************************************* |
2376 |
|
ERROR: when generating an adjoint with OpenAD, the openad package |
2377 |
|
must be enabled. Please add it to packages.conf. |
2378 |
|
********************************************************************* |
2379 |
|
|
2380 |
EOF |
EOF |
2381 |
|
exit 1 |
2382 |
fi |
fi |
2383 |
fi |
fi |
2384 |
|
|
2570 |
|
|
2571 |
# 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 |
2572 |
# compiler. |
# compiler. |
2573 |
if test -f ./adSrcFiles.tmp ; then |
if test -f $TMP.adSrcFiles ; then |
2574 |
rm -f ./adSrcFiles.tmp |
rm -f $TMP.adSrcFiles |
2575 |
fi |
fi |
2576 |
echo " Creating the list of files for the adjoint compiler." |
echo " Creating the list of files for the adjoint compiler." |
2577 |
touch adSrcFiles.tmp |
touch $TMP.adSrcFiles |
2578 |
for i in $SOURCEDIRS ; do |
for i in $SOURCEDIRS ; do |
2579 |
list_files=`( cd $i && ls -1 *.list 2>/dev/null )` |
list_files=`( cd $i && ls -1 *.list 2>/dev/null )` |
2580 |
for j in $list_files ; do |
for j in $list_files ; do |
2581 |
cat $i/$j >> adSrcFiles.tmp |
cat $i/$j >> $TMP.adSrcFiles |
2582 |
done |
done |
2583 |
done |
done |
2584 |
if test ! "x"$FS = "x.f" ; then |
if test ! "x"$FS = "x.f" ; then |
2585 |
cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f |
cat $TMP.adSrcFiles | sed -e "s/\.f/.$FS/g" > $TMP.adSrcFiles_f |
2586 |
mv -f adSrcFiles.tmp_f adSrcFiles.tmp |
mv -f $TMP.adSrcFiles_f $TMP.adSrcFiles |
2587 |
fi |
fi |
2588 |
|
|
2589 |
echo |
echo |
2595 |
fi |
fi |
2596 |
done |
done |
2597 |
|
|
2598 |
#if test ! "x$DIVA" = x -a ! "x$MPI" = x ; then |
if test ! "x$DIVA" = x -a ! "x$MPI" = x ; then |
|
if test ! "x$MPI" = x ; then |
|
2599 |
if test ! "x$MPIINCLUDEDIR" = x ; then |
if test ! "x$MPIINCLUDEDIR" = x ; then |
2600 |
# Do a local copy of MPI headers files (in local dir ./mpi_headers/) after |
# Do a local copy of MPI headers files (in local dir ./mpi_headers/) after |
2601 |
# checking for additional included headers (in case of chain of included |
# checking for additional included headers (in case of chain of included |
2605 |
fi |
fi |
2606 |
|
|
2607 |
echo " Determining the list of source and include files" |
echo " Determining the list of source and include files" |
2608 |
rm -rf .links.tmp |
rm -rf $TMP.links |
2609 |
mkdir .links.tmp |
mkdir $TMP.links |
2610 |
touch .links.tmp/foo |
touch $TMP.links/foo |
2611 |
if test ! -r ".links.tmp/foo" ; then |
if test ! -r "$TMP.links/foo" ; then |
2612 |
echo |
echo |
2613 |
echo "ERROR : something is wrong with your directory permissions or" |
echo "ERROR : something is wrong with your directory permissions or" |
2614 |
echo " your user file-creation mask (\"umask\") since creating a" |
echo " your user file-creation mask (\"umask\") since creating a" |
2624 |
echo |
echo |
2625 |
exit 1 |
exit 1 |
2626 |
fi |
fi |
2627 |
rm -f .links.tmp/foo |
rm -f $TMP.links/foo |
2628 |
|
|
2629 |
if test "x$OPENAD" != x ; then |
if test "x$OPENAD" != x ; then |
2630 |
OAD_DONT_COMPILE="/dev/null" |
OAD_DONT_COMPILE="/dev/null" |
2667 |
echo " OpenAD exceptions: " |
echo " OpenAD exceptions: " |
2668 |
fi |
fi |
2669 |
|
|
2670 |
echo "# This section creates symbolic links" > srclinks.tmp |
echo "# This section creates symbolic links" > $TMP.srclinks |
2671 |
echo "" >> srclinks.tmp |
echo "" >> $TMP.srclinks |
2672 |
printf 'F77_SRC_FILES = ' > F77srclist.tmp |
printf 'F77_SRC_FILES = ' > $TMP.F77srclist |
2673 |
printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp |
printf 'NON_AD_F77_SRC_FILES = ' > $TMP.nonADF77srclist |
2674 |
printf 'C_SRC_FILES = ' > csrclist.tmp |
printf 'C_SRC_FILES = ' > $TMP.csrclist |
2675 |
printf 'F90_SRC_FILES = ' > F90srclist.tmp |
printf 'F90_SRC_FILES = ' > $TMP.F90srclist |
2676 |
printf 'H_SRC_FILES = ' > hsrclist.tmp |
printf 'H_SRC_FILES = ' > $TMP.hsrclist |
2677 |
printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp |
printf 'AD_FLOW_FILES = ' > $TMP.ad_flow_files |
2678 |
alldirs="$SOURCEDIRS $INCLUDEDIRS ." |
alldirs="$SOURCEDIRS $INCLUDEDIRS ." |
2679 |
for d in $alldirs ; do |
for d in $alldirs ; do |
2680 |
deplist= |
deplist= |
2684 |
sfiles=`( echo $sfiles | grep -v _cb2m\. )` |
sfiles=`( echo $sfiles | grep -v _cb2m\. )` |
2685 |
fi |
fi |
2686 |
for sf in $sfiles ; do |
for sf in $sfiles ; do |
2687 |
if test ! -r ".links.tmp/$sf" ; then |
if test ! -r "$TMP.links/$sf" ; then |
2688 |
if test -f "$d/$sf" ; then |
if test -f "$d/$sf" ; then |
2689 |
ignore_f=f |
ignore_f=f |
2690 |
case $d/$sf in |
case $d/$sf in |
2709 |
if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then |
if test "x$HAVE_TEST_L" = xt -a "x$d" = x. -a -L $sf ; then |
2710 |
ignore_f=t |
ignore_f=t |
2711 |
else |
else |
2712 |
touch .links.tmp/$sf |
touch $TMP.links/$sf |
2713 |
deplist="$deplist $sf" |
deplist="$deplist $sf" |
2714 |
fi |
fi |
2715 |
;; |
;; |
2718 |
extn=`echo $sf | $AWK -F. '{print $NF}'` |
extn=`echo $sf | $AWK -F. '{print $NF}'` |
2719 |
case $extn in |
case $extn in |
2720 |
F) |
F) |
2721 |
echo " \\" >> F77srclist.tmp |
echo " \\" >> $TMP.F77srclist |
2722 |
printf " $sf" >> F77srclist.tmp |
printf " $sf" >> $TMP.F77srclist |
2723 |
if test "x$OPENAD" != x ; then |
if test "x$OPENAD" = x ; then |
2724 |
|
basename=${sf%%.F} |
2725 |
|
isAD=`egrep ^$basename.f'[ ]*' $TMP.adSrcFiles` |
2726 |
|
if test -z "$isAD" ; then |
2727 |
|
echo " \\" >> $TMP.nonADF77srclist |
2728 |
|
printf " $sf" >> $TMP.nonADF77srclist |
2729 |
|
fi |
2730 |
|
else #- OpenAD case: |
2731 |
basename=${sf%%.F} |
basename=${sf%%.F} |
2732 |
isAD=`egrep ^$basename.f'[ ]*' adSrcFiles.tmp` |
isAD=`egrep ^$basename.f'[ ]*' $TMP.adSrcFiles` |
2733 |
if test -z "$isAD" ; then |
if test -z "$isAD" ; then |
2734 |
toBeIgnored=`egrep ^$basename'[ ]*' ${OAD_DONT_COMPILE}` |
toBeIgnored=`egrep ^$basename'[ ]*' ${OAD_DONT_COMPILE}` |
2735 |
if test -z "$toBeIgnored" ; then |
if test -z "$toBeIgnored" ; then |
2736 |
echo " \\" >> nonADF77srclist.tmp |
echo " \\" >> $TMP.nonADF77srclist |
2737 |
printf " $sf" >> nonADF77srclist.tmp |
printf " $sf" >> $TMP.nonADF77srclist |
2738 |
else |
else |
2739 |
echo " not to be compiled : $sf" |
echo " not to be compiled : $sf" |
2740 |
fi |
fi |
2749 |
echo " original to be kept : $sf" |
echo " original to be kept : $sf" |
2750 |
fi |
fi |
2751 |
if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then |
if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then |
2752 |
echo " \\" >> nonADF77srclist.tmp |
echo " \\" >> $TMP.nonADF77srclist |
2753 |
printf " $sf" >> nonADF77srclist.tmp |
printf " $sf" >> $TMP.nonADF77srclist |
2754 |
fi |
fi |
2755 |
fi |
fi |
2756 |
fi |
fi |
2757 |
;; |
;; |
2758 |
F90) |
F90) |
2759 |
echo " \\" >> F90srclist.tmp |
echo " \\" >> $TMP.F90srclist |
2760 |
printf " $sf" >> F90srclist.tmp |
printf " $sf" >> $TMP.F90srclist |
2761 |
;; |
;; |
2762 |
c) |
c) |
2763 |
echo " \\" >> csrclist.tmp |
echo " \\" >> $TMP.csrclist |
2764 |
printf " $sf" >> csrclist.tmp |
printf " $sf" >> $TMP.csrclist |
2765 |
;; |
;; |
2766 |
h) |
h) |
2767 |
echo " \\" >> hsrclist.tmp |
echo " \\" >> $TMP.hsrclist |
2768 |
printf " $sf" >> hsrclist.tmp |
printf " $sf" >> $TMP.hsrclist |
2769 |
;; |
;; |
2770 |
flow) |
flow) |
2771 |
echo " \\" >> ad_flow_files.tmp |
echo " \\" >> $TMP.ad_flow_files |
2772 |
printf " $sf" >> ad_flow_files.tmp |
printf " $sf" >> $TMP.ad_flow_files |
2773 |
;; |
;; |
2774 |
esac |
esac |
2775 |
fi |
fi |
2778 |
done |
done |
2779 |
if test "x$deplist" != x ; then |
if test "x$deplist" != x ; then |
2780 |
if test "$d" != "." ; then |
if test "$d" != "." ; then |
2781 |
echo "" >> srclinks.tmp |
echo "" >> $TMP.srclinks |
2782 |
echo "# These files are linked from $d" >> srclinks.tmp |
echo "# These files are linked from $d" >> $TMP.srclinks |
2783 |
echo "$deplist :" >> srclinks.tmp |
echo "$deplist :" >> $TMP.srclinks |
2784 |
# We need to make sure that the link isn't already there. |
# We need to make sure that the link isn't already there. |
2785 |
# 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" |
2786 |
# 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. |
2787 |
printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp |
printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> $TMP.srclinks |
2788 |
fi |
fi |
2789 |
fi |
fi |
2790 |
done |
done |
2791 |
rm -rf .links.tmp |
rm -rf $TMP.links |
2792 |
echo "" >> F77srclist.tmp |
echo "" >> $TMP.F77srclist |
2793 |
echo "" >> nonADF77srclist.tmp |
echo "" >> $TMP.nonADF77srclist |
2794 |
echo "" >> csrclist.tmp |
echo "" >> $TMP.csrclist |
2795 |
echo "" >> F90srclist.tmp |
echo "" >> $TMP.F90srclist |
2796 |
echo "" >> hsrclist.tmp |
echo "" >> $TMP.hsrclist |
2797 |
echo "" >> ad_flow_files.tmp |
echo "" >> $TMP.ad_flow_files |
2798 |
|
|
2799 |
CMDLINE=$0 |
CMDLINE=$0 |
2800 |
for xx in "$@" ; do nw=`echo $xx | wc -w` |
for xx in "$@" ; do nw=`echo $xx | wc -w` |
2916 |
|
|
2917 |
EOF |
EOF |
2918 |
|
|
2919 |
cat F77srclist.tmp >> $MAKEFILE |
cat $TMP.F77srclist >> $MAKEFILE |
2920 |
cat nonADF77srclist.tmp >> $MAKEFILE |
cat $TMP.nonADF77srclist >> $MAKEFILE |
2921 |
cat csrclist.tmp >> $MAKEFILE |
cat $TMP.csrclist >> $MAKEFILE |
2922 |
cat F90srclist.tmp >> $MAKEFILE |
cat $TMP.F90srclist >> $MAKEFILE |
2923 |
cat hsrclist.tmp >> $MAKEFILE |
cat $TMP.hsrclist >> $MAKEFILE |
2924 |
cat ad_flow_files.tmp >> $MAKEFILE |
cat $TMP.ad_flow_files >> $MAKEFILE |
2925 |
|
|
2926 |
rm -f F77srclist.tmp nonADF77srclist.tmp csrclist.tmp F90srclist.tmp hsrclist.tmp ad_flow_files.tmp |
rm -f $TMP.F77srclist $TMP.nonADF77srclist $TMP.csrclist $TMP.F90srclist $TMP.hsrclist $TMP.ad_flow_files |
2927 |
|
|
2928 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
2929 |
|
|
2973 |
|
|
2974 |
small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES) |
small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES) |
2975 |
|
|
2976 |
output.txt: \$(EXECUTABLE) |
# output.txt: \$(EXECUTABLE) |
2977 |
@printf 'running ... ' |
# @printf 'running ... ' |
2978 |
@\$(EXECUTABLE) > \$@ |
# @\$(EXECUTABLE) > \$@ |
2979 |
|
|
2980 |
# remove most of the files that "make" generates |
# remove most of the files that "make" generates |
2981 |
clean: |
clean: |
3120 |
echo " Add the source list for AD code generation" |
echo " Add the source list for AD code generation" |
3121 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
3122 |
printf "AD_FILES = " >> $MAKEFILE |
printf "AD_FILES = " >> $MAKEFILE |
3123 |
AD_FILES=`cat adSrcFiles.tmp` |
AD_FILES=`cat $TMP.adSrcFiles` |
3124 |
for i in $AD_FILES ; do |
for i in $AD_FILES ; do |
3125 |
echo " \\" >> $MAKEFILE |
echo " \\" >> $MAKEFILE |
3126 |
printf " $i" >> $MAKEFILE |
printf " $i" >> $MAKEFILE |
3127 |
done |
done |
3128 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
3129 |
rm -f adSrcFiles.tmp |
rm -f $TMP.adSrcFiles |
3130 |
|
|
3131 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
3132 |
|
|
3142 |
@-rm -f ad_config.template |
@-rm -f ad_config.template |
3143 |
\$(MAKE) -f \$(MAKEFILE) \$(EXE_AD) |
\$(MAKE) -f \$(MAKEFILE) \$(EXE_AD) |
3144 |
|
|
3145 |
ad_input_code.$FS: \$(F77_SRC_FILES) \$(AD_FLOW_FILES) |
ad_input_code.$FS: \$(AD_FILES) \$(AD_FLOW_FILES) |
3146 |
@$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template |
@$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template |
3147 |
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 |
3148 |
@-rm -f ad_config.template |
@-rm -f ad_config.template |
3149 |
@\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES) |
@\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES) |
3150 |
@\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES) |
@\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES) |
3151 |
cat \$(FLOWFILES) \$(F77_PP_SRC_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS |
cat \$(FLOWFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS |
3152 |
|
|
3153 |
ad_taf_output.$FS: ad_input_code.$FS |
ad_taf_output.$FS: ad_input_code.$FS |
3154 |
|
@-rm -f ad_input_code_ad.$FS ; echo '' |
3155 |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS |
3156 |
ls -l ad_input_code_ad.$FS |
ls -l ad_input_code_ad.$FS |
3157 |
cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS |
cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS |
3161 |
ls -l ad_input_code_ad.$FS |
ls -l ad_input_code_ad.$FS |
3162 |
cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS |
cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS |
3163 |
|
|
3164 |
\$(EXE_AD): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES:.c=.o) \$(H_SRC_FILES) \$(F90_SRC_FILES) ad_taf_output.o \$(EMBEDDED_FILES) |
\$(EXE_AD): \$(SPECIAL_FILES) \$(H_SRC_FILES) ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES) |
3165 |
\$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(C_SRC_FILES:.c=.o) ad_taf_output.o \$(LIBS) |
\$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS) |
3166 |
|
|
3167 |
ad_tamc_output.$FS: ad_input_code.$FS |
ad_tamc_output.$FS: ad_input_code.$FS |
3168 |
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS |
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS |
3177 |
adtrick: |
adtrick: |
3178 |
patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff |
patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff |
3179 |
|
|
3180 |
adobj: ad_taf_output.o \$(OBJFILES) |
adobj: ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) |
3181 |
|
|
3182 |
# ... FTL ... |
# ... FTL ... |
3183 |
ftlall: ftl_exe_target |
ftlall: ftl_exe_target |
3191 |
@-rm -f ad_config.template |
@-rm -f ad_config.template |
3192 |
\$(MAKE) -f \$(MAKEFILE) \$(EXE_FTL) |
\$(MAKE) -f \$(MAKEFILE) \$(EXE_FTL) |
3193 |
|
|
3194 |
ftl_input_code.$FS: \$(F77_SRC_FILES) |
ftl_input_code.$FS: \$(AD_FILES) |
3195 |
@$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template |
@$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template |
3196 |
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 |
3197 |
@-rm -f ad_config.template |
@-rm -f ad_config.template |
3198 |
@\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES) |
@\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES) |
3199 |
@\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES) |
@\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES) |
3200 |
cat \$(AD_FLOW_FILES) \$(F77_PP_SRC_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ftl_input_code.$FS |
cat \$(AD_FLOW_FILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ftl_input_code.$FS |
3201 |
|
|
3202 |
ftl_taf_output.$FS: ftl_input_code.$FS |
ftl_taf_output.$FS: ftl_input_code.$FS |
3203 |
|
@-rm -f ftl_input_code_tl.$FS ; echo '' |
3204 |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS |
3205 |
ls -l ftl_input_code_tl.$FS |
ls -l ftl_input_code_tl.$FS |
3206 |
cat ftl_input_code_tl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS |
cat ftl_input_code_tl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS |
3210 |
ls -l ftl_input_code_tl.$FS |
ls -l ftl_input_code_tl.$FS |
3211 |
cat ftl_input_code_tl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS |
cat ftl_input_code_tl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS |
3212 |
|
|
3213 |
\$(EXE_FTL): ftl_taf_output.o \$(C_SRC_FILES:.c=.o) |
\$(EXE_FTL): \$(SPECIAL_FILES) \$(H_SRC_FILES) ftl_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES) |
3214 |
\$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(C_SRC_FILES:.c=.o) ftl_taf_output.o \$(LIBS) |
\$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) ftl_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS) |
3215 |
|
|
3216 |
ftl_tamc_output.$FS: ftl_input_code.$FS |
ftl_tamc_output.$FS: ftl_input_code.$FS |
3217 |
\$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS |
\$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS |
3255 |
# ============ begin OpenAD specific section ============== |
# ============ begin OpenAD specific section ============== |
3256 |
|
|
3257 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
3258 |
|
# ... OpenAD ... |
3259 |
|
|
3260 |
# all the source files linked from the various locations: |
# all the source files linked from the various locations: |
3261 |
ALL_LINKED_FILES= \ |
ALL_LINKED_FILES= \ |
3295 |
echo " \\" >> $MAKEFILE |
echo " \\" >> $MAKEFILE |
3296 |
printf " ${i}_mod.f$FS90" >> $MAKEFILE |
printf " ${i}_mod.f$FS90" >> $MAKEFILE |
3297 |
done |
done |
3298 |
AD_FILES=`cat adSrcFiles.tmp` |
AD_FILES=`cat $TMP.adSrcFiles` |
3299 |
for i in $AD_FILES ; do |
for i in $AD_FILES ; do |
3300 |
basename=${i%%.f} |
basename=${i%%.f} |
3301 |
toBeIgnored=`egrep ^$basename'[ ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}` |
toBeIgnored=`egrep ^$basename'[ ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}` |
3305 |
fi |
fi |
3306 |
done |
done |
3307 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
3308 |
rm -f adSrcFiles.tmp |
rm -f $TMP.adSrcFiles |
3309 |
|
|
3310 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
3311 |
|
|
3312 |
adAll: \$(EXE_AD) |
adAll: ad_exe_target |
3313 |
.PHONY: adAll |
.PHONY: adAll |
3314 |
|
|
3315 |
|
ad_exe_target: |
3316 |
|
@echo Update AD_CONFIG.h and make \$(EXE_AD) |
3317 |
|
@$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template |
3318 |
|
@cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h |
3319 |
|
@-rm -f ad_config.template |
3320 |
|
\$(MAKE) -f \$(MAKEFILE) \$(EXE_AD) |
3321 |
|
|
3322 |
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)) |
3323 |
|
|
3324 |
.PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) |
.PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) |
3376 |
small_f: \$(CB2M_F90_PP_SRC_FILES) |
small_f: \$(CB2M_F90_PP_SRC_FILES) |
3377 |
.PHONY: small_f |
.PHONY: small_f |
3378 |
|
|
3379 |
ad_output.txt: \$(EXE_AD) |
# ad_output.txt: \$(EXE_AD) |
3380 |
@printf 'linking data files ... ' |
# @printf 'linking data files ... ' |
3381 |
\$(LN) -f ../input_ad/data* ../input_ad/eedata . |
# \$(LN) -f ../input_ad/data* ../input_ad/eedata . |
3382 |
\$(LN) -f ../../global_ocean.90x40x15/input/*.bin . |
# \$(LN) -f ../../global_ocean.90x40x15/input/*.bin . |
3383 |
@printf 'running ... ' |
# @printf 'running ... ' |
3384 |
@./\$(EXE_AD) > \$@ |
# @./\$(EXE_AD) > \$@ |
3385 |
|
|
3386 |
ad_input_code.f$FS90: \$(CB2M_AD_FILES) |
ad_input_code.f$FS90: \$(CB2M_AD_FILES) |
3387 |
cat \$^ > \$@ |
cat \$^ > \$@ |
3418 |
ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 \${OADTOOLS}/insertTemplateDir.bash |
ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90: ad_input_code_sf.pre.s2p.xb.x2w.w2f.f$FS90 \${OADTOOLS}/insertTemplateDir.bash |
3419 |
\${OADTOOLS}/insertTemplateDir.bash \$< \$@ |
\${OADTOOLS}/insertTemplateDir.bash \$< \$@ |
3420 |
|
|
3421 |
PPEXTRAS=\$(wildcard \${OADTOOLS}/ad_template.*.F) \${OADTOOLS}/ad_inline.F |
PPEXTRAS=\$(notdir \$(wildcard \${OADTOOLS}/ad_template.*.F)) ad_inline.F |
3422 |
# postprocess F' |
# postprocess F' |
3423 |
postProcess.tag: ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90 \$(PPEXTRAS:.F=.f) | w2f__types.f90 |
postProcess.tag: ad_input_code_sf.pre.s2p.xb.x2w.w2f.td.f$FS90 \$(PPEXTRAS:.F=.f) | w2f__types.f90 |
3424 |
\${OPENADFORTTK_BASE}/tools/SourceProcessing/postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed --separateOutput --pathSuffix "" --filenameSuffix "_oad" -m r -i \${OADTOOLS}/ad_inline.f \$< |
\${OPENADFORTTK_BASE}/tools/SourceProcessing/postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed --separateOutput --pathSuffix "" --filenameSuffix "_oad" -m r -i ad_inline.f \$< |
3425 |
# the target is a placeholder to trigger a single execution of the rule |
# the target is a placeholder to trigger a single execution of the rule |
3426 |
touch \$@ |
touch \$@ |
3427 |
# put this so make knows about the postprocessing output |
# put this so make knows about the postprocessing output |
3432 |
\$(LN) \${XAIFSCHEMAROOT}/schema/\$@ . |
\$(LN) \${XAIFSCHEMAROOT}/schema/\$@ . |
3433 |
|
|
3434 |
# link the support files: |
# link the support files: |
3435 |
\$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES): |
\$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES) \$(PPEXTRAS): |
3436 |
\$(LN) \${OADTOOLS}/\$@ . |
\$(LN) \${OADTOOLS}/\$@ . |
3437 |
|
|
3438 |
AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag \$(PPEXTRAS:.F=.f) |
AD_CLEAN += *_mod.h *_mod.F90 *.FF90 *.mod-whirl temp.sed oad_cp.* postProcess.tag |
3439 |
|
|
3440 |
# ============ end OpenAD specific section ============== |
# ============ end OpenAD specific section ============== |
3441 |
|
|
3471 |
done |
done |
3472 |
|
|
3473 |
echo " Add rules for links" |
echo " Add rules for links" |
3474 |
cat srclinks.tmp >> $MAKEFILE |
cat $TMP.srclinks >> $MAKEFILE |
3475 |
rm -f srclinks.tmp |
rm -f $TMP.srclinks |
3476 |
|
|
3477 |
echo " Adding makedepend marker" |
echo " Adding makedepend marker" |
3478 |
printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE |
printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE |