72 |
|
|
73 |
tmp1=`uname`"_"`uname -m` |
tmp1=`uname`"_"`uname -m` |
74 |
tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` |
tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` |
75 |
PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'` |
tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'` |
76 |
|
PLATFORM=`echo $tmp3 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'` |
77 |
OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` |
OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` |
78 |
echo " The platform appears to be: $PLATFORM" |
echo " The platform appears to be: $PLATFORM" |
79 |
# if test "x$OFLIST" = x ; then |
# if test "x$OFLIST" = x ; then |
105 |
fi |
fi |
106 |
|
|
107 |
# look for possible fortran compilers |
# look for possible fortran compilers |
108 |
tmp="$MITGCM_FC $FC g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95" |
tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95" |
109 |
p_FC= |
p_FC= |
110 |
for c in $tmp ; do |
for c in $tmp ; do |
111 |
rm -f ./hello.f ./hello |
rm -f ./hello.f ./hello |
122 |
p_FC="$p_FC $c" |
p_FC="$p_FC $c" |
123 |
fi |
fi |
124 |
done |
done |
125 |
|
rm -f ./hello.f ./hello |
126 |
if test "x${p_FC}" = x ; then |
if test "x${p_FC}" = x ; then |
127 |
cat 1>&2 <<EOF |
cat 1>&2 <<EOF |
128 |
|
|
337 |
|
|
338 |
AUTODIFF_PKG_USED=f |
AUTODIFF_PKG_USED=f |
339 |
AD_OPTFILE= |
AD_OPTFILE= |
340 |
|
TAF= |
341 |
|
AD_TAF_FLAGS= |
342 |
|
FTL_TAF_FLAGS= |
343 |
|
SVD_TAF_FLAGS= |
344 |
|
TAF_EXTRA= |
345 |
|
TAMC= |
346 |
|
AD_TAMC_FLAGS= |
347 |
|
FTL_TAF_FLAGS= |
348 |
|
SVD_TAMC_FLAGS= |
349 |
|
TAMC_EXTRA= |
350 |
|
|
351 |
|
|
352 |
# The following state can be set directly by command-line switches |
# The following state can be set directly by command-line switches |
353 |
gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT" |
gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT" |
360 |
gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF" |
gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF" |
361 |
|
|
362 |
# The following are all related to adjoint/tangent-linear stuff |
# The following are all related to adjoint/tangent-linear stuff |
363 |
gm_s7="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF DIFF_FLAGS AD_TAMC_FLAGS AD_TAF_FLAGS" |
gm_s7="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS" |
364 |
gm_s8="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS" |
gm_s8="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS" |
365 |
gm_s9="" |
gm_s9="TAF_EXTRA TAMC_EXTRA" |
366 |
|
|
367 |
gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8" |
gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8 $gm_s9" |
368 |
|
|
369 |
|
|
370 |
echo |
echo |
509 |
-ds | --ds) |
-ds | --ds) |
510 |
DUMPSTATE=t ;; |
DUMPSTATE=t ;; |
511 |
|
|
512 |
|
-taf_extra | --taf_extra) |
513 |
|
ac_prev=TAF_EXTRA ;; |
514 |
|
-taf_extra=* | --taf_extra=*) |
515 |
|
TAF_EXTRA=$ac_optarg ;; |
516 |
|
|
517 |
|
-tamc_extra | --tamc_extra) |
518 |
|
ac_prev=TAMC_EXTRA ;; |
519 |
|
-tamc_extra=* | --tamc_extra=*) |
520 |
|
TAMC_EXTRA=$ac_optarg ;; |
521 |
|
|
522 |
-*) |
-*) |
523 |
echo "Error: unrecognized option: "$ac_option |
echo "Error: unrecognized option: "$ac_option |
524 |
usage |
usage |
1042 |
fi |
fi |
1043 |
done |
done |
1044 |
|
|
1045 |
echo " Searching for CPP_OPTIONS.h in order to warn about the presence" |
echo " Searching for CPP_OPTIONS.h in order to warn about the presence" |
1046 |
echo " of \"#define ALLOW_PKGNAME\"-type statements:" |
echo " of \"#define ALLOW_PKGNAME\"-type statements:" |
1047 |
CPP_OPTIONS= |
CPP_OPTIONS= |
1048 |
spaths=". $INCLUDEDIRS" |
spaths=". $INCLUDEDIRS" |
1049 |
for i in $spaths ; do |
for i in $spaths ; do |
1174 |
echo "# $0 $@" >> $MAKEFILE |
echo "# $0 $@" >> $MAKEFILE |
1175 |
echo "# executed by:" >> $MAKEFILE |
echo "# executed by:" >> $MAKEFILE |
1176 |
echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE |
echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE |
1177 |
|
|
1178 |
|
EXE_AD=$EXECUTABLE"_ad" |
1179 |
|
EXE_FTL=$EXECUTABLE"_ftl" |
1180 |
|
EXE_SVD=$EXECUTABLE"_svd" |
1181 |
|
|
1182 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
1183 |
# |
# |
1184 |
# BUILDDIR : Directory where object files are written |
# BUILDDIR : Directory where object files are written |
1209 |
|
|
1210 |
#eh3 new defines for the adjoint work |
#eh3 new defines for the adjoint work |
1211 |
AUTODIFF = ${ROOTDIR}/pkg/autodiff |
AUTODIFF = ${ROOTDIR}/pkg/autodiff |
1212 |
|
EXE_AD = ${EXE_AD} |
1213 |
|
EXE_FTL = ${EXE_FTL} |
1214 |
|
EXE_SVD = ${EXE_SVD} |
1215 |
|
|
1216 |
EOF |
EOF |
1217 |
|
|
1293 |
@\$(EXECUTABLE) > \$@ |
@\$(EXECUTABLE) > \$@ |
1294 |
|
|
1295 |
clean: |
clean: |
1296 |
|
-cat AD_CONFIG.template > AD_CONFIG.h |
1297 |
-rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} |
-rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} |
1298 |
Clean: |
Clean: |
1299 |
@make clean |
@make clean |
1300 |
@make cleanlinks |
@make cleanlinks |
1301 |
-rm -f Makefile.bak genmake_state genmake_optfile make.log |
-rm -f Makefile.bak genmake_state genmake_*optfile make.log |
1302 |
CLEAN: |
CLEAN: |
1303 |
@make Clean |
@make Clean |
1304 |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
1306 |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
1307 |
-rm -f \$(EXECUTABLE) output.txt |
-rm -f \$(EXECUTABLE) output.txt |
1308 |
|
|
1309 |
Makefile: makefile |
#eh3 Makefile: makefile |
1310 |
makefile: |
makefile: |
1311 |
${0} $@ |
${0} $@ |
1312 |
cleanlinks: |
cleanlinks: |
1336 |
TAMC = ${TAMC} |
TAMC = ${TAMC} |
1337 |
TAF = ${TAF} |
TAF = ${TAF} |
1338 |
|
|
1339 |
|
TAF_EXTRA = ${TAF_EXTRA} |
1340 |
|
TAMC_EXTRA = ${TAMC_EXTRA} |
1341 |
|
|
1342 |
EOF |
EOF |
1343 |
|
|
1344 |
ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS" |
ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS" |
1361 |
echo -n " $i" >> $MAKEFILE |
echo -n " $i" >> $MAKEFILE |
1362 |
done |
done |
1363 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
1364 |
|
rm -f ad_files |
1365 |
|
|
1366 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
1367 |
|
|
1368 |
|
# ... AD ... |
1369 |
ad_input_code.f: \$(F77FILES) |
adall: ad_taf |
1370 |
|
adtaf: ad_taf_output.f |
1371 |
|
adtamc: ad_tamc_output.f |
1372 |
|
|
1373 |
|
ad_input_code.f: \$(AD_FILES) \$(HEADERFILES) |
1374 |
|
cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h |
1375 |
|
@make \$(F77FILES) |
1376 |
@make \$(AD_FLOW_FILES) |
@make \$(AD_FLOW_FILES) |
1377 |
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f |
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f |
1378 |
|
|
|
# ... AD ... |
|
1379 |
ad_taf_output.f: ad_input_code.f |
ad_taf_output.f: ad_input_code.f |
1380 |
\$(TAF) \$(AD_TAF_FLAGS) ad_input_code.f |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
1381 |
cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f |
cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f |
1382 |
|
|
1383 |
ad_taf: ad_taf_output.o \$(OBJFILES) |
ad_taf: ad_taf_output.o \$(OBJFILES) |
1384 |
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) |
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) |
1385 |
|
|
1386 |
ad_tamc_output.f: ad_input_code.f |
ad_tamc_output.f: ad_input_code.f |
1387 |
\$(TAMC) \$(AD_TAMC_FLAGS) ad_input_code.f |
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f |
1388 |
cat ad_input_code_ad.f | sed -f adjoint_sed > ad_tamc_output.f |
cat ad_input_code_ad.f | sed -f adjoint_sed > ad_tamc_output.f |
1389 |
|
|
1390 |
ad_tamc: ad_tamc_output.o \$(OBJFILES) |
ad_tamc: ad_tamc_output.o \$(OBJFILES) |
1391 |
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) |
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) |
1392 |
|
|
1393 |
|
|
1394 |
# ... FLT ... |
# ... FTL ... |
1395 |
flt_taf_output.f: ad_input_code.f |
ftlall: ftl_taf |
1396 |
\$(TAF) \$(FTL_TAF_FLAGS) ad_input_code.f |
ftltaf: ftl_taf_output.f |
1397 |
cat ad_input_code_ad.f | sed -f adjoint_sed > flt_taf_output.f |
ftltamc: ftl_tamc_output.f |
1398 |
|
|
1399 |
|
ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES) |
1400 |
|
cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h |
1401 |
|
@make \$(F77FILES) |
1402 |
|
@make \$(AD_FLOW_FILES) |
1403 |
|
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f |
1404 |
|
|
1405 |
flt_taf: flt_taf_output.o \$(OBJFILES) |
ftl_taf_output.f: ftl_input_code.f |
1406 |
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) flt_taf_output.o \$(LIBS) |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f |
1407 |
|
cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f |
1408 |
|
|
1409 |
flt_tamc_output.f: ad_input_code.f |
ftl_taf: ftl_taf_output.o \$(OBJFILES) |
1410 |
\$(TAMC) \$(FTL_TAF_FLAGS) ad_input_code.f |
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) |
|
cat ad_input_code_ad.f | sed -f adjoint_sed > flt_tamc_output.f |
|
1411 |
|
|
1412 |
flt_tamc: flt_tamc_output.o \$(OBJFILES) |
ftl_tamc_output.f: ftl_input_code.f |
1413 |
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) flt_tamc_output.o \$(LIBS) |
\$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f |
1414 |
|
cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_tamc_output.f |
1415 |
|
|
1416 |
|
ftl_tamc: ftl_tamc_output.o \$(OBJFILES) |
1417 |
|
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS) |
1418 |
|
|
1419 |
|
|
1420 |
# ... SVD ... |
# ... SVD ... |
1421 |
svd_taf_output.f: ad_input_code.f |
svd: svd_taf |
1422 |
\$(TAF) \$(SVD_TAF_FLAGS) ad_input_code.f |
svd_taf_f: svd_taf_output.f |
1423 |
cat ad_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f |
|
1424 |
|
svd_input_code.f: \$(SRCFILES) |
1425 |
|
cmp svd_config.template AD_CONFIG.h || cat svd_config.template > AD_CONFIG.h |
1426 |
|
@make \$(F77FILES) |
1427 |
|
@make \$(AD_FLOW_FILES) |
1428 |
|
cat \$(AD_FLOW_FILES) \$(AD_FILES) > svd_input_code.f |
1429 |
|
|
1430 |
|
svd_taf_output.f: svd_input_code.f |
1431 |
|
\$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) svd_input_code.f |
1432 |
|
cat svd_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f |
1433 |
|
|
1434 |
svd_taf: svd_taf_output.o \$(OBJFILES) |
svd_taf: svd_taf_output.o \$(OBJFILES) |
1435 |
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS) |
\$(LINK) -o ${EXE_SVD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS) |
1436 |
|
|
1437 |
|
|
1438 |
#========================================= |
#========================================= |
1473 |
|
|
1474 |
printf "\n=== Done ===\n" |
printf "\n=== Done ===\n" |
1475 |
|
|
1476 |
|
# Write the "template" files for the adjoint builds |
1477 |
|
cat >AD_CONFIG.template <<EOF |
1478 |
|
C WARNING: This file is automatically generated by genmake2 and |
1479 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1480 |
|
C unless you are CERTAIN that you know what you are doing. |
1481 |
|
|
1482 |
|
#undef ALLOW_ADJOINT_RUN |
1483 |
|
#undef ALLOW_TANGENTLINEAR_RUN |
1484 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1485 |
|
EOF |
1486 |
|
cat >ad_config.template <<EOF |
1487 |
|
C WARNING: This file is automatically generated by genmake2 and |
1488 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1489 |
|
C unless you are CERTAIN that you know what you are doing. |
1490 |
|
|
1491 |
|
#define ALLOW_ADJOINT_RUN |
1492 |
|
#undef ALLOW_TANGENTLINEAR_RUN |
1493 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1494 |
|
EOF |
1495 |
|
cat >ftl_config.template <<EOF |
1496 |
|
C WARNING: This file is automatically generated by genmake2 and |
1497 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1498 |
|
C unless you are CERTAIN that you know what you are doing. |
1499 |
|
|
1500 |
|
#undef ALLOW_ADJOINT_RUN |
1501 |
|
#define ALLOW_TANGENTLINEAR_RUN |
1502 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1503 |
|
EOF |
1504 |
|
cat >svd_config.template <<EOF |
1505 |
|
C WARNING: This file is automatically generated by genmake2 and |
1506 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1507 |
|
C unless you are CERTAIN that you know what you are doing. |
1508 |
|
|
1509 |
|
#undef ALLOW_ADJOINT_RUN |
1510 |
|
#undef ALLOW_TANGENTLINEAR_RUN |
1511 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1512 |
|
EOF |
1513 |
|
cp AD_CONFIG.template AD_CONFIG.h |
1514 |
|
|
1515 |
|
|
1516 |
# Write the "state" for future records |
# Write the "state" for future records |
1517 |
if test "x$DUMPSTATE" != xf ; then |
if test "x$DUMPSTATE" != xf ; then |