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 |
|
|
910 |
fi |
fi |
911 |
done |
done |
912 |
|
|
|
# This is compatible with the old genmake. The "DISABLE_*" flags |
|
|
# need to be replaced by the "ALLOW_*" flags set below. |
|
|
# |
|
|
# echo -n " Setting package-specific CPP flags: " |
|
|
# pkrm=( mom_fluxform mom_vecinv generic_advdiff ) |
|
|
# pkrmdef=( -DDISABLE_MOM_FLUXFORM -DDISABLE_MOM_VECINV -DDISABLE_GENERIC_ADVDIFF -DDISABLE_DEBUGMODE ) |
|
|
# echo -n " " |
|
|
# i=0 |
|
|
# while test $i -lt "${#pkrm[@]}" ; do |
|
|
# echo "$PACKAGES" | grep "${pk[$i]}" > /dev/null 2>&1 |
|
|
# RETVAL=$? |
|
|
# if test "x$RETVAL" = x1 ; then |
|
|
# DEFINES="$DEFINES ${pkdef[$i]}" |
|
|
# echo -n " ${pkdef[$i]}" |
|
|
# fi |
|
|
# i=$(( $i + 1 )) |
|
|
# done |
|
|
# echo |
|
913 |
|
|
914 |
# Create a list of #define and #undef to enable/disable packages |
# Create a list of #define and #undef to enable/disable packages |
915 |
PACKAGES_DOT_H=PACKAGES_CONFIG.h |
PACKAGES_DOT_H=PACKAGES_CONFIG.h |
943 |
if test "x$has_pack" = xf ; then |
if test "x$has_pack" = xf ; then |
944 |
undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'` |
undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'` |
945 |
echo "#undef $undef" >> $PACKAGES_DOT_H".tmp" |
echo "#undef $undef" >> $PACKAGES_DOT_H".tmp" |
|
# DEFINES="$DEFINES -U$undef" |
|
|
|
|
|
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
|
|
case $n in |
|
|
mom_fluxform) |
|
|
DEFINES="$DEFINES -DDISABLE_MOM_FLUXFORM" |
|
|
;; |
|
|
mom_vecinv) |
|
|
DEFINES="$DEFINES -DDISABLE_MOM_VECINV" |
|
|
;; |
|
|
debug) |
|
|
DEFINES="$DEFINES -DDISABLE_DEBUGMODE" |
|
|
;; |
|
|
esac |
|
|
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
|
|
|
|
946 |
fi |
fi |
947 |
fi |
fi |
948 |
done |
done |
1008 |
fi |
fi |
1009 |
done |
done |
1010 |
|
|
1011 |
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" |
1012 |
echo " of \"#define ALLOW_PKGNAME\"-type statements:" |
echo " of \"#define ALLOW_PKGNAME\"-type statements:" |
1013 |
CPP_OPTIONS= |
CPP_OPTIONS= |
1014 |
spaths=". $INCLUDEDIRS" |
spaths=". $INCLUDEDIRS" |
1015 |
for i in $spaths ; do |
for i in $spaths ; do |
1140 |
echo "# $0 $@" >> $MAKEFILE |
echo "# $0 $@" >> $MAKEFILE |
1141 |
echo "# executed by:" >> $MAKEFILE |
echo "# executed by:" >> $MAKEFILE |
1142 |
echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE |
echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE |
1143 |
|
|
1144 |
|
EXE_AD=$EXECUTABLE"_ad" |
1145 |
|
EXE_FTL=$EXECUTABLE"_ftl" |
1146 |
|
EXE_SVD=$EXECUTABLE"_svd" |
1147 |
|
|
1148 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
1149 |
# |
# |
1150 |
# BUILDDIR : Directory where object files are written |
# BUILDDIR : Directory where object files are written |
1175 |
|
|
1176 |
#eh3 new defines for the adjoint work |
#eh3 new defines for the adjoint work |
1177 |
AUTODIFF = ${ROOTDIR}/pkg/autodiff |
AUTODIFF = ${ROOTDIR}/pkg/autodiff |
1178 |
|
EXE_AD = ${EXE_AD} |
1179 |
|
EXE_FTL = ${EXE_FTL} |
1180 |
|
EXE_SVD = ${EXE_SVD} |
1181 |
|
|
1182 |
EOF |
EOF |
1183 |
|
|
1259 |
@\$(EXECUTABLE) > \$@ |
@\$(EXECUTABLE) > \$@ |
1260 |
|
|
1261 |
clean: |
clean: |
1262 |
|
-cat AD_CONFIG.template > AD_CONFIG.h |
1263 |
-rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} |
-rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} |
1264 |
Clean: |
Clean: |
1265 |
@make clean |
@make clean |
1266 |
@make cleanlinks |
@make cleanlinks |
1267 |
-rm -f Makefile.bak genmake_state genmake_optfile make.log |
-rm -f Makefile.bak genmake_state genmake_*optfile make.log |
1268 |
CLEAN: |
CLEAN: |
1269 |
@make Clean |
@make Clean |
1270 |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
1272 |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
1273 |
-rm -f \$(EXECUTABLE) output.txt |
-rm -f \$(EXECUTABLE) output.txt |
1274 |
|
|
1275 |
Makefile: makefile |
#eh3 Makefile: makefile |
1276 |
makefile: |
makefile: |
1277 |
${0} $@ |
${0} $@ |
1278 |
cleanlinks: |
cleanlinks: |
1327 |
echo -n " $i" >> $MAKEFILE |
echo -n " $i" >> $MAKEFILE |
1328 |
done |
done |
1329 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
1330 |
|
rm -f ad_files |
1331 |
|
|
1332 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
1333 |
|
|
1334 |
ad_input_code.f: \$(F77FILES) |
# ... AD ... |
1335 |
|
adall: ad_taf |
1336 |
|
adtaf: ad_taf_output.f |
1337 |
|
adtamc: ad_tamc_output.f |
1338 |
|
|
1339 |
|
ad_input_code.f: \$(AD_FILES) \$(HEADERFILES) |
1340 |
|
cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h |
1341 |
|
@make \$(F77FILES) |
1342 |
@make \$(AD_FLOW_FILES) |
@make \$(AD_FLOW_FILES) |
1343 |
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f |
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f |
1344 |
|
|
|
# ... AD ... |
|
1345 |
ad_taf_output.f: ad_input_code.f |
ad_taf_output.f: ad_input_code.f |
1346 |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
1347 |
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 |
1348 |
|
|
1349 |
ad_taf: ad_taf_output.o \$(OBJFILES) |
ad_taf: ad_taf_output.o \$(OBJFILES) |
1350 |
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) |
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) |
1351 |
|
|
1352 |
ad_tamc_output.f: ad_input_code.f |
ad_tamc_output.f: ad_input_code.f |
1353 |
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f |
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f |
1354 |
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 |
1355 |
|
|
1356 |
ad_tamc: ad_tamc_output.o \$(OBJFILES) |
ad_tamc: ad_tamc_output.o \$(OBJFILES) |
1357 |
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) |
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) |
1358 |
|
|
1359 |
|
|
1360 |
# ... FLT ... |
# ... FTL ... |
1361 |
flt_taf_output.f: ad_input_code.f |
ftlall: ftl_taf |
1362 |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
ftltaf: ftl_taf_output.f |
1363 |
cat ad_input_code_ad.f | sed -f adjoint_sed > flt_taf_output.f |
ftltamc: ftl_tamc_output.f |
1364 |
|
|
1365 |
flt_taf: flt_taf_output.o \$(OBJFILES) |
ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES) |
1366 |
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) flt_taf_output.o \$(LIBS) |
cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h |
1367 |
|
@make \$(F77FILES) |
1368 |
|
@make \$(AD_FLOW_FILES) |
1369 |
|
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f |
1370 |
|
|
1371 |
|
ftl_taf_output.f: ftl_input_code.f |
1372 |
|
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f |
1373 |
|
cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f |
1374 |
|
|
1375 |
|
ftl_taf: ftl_taf_output.o \$(OBJFILES) |
1376 |
|
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) |
1377 |
|
|
1378 |
flt_tamc_output.f: ad_input_code.f |
ftl_tamc_output.f: ftl_input_code.f |
1379 |
\$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f |
\$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f |
1380 |
cat ad_input_code_ad.f | sed -f adjoint_sed > flt_tamc_output.f |
cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_tamc_output.f |
1381 |
|
|
1382 |
flt_tamc: flt_tamc_output.o \$(OBJFILES) |
ftl_tamc: ftl_tamc_output.o \$(OBJFILES) |
1383 |
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) flt_tamc_output.o \$(LIBS) |
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS) |
1384 |
|
|
1385 |
|
|
1386 |
# ... SVD ... |
# ... SVD ... |
1387 |
svd_taf_output.f: ad_input_code.f |
svd: svd_taf |
1388 |
\$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
svd_taf_f: svd_taf_output.f |
1389 |
cat ad_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f |
|
1390 |
|
svd_input_code.f: \$(SRCFILES) |
1391 |
|
cmp svd_config.template AD_CONFIG.h || cat svd_config.template > AD_CONFIG.h |
1392 |
|
@make \$(F77FILES) |
1393 |
|
@make \$(AD_FLOW_FILES) |
1394 |
|
cat \$(AD_FLOW_FILES) \$(AD_FILES) > svd_input_code.f |
1395 |
|
|
1396 |
|
svd_taf_output.f: svd_input_code.f |
1397 |
|
\$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) svd_input_code.f |
1398 |
|
cat svd_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f |
1399 |
|
|
1400 |
svd_taf: svd_taf_output.o \$(OBJFILES) |
svd_taf: svd_taf_output.o \$(OBJFILES) |
1401 |
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS) |
\$(LINK) -o ${EXE_SVD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS) |
1402 |
|
|
1403 |
|
|
1404 |
#========================================= |
#========================================= |
1439 |
|
|
1440 |
printf "\n=== Done ===\n" |
printf "\n=== Done ===\n" |
1441 |
|
|
1442 |
|
# Write the "template" files for the adjoint builds |
1443 |
|
cat >AD_CONFIG.template <<EOF |
1444 |
|
C WARNING: This file is automatically generated by genmake2 and |
1445 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1446 |
|
C unless you are CERTAIN that you know what you are doing. |
1447 |
|
|
1448 |
|
#undef ALLOW_ADJOINT_RUN |
1449 |
|
#undef ALLOW_TANGENTLINEAR_RUN |
1450 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1451 |
|
EOF |
1452 |
|
cat >ad_config.template <<EOF |
1453 |
|
C WARNING: This file is automatically generated by genmake2 and |
1454 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1455 |
|
C unless you are CERTAIN that you know what you are doing. |
1456 |
|
|
1457 |
|
#define ALLOW_ADJOINT_RUN |
1458 |
|
#undef ALLOW_TANGENTLINEAR_RUN |
1459 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1460 |
|
EOF |
1461 |
|
cat >ftl_config.template <<EOF |
1462 |
|
C WARNING: This file is automatically generated by genmake2 and |
1463 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1464 |
|
C unless you are CERTAIN that you know what you are doing. |
1465 |
|
|
1466 |
|
#undef ALLOW_ADJOINT_RUN |
1467 |
|
#define ALLOW_TANGENTLINEAR_RUN |
1468 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1469 |
|
EOF |
1470 |
|
cat >svd_config.template <<EOF |
1471 |
|
C WARNING: This file is automatically generated by genmake2 and |
1472 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1473 |
|
C unless you are CERTAIN that you know what you are doing. |
1474 |
|
|
1475 |
|
#undef ALLOW_ADJOINT_RUN |
1476 |
|
#undef ALLOW_TANGENTLINEAR_RUN |
1477 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1478 |
|
EOF |
1479 |
|
cp AD_CONFIG.template AD_CONFIG.h |
1480 |
|
|
1481 |
|
|
1482 |
# Write the "state" for future records |
# Write the "state" for future records |
1483 |
if test "x$DUMPSTATE" != xf ; then |
if test "x$DUMPSTATE" != xf ; then |