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 |
1083 |
} |
} |
1084 |
|
|
1085 |
check_lapack_libs() { |
check_lapack_libs() { |
1086 |
if test ! "x$SKIP_LAPACK_CHECK" = x ; then |
if test "x$CHECK_FOR_LAPACK" = xf ; then return ; fi |
|
return |
|
|
fi |
|
1087 |
echo >> $LOGFILE |
echo >> $LOGFILE |
1088 |
echo "running: check_lapack_libs()" >> $LOGFILE |
echo "running: check_lapack_libs()" >> $LOGFILE |
1089 |
cat <<EOF > genmake_tla.F |
cat <<EOF > genmake_tla.F |
1279 |
DEVEL= |
DEVEL= |
1280 |
HAVE_TEST_L= |
HAVE_TEST_L= |
1281 |
|
|
1282 |
# comment this line out to enable lapack test |
# set this to "t" to enable lapack test |
1283 |
SKIP_LAPACK_CHECK=t |
CHECK_FOR_LAPACK=f |
1284 |
|
|
1285 |
# DEFINES checked by test compilation or command-line |
# DEFINES checked by test compilation or command-line |
1286 |
HAVE_SYSTEM= |
HAVE_SYSTEM= |
1327 |
FS90= |
FS90= |
1328 |
|
|
1329 |
AUTODIFF_PKG_USED=f |
AUTODIFF_PKG_USED=f |
1330 |
|
OPENAD= |
1331 |
AD_OPTFILE= |
AD_OPTFILE= |
1332 |
TAF= |
TAF= |
1333 |
AD_TAF_FLAGS= |
AD_TAF_FLAGS= |
1358 |
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" |
1359 |
|
|
1360 |
# The following are all related to adjoint/tangent-linear stuff |
# The following are all related to adjoint/tangent-linear stuff |
1361 |
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" |
1362 |
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" |
1363 |
gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES" |
gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES" |
1364 |
|
|
1410 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
1411 |
OPTFILE=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
1412 |
|
|
1413 |
|
-oad | --oad) |
1414 |
|
OPENAD="true" ;; |
1415 |
-adoptfile | --adoptfile | -adof | --adof) |
-adoptfile | --adoptfile | -adof | --adof) |
1416 |
ac_prev=AD_OPTFILE ;; |
ac_prev=AD_OPTFILE ;; |
1417 |
-adoptfile=* | --adoptfile=* | -adof=* | --adof=*) |
-adoptfile=* | --adoptfile=* | -adof=* | --adof=*) |
1581 |
|
|
1582 |
done |
done |
1583 |
|
|
1584 |
TMP=./genmk_$$ |
#TMP=./genmk_$$ |
1585 |
#- try to put temporary files in system-local /tmp dir |
#- try to put temporary files in system-local /tmp dir |
1586 |
#TMP=/tmp/genmk_$$ |
TMP=/tmp/genmk_$$ |
1587 |
#touch $TMP ; retVal=$? |
touch $TMP ; retVal=$? |
1588 |
#if [ $retVal -eq 0 ] ; then |
if [ $retVal -eq 0 ] ; then |
1589 |
# if test ! -r $TMP ; then TMP=./genmk_$$ ; fi |
if test ! -r $TMP ; then TMP=./genmk_$$ ; fi |
1590 |
#else |
else |
1591 |
# TMP=./genmk_$$ |
TMP=./genmk_$$ |
1592 |
#fi |
fi |
1593 |
#rm -f $TMP |
rm -f $TMP |
1594 |
##echo " temp files: $TMP.*" |
#echo " temp files: $TMP.*" |
1595 |
|
|
1596 |
printf " getting local config information: " |
printf " getting local config information: " |
1597 |
if test -f $gm_local ; then |
if test -f $gm_local ; then |
1685 |
|
|
1686 |
echo " getting AD_OPTFILE information:" |
echo " getting AD_OPTFILE information:" |
1687 |
if test "x${AD_OPTFILE}" = x ; then |
if test "x${AD_OPTFILE}" = x ; then |
1688 |
if test "x$MITGCM_AD_OF" = x ; then |
if test "x$MITGCM_AD_OF" != x ; then |
1689 |
|
AD_OPTFILE=$MITGCM_AD_OF |
1690 |
|
elif test "x$OPENAD" = x ; then |
1691 |
AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default |
AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default |
1692 |
else |
else |
1693 |
AD_OPTFILE=$MITGCM_AD_OF |
AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_oad |
1694 |
fi |
fi |
1695 |
fi |
fi |
1696 |
if test "x${AD_OPTFILE}" != xNONE ; then |
if test "x${AD_OPTFILE}" != xNONE ; then |
2363 |
fi |
fi |
2364 |
fi |
fi |
2365 |
|
|
|
# Check for package RADTRANS: if LAPACK is not available, |
|
|
# then issue a warning that the direct radtrans solver is not available. |
|
|
if test "x$HAVE_LAPACK" != xt ; then |
|
|
echo " $PACKAGES " | grep ' radtrans ' > /dev/null 2>&1 |
|
|
RETVAL=$? |
|
|
if test "x$RETVAL" = x0 ; then |
|
|
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: |
|
|
|
|
|
1) LAPACK is correctly installed for this compiler and |
|
|
2) the LIBS variable (within the "optfile") specifies the correct |
|
|
LAPACK library to link against. |
|
|
********************************************************************* |
|
|
EOF |
|
|
fi |
|
|
fi |
|
|
|
|
2366 |
# Make sure the openad package is enabled if using OpenAD |
# Make sure the openad package is enabled if using OpenAD |
2367 |
if test "x$OPENAD" != x ; then |
if test "x$OPENAD" != x ; then |
2368 |
echo " $PACKAGES " | grep ' openad ' > /dev/null 2>&1 |
echo " $PACKAGES " | grep ' openad ' > /dev/null 2>&1 |
2631 |
OAD_CB2M_FILES="/dev/null" |
OAD_CB2M_FILES="/dev/null" |
2632 |
OADTOOLS="$TOOLSDIR/OAD_support" |
OADTOOLS="$TOOLSDIR/OAD_support" |
2633 |
echo " looking for dontCompile file: " |
echo " looking for dontCompile file: " |
2634 |
for i in "." $MODS ; do |
for i in "." $MODS $OADTOOLS ; do |
2635 |
if test -r $i"/dontCompile" ; then |
if test -r $i"/dontCompile" ; then |
2636 |
OAD_DONT_COMPILE=$i"/dontCompile" |
OAD_DONT_COMPILE=$i"/dontCompile" |
2637 |
echo " found $OAD_DONT_COMPILE" |
echo " found $OAD_DONT_COMPILE" |
2639 |
fi |
fi |
2640 |
done |
done |
2641 |
echo " looking for dontTransform file: " |
echo " looking for dontTransform file: " |
2642 |
for i in "." $MODS ; do |
for i in "." $MODS $OADTOOLS ; do |
2643 |
if test -r $i"/dontTransform" ; then |
if test -r $i"/dontTransform" ; then |
2644 |
OAD_DONT_TRANSFORM=$i"/dontTransform" |
OAD_DONT_TRANSFORM=$i"/dontTransform" |
2645 |
echo " found $OAD_DONT_TRANSFORM" |
echo " found $OAD_DONT_TRANSFORM" |
2647 |
fi |
fi |
2648 |
done |
done |
2649 |
echo " looking for keepOriginal file: " |
echo " looking for keepOriginal file: " |
2650 |
for i in "." $MODS ; do |
for i in "." $MODS $OADTOOLS ; do |
2651 |
if test -r $i"/keepOriginal" ; then |
if test -r $i"/keepOriginal" ; then |
2652 |
OAD_KEEP_ORIGINAL=$i"/keepOriginal" |
OAD_KEEP_ORIGINAL=$i"/keepOriginal" |
2653 |
echo " found $OAD_KEEP_ORIGINAL" |
echo " found $OAD_KEEP_ORIGINAL" |
2655 |
fi |
fi |
2656 |
done |
done |
2657 |
echo " looking for cb2mFiles: " |
echo " looking for cb2mFiles: " |
2658 |
for i in "." $MODS ; do |
for i in "." $MODS $OADTOOLS ; do |
2659 |
if test -r $i"/cb2mFiles" ; then |
if test -r $i"/cb2mFiles" ; then |
2660 |
OAD_CB2M_FILES=$i"/cb2mFiles" |
OAD_CB2M_FILES=$i"/cb2mFiles" |
2661 |
echo " found $OAD_CB2M_FILES" |
echo " found $OAD_CB2M_FILES" |
2971 |
|
|
2972 |
small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES) |
small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES) |
2973 |
|
|
|
output.txt: \$(EXECUTABLE) |
|
|
@printf 'running ... ' |
|
|
@\$(EXECUTABLE) > \$@ |
|
|
|
|
2974 |
# remove most of the files that "make" generates |
# remove most of the files that "make" generates |
2975 |
clean: |
clean: |
2976 |
-rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template |
-rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template |
3249 |
# ============ begin OpenAD specific section ============== |
# ============ begin OpenAD specific section ============== |
3250 |
|
|
3251 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
3252 |
|
# ... OpenAD ... |
3253 |
|
|
3254 |
# all the source files linked from the various locations: |
# all the source files linked from the various locations: |
3255 |
ALL_LINKED_FILES= \ |
ALL_LINKED_FILES= \ |
3303 |
|
|
3304 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
3305 |
|
|
3306 |
adAll: \$(EXE_AD) |
adAll: ad_exe_target |
3307 |
.PHONY: adAll |
.PHONY: adAll |
3308 |
|
|
3309 |
|
ad_exe_target: |
3310 |
|
@echo Update AD_CONFIG.h and make \$(EXE_AD) |
3311 |
|
@$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template |
3312 |
|
@cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h |
3313 |
|
@-rm -f ad_config.template |
3314 |
|
\$(MAKE) -f \$(MAKEFILE) \$(EXE_AD) |
3315 |
|
|
3316 |
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)) |
3317 |
|
|
3318 |
.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) |
3370 |
small_f: \$(CB2M_F90_PP_SRC_FILES) |
small_f: \$(CB2M_F90_PP_SRC_FILES) |
3371 |
.PHONY: small_f |
.PHONY: small_f |
3372 |
|
|
|
ad_output.txt: \$(EXE_AD) |
|
|
@printf 'linking data files ... ' |
|
|
\$(LN) -f ../input_ad/data* ../input_ad/eedata . |
|
|
\$(LN) -f ../../global_ocean.90x40x15/input/*.bin . |
|
|
@printf 'running ... ' |
|
|
@./\$(EXE_AD) > \$@ |
|
|
|
|
3373 |
ad_input_code.f$FS90: \$(CB2M_AD_FILES) |
ad_input_code.f$FS90: \$(CB2M_AD_FILES) |
3374 |
cat \$^ > \$@ |
cat \$^ > \$@ |
3375 |
|
|