1 |
#!/bin/bash |
#!/bin/sh |
2 |
# |
# |
3 |
# $Header$ |
# $Header$ |
4 |
# |
# |
216 |
cat $1 | sed -e 's/#.*$//g' \ |
cat $1 | sed -e 's/#.*$//g' \ |
217 |
| $AWK 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \ |
| $AWK 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \ |
218 |
> ./.pd_tmp |
> ./.pd_tmp |
219 |
source ./.pd_tmp |
. ./.pd_tmp |
220 |
rm -f ./.pd_tmp |
rm -f ./.pd_tmp |
221 |
|
|
222 |
echo -n "PNAME = "${} |
echo -n "PNAME = "${} |
281 |
cat > genmake_test.c <<EOF |
cat > genmake_test.c <<EOF |
282 |
void tcall( char * string ) { tsub( string ); } |
void tcall( char * string ) { tsub( string ); } |
283 |
EOF |
EOF |
284 |
$MAKE genmake_test.o > genmake_test.log 2>&1 |
$MAKE genmake_test.o >> genmake_warnings 2>&1 |
285 |
RETVAL=$? |
RETVAL=$? |
286 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
|
cat genmake_test.log >> genmake_errors |
|
287 |
FC_NAMEMANGLE=$default_nm |
FC_NAMEMANGLE=$default_nm |
288 |
echo |
cat <<EOF>> genmake_errors |
289 |
echo "WARNING: C test compile fails -- please see \"genmake_errors\"" |
|
290 |
echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'" |
WARNING: C test compile fails |
291 |
echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here." |
WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE' |
292 |
|
WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here |
293 |
|
EOF |
294 |
return 1 |
return 1 |
295 |
fi |
fi |
296 |
c_tcall=`nm genmake_test.o | grep tcall | cut -d ' ' -f 3` |
c_tcall=`nm genmake_test.o | grep tcall | cut -d ' ' -f 3` |
297 |
RETVAL=$? |
RETVAL=$? |
298 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
299 |
FC_NAMEMANGLE=$default_nm |
FC_NAMEMANGLE=$default_nm |
300 |
echo |
cat <<EOF>> genmake_warnings |
301 |
echo "WARNING: The \"nm\" command failed." |
|
302 |
echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'" |
WARNING: The "nm" command failed. |
303 |
echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here." |
WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE' |
304 |
|
WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here |
305 |
|
EOF |
306 |
return 1 |
return 1 |
307 |
fi |
fi |
308 |
cat > genmake_tcomp.f <<EOF |
cat > genmake_tcomp.f <<EOF |
311 |
call tsub( string ) |
call tsub( string ) |
312 |
end |
end |
313 |
EOF |
EOF |
314 |
$FC $FFLAGS $DEFINES -c genmake_tcomp.f > genmake_tcomp.log 2>&1 |
$FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1 |
315 |
RETVAL=$? |
RETVAL=$? |
316 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
|
cat genmake_tcomp.log >> genmake_errors |
|
317 |
FC_NAMEMANGLE=$default_nm |
FC_NAMEMANGLE=$default_nm |
318 |
echo |
cat <<EOF>> genmake_warnings |
319 |
echo "WARNING: FORTRAN test compile fails -- please see \"genmake_errors\"" |
|
320 |
echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'" |
WARNING: FORTRAN test compile fails -- please see "genmake_errors" |
321 |
echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here." |
WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE' |
322 |
|
WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here. |
323 |
|
EOF |
324 |
return 1 |
return 1 |
325 |
fi |
fi |
326 |
f_tcall=`nm genmake_tcomp.o | grep tcall | cut -d ' ' -f 3` |
f_tcall=`nm genmake_tcomp.o | grep tcall | cut -d ' ' -f 3` |
327 |
RETVAL=$? |
RETVAL=$? |
328 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
329 |
FC_NAMEMANGLE=$default_nm |
FC_NAMEMANGLE=$default_nm |
330 |
echo |
cat <<EOF>> genmake_warnings |
331 |
echo "WARNING: The \"nm\" command failed." |
|
332 |
echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'" |
WARNING: The "nm" command failed. |
333 |
echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here." |
WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE' |
334 |
|
WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here. |
335 |
|
EOF |
336 |
return 1 |
return 1 |
337 |
fi |
fi |
338 |
|
|
359 |
rm -f genmake_tcomp.* genmake_test.* |
rm -f genmake_tcomp.* genmake_test.* |
360 |
} |
} |
361 |
|
|
362 |
|
|
363 |
|
check_HAVE_CLOC() { |
364 |
|
get_fortran_c_namemangling |
365 |
|
cat <<EOF > genmake_tc_1.c |
366 |
|
$FC_NAMEMANGLE |
367 |
|
#include <stdio.h> |
368 |
|
#include <stdlib.h> |
369 |
|
#include <unistd.h> |
370 |
|
#include <assert.h> |
371 |
|
#include <sys/time.h> |
372 |
|
void FC_NAMEMANGLE(cloc) ( double *curtim ) |
373 |
|
{ |
374 |
|
struct timeval tv1; |
375 |
|
gettimeofday(&tv1 , (void *)NULL ); |
376 |
|
*curtim = (double)((tv1.tv_usec)+(tv1.tv_sec)*1.E6); |
377 |
|
*curtim = *curtim/1.E6; |
378 |
|
} |
379 |
|
EOF |
380 |
|
make genmake_tc_1.o >> genmake_tc.log 2>&1 |
381 |
|
RET_C=$? |
382 |
|
cat <<EOF > genmake_tc_2.f |
383 |
|
program hello |
384 |
|
Real*8 wtime |
385 |
|
external cloc |
386 |
|
call cloc(wtime) |
387 |
|
print *," HELLO WORLD", wtime |
388 |
|
end program hello |
389 |
|
EOF |
390 |
|
$FC $FFLAGS -o genmake_tc genmake_tc_2.f genmake_tc_1.o >> genmake_tc.log 2>&1 |
391 |
|
RET_F=$? |
392 |
|
test -x ./genmake_tc && ./genmake_tc >> genmake_tc.log 2>&1 |
393 |
|
RETVAL=$? |
394 |
|
if test "x$RETVAL" = x0 ; then |
395 |
|
HAVE_CLOC=t |
396 |
|
DEFINES="$DEFINES -DHAVE_CLOC" |
397 |
|
fi |
398 |
|
rm -f genmake_tc* |
399 |
|
} |
400 |
|
|
401 |
|
|
402 |
# Set defaults here |
# Set defaults here |
403 |
COMMANDL="$0 $@" |
COMMANDL="$0 $@" |
404 |
|
|
434 |
HAVE_SYSTEM= |
HAVE_SYSTEM= |
435 |
HAVE_FDATE= |
HAVE_FDATE= |
436 |
FC_NAMEMANGLE= |
FC_NAMEMANGLE= |
437 |
|
HAVE_CLOC= |
438 |
|
|
439 |
MODS= |
MODS= |
440 |
TOOLSDIR= |
TOOLSDIR= |
497 |
gm_local="genmake_local" |
gm_local="genmake_local" |
498 |
for i in . $MODS ; do |
for i in . $MODS ; do |
499 |
if test -r $i/$gm_local ; then |
if test -r $i/$gm_local ; then |
500 |
source $i/$gm_local |
. $i/$gm_local |
501 |
break |
break |
502 |
fi |
fi |
503 |
done |
done |
504 |
echo -n " getting local config information: " |
echo -n " getting local config information: " |
505 |
if test -e $gm_local ; then |
if test -e $gm_local ; then |
506 |
echo "using $gm_local" |
echo "using $gm_local" |
507 |
source $gm_local |
. $gm_local |
508 |
# echo "DISABLE=$DISABLE" |
# echo "DISABLE=$DISABLE" |
509 |
# echo "ENABLE=$ENABLE" |
# echo "ENABLE=$ENABLE" |
510 |
else |
else |
708 |
if test "x$OPTFILE" != xNONE ; then |
if test "x$OPTFILE" != xNONE ; then |
709 |
if test -f "$OPTFILE" -a -r "$OPTFILE" ; then |
if test -f "$OPTFILE" -a -r "$OPTFILE" ; then |
710 |
echo " using OPTFILE=\"$OPTFILE\"" |
echo " using OPTFILE=\"$OPTFILE\"" |
711 |
source "$OPTFILE" |
. "$OPTFILE" |
712 |
RETVAL=$? |
RETVAL=$? |
713 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
714 |
echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" |
echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" |
735 |
if test "x${AD_OPTFILE}" != xNONE ; then |
if test "x${AD_OPTFILE}" != xNONE ; then |
736 |
if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then |
if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then |
737 |
echo " using AD_OPTFILE=\"$AD_OPTFILE\"" |
echo " using AD_OPTFILE=\"$AD_OPTFILE\"" |
738 |
source "$AD_OPTFILE" |
. "$AD_OPTFILE" |
739 |
RETVAL=$? |
RETVAL=$? |
740 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
741 |
echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\"" |
echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\"" |
751 |
fi |
fi |
752 |
fi |
fi |
753 |
|
|
754 |
# Check that FC, LINK, CPP, and S64 are defined. If not, complain |
# Check that FC, LINK, CPP, S64, LN, and MAKE are defined. If not, |
755 |
# and abort! |
# either set defaults or complain and abort! |
756 |
if test "x$FC" = x ; then |
if test "x$FC" = x ; then |
757 |
cat <<EOF 1>&2 |
cat <<EOF 1>&2 |
758 |
|
|
769 |
if test "x$CPP" = x ; then |
if test "x$CPP" = x ; then |
770 |
CPP="cpp" |
CPP="cpp" |
771 |
fi |
fi |
772 |
|
if test "x$MAKE" = x ; then |
773 |
|
MAKE="make" |
774 |
|
fi |
775 |
echo "#define A a" | $CPP > test_cpp 2>&1 |
echo "#define A a" | $CPP > test_cpp 2>&1 |
776 |
RETVAL=$? |
RETVAL=$? |
777 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
791 |
if test "x$MAKEDEPEND" = x ; then |
if test "x$MAKEDEPEND" = x ; then |
792 |
MAKEDEPEND=makedepend |
MAKEDEPEND=makedepend |
793 |
fi |
fi |
794 |
|
if test "x$LN" = x ; then |
795 |
|
LN="ln -s" |
796 |
|
fi |
797 |
|
echo "test" > genmake_test_ln |
798 |
|
$LN genmake_test_ln genmake_tlink |
799 |
|
RETVAL=$? |
800 |
|
if test "x$RETVAL" != x0 ; then |
801 |
|
cat <<EOF 1>&2 |
802 |
|
|
803 |
|
Error: The command "ln -s" failed -- please specify a working soft-link |
804 |
|
command in the optfile. |
805 |
|
|
806 |
|
EOF |
807 |
|
exit 1 |
808 |
|
fi |
809 |
|
rm -f genmake_test_ln genmake_tlink |
810 |
|
|
811 |
|
|
812 |
printf "\n=== Checking system libraries ===\n" |
printf "\n=== Checking system libraries ===\n" |
849 |
fi |
fi |
850 |
rm -f genmake_tcomp* |
rm -f genmake_tcomp* |
851 |
|
|
852 |
echo " The name mangling convention for $FC is... " |
echo -n " Can we call simple C routines (here, \"cloc()\") using $FC... " |
853 |
#FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) X ## _" |
check_HAVE_CLOC |
854 |
if test "x$FC_NAMEMANGLE" = x ; then |
if test "x$HAVE_CLOC" != x ; then |
855 |
get_fortran_c_namemangling |
echo "yes" |
856 |
|
else |
857 |
|
echo "no" |
858 |
fi |
fi |
|
echo " '$FC_NAMEMANGLE'" |
|
859 |
echo "$FC_NAMEMANGLE" > FC_NAMEMANGLE.h.template |
echo "$FC_NAMEMANGLE" > FC_NAMEMANGLE.h.template |
860 |
cmp FC_NAMEMANGLE.h FC_NAMEMANGLE.h.template > /dev/null 2>&1 |
cmp FC_NAMEMANGLE.h FC_NAMEMANGLE.h.template > /dev/null 2>&1 |
861 |
RETVAL=$? |
RETVAL=$? |
862 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
863 |
mv -f FC_NAMEMANGLE.h.template FC_NAMEMANGLE.h |
mv -f FC_NAMEMANGLE.h.template FC_NAMEMANGLE.h |
864 |
fi |
fi |
865 |
|
rm -f genmake_t* |
866 |
|
|
867 |
|
|
868 |
printf "\n=== Setting defaults ===\n" |
printf "\n=== Setting defaults ===\n" |
917 |
# they appear as regular source code |
# they appear as regular source code |
918 |
if test -r $ROOTDIR"/eesupp/src/Makefile" ; then |
if test -r $ROOTDIR"/eesupp/src/Makefile" ; then |
919 |
echo " Making source files in eesupp from templates" |
echo " Making source files in eesupp from templates" |
920 |
$MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1 |
( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1 |
921 |
RETVAL=$? |
RETVAL=$? |
922 |
if test "x${RETVAL}" = x0 ; then |
if test "x${RETVAL}" = x0 ; then |
923 |
rm -f make_eesupp.errors |
rm -f make_eesupp.errors |
954 |
echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\"" |
echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\"" |
955 |
exit 1 |
exit 1 |
956 |
fi |
fi |
957 |
source ./.pd_tmp |
. ./.pd_tmp |
958 |
rm -f ./.pd_tmp |
rm -f ./.pd_tmp |
959 |
|
|
960 |
# Search for default packages. Note that a "$ROOTDIR/pkg/pkg_groups" |
# Search for default packages. Note that a "$ROOTDIR/pkg/pkg_groups" |
1548 |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
1549 |
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 |
1550 |
|
|
1551 |
|
adtafonly: |
1552 |
|
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
1553 |
|
cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f |
1554 |
|
|
1555 |
ad_taf: ad_taf_output.o \$(OBJFILES) |
ad_taf: ad_taf_output.o \$(OBJFILES) |
1556 |
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) |
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) |
1557 |
|
|
1578 |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f |
1579 |
cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f |
cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f |
1580 |
|
|
1581 |
|
ftltafonly: |
1582 |
|
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f |
1583 |
|
cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f |
1584 |
|
|
1585 |
ftl_taf: ftl_taf_output.o \$(OBJFILES) |
ftl_taf: ftl_taf_output.o \$(OBJFILES) |
1586 |
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) |
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) |
1587 |
|
|
1594 |
|
|
1595 |
|
|
1596 |
# ... SVD ... |
# ... SVD ... |
1597 |
svd: svd_taf |
svdtaf: ad_taf_output.f ftl_taf_output.f |
1598 |
svd_taf_f: svd_taf_output.f |
svdall: svd_taf |
|
|
|
|
svd_input_code.f: \$(SRCFILES) |
|
|
cmp svd_config.template AD_CONFIG.h || cat svd_config.template > AD_CONFIG.h |
|
|
@make \$(F77FILES) |
|
|
@make \$(AD_FLOW_FILES) |
|
|
cat \$(AD_FLOW_FILES) \$(AD_FILES) > svd_input_code.f |
|
|
|
|
|
svd_taf_output.f: svd_input_code.f |
|
|
\$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) svd_input_code.f |
|
|
cat svd_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f |
|
1599 |
|
|
1600 |
svd_taf: svd_taf_output.o \$(OBJFILES) |
svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES) |
1601 |
\$(LINK) -o ${EXE_SVD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS) |
\$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS) |
1602 |
|
|
1603 |
|
|
1604 |
#========================================= |
#========================================= |