X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5c8ede40c4f5e920bd12b2e4ede74db2892e0d60..7f04fa5306f52960db709bb520c49e9f4ecec000:/src/smpi/smpif2c.in diff --git a/src/smpi/smpif2c.in b/src/smpi/smpif2c.in index 1d6c4d0703..4b99f2b946 100755 --- a/src/smpi/smpif2c.in +++ b/src/smpi/smpif2c.in @@ -5,17 +5,27 @@ use strict; use File::Temp; use File::Copy; -my $include="-I@top_srcdir@/include -I@top_srcdir@/include/smpi -I@includedir@ -I@includedir@/smpi"; +my $include="@includeflag@@f2cflags@"; foreach my $fortran (@ARGV) { my $output = $fortran; $output =~ s/.f$/.c/; + + #print "F2C INPUT : ".$fortran."\n"; + #print "F2C OUTPUT: ".$output."\n"; + + my$outputdir = $output; + $outputdir=~s/[^\/]*\.c$//g; + #print "F2C DIR : ".$outputdir."\n"; + my $tmp = new File::Temp; $tmp->autoflush(1); - `f2c $include -w -a $fortran`; + #print "f2c -d$outputdir $include -w -a $fortran\n"; + `f2c -d$outputdir $include -w -a $fortran`; die "F2C failed\n" if $?; - open F2C,"<$output"; + open F2C,"<$output" or die "Unable to open file $output"; my $started = 0; + my $cutext = 0; print $tmp "#ifndef INTEGER_STAR_8\n"; print $tmp "#define INTEGER_STAR_8\n"; print $tmp "#endif\n"; @@ -30,7 +40,7 @@ foreach my $fortran (@ARGV) { if(/^} (.*?);/) { $_ = "}* __attribute__((weak)) $1 = NULL;\n"; } elsif(/^#define\s*(\S*)\s*\(?([^.]*)(\..*?)?\)?$/) { - $_ = "#define $1 $2\[smpi_process_index()\]"; + $_ = "#define $1 $2\[smpi_current_rank\]"; if(defined $3) { $_ .= $3; } @@ -42,8 +52,18 @@ foreach my $fortran (@ARGV) { if(/\/\* Table of constant values \*\// || /MAIN__/) { $started = 0; } + if(/extern \/\* Subroutine \*\//) { + $cutext = 1; + } + $_ =~ s/(mpi_[\w]*_)_/$1/g; + if($cutext) { + if(/;$/) { + $cutext = 0; + } + next; + } if(/\/* Main program alias \*\/\s*int\s+.*\s*\(\s*\)\s*{(.*)}/) { - $_ = "int smpi_simulated_main(int argc, char** argv) { smpi_process_init(&argc, &argv); $1 }\n"; + $_ = "int smpi_simulated_main_(int argc, char** argv) { smpi_process_init(&argc, &argv); $1 }\n"; } print $tmp "$_\n"; }