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 |
|
-nocat4ad | -dog4ad | -ncad | -dad |
26 |
|
do not concatenate (cat) source code sent to TAF |
27 |
|
resulting in compilation of multiple files |
28 |
|
|
29 |
-adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME |
-adoptfile NAME | --adoptfile NAME | -adof NAME | --adof NAME |
30 |
-adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME |
-adoptfile=NAME | --adoptfile=NAME | -adof=NAME | --adof=NAME |
31 |
Use "NAME" as the adoptfile. By default, the file at |
Use "NAME" as the adoptfile. By default, the file at |
32 |
|
"tools/adjoint_options/adjoint_oad" (for OpenAD built) or |
33 |
"tools/adjoint_options/adjoint_default" will be used. |
"tools/adjoint_options/adjoint_default" will be used. |
34 |
|
|
35 |
-nooptfile | --nooptfile |
-nooptfile | --nooptfile |
216 |
expand_pkg_groups() { |
expand_pkg_groups() { |
217 |
new_packages= |
new_packages= |
218 |
if test -r $PKG_GROUPS ; then |
if test -r $PKG_GROUPS ; then |
219 |
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 |
220 |
cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp |
cat $TMP.p1 | $AWK '(NF>2 && $2==":"){ print $0 }' > $TMP.p2 |
221 |
matched=0 |
matched=0 |
222 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
223 |
line=`grep "^ *$i" ./p2.tmp` |
line=`grep "^ *$i" $TMP.p2` |
224 |
RETVAL=$? |
RETVAL=$? |
225 |
if test "x$RETVAL" = x0 ; then |
if test "x$RETVAL" = x0 ; then |
226 |
matched=1 |
matched=1 |
232 |
fi |
fi |
233 |
done |
done |
234 |
PACKAGES=$new_packages |
PACKAGES=$new_packages |
235 |
rm -f ./p[1,2].tmp |
rm -f $TMP.p[1,2] |
236 |
return $matched |
return $matched |
237 |
else |
else |
238 |
echo "Warning: can't read package groups definition file: $PKG_GROUPS" |
echo "Warning: can't read package groups definition file: $PKG_GROUPS" |
615 |
mpi_headers_do_local_copy() { |
mpi_headers_do_local_copy() { |
616 |
|
|
617 |
dBug=0 |
dBug=0 |
618 |
#----- check for additional headers (chain of included headers) |
rm -rf ./mpi_headers |
619 |
listIni=$MPI_HEADER_FILES |
if test -d $MPIINCLUDEDIR ; then |
620 |
echo $listIni | grep "\<mpif.h\>" > /dev/null 2>&1 |
|
621 |
outp=$? |
#----- check for additional headers (chain of included headers) |
622 |
#- always check mpif.h (the only mpi-header included in standard MITgcm code) |
echo -n ' Check MPI headers ... ' |
623 |
if test $outp != 0 ; then listIni="mpif.h $listIni" ; fi |
listIni=$MPI_HEADER_FILES |
624 |
if test $dBug = 1 ; then echo "listIni='$listIni'" ; fi |
echo $listIni | grep "\<mpif.h\>" > /dev/null 2>&1 |
625 |
doCheck=1 ; list2copy='' ; list2check=$listIni |
outp=$? |
626 |
while test $doCheck = 1 ; do |
#- always check mpif.h (the only mpi-header included in standard MITgcm code) |
627 |
newList='' |
if test $outp != 0 ; then listIni="mpif.h $listIni" ; fi |
628 |
for i in $list2check ; do |
if test $dBug = 1 ; then echo "listIni='$listIni'" ; fi |
629 |
if test -f $MPIINCLUDEDIR/$i ; then |
|
630 |
newInc=`grep '^ *include ' $MPIINCLUDEDIR/$i | \ |
doCheck=1 ; list2copy='' ; list2check=$listIni |
631 |
|
while test $doCheck = 1 ; do |
632 |
|
newList='' |
633 |
|
for i in $list2check ; do |
634 |
|
if test -f $MPIINCLUDEDIR/$i ; then |
635 |
|
newInc=`grep '^ *include ' $MPIINCLUDEDIR/$i | \ |
636 |
sed -e 's/^ *include //' -e 's/\!.*$//' -e "s/'//g" -e 's/\"//g'` |
sed -e 's/^ *include //' -e 's/\!.*$//' -e "s/'//g" -e 's/\"//g'` |
637 |
if test $dBug = 1 ; then echo -n "checking $i : newInc='$newInc'" ; fi |
if test $dBug = 1 ; then echo -n "checking $i : newInc='$newInc'" ; fi |
638 |
for j in $newInc ; do |
for j in $newInc ; do |
639 |
echo $listIni $list2copy $newList | grep "\<$j\>" > /dev/null 2>&1 |
echo $listIni $list2copy $newList | grep "\<$j\>" > /dev/null 2>&1 |
640 |
outp=$? |
outp=$? |
641 |
if test $outp != 0 ; then |
if test $outp != 0 ; then |
642 |
if test $dBug = 1 ; then echo -n " ; adding $j" ; fi |
if test $dBug = 1 ; then echo -n " ; adding $j" ; fi |
643 |
newList="$newList $j" |
newList="$newList $j" |
644 |
fi |
fi |
645 |
done |
done |
646 |
if test $dBug = 1 ; then echo "" ; fi |
if test $dBug = 1 ; then echo "" ; fi |
647 |
fi |
fi |
648 |
|
done |
649 |
|
if test "x$newList" = x ; then doCheck=0 |
650 |
|
else list2check=$newList ; list2copy="$list2copy $newList" |
651 |
|
fi |
652 |
done |
done |
653 |
if test "x$newList" = x ; then doCheck=0 |
list2copy="$MPI_HEADER_FILES $list2copy" |
654 |
else list2check=$newList ; list2copy="$list2copy $newList" |
if test $dBug = 1 ; then echo "list2copy='$list2copy'" ; fi |
655 |
fi |
|
656 |
done |
#----- create local mpi_headers dir if we have files to copy |
657 |
list2copy="$MPI_HEADER_FILES $list2copy" |
mkListInc=`echo $list2copy | wc -w` |
658 |
if test $dBug = 1 ; then echo "list2copy='$list2copy'" ; fi |
if test $mkListInc != 0 ; then |
659 |
#----- make local copy and update LOCAL_MPI_HEADERS (if not already set) |
echo 'create local "./mpi_headers" dir' |
660 |
mkListInc=0 |
mkdir -p ./mpi_headers |
661 |
for i in $list2copy ; do |
INCLUDES="-I./mpi_headers $INCLUDES" |
662 |
if test -f $MPIINCLUDEDIR/$i ; then |
mkListInc=1 |
663 |
|
fi |
664 |
|
if test "x$LOCAL_MPI_HEADERS" != x ; then mkListInc=0 ; fi |
665 |
|
|
666 |
|
#----- make local copy and update LOCAL_MPI_HEADERS (if not already set) |
667 |
|
for i in $list2copy ; do |
668 |
|
if test -f $MPIINCLUDEDIR/$i ; then |
669 |
cp -p $MPIINCLUDEDIR/$i ./mpi_headers |
cp -p $MPIINCLUDEDIR/$i ./mpi_headers |
670 |
if test $i = 'mpif.h' ; then |
if test $i = 'mpif.h' ; then |
671 |
perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h |
perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h |
672 |
fi |
fi |
673 |
if test $mkListInc = 1 ; then |
if test $mkListInc = 2 ; then |
674 |
LOCAL_MPI_HEADERS="$LOCAL_MPI_HEADERS ./mpi_headers/$i" |
LOCAL_MPI_HEADERS="$LOCAL_MPI_HEADERS ./mpi_headers/$i" |
675 |
fi |
fi |
676 |
if test "x$LOCAL_MPI_HEADERS" = x ; then |
if test $mkListInc = 1 ; then |
677 |
LOCAL_MPI_HEADERS="./mpi_headers/$i" ; mkListInc=1 |
LOCAL_MPI_HEADERS="./mpi_headers/$i" ; mkListInc=2 |
678 |
fi |
fi |
679 |
fi |
fi |
680 |
done |
done |
681 |
|
else |
682 |
|
echo "WARNING: MPIINCLUDEDIR='$MPIINCLUDEDIR' is not a directory" |
683 |
|
echo "WARNING: => skip checking for MPI headers (no ./mpi_headers dir)" |
684 |
|
# exit -1 |
685 |
|
fi |
686 |
} |
} |
687 |
|
|
688 |
# Parse the package dependency information |
# Parse the package dependency information |
1087 |
} |
} |
1088 |
|
|
1089 |
check_lapack_libs() { |
check_lapack_libs() { |
1090 |
if test ! "x$SKIP_LAPACK_CHECK" = x ; then |
if test "x$CHECK_FOR_LAPACK" = xf ; then return ; fi |
|
return |
|
|
fi |
|
1091 |
echo >> $LOGFILE |
echo >> $LOGFILE |
1092 |
echo "running: check_lapack_libs()" >> $LOGFILE |
echo "running: check_lapack_libs()" >> $LOGFILE |
1093 |
cat <<EOF > genmake_tla.F |
cat <<EOF > genmake_tla.F |
1283 |
DEVEL= |
DEVEL= |
1284 |
HAVE_TEST_L= |
HAVE_TEST_L= |
1285 |
|
|
1286 |
# comment this line out to enable lapack test |
# set this to "t" to enable lapack test |
1287 |
SKIP_LAPACK_CHECK=t |
CHECK_FOR_LAPACK=f |
1288 |
|
|
1289 |
# DEFINES checked by test compilation or command-line |
# DEFINES checked by test compilation or command-line |
1290 |
HAVE_SYSTEM= |
HAVE_SYSTEM= |
1331 |
FS90= |
FS90= |
1332 |
|
|
1333 |
AUTODIFF_PKG_USED=f |
AUTODIFF_PKG_USED=f |
1334 |
|
OPENAD= |
1335 |
AD_OPTFILE= |
AD_OPTFILE= |
1336 |
|
CAT_SRC_FOR_TAF=1 |
1337 |
TAF= |
TAF= |
1338 |
AD_TAF_FLAGS= |
AD_TAF_FLAGS= |
1339 |
FTL_TAF_FLAGS= |
FTL_TAF_FLAGS= |
1359 |
gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM" |
gm_s4="LN S64 LINK PACKAGES INCLUDES FFLAGS FOPTIM" |
1360 |
gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS" |
gm_s5="CFLAGS LIBS KPP KFLAGS1 KFLAGS2 KPPFILES NOOPTFILES NOOPTFLAGS" |
1361 |
gm_s6="PWD TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK" |
gm_s6="PWD TOOLSDIR SOURCEDIRS INCLUDEDIRS EXEDIR EXECUTABLE EXEHOOK" |
1362 |
gm_s7="THISHOST THISUSER THISDATE THISVER MACHINE FC_NAMEMANGLE" |
gm_s7="TMP THISHOST THISUSER THISDATE THISVER MACHINE FC_NAMEMANGLE" |
1363 |
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" |
1364 |
|
|
1365 |
# The following are all related to adjoint/tangent-linear stuff |
# The following are all related to adjoint/tangent-linear stuff |
1366 |
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" |
1367 |
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" |
1368 |
gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES" |
gm_s12="TAF_EXTRA TAMC_EXTRA DIVA MPIINCLUDEDIR MPI_HEADER_FILES" |
1369 |
|
|
1415 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
1416 |
OPTFILE=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
1417 |
|
|
1418 |
|
-oad | --oad) |
1419 |
|
OPENAD="true" ; ALWAYS_USE_F90=1 ;; |
1420 |
|
-nocat4ad | -dog4ad | -ncad | -dad) |
1421 |
|
CAT_SRC_FOR_TAF=0 ;; |
1422 |
-adoptfile | --adoptfile | -adof | --adof) |
-adoptfile | --adoptfile | -adof | --adof) |
1423 |
ac_prev=AD_OPTFILE ;; |
ac_prev=AD_OPTFILE ;; |
1424 |
-adoptfile=* | --adoptfile=* | -adof=* | --adof=*) |
-adoptfile=* | --adoptfile=* | -adof=* | --adof=*) |
1588 |
|
|
1589 |
done |
done |
1590 |
|
|
1591 |
|
#TMP=./genmk_$$ |
1592 |
|
#- try to put temporary files in system-local /tmp dir |
1593 |
|
TMP=/tmp/genmk_${USER}_$$ |
1594 |
|
touch $TMP ; retVal=$? |
1595 |
|
if [ $retVal -eq 0 ] ; then |
1596 |
|
if test ! -r $TMP ; then TMP=./genmk_$$ ; fi |
1597 |
|
else |
1598 |
|
TMP=./genmk_$$ |
1599 |
|
fi |
1600 |
|
rm -f $TMP |
1601 |
|
#echo " temp files: $TMP.*" |
1602 |
|
|
1603 |
printf " getting local config information: " |
printf " getting local config information: " |
1604 |
if test -f $gm_local ; then |
if test -f $gm_local ; then |
1605 |
echo "using $gm_local" |
echo "using $gm_local" |
1692 |
|
|
1693 |
echo " getting AD_OPTFILE information:" |
echo " getting AD_OPTFILE information:" |
1694 |
if test "x${AD_OPTFILE}" = x ; then |
if test "x${AD_OPTFILE}" = x ; then |
1695 |
if test "x$MITGCM_AD_OF" = x ; then |
if test "x$MITGCM_AD_OF" != x ; then |
1696 |
|
AD_OPTFILE=$MITGCM_AD_OF |
1697 |
|
elif test "x$OPENAD" = x ; then |
1698 |
AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default |
AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default |
1699 |
else |
else |
1700 |
AD_OPTFILE=$MITGCM_AD_OF |
AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_oad |
1701 |
fi |
fi |
1702 |
fi |
fi |
1703 |
if test "x${AD_OPTFILE}" != xNONE ; then |
if test "x${AD_OPTFILE}" != xNONE ; then |
1964 |
fi |
fi |
1965 |
rm -f genmake_tcomp* |
rm -f genmake_tcomp* |
1966 |
|
|
1967 |
printf " Do we have the etime() command using $FC... " |
printf " Do we have the etime() command using $FC... " |
1968 |
cat > genmake_tcomp.$FS <<EOF |
cat > genmake_tcomp_1.$FS <<EOF |
1969 |
program hello |
program hello |
1970 |
REAL*4 ACTUAL, TARRAY(2) |
REAL*4 actual, tarray(2) |
1971 |
EXTERNAL ETIME |
EXTERNAL ETIME |
1972 |
REAL*4 ETIME |
REAL*4 ETIME |
1973 |
actual = etime( tarray ) |
actual = ETIME( tarray ) |
1974 |
print *, tarray |
print *, tarray |
1975 |
end |
end |
1976 |
EOF |
EOF |
1977 |
$FC $FFLAGS -o genmake_tcomp genmake_tcomp.$FS > genmake_tcomp.log 2>&1 |
$FC $FFLAGS -o genmake_tcomp_1 genmake_tcomp_1.$FS > genmake_tcomp.log 2>&1 |
1978 |
RETVAL=$? |
RETVAL=$? |
1979 |
if test "x$RETVAL" = x0 ; then |
if test "x$RETVAL" = x0 ; then |
1980 |
HAVE_ETIME=t |
HAVE_ETIME='Fct' |
1981 |
DEFINES="$DEFINES -DHAVE_ETIME" |
DEFINES="$DEFINES -DHAVE_ETIME_FCT" |
1982 |
echo "yes" |
echo " yes (${HAVE_ETIME})" |
1983 |
else |
else |
1984 |
|
cat > genmake_tcomp_2.$FS <<EOF |
1985 |
|
program hello |
1986 |
|
REAL*4 actual, tarray(2) |
1987 |
|
actual = -999. |
1988 |
|
call ETIME( tarray, actual ) |
1989 |
|
if ( actual.ge.0. ) then |
1990 |
|
print *, 0, tarray, actual |
1991 |
|
else |
1992 |
|
print *, 1, tarray, actual |
1993 |
|
endif |
1994 |
|
end |
1995 |
|
EOF |
1996 |
|
$FC $FFLAGS -o genmake_tcomp_2 genmake_tcomp_2.$FS >> genmake_tcomp.log 2>&1 |
1997 |
|
RETVAL=$? |
1998 |
|
if test "x$RETVAL" = x0 ; then |
1999 |
|
echo -n 'c,' |
2000 |
|
./genmake_tcomp_2 > genmake_tcomp_2.out 2>&1 |
2001 |
|
RETVAL=$? |
2002 |
|
fi |
2003 |
|
if test "x$RETVAL" = x0 ; then |
2004 |
|
echo -n 'r:' |
2005 |
|
RETVAL=`cat genmake_tcomp_2.out | $AWK '{print $1}'` |
2006 |
|
fi |
2007 |
|
if test "x$RETVAL" = x0 ; then |
2008 |
|
HAVE_ETIME='SbR' |
2009 |
|
DEFINES="$DEFINES -DHAVE_ETIME_SBR" |
2010 |
|
echo " yes (${HAVE_ETIME})" |
2011 |
|
else |
2012 |
HAVE_ETIME= |
HAVE_ETIME= |
2013 |
echo "no" |
echo " no" |
2014 |
|
fi |
2015 |
fi |
fi |
2016 |
|
#mkdir chk_etime ; cp -p -f genmake_tcomp* chk_etime |
2017 |
rm -f genmake_tcomp* |
rm -f genmake_tcomp* |
2018 |
|
|
2019 |
printf " Can we call simple C routines (here, \"cloc()\") using $FC... " |
printf " Can we call simple C routines (here, \"cloc()\") using $FC... " |
2293 |
fi |
fi |
2294 |
|
|
2295 |
echo " applying DISABLE settings" |
echo " applying DISABLE settings" |
2296 |
echo "" > ./.tmp_pack |
echo "" > $TMP.pack |
2297 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
2298 |
echo $i >> ./.tmp_pack |
echo $i >> $TMP.pack |
2299 |
done |
done |
2300 |
for i in `grep "-" ./.tmp_pack` ; do |
for i in `grep "-" $TMP.pack` ; do |
2301 |
j=`echo $i | sed 's/[-]//'` |
j=`echo $i | sed 's/[-]//'` |
2302 |
DISABLE="$DISABLE $j" |
DISABLE="$DISABLE $j" |
2303 |
done |
done |
2315 |
done |
done |
2316 |
PACKAGES="$pack" |
PACKAGES="$pack" |
2317 |
echo " applying ENABLE settings" |
echo " applying ENABLE settings" |
2318 |
echo "" > ./.tmp_pack |
echo "" > $TMP.pack |
2319 |
PACKAGES="$PACKAGES $ENABLE" |
PACKAGES="$PACKAGES $ENABLE" |
2320 |
# Test if each explicitly referenced package exists |
# Test if each explicitly referenced package exists |
2321 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
2324 |
echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'" |
echo "Error: dir '$ROOTDIR/pkg/$i' missing for package '$i'" |
2325 |
exit 1 |
exit 1 |
2326 |
fi |
fi |
2327 |
echo $i >> ./.tmp_pack |
echo $i >> $TMP.pack |
2328 |
done |
done |
2329 |
PACKAGES= |
PACKAGES= |
2330 |
for i in `grep -v "-" ./.tmp_pack | sort | uniq` ; do |
for i in `grep -v "-" $TMP.pack | sort | uniq` ; do |
2331 |
PACKAGES="$PACKAGES $i" |
PACKAGES="$PACKAGES $i" |
2332 |
done |
done |
2333 |
rm -f ./.tmp_pack |
rm -f $TMP.pack |
2334 |
echo " packages are: $PACKAGES" |
echo " packages are: $PACKAGES" |
2335 |
|
|
2336 |
# Check for package MNC: if NetCDF is available, then build the MNC |
# Check for package MNC: if NetCDF is available, then build the MNC |
2400 |
fi |
fi |
2401 |
fi |
fi |
2402 |
|
|
2403 |
# Check for package RADTRANS: if LAPACK is not available, |
# Make sure the openad package is enabled if using OpenAD |
2404 |
# then issue a warning that the direct radtrans solver is not available. |
if test "x$OPENAD" != x ; then |
2405 |
if test "x$HAVE_LAPACK" != xt ; then |
echo " $PACKAGES " | grep ' openad ' > /dev/null 2>&1 |
|
echo " $PACKAGES " | grep ' radtrans ' > /dev/null 2>&1 |
|
2406 |
RETVAL=$? |
RETVAL=$? |
2407 |
if test "x$RETVAL" = x0 ; then |
if test "x$RETVAL" != x0 ; then |
2408 |
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: |
|
2409 |
|
|
|
1) LAPACK is correctly installed for this compiler and |
|
|
2) the LIBS variable (within the "optfile") specifies the correct |
|
|
LAPACK library to link against. |
|
2410 |
********************************************************************* |
********************************************************************* |
2411 |
|
ERROR: when generating an adjoint with OpenAD, the openad package |
2412 |
|
must be enabled. Please add it to packages.conf. |
2413 |
|
********************************************************************* |
2414 |
|
|
2415 |
EOF |
EOF |
2416 |
|
exit 1 |
2417 |
fi |
fi |
2418 |
fi |
fi |
2419 |
|
|
2605 |
|
|
2606 |
# 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 |
2607 |
# compiler. |
# compiler. |
2608 |
if test -f ./adSrcFiles.tmp ; then |
if test -f $TMP.adSrcFiles ; then |
2609 |
rm -f ./adSrcFiles.tmp |
rm -f $TMP.adSrcFiles |
2610 |
fi |
fi |
2611 |
echo " Creating the list of files for the adjoint compiler." |
echo " Creating the list of files for the adjoint compiler." |
2612 |
touch adSrcFiles.tmp |
touch $TMP.adSrcFiles |
2613 |
for i in $SOURCEDIRS ; do |
for i in $SOURCEDIRS ; do |
2614 |
list_files=`( cd $i && ls -1 *.list 2>/dev/null )` |
list_files=`( cd $i && ls -1 *.list 2>/dev/null )` |
2615 |
for j in $list_files ; do |
for j in $list_files ; do |
2616 |
cat $i/$j >> adSrcFiles.tmp |
cat $i/$j >> $TMP.adSrcFiles |
2617 |
done |
done |
2618 |
done |
done |
2619 |
if test ! "x"$FS = "x.f" ; then |
if test ! "x"$FS = "x.f" ; then |
2620 |
cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f |
cat $TMP.adSrcFiles | sed -e "s/\.f/.$FS/g" > $TMP.adSrcFiles_f |
2621 |
mv -f adSrcFiles.tmp_f adSrcFiles.tmp |
mv -f $TMP.adSrcFiles_f $TMP.adSrcFiles |
2622 |
fi |
fi |
2623 |
|
|
2624 |
echo |
echo |
2631 |
done |
done |
2632 |
|
|
2633 |
if test ! "x$DIVA" = x -a ! "x$MPI" = x ; then |
if test ! "x$DIVA" = x -a ! "x$MPI" = x ; then |
2634 |
if test ! "x$MPIINCLUDEDIR" = x ; then |
if test ! "x$MPIINCLUDEDIR" = x ; then |
|
if test -d $MPIINCLUDEDIR ; then |
|
|
echo " Creating the pseudo-MPI include directory" |
|
|
INCLUDES="-I./mpi_headers $INCLUDES" |
|
|
rm -rf ./mpi_headers |
|
|
mkdir -p ./mpi_headers |
|
2635 |
# 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 |
2636 |
# checking for additional included headers (in case of chain of included |
# checking for additional included headers (in case of chain of included |
2637 |
# header); also set LOCAL_MPI_HEADERS (if not already set) |
# header); also set LOCAL_MPI_HEADERS (if not already set) |
2638 |
mpi_headers_do_local_copy |
mpi_headers_do_local_copy |
|
else |
|
|
echo "WARNING: MPIINCLUDEDIR='$MPIINCLUDEDIR' is not a dir" |
|
|
echo "WARNING: ==> cannot create pseudo-MPI include directory" |
|
|
# exit -1 |
|
2639 |
fi |
fi |
|
fi |
|
2640 |
fi |
fi |
2641 |
|
|
2642 |
echo " Determining the list of source and include files" |
echo " Determining the list of source and include files" |
2643 |
rm -rf .links.tmp |
rm -rf $TMP.links |
2644 |
mkdir .links.tmp |
mkdir $TMP.links |
2645 |
touch .links.tmp/foo |
touch $TMP.links/foo |
2646 |
if test ! -r ".links.tmp/foo" ; then |
if test ! -r "$TMP.links/foo" ; then |
2647 |
echo |
echo |
2648 |
echo "ERROR : something is wrong with your directory permissions or" |
echo "ERROR : something is wrong with your directory permissions or" |
2649 |
echo " your user file-creation mask (\"umask\") since creating a" |
echo " your user file-creation mask (\"umask\") since creating a" |
2659 |
echo |
echo |
2660 |
exit 1 |
exit 1 |
2661 |
fi |
fi |
2662 |
rm -f .links.tmp/foo |
rm -f $TMP.links/foo |
2663 |
|
|
2664 |
if test "x$OPENAD" != x ; then |
if test "x$OPENAD" != x ; then |
2665 |
OAD_DONT_COMPILE="/dev/null" |
OAD_DONT_COMPILE="/dev/null" |
2668 |
OAD_CB2M_FILES="/dev/null" |
OAD_CB2M_FILES="/dev/null" |
2669 |
OADTOOLS="$TOOLSDIR/OAD_support" |
OADTOOLS="$TOOLSDIR/OAD_support" |
2670 |
echo " looking for dontCompile file: " |
echo " looking for dontCompile file: " |
2671 |
for i in "." $MODS ; do |
for i in "." $MODS $OADTOOLS ; do |
2672 |
if test -r $i"/dontCompile" ; then |
if test -r $i"/dontCompile" ; then |
2673 |
OAD_DONT_COMPILE=$i"/dontCompile" |
OAD_DONT_COMPILE=$i"/dontCompile" |
2674 |
echo " found $OAD_DONT_COMPILE" |
echo " found $OAD_DONT_COMPILE" |
2676 |
fi |
fi |
2677 |
done |
done |
2678 |
echo " looking for dontTransform file: " |
echo " looking for dontTransform file: " |
2679 |
for i in "." $MODS ; do |
for i in "." $MODS $OADTOOLS ; do |
2680 |
if test -r $i"/dontTransform" ; then |
if test -r $i"/dontTransform" ; then |
2681 |
OAD_DONT_TRANSFORM=$i"/dontTransform" |
OAD_DONT_TRANSFORM=$i"/dontTransform" |
2682 |
echo " found $OAD_DONT_TRANSFORM" |
echo " found $OAD_DONT_TRANSFORM" |
2684 |
fi |
fi |
2685 |
done |
done |
2686 |
echo " looking for keepOriginal file: " |
echo " looking for keepOriginal file: " |
2687 |
for i in "." $MODS ; do |
for i in "." $MODS $OADTOOLS ; do |
2688 |
if test -r $i"/keepOriginal" ; then |
if test -r $i"/keepOriginal" ; then |
2689 |
OAD_KEEP_ORIGINAL=$i"/keepOriginal" |
OAD_KEEP_ORIGINAL=$i"/keepOriginal" |
2690 |
echo " found $OAD_KEEP_ORIGINAL" |
echo " found $OAD_KEEP_ORIGINAL" |
2692 |
fi |
fi |
2693 |
done |
done |
2694 |
echo " looking for cb2mFiles: " |
echo " looking for cb2mFiles: " |
2695 |
for i in "." $MODS ; do |
for i in "." $MODS $OADTOOLS ; do |
2696 |
if test -r $i"/cb2mFiles" ; then |
if test -r $i"/cb2mFiles" ; then |
2697 |
OAD_CB2M_FILES=$i"/cb2mFiles" |
OAD_CB2M_FILES=$i"/cb2mFiles" |
2698 |
echo " found $OAD_CB2M_FILES" |
echo " found $OAD_CB2M_FILES" |
2702 |
echo " OpenAD exceptions: " |
echo " OpenAD exceptions: " |
2703 |
fi |
fi |
2704 |
|
|
2705 |
echo "# This section creates symbolic links" > srclinks.tmp |
echo "# This section creates symbolic links" > $TMP.srclinks |
2706 |
echo "" >> srclinks.tmp |
echo "" >> $TMP.srclinks |
2707 |
printf 'F77_SRC_FILES = ' > F77srclist.tmp |
printf 'F77_SRC_FILES = ' > $TMP.F77srclist |
2708 |
printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp |
printf 'NON_AD_F77_SRC_FILES = ' > $TMP.nonADF77srclist |
2709 |
printf 'C_SRC_FILES = ' > csrclist.tmp |
printf 'C_SRC_FILES = ' > $TMP.csrclist |
2710 |
printf 'F90_SRC_FILES = ' > F90srclist.tmp |
printf 'F90_SRC_FILES = ' > $TMP.F90srclist |
2711 |
printf 'H_SRC_FILES = ' > hsrclist.tmp |
printf 'H_SRC_FILES = ' > $TMP.hsrclist |
2712 |
printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp |
printf 'AD_FLOW_FILES = ' > $TMP.ad_flow_files |
2713 |
alldirs="$SOURCEDIRS $INCLUDEDIRS ." |
alldirs="$SOURCEDIRS $INCLUDEDIRS ." |
2714 |
for d in $alldirs ; do |
for d in $alldirs ; do |
2715 |
deplist= |
deplist= |
2719 |
sfiles=`( echo $sfiles | grep -v _cb2m\. )` |
sfiles=`( echo $sfiles | grep -v _cb2m\. )` |
2720 |
fi |
fi |
2721 |
for sf in $sfiles ; do |
for sf in $sfiles ; do |
2722 |
if test ! -r ".links.tmp/$sf" ; then |
if test ! -r "$TMP.links/$sf" ; then |
2723 |
if test -f "$d/$sf" ; then |
if test -f "$d/$sf" ; then |
2724 |
ignore_f=f |
ignore_f=f |
2725 |
case $d/$sf in |
case $d/$sf in |
2744 |
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 |
2745 |
ignore_f=t |
ignore_f=t |
2746 |
else |
else |
2747 |
touch .links.tmp/$sf |
touch $TMP.links/$sf |
2748 |
deplist="$deplist $sf" |
deplist="$deplist $sf" |
2749 |
fi |
fi |
2750 |
;; |
;; |
2753 |
extn=`echo $sf | $AWK -F. '{print $NF}'` |
extn=`echo $sf | $AWK -F. '{print $NF}'` |
2754 |
case $extn in |
case $extn in |
2755 |
F) |
F) |
2756 |
echo " \\" >> F77srclist.tmp |
echo " \\" >> $TMP.F77srclist |
2757 |
printf " $sf" >> F77srclist.tmp |
printf " $sf" >> $TMP.F77srclist |
2758 |
if test "x$OPENAD" != x ; then |
if test "x$OPENAD" = x ; then |
2759 |
basename=${sf%%.F} |
basename=${sf%%.F} |
2760 |
isAD=`egrep ^$basename.f'[ ]*' adSrcFiles.tmp` |
isAD=`egrep ^$basename.f'[ ]*' $TMP.adSrcFiles` |
2761 |
|
if test -z "$isAD" ; then |
2762 |
|
echo " \\" >> $TMP.nonADF77srclist |
2763 |
|
printf " $sf" >> $TMP.nonADF77srclist |
2764 |
|
fi |
2765 |
|
else #- OpenAD case: |
2766 |
|
basename=${sf%%.F} |
2767 |
|
isAD=`egrep ^$basename.f'[ ]*' $TMP.adSrcFiles` |
2768 |
if test -z "$isAD" ; then |
if test -z "$isAD" ; then |
2769 |
toBeIgnored=`egrep ^$basename'[ ]*' ${OAD_DONT_COMPILE}` |
toBeIgnored=`egrep ^$basename'[ ]*' ${OAD_DONT_COMPILE}` |
2770 |
if test -z "$toBeIgnored" ; then |
if test -z "$toBeIgnored" ; then |
2771 |
echo " \\" >> nonADF77srclist.tmp |
echo " \\" >> $TMP.nonADF77srclist |
2772 |
printf " $sf" >> nonADF77srclist.tmp |
printf " $sf" >> $TMP.nonADF77srclist |
2773 |
else |
else |
2774 |
echo " not to be compiled : $sf" |
echo " not to be compiled : $sf" |
2775 |
fi |
fi |
2784 |
echo " original to be kept : $sf" |
echo " original to be kept : $sf" |
2785 |
fi |
fi |
2786 |
if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then |
if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then |
2787 |
echo " \\" >> nonADF77srclist.tmp |
echo " \\" >> $TMP.nonADF77srclist |
2788 |
printf " $sf" >> nonADF77srclist.tmp |
printf " $sf" >> $TMP.nonADF77srclist |
2789 |
fi |
fi |
2790 |
fi |
fi |
2791 |
fi |
fi |
2792 |
;; |
;; |
2793 |
F90) |
F90) |
2794 |
echo " \\" >> F90srclist.tmp |
echo " \\" >> $TMP.F90srclist |
2795 |
printf " $sf" >> F90srclist.tmp |
printf " $sf" >> $TMP.F90srclist |
2796 |
;; |
;; |
2797 |
c) |
c) |
2798 |
echo " \\" >> csrclist.tmp |
echo " \\" >> $TMP.csrclist |
2799 |
printf " $sf" >> csrclist.tmp |
printf " $sf" >> $TMP.csrclist |
2800 |
;; |
;; |
2801 |
h) |
h) |
2802 |
echo " \\" >> hsrclist.tmp |
echo " \\" >> $TMP.hsrclist |
2803 |
printf " $sf" >> hsrclist.tmp |
printf " $sf" >> $TMP.hsrclist |
2804 |
;; |
;; |
2805 |
flow) |
flow) |
2806 |
echo " \\" >> ad_flow_files.tmp |
echo " \\" >> $TMP.ad_flow_files |
2807 |
printf " $sf" >> ad_flow_files.tmp |
printf " $sf" >> $TMP.ad_flow_files |
2808 |
;; |
;; |
2809 |
esac |
esac |
2810 |
fi |
fi |
2813 |
done |
done |
2814 |
if test "x$deplist" != x ; then |
if test "x$deplist" != x ; then |
2815 |
if test "$d" != "." ; then |
if test "$d" != "." ; then |
2816 |
echo "" >> srclinks.tmp |
echo "" >> $TMP.srclinks |
2817 |
echo "# These files are linked from $d" >> srclinks.tmp |
echo "# These files are linked from $d" >> $TMP.srclinks |
2818 |
echo "$deplist :" >> srclinks.tmp |
echo "$deplist :" >> $TMP.srclinks |
2819 |
# We need to make sure that the link isn't already there. |
# We need to make sure that the link isn't already there. |
2820 |
# 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" |
2821 |
# 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. |
2822 |
printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp |
printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> $TMP.srclinks |
2823 |
fi |
fi |
2824 |
fi |
fi |
2825 |
done |
done |
2826 |
rm -rf .links.tmp |
rm -rf $TMP.links |
2827 |
echo "" >> F77srclist.tmp |
echo "" >> $TMP.F77srclist |
2828 |
echo "" >> nonADF77srclist.tmp |
echo "" >> $TMP.nonADF77srclist |
2829 |
echo "" >> csrclist.tmp |
echo "" >> $TMP.csrclist |
2830 |
echo "" >> F90srclist.tmp |
echo "" >> $TMP.F90srclist |
2831 |
echo "" >> hsrclist.tmp |
echo "" >> $TMP.hsrclist |
2832 |
echo "" >> ad_flow_files.tmp |
echo "" >> $TMP.ad_flow_files |
2833 |
|
|
2834 |
CMDLINE=$0 |
CMDLINE=$0 |
2835 |
for xx in "$@" ; do nw=`echo $xx | wc -w` |
for xx in "$@" ; do nw=`echo $xx | wc -w` |
2931 |
KFLAGS1 = ${KFLAGS1} |
KFLAGS1 = ${KFLAGS1} |
2932 |
KFLAGS2 = ${KFLAGS2} |
KFLAGS2 = ${KFLAGS2} |
2933 |
# Optim./debug for FC |
# Optim./debug for FC |
2934 |
FFLAGS = ${FFLAGS} ${FEXTRAFLAGS} |
FFLAGS = ${FFLAGS} |
2935 |
FOPTIM = ${FOPTIM} |
FOPTIM = ${FOPTIM} ${FEXTRAFLAGS} |
2936 |
# Optim./debug for FC |
# Optim./debug for FC |
2937 |
F90FLAGS = ${F90FLAGS} |
F90FLAGS = ${F90FLAGS} |
2938 |
F90OPTIM = ${F90OPTIM} |
F90OPTIM = ${F90OPTIM} |
2951 |
|
|
2952 |
EOF |
EOF |
2953 |
|
|
2954 |
cat F77srclist.tmp >> $MAKEFILE |
cat $TMP.F77srclist >> $MAKEFILE |
2955 |
cat nonADF77srclist.tmp >> $MAKEFILE |
cat $TMP.nonADF77srclist >> $MAKEFILE |
2956 |
cat csrclist.tmp >> $MAKEFILE |
cat $TMP.csrclist >> $MAKEFILE |
2957 |
cat F90srclist.tmp >> $MAKEFILE |
cat $TMP.F90srclist >> $MAKEFILE |
2958 |
cat hsrclist.tmp >> $MAKEFILE |
cat $TMP.hsrclist >> $MAKEFILE |
2959 |
cat ad_flow_files.tmp >> $MAKEFILE |
cat $TMP.ad_flow_files >> $MAKEFILE |
2960 |
|
|
2961 |
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 |
2962 |
|
|
2963 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
2964 |
|
|
3008 |
|
|
3009 |
small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES) |
small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES) |
3010 |
|
|
|
output.txt: \$(EXECUTABLE) |
|
|
@printf 'running ... ' |
|
|
@\$(EXECUTABLE) > \$@ |
|
|
|
|
3011 |
# remove most of the files that "make" generates |
# remove most of the files that "make" generates |
3012 |
clean: |
clean: |
3013 |
-rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template |
-rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template |
3036 |
-rm -f *.txt STDOUT.* STDERR.* *diagnostics.log *.[0-9][0-9][0-9][0-9].log |
-rm -f *.txt STDOUT.* STDERR.* *diagnostics.log *.[0-9][0-9][0-9][0-9].log |
3037 |
-rm -f datetime costfinal divided.ctrl snapshot* output_adm.txt.diva_* |
-rm -f datetime costfinal divided.ctrl snapshot* output_adm.txt.diva_* |
3038 |
-rm -f *_MIT_CE_000.opt0000 costfunction*0000 |
-rm -f *_MIT_CE_000.opt0000 costfunction*0000 |
3039 |
-rm -f oad_cp.000.[0-9][0-9][0-9][0-9][0-9] |
-rm -f oad_cp.[0-9][0-9][0-9].????? |
3040 |
|
|
3041 |
makefile: |
makefile: |
3042 |
$THIS_SCRIPT $G2ARGS |
$THIS_SCRIPT $G2ARGS |
3151 |
echo " Add the source list for AD code generation" |
echo " Add the source list for AD code generation" |
3152 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
3153 |
printf "AD_FILES = " >> $MAKEFILE |
printf "AD_FILES = " >> $MAKEFILE |
3154 |
AD_FILES=`cat adSrcFiles.tmp` |
AD_FILES=`cat $TMP.adSrcFiles` |
3155 |
for i in $AD_FILES ; do |
for i in $AD_FILES ; do |
3156 |
echo " \\" >> $MAKEFILE |
echo " \\" >> $MAKEFILE |
3157 |
printf " $i" >> $MAKEFILE |
printf " $i" >> $MAKEFILE |
3158 |
done |
done |
3159 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
3160 |
rm -f adSrcFiles.tmp |
rm -f $TMP.adSrcFiles |
3161 |
|
|
3162 |
|
if test $CAT_SRC_FOR_TAF = 0 ; then |
3163 |
|
cat >>$MAKEFILE <<EOF |
3164 |
|
|
3165 |
|
# ... Utilities ... |
3166 |
|
remove_comments: |
3167 |
|
sed -i.bak -f \$(TOOLSDIR)/remove_comments_sed \$(AD_FILES) |
3168 |
|
@-rm -f \$(AD_FILES:.$FS=.$FS.bak) |
3169 |
|
adj_sed: |
3170 |
|
sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_ad.$FS) |
3171 |
|
@-rm -f \$(AD_FILES:.$FS=_ad.$FS.bak) |
3172 |
|
ftl_sed: |
3173 |
|
sed -i.bak -f \$(TOOLSDIR)/adjoint_sed \$(AD_FILES:.$FS=_tl.$FS) |
3174 |
|
@-rm -f \$(AD_FILES:.$FS=_tl.$FS.bak) |
3175 |
|
adobjfiles: \$(AD_FILES:.$FS=_ad.o) |
3176 |
|
ftlobjfiles: \$(AD_FILES:.$FS=_tl.o) |
3177 |
|
EOF |
3178 |
|
fi |
3179 |
|
|
3180 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
3181 |
|
|
3199 |
@\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES) |
@\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES) |
3200 |
cat \$(FLOWFILES) \$(AD_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 |
3201 |
|
|
3202 |
ad_taf_output.$FS: ad_input_code.$FS |
adtafonly: |
3203 |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS |
3204 |
ls -l ad_input_code_ad.$FS |
ls -l ad_input_code_ad.$FS |
3205 |
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 |
3206 |
|
|
3207 |
adtafonly: |
EOF |
3208 |
|
|
3209 |
|
if test $CAT_SRC_FOR_TAF = 1 ; then |
3210 |
|
cat >>$MAKEFILE <<EOF |
3211 |
|
# ... send 1 file to TAF ... |
3212 |
|
ad_taf_output.$FS: ad_input_code.$FS |
3213 |
|
@-rm -f ad_input_code_ad.$FS ; echo '' |
3214 |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS |
3215 |
ls -l ad_input_code_ad.$FS |
ls -l ad_input_code_ad.$FS |
3216 |
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 |
3217 |
|
|
3218 |
\$(EXE_AD): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) ad_taf_output.o \$(OBJFILES) \$(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) |
3219 |
\$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) 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) |
3220 |
|
|
3221 |
ad_tamc_output.$FS: ad_input_code.$FS |
adobj: ad_taf_output.o \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) |
|
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS |
|
|
cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS |
|
3222 |
|
|
3223 |
ad_tamc: ad_tamc_output.o \$(OBJFILES) |
EOF |
|
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) |
|
3224 |
|
|
3225 |
|
else |
3226 |
|
cat >>$MAKEFILE <<EOF |
3227 |
|
# ... send multiple files to TAF ... |
3228 |
|
ad_taf_output.$FS: \$(AD_FLOW_FILES) \$(AD_FILES) |
3229 |
|
@$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template |
3230 |
|
cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h |
3231 |
|
@-rm -f ad_config.template |
3232 |
|
@\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES) |
3233 |
|
@\$(MAKE) -f \$(MAKEFILE) \$(FLOWFILES) |
3234 |
|
@-rm -f \$(AD_FILES:.$FS=_ad.$FS) \$(AD_FILES:.$FS=_ad.o); echo '' |
3235 |
|
\$(MAKE) -f \$(MAKEFILE) remove_comments |
3236 |
|
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) \$(FLOWFILES) \$(AD_FILES) |
3237 |
|
\$(MAKE) -f \$(MAKEFILE) adj_sed |
3238 |
|
cat \$(AD_FILES:.$FS=_ad.$FS) > ad_taf_output.$FS |
3239 |
|
|
3240 |
|
\$(EXE_AD): \$(SPECIAL_FILES) \$(H_SRC_FILES) ad_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES) |
3241 |
|
\$(MAKE) -f \$(MAKEFILE) adobjfiles |
3242 |
|
\$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(AD_FILES:.$FS=_ad.o) \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS) |
3243 |
|
|
3244 |
|
adobj: ad_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) |
3245 |
|
\$(MAKE) -f \$(MAKEFILE) adobjfiles |
3246 |
|
|
3247 |
|
EOF |
3248 |
|
fi |
3249 |
|
|
3250 |
|
cat >>$MAKEFILE <<EOF |
3251 |
adonlyfwd: |
adonlyfwd: |
3252 |
patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff |
patch < \$(TOOLSDIR)/ad_taf_output.f.onlyfwd.diff |
3253 |
|
|
3254 |
adtrick: |
adtrick: |
3255 |
patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff |
patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff |
3256 |
|
|
3257 |
adobj: ad_taf_output.o \$(OBJFILES) |
ad_tamc_output.$FS: ad_input_code.$FS |
3258 |
|
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS |
3259 |
|
cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.$FS |
3260 |
|
|
3261 |
|
ad_tamc: ad_tamc_output.o \$(OBJFILES) |
3262 |
|
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) |
3263 |
|
|
3264 |
# ... FTL ... |
# ... FTL ... |
3265 |
ftlall: ftl_exe_target |
ftlall: ftl_exe_target |
3281 |
@\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES) |
@\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES) |
3282 |
cat \$(AD_FLOW_FILES) \$(AD_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 |
3283 |
|
|
3284 |
ftl_taf_output.$FS: ftl_input_code.$FS |
ftltafonly: |
3285 |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS |
3286 |
ls -l ftl_input_code_ftl.$FS |
ls -l ftl_input_code_tl.$FS |
3287 |
cat ftl_input_code_ftl.$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 |
3288 |
|
|
3289 |
ftltafonly: |
EOF |
3290 |
|
|
3291 |
|
if test $CAT_SRC_FOR_TAF = 1 ; then |
3292 |
|
cat >>$MAKEFILE <<EOF |
3293 |
|
# ... send 1 file to TAF ... |
3294 |
|
ftl_taf_output.$FS: ftl_input_code.$FS |
3295 |
|
@-rm -f ftl_input_code_tl.$FS ; echo '' |
3296 |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS |
3297 |
ls -l ftl_input_code_ftl.$FS |
ls -l ftl_input_code_tl.$FS |
3298 |
cat ftl_input_code_ftl.$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 |
3299 |
|
|
3300 |
|
\$(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) |
3301 |
|
\$(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) |
3302 |
|
|
3303 |
|
EOF |
3304 |
|
|
3305 |
|
else |
3306 |
|
cat >>$MAKEFILE <<EOF |
3307 |
|
# ... send multiple files to TAF ... |
3308 |
|
ftl_taf_output.$FS: \$(AD_FLOW_FILES) \$(AD_FILES) |
3309 |
|
@$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "TangLin version" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ad_config.template |
3310 |
|
cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h |
3311 |
|
@-rm -f ad_config.template |
3312 |
|
@\$(MAKE) -f \$(MAKEFILE) \$(F77_PP_SRC_FILES) |
3313 |
|
@\$(MAKE) -f \$(MAKEFILE) \$(AD_FLOW_FILES) |
3314 |
|
@-rm -f \$(AD_FILES:.$FS=_tl.$FS) \$(AD_FILES:.$FS=_tl.o); echo '' |
3315 |
|
\$(MAKE) -f \$(MAKEFILE) remove_comments |
3316 |
|
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) \$(AD_FLOW_FILES) \$(AD_FILES) |
3317 |
|
\$(MAKE) -f \$(MAKEFILE) ftl_sed |
3318 |
|
cat \$(AD_FILES:.$FS=_tl.$FS) > ftl_taf_output.$FS |
3319 |
|
|
3320 |
|
\$(EXE_FTL): \$(SPECIAL_FILES) \$(H_SRC_FILES) ftl_taf_output.$FS \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(EMBEDDED_FILES) |
3321 |
|
\$(MAKE) -f \$(MAKEFILE) ftlobjfiles |
3322 |
|
\$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(AD_FILES:.$FS=_tl.o) \$(NON_AD_F77_SRC_FILES:.F=.o) \$(F90_SRC_FILES:.F90=.o) \$(C_SRC_FILES:.c=.o) \$(LIBS) |
3323 |
|
|
3324 |
\$(EXE_FTL): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) ftl_taf_output.o \$(OBJFILES) \$(EMBEDDED_FILES) |
EOF |
3325 |
\$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) |
fi |
3326 |
|
|
3327 |
|
cat >>$MAKEFILE <<EOF |
3328 |
ftl_tamc_output.$FS: ftl_input_code.$FS |
ftl_tamc_output.$FS: ftl_input_code.$FS |
3329 |
\$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS |
\$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS |
3330 |
cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS |
cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.$FS |
3367 |
# ============ begin OpenAD specific section ============== |
# ============ begin OpenAD specific section ============== |
3368 |
|
|
3369 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
3370 |
|
# ... OpenAD ... |
3371 |
|
|
3372 |
# all the source files linked from the various locations: |
# all the source files linked from the various locations: |
3373 |
ALL_LINKED_FILES= \ |
ALL_LINKED_FILES= \ |
3407 |
echo " \\" >> $MAKEFILE |
echo " \\" >> $MAKEFILE |
3408 |
printf " ${i}_mod.f$FS90" >> $MAKEFILE |
printf " ${i}_mod.f$FS90" >> $MAKEFILE |
3409 |
done |
done |
3410 |
AD_FILES=`cat adSrcFiles.tmp` |
AD_FILES=`cat $TMP.adSrcFiles` |
3411 |
for i in $AD_FILES ; do |
for i in $AD_FILES ; do |
3412 |
basename=${i%%.f} |
basename=${i%%.f} |
3413 |
toBeIgnored=`egrep ^$basename'[ ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}` |
toBeIgnored=`egrep ^$basename'[ ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}` |
3417 |
fi |
fi |
3418 |
done |
done |
3419 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
3420 |
rm -f adSrcFiles.tmp |
rm -f $TMP.adSrcFiles |
3421 |
|
|
3422 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
3423 |
|
|
3424 |
adAll: \$(EXE_AD) |
adAll: ad_exe_target |
3425 |
.PHONY: adAll |
.PHONY: adAll |
3426 |
|
|
3427 |
|
ad_exe_target: |
3428 |
|
@echo Update AD_CONFIG.h and make \$(EXE_AD) |
3429 |
|
@$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Adjoint version" -bAD_CONFIG_H -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template |
3430 |
|
@cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h |
3431 |
|
@-rm -f ad_config.template |
3432 |
|
\$(MAKE) -f \$(MAKEFILE) \$(EXE_AD) |
3433 |
|
|
3434 |
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)) |
3435 |
|
|
3436 |
.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) |
3447 |
OAD_cp.F90 \ |
OAD_cp.F90 \ |
3448 |
OAD_rev.F90 \ |
OAD_rev.F90 \ |
3449 |
OAD_tape.F90 \ |
OAD_tape.F90 \ |
3450 |
|
OAD_regular_cp.F90 \ |
3451 |
revolve.F90 |
revolve.F90 |
3452 |
|
|
3453 |
OPENAD_SUPPORT_C_SRC_FILES = \ |
OPENAD_SUPPORT_C_SRC_FILES = \ |
3489 |
small_f: \$(CB2M_F90_PP_SRC_FILES) |
small_f: \$(CB2M_F90_PP_SRC_FILES) |
3490 |
.PHONY: small_f |
.PHONY: small_f |
3491 |
|
|
|
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) > \$@ |
|
|
|
|
3492 |
ad_input_code.f$FS90: \$(CB2M_AD_FILES) |
ad_input_code.f$FS90: \$(CB2M_AD_FILES) |
3493 |
cat \$^ > \$@ |
cat \$^ > \$@ |
3494 |
|
|
3524 |
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 |
3525 |
\${OADTOOLS}/insertTemplateDir.bash \$< \$@ |
\${OADTOOLS}/insertTemplateDir.bash \$< \$@ |
3526 |
|
|
3527 |
PPEXTRAS=\$(wildcard \${OADTOOLS}/ad_template.*.F) \${OADTOOLS}/ad_inline.F |
PPEXTRAS=\$(notdir \$(wildcard \${OADTOOLS}/ad_template.*.F)) ad_inline.F |
3528 |
# postprocess F' |
# postprocess F' |
3529 |
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 |
3530 |
\${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 \$< |
3531 |
# 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 |
3532 |
touch \$@ |
touch \$@ |
3533 |
# put this so make knows about the postprocessing output |
# put this so make knows about the postprocessing output |
3538 |
\$(LN) \${XAIFSCHEMAROOT}/schema/\$@ . |
\$(LN) \${XAIFSCHEMAROOT}/schema/\$@ . |
3539 |
|
|
3540 |
# link the support files: |
# link the support files: |
3541 |
\$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES): |
\$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES) \$(PPEXTRAS): |
3542 |
\$(LN) \${OADTOOLS}/\$@ . |
\$(LN) \${OADTOOLS}/\$@ . |
3543 |
|
|
3544 |
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 |
3545 |
|
|
3546 |
# ============ end OpenAD specific section ============== |
# ============ end OpenAD specific section ============== |
3547 |
|
|
3577 |
done |
done |
3578 |
|
|
3579 |
echo " Add rules for links" |
echo " Add rules for links" |
3580 |
cat srclinks.tmp >> $MAKEFILE |
cat $TMP.srclinks >> $MAKEFILE |
3581 |
rm -f srclinks.tmp |
rm -f $TMP.srclinks |
3582 |
|
|
3583 |
echo " Adding makedepend marker" |
echo " Adding makedepend marker" |
3584 |
printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE |
printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE |