607 |
mpi_headers_do_local_copy() { |
mpi_headers_do_local_copy() { |
608 |
|
|
609 |
dBug=0 |
dBug=0 |
610 |
#----- check for additional headers (chain of included headers) |
rm -rf ./mpi_headers |
611 |
listIni=$MPI_HEADER_FILES |
if test -d $MPIINCLUDEDIR ; then |
612 |
echo $listIni | grep "\<mpif.h\>" > /dev/null 2>&1 |
|
613 |
outp=$? |
#----- check for additional headers (chain of included headers) |
614 |
#- always check mpif.h (the only mpi-header included in standard MITgcm code) |
echo -n ' Check MPI headers ... ' |
615 |
if test $outp != 0 ; then listIni="mpif.h $listIni" ; fi |
listIni=$MPI_HEADER_FILES |
616 |
if test $dBug = 1 ; then echo "listIni='$listIni'" ; fi |
echo $listIni | grep "\<mpif.h\>" > /dev/null 2>&1 |
617 |
doCheck=1 ; list2copy='' ; list2check=$listIni |
outp=$? |
618 |
while test $doCheck = 1 ; do |
#- always check mpif.h (the only mpi-header included in standard MITgcm code) |
619 |
newList='' |
if test $outp != 0 ; then listIni="mpif.h $listIni" ; fi |
620 |
for i in $list2check ; do |
if test $dBug = 1 ; then echo "listIni='$listIni'" ; fi |
621 |
if test -f $MPIINCLUDEDIR/$i ; then |
|
622 |
newInc=`grep '^ *include ' $MPIINCLUDEDIR/$i | \ |
doCheck=1 ; list2copy='' ; list2check=$listIni |
623 |
|
while test $doCheck = 1 ; do |
624 |
|
newList='' |
625 |
|
for i in $list2check ; do |
626 |
|
if test -f $MPIINCLUDEDIR/$i ; then |
627 |
|
newInc=`grep '^ *include ' $MPIINCLUDEDIR/$i | \ |
628 |
sed -e 's/^ *include //' -e 's/\!.*$//' -e "s/'//g" -e 's/\"//g'` |
sed -e 's/^ *include //' -e 's/\!.*$//' -e "s/'//g" -e 's/\"//g'` |
629 |
if test $dBug = 1 ; then echo -n "checking $i : newInc='$newInc'" ; fi |
if test $dBug = 1 ; then echo -n "checking $i : newInc='$newInc'" ; fi |
630 |
for j in $newInc ; do |
for j in $newInc ; do |
631 |
echo $listIni $list2copy $newList | grep "\<$j\>" > /dev/null 2>&1 |
echo $listIni $list2copy $newList | grep "\<$j\>" > /dev/null 2>&1 |
632 |
outp=$? |
outp=$? |
633 |
if test $outp != 0 ; then |
if test $outp != 0 ; then |
634 |
if test $dBug = 1 ; then echo -n " ; adding $j" ; fi |
if test $dBug = 1 ; then echo -n " ; adding $j" ; fi |
635 |
newList="$newList $j" |
newList="$newList $j" |
636 |
fi |
fi |
637 |
done |
done |
638 |
if test $dBug = 1 ; then echo "" ; fi |
if test $dBug = 1 ; then echo "" ; fi |
639 |
fi |
fi |
640 |
|
done |
641 |
|
if test "x$newList" = x ; then doCheck=0 |
642 |
|
else list2check=$newList ; list2copy="$list2copy $newList" |
643 |
|
fi |
644 |
done |
done |
645 |
if test "x$newList" = x ; then doCheck=0 |
list2copy="$MPI_HEADER_FILES $list2copy" |
646 |
else list2check=$newList ; list2copy="$list2copy $newList" |
if test $dBug = 1 ; then echo "list2copy='$list2copy'" ; fi |
647 |
fi |
|
648 |
done |
#----- create local mpi_headers dir if we have files to copy |
649 |
list2copy="$MPI_HEADER_FILES $list2copy" |
mkListInc=`echo $list2copy | wc -w` |
650 |
if test $dBug = 1 ; then echo "list2copy='$list2copy'" ; fi |
if test $mkListInc != 0 ; then |
651 |
#----- make local copy and update LOCAL_MPI_HEADERS (if not already set) |
echo 'create local "./mpi_headers" dir' |
652 |
mkListInc=0 |
mkdir -p ./mpi_headers |
653 |
for i in $list2copy ; do |
INCLUDES="-I./mpi_headers $INCLUDES" |
654 |
if test -f $MPIINCLUDEDIR/$i ; then |
mkListInc=1 |
655 |
|
fi |
656 |
|
if test "x$LOCAL_MPI_HEADERS" != x ; then mkListInc=0 ; fi |
657 |
|
|
658 |
|
#----- make local copy and update LOCAL_MPI_HEADERS (if not already set) |
659 |
|
for i in $list2copy ; do |
660 |
|
if test -f $MPIINCLUDEDIR/$i ; then |
661 |
cp -p $MPIINCLUDEDIR/$i ./mpi_headers |
cp -p $MPIINCLUDEDIR/$i ./mpi_headers |
662 |
if test $i = 'mpif.h' ; then |
if test $i = 'mpif.h' ; then |
663 |
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 |
664 |
fi |
fi |
665 |
if test $mkListInc = 1 ; then |
if test $mkListInc = 2 ; then |
666 |
LOCAL_MPI_HEADERS="$LOCAL_MPI_HEADERS ./mpi_headers/$i" |
LOCAL_MPI_HEADERS="$LOCAL_MPI_HEADERS ./mpi_headers/$i" |
667 |
fi |
fi |
668 |
if test "x$LOCAL_MPI_HEADERS" = x ; then |
if test $mkListInc = 1 ; then |
669 |
LOCAL_MPI_HEADERS="./mpi_headers/$i" ; mkListInc=1 |
LOCAL_MPI_HEADERS="./mpi_headers/$i" ; mkListInc=2 |
670 |
fi |
fi |
671 |
fi |
fi |
672 |
done |
done |
673 |
|
else |
674 |
|
echo "WARNING: MPIINCLUDEDIR='$MPIINCLUDEDIR' is not a directory" |
675 |
|
echo "WARNING: => skip checking for MPI headers (no ./mpi_headers dir)" |
676 |
|
# exit -1 |
677 |
|
fi |
678 |
} |
} |
679 |
|
|
680 |
# Parse the package dependency information |
# Parse the package dependency information |
2579 |
done |
done |
2580 |
|
|
2581 |
if test ! "x$DIVA" = x -a ! "x$MPI" = x ; then |
if test ! "x$DIVA" = x -a ! "x$MPI" = x ; then |
2582 |
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 |
|
2583 |
# 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 |
2584 |
# checking for additional included headers (in case of chain of included |
# checking for additional included headers (in case of chain of included |
2585 |
# header); also set LOCAL_MPI_HEADERS (if not already set) |
# header); also set LOCAL_MPI_HEADERS (if not already set) |
2586 |
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 |
|
2587 |
fi |
fi |
|
fi |
|
2588 |
fi |
fi |
2589 |
|
|
2590 |
echo " Determining the list of source and include files" |
echo " Determining the list of source and include files" |
2615 |
OAD_KEEP_ORIGINAL="/dev/null" |
OAD_KEEP_ORIGINAL="/dev/null" |
2616 |
OAD_CB2M_FILES="/dev/null" |
OAD_CB2M_FILES="/dev/null" |
2617 |
OADTOOLS="$TOOLSDIR/OAD_support" |
OADTOOLS="$TOOLSDIR/OAD_support" |
|
test -f "oadtempflile" && \rm -f "oadtempflile" |
|
|
cat >> "oadtempflile" <<EOF |
|
|
$OADTOOLS |
|
|
EOF |
|
2618 |
echo " looking for dontCompile file: " |
echo " looking for dontCompile file: " |
2619 |
for i in "." $MODS ; do |
for i in "." $MODS ; do |
2620 |
if test -r $i"/dontCompile" ; then |
if test -r $i"/dontCompile" ; then |
2703 |
F) |
F) |
2704 |
echo " \\" >> F77srclist.tmp |
echo " \\" >> F77srclist.tmp |
2705 |
printf " $sf" >> F77srclist.tmp |
printf " $sf" >> F77srclist.tmp |
2706 |
if test "x$OPENAD" != x ; then |
if test "x$OPENAD" = x ; then |
2707 |
|
basename=${sf%%.F} |
2708 |
|
isAD=`egrep ^$basename.f'[ ]*' adSrcFiles.tmp` |
2709 |
|
if test -z "$isAD" ; then |
2710 |
|
echo " \\" >> nonADF77srclist.tmp |
2711 |
|
printf " $sf" >> nonADF77srclist.tmp |
2712 |
|
fi |
2713 |
|
else #- OpenAD case: |
2714 |
basename=${sf%%.F} |
basename=${sf%%.F} |
2715 |
isAD=`egrep ^$basename.f'[ ]*' adSrcFiles.tmp` |
isAD=`egrep ^$basename.f'[ ]*' adSrcFiles.tmp` |
2716 |
if test -z "$isAD" ; then |
if test -z "$isAD" ; then |
2985 |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
2986 |
-find \$(EXEDIR) -name "*.data" -exec rm {} \; |
-find \$(EXEDIR) -name "*.data" -exec rm {} \; |
2987 |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
2988 |
-rm -f *.txt STD* *diagnostics.log datetime |
-rm -f *.txt STDOUT.* STDERR.* *diagnostics.log *.[0-9][0-9][0-9][0-9].log |
2989 |
-rm -f *_MIT_CE_000.opt0000 costfunction*0000 costfinal |
-rm -f datetime costfinal divided.ctrl snapshot* output_adm.txt.diva_* |
2990 |
-rm -f divided.ctrl snapshot* oad_cp.000.[0-9][0-9][0-9][0-9][0-9] |
-rm -f *_MIT_CE_000.opt0000 costfunction*0000 |
2991 |
|
-rm -f oad_cp.[0-9][0-9][0-9].????? |
2992 |
|
|
2993 |
makefile: |
makefile: |
2994 |
$THIS_SCRIPT $G2ARGS |
$THIS_SCRIPT $G2ARGS |
3134 |
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 |
3135 |
|
|
3136 |
ad_taf_output.$FS: ad_input_code.$FS |
ad_taf_output.$FS: ad_input_code.$FS |
3137 |
|
@-rm -f ad_input_code_ad.$FS |
3138 |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS |
3139 |
ls -l ad_input_code_ad.$FS |
ls -l ad_input_code_ad.$FS |
3140 |
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 |
3144 |
ls -l ad_input_code_ad.$FS |
ls -l ad_input_code_ad.$FS |
3145 |
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 |
3146 |
|
|
3147 |
\$(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) |
3148 |
\$(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) |
3149 |
|
|
3150 |
ad_tamc_output.$FS: ad_input_code.$FS |
ad_tamc_output.$FS: ad_input_code.$FS |
3151 |
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS |
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS |
3160 |
adtrick: |
adtrick: |
3161 |
patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff |
patch < \$(TOOLSDIR)/ad_taf_output.f.adtrick.diff |
3162 |
|
|
3163 |
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) |
3164 |
|
|
3165 |
# ... FTL ... |
# ... FTL ... |
3166 |
ftlall: ftl_exe_target |
ftlall: ftl_exe_target |
3183 |
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 |
3184 |
|
|
3185 |
ftl_taf_output.$FS: ftl_input_code.$FS |
ftl_taf_output.$FS: ftl_input_code.$FS |
3186 |
|
@-rm -f ftl_input_code_tl.$FS |
3187 |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS |
3188 |
ls -l ftl_input_code_ftl.$FS |
ls -l ftl_input_code_tl.$FS |
3189 |
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 |
3190 |
|
|
3191 |
ftltafonly: |
ftltafonly: |
3192 |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS |
3193 |
ls -l ftl_input_code_ftl.$FS |
ls -l ftl_input_code_tl.$FS |
3194 |
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 |
3195 |
|
|
3196 |
\$(EXE_FTL): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) ftl_taf_output.o \$(OBJFILES) \$(EMBEDDED_FILES) |
\$(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) |
3197 |
\$(LINK) -o \${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) 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) |
3198 |
|
|
3199 |
ftl_tamc_output.$FS: ftl_input_code.$FS |
ftl_tamc_output.$FS: ftl_input_code.$FS |
3200 |
\$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS |
\$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.$FS |
3393 |
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 |
3394 |
\${OADTOOLS}/insertTemplateDir.bash \$< \$@ |
\${OADTOOLS}/insertTemplateDir.bash \$< \$@ |
3395 |
|
|
3396 |
PPEXTRAS=\$(wildcard \${OADTOOLS}/ad_template.*.F) \${OADTOOLS}/ad_inline.F |
PPEXTRAS=\$(notdir \$(wildcard \${OADTOOLS}/ad_template.*.F)) ad_inline.F |
3397 |
# postprocess F' |
# postprocess F' |
3398 |
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 |
3399 |
\${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 \$< |
3400 |
# 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 |
3401 |
touch \$@ |
touch \$@ |
3402 |
# put this so make knows about the postprocessing output |
# put this so make knows about the postprocessing output |
3407 |
\$(LN) \${XAIFSCHEMAROOT}/schema/\$@ . |
\$(LN) \${XAIFSCHEMAROOT}/schema/\$@ . |
3408 |
|
|
3409 |
# link the support files: |
# link the support files: |
3410 |
\$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES): |
\$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES) \$(PPEXTRAS): |
3411 |
\$(LN) \${OADTOOLS}/\$@ . |
\$(LN) \${OADTOOLS}/\$@ . |
3412 |
|
|
3413 |
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 |
3414 |
|
|
3415 |
# ============ end OpenAD specific section ============== |
# ============ end OpenAD specific section ============== |
3416 |
|
|