Commit 5667db7c authored by Philip Carns's avatar Philip Carns
Browse files

support -fc, -f90, and -f77 in gen-fortran script


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@499 3b7491f3-a168-0410-bf4b-c445ed680a29
parent 7125ced8
...@@ -72,18 +72,42 @@ if($trim_exe_path) ...@@ -72,18 +72,42 @@ if($trim_exe_path)
open (OUTPUT, ">$output_file") || die("Error opening output file: $!"); open (OUTPUT, ">$output_file") || die("Error opening output file: $!");
# substitute arguments and darshan options into commands # split the link command from the original mpicc script so that we have the
$base_link_cmd = $link_cmd; # part before the "foo.o -o foo", which is assumed to be FC, and the part
$base_link_cmd =~ s/foo.o -o foo/"\$\{allargs\[\@\]\}"/g; # that comes afterwards, which is assumed to be the required link flags and
$link_cmd =~ s/foo.o -o foo/"\$\{newallargs\[\@\]\}" -L$DARSHAN_LIB_PATH $DARSHAN_LDFLAGS \$FMPICH -ldarshan-mpi-io -lz $CP_WRAPPERS/g; # libraries.
$link_cmd =~ s/$/ -L$DARSHAN_LIB_PATH -ldarshan-posix/g; if(!($link_cmd =~ /(.+)\s+(foo.o -o foo)\s+(.*)/))
$compile_cmd =~ s/-c foo.c/"\$\{allargs\[\@\]\}"/g; {
printf STDERR "Error: improperly formatted link cmd: $link_cmd\n";
exit(1);
}
$FC_from_link=$1;
$base_link_cmd_suffix="\"\$\{allargs\[\@\]\}\" $3";
$link_cmd_suffix="\"\$\{newallargs\[\@\]\}\" -L$DARSHAN_LIB_PATH $DARSHAN_LD_FLAGS \$FMPICH -ldarshan-mpi-io -lz $CP_WRAPPERS $3 -L$DARSHAN_LIB_PATH -ldarshan-posix";
# repeat the above step for the compilation command line
if(!($compile_cmd =~ /(.+)\s+(-c foo.c)\s+(.*)/))
{
printf STDERR "Error: improperly formatted compile cmd: $compile_cmd\n";
exit(1);
}
$FC_from_compile=$1;
$compile_cmd_suffix="\"\$\{allargs\[\@\]\}\" $3";
# we expect to see the same FC command in both the link and compile steps
if($FC_from_link ne $FC_from_compile)
{
printf STDERR "Error: cannot find matching FC from: $compile_cmd\n";
printf STDERR "and: $link_cmd\n";
exit(1);
}
$FC=$FC_from_compile;
# create link cmd with noshrargs variable # create link cmd with noshrargs variable
$link_cmd_no_shared = $base_link_cmd; $link_cmd_no_shared_suffix = $base_link_cmd_suffix;
$link_cmd_no_shared =~ s/allargs/noshrargs/; $link_cmd_no_shared_suffix =~ s/allargs/noshrargs/;
print OUTPUT<<'EOF'; print OUTPUT<<"EOF";
#!/bin/bash #!/bin/bash
# #
# Auto-generated mpicc script from darshan-gen-cc.pl # Auto-generated mpicc script from darshan-gen-cc.pl
...@@ -93,6 +117,7 @@ print OUTPUT<<'EOF'; ...@@ -93,6 +117,7 @@ print OUTPUT<<'EOF';
# Show is set to echo to cause the compilation command to be echoed instead # Show is set to echo to cause the compilation command to be echoed instead
# of executed. # of executed.
Show= Show=
FC="$FC"
EOF EOF
if ($xl_check == 1) if ($xl_check == 1)
...@@ -150,6 +175,18 @@ print OUTPUT<<'EOF'; ...@@ -150,6 +175,18 @@ print OUTPUT<<'EOF';
linking=no linking=no
fi fi
;; ;;
-f77=*)
FC=`echo A$arg | sed -e 's/A-f77=//g'`
addarg=no
;;
-f90=*)
FC=`echo A$arg | sed -e 's/A-f90=//g'`
addarg=no
;;
-fc=*)
FC=`echo A$arg | sed -e 's/A-fc=//g'`
addarg=no
;;
-show) -show)
addarg=no addarg=no
Show=echo Show=echo
...@@ -226,7 +263,7 @@ print OUTPUT<<"EOF"; ...@@ -226,7 +263,7 @@ print OUTPUT<<"EOF";
fi fi
argno=`expr \$argno + 1` argno=`expr \$argno + 1`
done done
$link_cmd_no_shared -Wl,-Map,\$tmpfile \$LDFLAGS -o /dev/null >& /dev/null \$FC $link_cmd_no_shared_suffix -Wl,-Map,\$tmpfile \$LDFLAGS -o /dev/null >& /dev/null
# is MPI in there? # is MPI in there?
grep -i MPI \$tmpfile >& /dev/null grep -i MPI \$tmpfile >& /dev/null
...@@ -253,18 +290,18 @@ print OUTPUT<<"EOF"; ...@@ -253,18 +290,18 @@ print OUTPUT<<"EOF";
# disable darshan if something else is already using PMPI; we don't # disable darshan if something else is already using PMPI; we don't
# want to cause any symbol conflicts # want to cause any symbol conflicts
if [ \$rc_pmpi -ne 0 ] && [ \$compiler_check -eq 0 ]; then if [ \$rc_pmpi -ne 0 ] && [ \$compiler_check -eq 0 ]; then
\$Show $link_cmd \$Show \$FC $link_cmd_suffix
used_darshan=1 used_darshan=1
fi fi
fi fi
# otherwise use the normal command line # otherwise use the normal command line
if [ "\$used_darshan" = "0" ] ; then if [ "\$used_darshan" = "0" ] ; then
\$Show $base_link_cmd \$Show \$FC $base_link_cmd_suffix
fi fi
rc=\$? rc=\$?
else else
\$Show $compile_cmd \$Show \$FC $compile_cmd_suffix
rc=\$? rc=\$?
fi fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment