| 932 |
fi |
fi |
| 933 |
let modsCount=modsCount+1 |
let modsCount=modsCount+1 |
| 934 |
done |
done |
| 935 |
if test modsCount -gt 1 ; then |
if test $modsCount -gt 1 ; then |
| 936 |
echo "ERROR: some uses of MODS break with more than one directory specified" |
echo "ERROR: some uses of MODS break with more than one directory specified" |
| 937 |
exit -1; |
exit -1; |
| 938 |
fi |
fi |
| 1908 |
if test -z "$toBeIgnored" ; then |
if test -z "$toBeIgnored" ; then |
| 1909 |
echo " \\" >> nonADF77srclist.tmp |
echo " \\" >> nonADF77srclist.tmp |
| 1910 |
printf " $sf" >> nonADF77srclist.tmp |
printf " $sf" >> nonADF77srclist.tmp |
| 1911 |
|
else |
| 1912 |
|
echo "Ignoring $sf" |
| 1913 |
|
fi |
| 1914 |
|
else # file is initially listed as an AD file but we exclude it |
| 1915 |
|
notToBeTransformed=`egrep ^$basename'[ ]*' ${MODS}/dontTransform` |
| 1916 |
|
if test -n "$notToBeTransformed" ; then |
| 1917 |
|
echo " \\" >> nonADF77srclist.tmp |
| 1918 |
|
printf " $sf" >> nonADF77srclist.tmp |
| 1919 |
fi |
fi |
| 1920 |
fi |
fi |
| 1921 |
;; |
;; |
| 1946 |
done |
done |
| 1947 |
rm -rf .links.tmp |
rm -rf .links.tmp |
| 1948 |
echo "" >> F77srclist.tmp |
echo "" >> F77srclist.tmp |
| 1949 |
|
for i in `cat ${MODS}/keepOriginal` |
| 1950 |
|
do |
| 1951 |
|
echo " \\" >> nonADF77srclist.tmp |
| 1952 |
|
printf " $i" >> nonADF77srclist.tmp |
| 1953 |
|
done |
| 1954 |
echo "" >> nonADF77srclist.tmp |
echo "" >> nonADF77srclist.tmp |
| 1955 |
echo "" >> csrclist.tmp |
echo "" >> csrclist.tmp |
| 1956 |
echo "" >> F90srclist.tmp |
echo "" >> F90srclist.tmp |
| 2224 |
printf "AD_FILES = " >> $MAKEFILE |
printf "AD_FILES = " >> $MAKEFILE |
| 2225 |
AD_FILES=`cat adSrcFiles.tmp` |
AD_FILES=`cat adSrcFiles.tmp` |
| 2226 |
for i in $AD_FILES ; do |
for i in $AD_FILES ; do |
| 2227 |
|
basename=${i%%.f} |
| 2228 |
|
toBeIgnored=`egrep ^$basename'[ ]*' ${MODS}/dontCompile ${MODS}/dontTransform` |
| 2229 |
|
if test -z "$toBeIgnored" ; then |
| 2230 |
echo " \\" >> $MAKEFILE |
echo " \\" >> $MAKEFILE |
| 2231 |
printf " $i" >> $MAKEFILE |
printf " $i" >> $MAKEFILE |
| 2232 |
|
else |
| 2233 |
|
echo "Ignoring $i" |
| 2234 |
|
fi |
| 2235 |
done |
done |
| 2236 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
| 2237 |
rm -f adSrcFiles.tmp |
rm -f adSrcFiles.tmp |
| 2250 |
PARAMS \ |
PARAMS \ |
| 2251 |
BAR2 \ |
BAR2 \ |
| 2252 |
BARRIER \ |
BARRIER \ |
|
CD_CODE_VARS \ |
|
| 2253 |
CG2D \ |
CG2D \ |
| 2254 |
CG3D \ |
CG3D \ |
| 2255 |
DFILE \ |
DFILE \ |
| 2282 |
.PHONY: adAll |
.PHONY: adAll |
| 2283 |
adAll: \$(EXE_AD) |
adAll: \$(EXE_AD) |
| 2284 |
|
|
|
# these are all fixed format: |
|
|
CB2M_F77_TO_FF90_SRC_FILES=\$(F77_SRC_FILES:.F=_cb2m.FF90) |
|
|
CB2M_F90_SRC_FILES=\$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) |
|
| 2285 |
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)) |
| 2286 |
|
|
| 2287 |
.PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.ff90) |
.PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) |
| 2288 |
|
|
| 2289 |
.PHONY: adDepend |
.PHONY: adDepend |
| 2290 |
#this file is included at the bottom |
adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90) |
|
adDepend: \$(ALL_LINKED_FILES) \$(CB2M_F90_SRC_FILES) \$(CB2M_F77_TO_FF90_SRC_FILES) |
|
| 2291 |
\$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES) |
\$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES) |
| 2292 |
\$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE) |
\$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE) |
| 2293 |
-rm -f makedepend.out |
-rm -f makedepend.out |
| 2294 |
|
|
|
|
|
| 2295 |
OPENAD_SUPPORT_F90_SRC_FILES = \ |
OPENAD_SUPPORT_F90_SRC_FILES = \ |
| 2296 |
w2f__types.f90 \ |
w2f__types.f90 \ |
| 2297 |
active_module.f90 \ |
active_module.f90 \ |
| 2301 |
OpenAD_tape.f90 |
OpenAD_tape.f90 |
| 2302 |
|
|
| 2303 |
OPENAD_SUPPORT_C_SRC_FILES = \ |
OPENAD_SUPPORT_C_SRC_FILES = \ |
| 2304 |
iaddr.c |
iaddr.c \ |
| 2305 |
|
timeRatio.c |
| 2306 |
|
|
| 2307 |
|
f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES) |
| 2308 |
|
cat \$^ > \$@ |
| 2309 |
|
|
| 2310 |
AD_OBJ_FILES=\$(OPENAD_SUPPORT_F90_SRC_FILES:.f90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) all_mods.xb.x2w.w2f.pp.o ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.o \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o) |
f95_test.f90: all_mods.xb.x2w.w2f.pp.f$FS90 \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90 |
| 2311 |
|
cat \$^ > \$@ |
| 2312 |
|
|
| 2313 |
|
f95_test.out: f95_test_mods.f90 f95_test.f90 |
| 2314 |
|
f95 -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1 |
| 2315 |
|
f95 -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1 |
| 2316 |
|
|
| 2317 |
\$(EXE_AD): \$(AD_OBJ_FILES) |
AD_OBJ_FILES=\$(OPENAD_SUPPORT_F90_SRC_FILES:.f90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) all_mods.xb.x2w.w2f.pp.o ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.o \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o) |
| 2318 |
|
|
| 2319 |
|
\$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(AD_OBJ_FILES) |
| 2320 |
@echo Creating \$@ ... |
@echo Creating \$@ ... |
| 2321 |
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$^ \$(LIBS) |
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES) \$(LIBS) |
| 2322 |
|
|
| 2323 |
# makefile debug rule |
# makefile debug rule |
| 2324 |
openad: ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f |
openad: ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90 |
| 2325 |
.PHONY: openad |
.PHONY: openad |
| 2326 |
|
|
| 2327 |
CB2MFILES= cb2m1.csh cb2m1.awk cb2m2.bash |
# create the module files |
| 2328 |
# create the module files and change the header files |
%_mod.FF90 : %.h ${MODS}/cb2mGetModules.csh ${MODS}/cb2mGetModules.awk |
| 2329 |
\$(CB2M_F90_SRC_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) : \$(ALL_LINKED_FILES) \$(CB2MFILES) |
${MODS}/cb2mGetModules.csh $< ${MODS}/cb2mGetModules.awk |
| 2330 |
./cb2m1.csh \$(CB2M_F90_SRC_NAMES) |
|
| 2331 |
|
# create the header files |
| 2332 |
# change everybody else to use the module files: |
%_mod.h : %.h ${MODS}/cb2mGetHeaders.csh ${MODS}/cb2mGetHeaders.awk |
| 2333 |
\$(CB2M_F77_TO_FF90_SRC_FILES): \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(CB2M_F90_SRC_FILES) |
${MODS}/cb2mGetHeaders.csh $< ${MODS}/cb2mGetHeaders.awk |
| 2334 |
./cb2m2.bash |
|
| 2335 |
|
# change everybody else to use the new module files: |
| 2336 |
|
%_cb2m.FF90 : %.F ${MODS}/cb2mUseModules.bash |
| 2337 |
|
${MODS}/cb2mUseModules.bash $< |
| 2338 |
|
|
| 2339 |
# makefile debug rule |
# makefile debug rule |
| 2340 |
small_f: \$(CB2M_F77_PP_SRC_FILES) \$(CB2M_F90_PP_SRC_FILES) |
small_f: \$(CB2M_F90_PP_SRC_FILES) |
| 2341 |
.PHONY: small_f |
.PHONY: small_f |
| 2342 |
|
|
| 2343 |
ad_output.txt: \$(EXE_AD) |
ad_output.txt: \$(EXE_AD) |
| 2347 |
@printf 'running ... ' |
@printf 'running ... ' |
| 2348 |
@./\$(EXE_AD) > \$@ |
@./\$(EXE_AD) > \$@ |
| 2349 |
|
|
| 2350 |
CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.ff90) |
CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90) |
| 2351 |
ad_input_code.$FS: ${MODS}/maxMinDefs.f \$(CB2M_AD_FILES) |
ad_input_code.f$FS90: ${MODS}/maxMinDefs.f \$(CB2M_AD_FILES) |
| 2352 |
cat \$^ > \$@ |
cat \$^ > \$@ |
| 2353 |
|
|
|
\$(CB2MFILES): |
|
|
\$(LN) \$(addprefix ${MODS}/, \$(CB2MFILES)) . |
|
|
|
|
| 2354 |
# strip all comments and blanks to reduce |
# strip all comments and blanks to reduce |
| 2355 |
# the file size in order to reduce perl's memory requirements |
# the file size in order to reduce perl's memory requirements |
| 2356 |
ad_input_code_sf.f : ad_input_code.f |
ad_input_code_sf.f$FS90 : ad_input_code.f$FS90 |
| 2357 |
cat \$^ | sed -f ${MODS}/strip.sed | sed -f ${MODS}/stop2print.sed > \$@ |
cat \$^ | sed -f ${MODS}/strip.sed | sed -f ${MODS}/stop2print.sed > \$@ |
| 2358 |
|
|
| 2359 |
# mfef90 preprocessing |
# mfef90 preprocessing |
| 2360 |
# expand statement functions |
# expand statement functions |
| 2361 |
# expose mfef90 specific substring handling |
# expose mfef90 specific substring handling |
| 2362 |
# add the w2f__types module |
# add the w2f__types module |
| 2363 |
ad_input_code_sf.w2f.f: ad_input_code_sf.f mfef90 whirl2f whirl2f_be w2f__types.f90 |
ad_input_code_sf.w2f.f$FS90: ad_input_code_sf.f$FS90 mfef90 whirl2f whirl2f_be w2f__types.f90 |
| 2364 |
./mfef90 -F -N132 \$< |
./mfef90 -F -N132 \$< |
| 2365 |
./whirl2f \$< |
mv \$<.B \$(basename \$<).B |
| 2366 |
cat w2f__types.f90 \$@ > \$@.1 |
./whirl2f \$(basename \$<).B |
| 2367 |
mv \$@.1 \$@ |
cat w2f__types.f90 \$(basename \$<).w2f.f > \$@ |
| 2368 |
|
|
| 2369 |
# canonicalizer |
# canonicalizer |
| 2370 |
ad_input_code_sf.w2f.canon.f: ad_input_code_sf.w2f.f canon.v1.py |
ad_input_code_sf.w2f.canon.f$FS90: ad_input_code_sf.w2f.f$FS90 canon.v1.py |
| 2371 |
python canon.v1.py \$< > \$@ |
python canon.v1.py \$< > \$@ |
| 2372 |
|
|
| 2373 |
# F -> WHIRL |
# F -> WHIRL |
| 2376 |
# as we are in fixed mode and cut of exactly there. |
# as we are in fixed mode and cut of exactly there. |
| 2377 |
# Otherwise mfef90 patches in spaces to fill up to 72 (or 132) |
# Otherwise mfef90 patches in spaces to fill up to 72 (or 132) |
| 2378 |
# characters respectively. |
# characters respectively. |
| 2379 |
ad_input_code_sf.w2f.canon.B: ad_input_code_sf.w2f.canon.f mfef90 |
ad_input_code_sf.w2f.canon.B: ad_input_code_sf.w2f.canon.f$FS90 mfef90 |
| 2380 |
./mfef90 -F \$< |
./mfef90 -F \$< |
| 2381 |
|
mv \$<.B \$@ |
| 2382 |
|
|
| 2383 |
# WHIRL -> XAIF |
# WHIRL -> XAIF |
| 2384 |
ad_input_code_sf.w2f.canon.xaif : ad_input_code_sf.w2f.canon.B whirl2xaif |
ad_input_code_sf.w2f.canon.xaif : ad_input_code_sf.w2f.canon.B whirl2xaif |
| 2386 |
|
|
| 2387 |
# XAIF -> XAIF' |
# XAIF -> XAIF' |
| 2388 |
ad_input_code_sf.w2f.canon.xb.xaif : ad_input_code_sf.w2f.canon.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd openad_adm |
ad_input_code_sf.w2f.canon.xb.xaif : ad_input_code_sf.w2f.canon.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd openad_adm |
| 2389 |
./openad_adm -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r |
./openad_adm -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r -p "recip_hFacC recip_rA" |
| 2390 |
|
|
| 2391 |
# XAIF' -> WHIRL' |
# XAIF' -> WHIRL' |
| 2392 |
ad_input_code_sf.w2f.canon.xb.x2w.B : ad_input_code_sf.w2f.canon.xb.xaif xaif2whirl |
ad_input_code_sf.w2f.canon.xb.x2w.B : ad_input_code_sf.w2f.canon.xb.xaif xaif2whirl |
| 2393 |
./xaif2whirl --structured ad_input_code_sf.w2f.canon.B \$< |
./xaif2whirl --debug 1 --structured ad_input_code_sf.w2f.canon.B \$< |
| 2394 |
|
|
| 2395 |
# WHIRL' -> F' |
# WHIRL' -> F' |
| 2396 |
ad_input_code_sf.w2f.canon.xb.x2w.w2f.f: ad_input_code_sf.w2f.canon.xb.x2w.B whirl2f whirl2f_be |
ad_input_code_sf.w2f.canon.xb.x2w.w2f.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.B whirl2f whirl2f_be |
| 2397 |
./whirl2f -openad \$< |
./whirl2f -FLIST:ftn_file=\$@ -openad \$< |
| 2398 |
|
|
| 2399 |
# undo slice hiding |
# undo slice hiding |
| 2400 |
# insert template directives |
# insert template directives |
| 2401 |
ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.f: ad_input_code_sf.w2f.canon.xb.x2w.w2f.f reslicer.py ${MODS}/insertTemplateDir.bash |
ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.w2f.f$FS90 reslicer.py ${MODS}/insertTemplateDir.bash |
| 2402 |
python reslicer.py \$< > \$<.1 |
python reslicer.py \$< > \$<.1 |
| 2403 |
${MODS}/insertTemplateDir.bash \$<.1 \$@ |
${MODS}/insertTemplateDir.bash \$<.1 \$@ |
| 2404 |
rm \$<.1 |
rm \$<.1 |
| 2405 |
|
|
| 2406 |
# postprocess F' |
# postprocess F' |
| 2407 |
ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.f multi-pp.pl ${MODS}/ad_inline.f ${MODS}/ad_template.checkpoint.f ${MODS}/ad_template.plain.f ${MODS}/ad_template.split.f ${MODS}/ad_template.sa_cg2d.f |
ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.f$FS90 multi-pp.pl ${MODS}/ad_inline.f ${MODS}/ad_template.checkpoint.f ${MODS}/ad_template.plain.f ${MODS}/ad_template.split.f ${MODS}/ad_template.sa_cg2d.f |
| 2408 |
perl multi-pp.pl -inline=${MODS}/ad_inline.f \$< |
perl multi-pp.pl -inline=${MODS}/ad_inline.f \$< |
| 2409 |
cat \$@ | sed 's/RETURN//' > \$@.1 |
# the postprocessor still gets the name wrong |
| 2410 |
mv \$@.1 \$@ |
cat \$<.pp | sed 's/RETURN//' > \$@ |
| 2411 |
|
|
| 2412 |
# extract all transformed modules |
# extract all transformed modules |
| 2413 |
all_mods.xb.x2w.w2f.pp.f: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f |
all_mods.xb.x2w.w2f.pp.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90 |
| 2414 |
cat \$< | sed -n '/MODULE /,/END MODULE/p' > \$@ |
cat \$< | sed -n '/MODULE /,/END MODULE/p' > \$@ |
| 2415 |
|
|
| 2416 |
# remove the transformed globals module from the |
# remove the transformed globals module from the |
| 2417 |
# transformed ad_input_code file |
# transformed ad_input_code file |
| 2418 |
# and remove for now the duplicate variables |
# and remove for now the duplicate variables |
| 2419 |
# and fix 2 data statements |
# and fix 2 data statements |
| 2420 |
ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f ${MODS}/fixData.sed |
ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90 ${MODS}/fixData.sed |
| 2421 |
cat \$< | sed '/MODULE /,/END MODULE/d' | sed '/^ INTEGER(w2f__i4) DOLOOP_UB/d' | sed -f ${MODS}/fixData.sed > \$@ |
# cat \$< | sed '/MODULE /,/END MODULE/d' | sed '/^ INTEGER(w2f__i4) DOLOOP_UB/d' | sed -f ${MODS}/fixData.sed > \$@ |
| 2422 |
|
cat \$< | sed '/MODULE /,/END MODULE/d' | sed '/^ INTEGER(w2f__i4) DOLOOP_UB/d' > \$@ |
| 2423 |
|
|
| 2424 |
# setup some links |
# setup some links |
| 2425 |
%.xsd: |
%.xsd: |
| 2433 |
\$(LN) ${MODS}/\$@ . |
\$(LN) ${MODS}/\$@ . |
| 2434 |
|
|
| 2435 |
whirl2xaif xaif2whirl: |
whirl2xaif xaif2whirl: |
| 2436 |
\$(LN) \${OPENADROOT}/OpenADFortTk/OpenADFortTk-i686-Linux/bin/\$@ . |
\$(LN) \${OPENADROOT}/OpenADFortTk/OpenADFortTk-x86-Linux/bin/\$@ . |
| 2437 |
|
|
| 2438 |
%.pl: |
%.pl: |
| 2439 |
\$(LN) \${OPENADROOT}/OpenADFortTk/OpenADFortTk-i686-Linux/bin/\$@ . |
\$(LN) \${OPENADROOT}/OpenADFortTk/OpenADFortTk-x86-Linux/bin/\$@ . |
| 2440 |
|
|
| 2441 |
%.py: |
%.py: |
| 2442 |
\$(LN) \${OPENADROOT}/OpenADFortTk/tools/canonicalize/\$@ . |
\$(LN) \${OPENADROOT}/OpenADFortTk/tools/canonicalize/\$@ . |