Commit 34b955a3 authored by Darius Buntinas's avatar Darius Buntinas
Browse files

[svn-r8154] reversed r8153, since there were other files that should not have been committed

parent 2c887617
......@@ -4120,13 +4120,18 @@ if test "$enable_f77" = yes ; then
"$ac_cv_sizeof_void_p" -gt "$pac_cv_f77_sizeof_integer" ; then
AC_DEFINE(HAVE_AINT_LARGER_THAN_FINT,1,[Define if addresses are larger than Fortran integers])
fi
if test "$ac_cv_sizeof_void_p" != 0 -a \
"$ac_cv_sizeof_void_p" != "$pac_cv_f77_sizeof_integer" ; then
AC_DEFINE(HAVE_AINT_DIFFERENT_THAN_FINT,1,[Define if addresses are a different size than Fortran integers])
fi
# Include a defined value for Fint is int
if test "$MPI_FINT" = "int" ; then
AC_DEFINE(HAVE_FINT_IS_INT,1,[Define if Fortran integer are the same size as C ints])
elif test "$SIZEOF_F77_INTEGER" != "$ac_cv_sizeof_int" ; then
# Make this fatal because we do not want to build a broken fortran
# interface
AC_MSG_ERROR([Fortran integers and C ints are not the same size. The current Fortran binding does not support this case. Either force the Fortran compiler to use integers of $ac_cv_sizeof_int bytes, or use --disable-f77 on the configure line for MPICH2.])
# interface (was error)
AC_MSG_WARN([Fortran integers and C ints are not the same size. The current Fortran binding does not support this case. Either force the Fortran compiler to use integers of $ac_cv_sizeof_int bytes, or use --disable-f77 on the configure line for MPICH2.])
fi
#
......
......@@ -39,6 +39,13 @@ $free = "MPIU_Free";
$header_file = "mpi_fortimpl.h";
$debug = 0;
$writeRoutineList = 0; # Set to 1 to get a list of MPI routines
$do_fint = 0; # Set to 1 to support C and Fortran integers of a
# different size
$within_fint = 0; # This is set to 1 while generating code for the
# do_fint branch
%fintToHandle = ( 'int' => 1, 'MPI_Request' => 1, 'MPI_Group' => 1,
'MPI_Win' => 1, 'MPI_Info' => 1, 'MPI_Errhandler' => 1,
'MPI_File' => 1, 'MPI_Op' => 1 );
@arg_addresses = ();
#
......@@ -412,16 +419,27 @@ foreach $_ (@ARGV) {
# 'Scan' => '1:2', 'Scan-1' => 'in:bufptr', 'Scan-2' => 'in:bufptr',
#
'Gather' => '1', 'Gather-1' => 'in:inplace',
'Gatherv' => '1', 'Gatherv-1' => 'in:inplace',
'Gatherv' => '1:5:6', 'Gatherv-1' => 'in:inplace',
'Gatherv-5' => 'in:fint2int_array:_commsize(*v9)',
'Gatherv-6' => 'in:fint2int_array:_commsize',
'Scatter' => '4', 'Scatter-4' => 'in:inplace',
'Scatterv' => '5', 'Scatterv-5' => 'in:inplace',
'Scatterv' => '2:3:5',
'Scatterv-2' => 'in:fint2int_array:_commsize(*v9)',
'Scatterv-3' => 'in:fint2int_array:_commsize',
'Scatterv-5' => 'in:inplace',
'Allgather' => '1', 'Allgather-1' => 'in:inplace',
'Allgatherv' => '1', 'Allgatherv-1' => 'in:inplace',
'Reduce' => '1', 'Reduce-1' => 'in:inplace',
'Allreduce' => '1', 'Allreduce-1' => 'in:inplace',
'Reduce_scatter' => '1', 'Reduce_scatter-1' => 'in:inplace',
'Scan' => '1', 'Scan-1' => 'in:inplace',
'Alltoallw' => '2:3:4:6:7:8',
'Alltoallw-2' => 'in:fint2int_array:_commsize(*v9)',
'Alltoallw-3' => 'in:fint2int_array:_commsize',
'Alltoallw-6' => 'in:fint2int_array:_commsize',
'Alltoallw-7' => 'in:fint2int_array:_commsize',
'Alltoallw-4' => 'in:handle_array:_commsize:MPI_Datatype',
'Alltoallw-8' => 'in:handle_array:_commsize:MPI_Datatype',
'Add_error_string' => '2', 'Add_error_string-2' => 'in:addnull',
'Attr_put' => '3', 'Attr_put-3' => 'in:addrint',
......@@ -437,9 +455,30 @@ foreach $_ (@ARGV) {
'Win_get_attr' => '3:4', 'Win_get_attr-4' => 'out:logical',
'Win_get_attr-3' => 'out:attraint:4',
'Buffer_detach' => '1', 'Buffer_detach-1' => 'out:bufaddr',
'Cart_create' => '4:5', 'Cart_create-4' => 'in:logical_array:*v2',
'Cart_create-5' => 'in:logical',
'Cart_get' => '4', 'Cart_get-4' => 'out:logical_array:*v2',
'Cart_create' => '3:4:5:6',
'Cart_create-3' => 'in:fint2int_array:*v2',
'Cart_create-4' => 'in:logical_array:*v2',
'Cart_create-5' => 'in:logical',
'Cart_create-6' => 'out:handle::MPI_Comm',
'Cart_get' => '3:4:5',
'Cart_get-3' => 'out:fint2int_array:*v2',
'Cart_get-4' => 'out:logical_array:*v2',
'Cart_get-5' => 'out:fint2int_array:*v2',
'Cart_sub' => '3', 'Cart_sub-3' => 'out:handle::MPI_Comm',
# FIXME: For cart_sub, need to update arg 2, in:finttoint_array, but
# size is size of input cart
'Dims_create' => '3',
'Dims_create-3' => 'inout:fint2int_array:*v2',
'Graph_create' => '3:4:5:6',
'Graph_create-3' => 'in:fint2int_array:*v2',
'Graph_create-4' => 'in:fint2int_array:*v2',
'Graph_create-5' => 'in:logical',
'Graph_create-6' => 'out:handle::MPI_Comm',
'Comm_create' => '3', 'Comm_create-3' => 'out:handle::MPI_Comm',
'Comm_dup' => '2', 'Comm_dup-2' => 'out:handle::MPI_Comm',
'Comm_split' => '4', 'Comm_split-4' => 'out:handle::MPI_Comm',
'Comm_free' => '1', 'Comm_free-1' => 'inout:handle::MPI_Comm',
'Comm_accept' => '1', 'Comm_accept-1' => 'in:addnull',
'Comm_connect' => '1', 'Comm_connect-1' => 'in:addnull',
'Comm_get_name' => '2', 'Comm_get_name-2' => 'out:blankpad',
......@@ -470,17 +509,21 @@ foreach $_ (@ARGV) {
'Publish_name' => '1:3', 'Publish_name-1' => 'in:addnull',
'Publish_name-3' => 'in:addnull',
# comm spawn multiple needs slightly different routines
'Comm_spawn_multiple' => '2:3:9',
'Comm_spawn_multiple' => '2:3:4:5:8:9',
'Comm_spawn_multiple-2' => 'in:chararray:*v1',
'Comm_spawn_multiple-3' => 'in:chararray2:*v1',
'Comm_spawn_multiple-9' => 'in:errcodesignore',
'Comm_spawn_multiple-9' => 'in:errcodesignore',
'Comm_spawn_multiple-4' => 'in:fint2int_array:*v1',
'Comm_spawn_multiple-5' => 'in:handle_array:*v1:MPI_Info',
'Comm_spawn_multiple-8' => 'out:handle::MPI_Comm',
'Initialized' => '1', 'Initialized-1' => 'out:logical',
'Op_create' => '2', 'Op_create-2' => 'in:logical',
'Iprobe' => '4:5', 'Iprobe-4' => 'out:logical',
'Iprobe-5' => 'in:status',
'Probe' => '4', 'Probe-4' => 'in:status',
'Recv' => '7', 'Recv-7' => 'in:status',
'Sendrecv' => '12', 'Sendrecv-12' => 'in:status',
'Sendrecv_replace' => '9', 'Sendrecv_replace-9' => 'in:status',
'Iprobe-5' => 'out:status',
'Probe' => '4', 'Probe-4' => 'out:status',
'Recv' => '7', 'Recv-7' => 'out:status',
'Sendrecv' => '12', 'Sendrecv-12' => 'out:status',
'Sendrecv_replace' => '9', 'Sendrecv_replace-9' => 'out:status',
# 'Send' => '1', 'Send-1' => 'in:bufptr',
# 'Ssend' => '1', 'Ssend-1' => 'in:bufptr',
# 'Rsend' => '1', 'Rsend-1' => 'in:bufptr',
......@@ -498,29 +541,75 @@ foreach $_ (@ARGV) {
# 'Recv_init' => '1', 'Recv_init-1' => 'in:bufptr',
# 'Sendrecv' => '1:6', 'Sendrecv-1' => 'in:bufptr', 'Sendrecv-6' => 'in:bufptr',
# 'Sendrecv_replace' => '1', 'Sendrecv_replace-1' => 'in:bufptr',
'Test_cancelled' => '2', 'Test_cancelled-2' => 'out:logical',
'Test' => '2:3', 'Test-2' => 'out:logical',
'Test-3' => 'in:status',
'Testall' => '3:4', 'Testall-3' => 'out:logical',
'Testall-4' => 'in:status_array',
'Testany' => '3:4:5', 'Testany-4' => 'out:logical',
'Test_cancelled' => '1:2',
'Test_cancelled-1' => 'in:status',
'Test_cancelled-2' => 'out:logical',
'Test' => '1:2:3', 'Test-1' => 'inout:handle::MPI_Request',
'Test-2' => 'out:logical',
'Test-3' => 'out:status',
'Testall' => '2:3:4', 'Testall-2' => 'inout:handle_array:*v1:MPI_Request',
'Testall-3' => 'out:logical',
'Testall-4' => 'out:status_array:*v1',
'Testany' => '2:3:4:5', 'Testany-2' => 'inout:handle_array:*v1:MPI_Request',
'Testany-4' => 'out:logical',
'Testany-3' => 'out:index',
'Testany-5' => 'in:status',
'Testany-5' => 'out:status',
'Testsome' => '4:5', 'Testsome-4' => 'out:index_array:*v3',
'Testsome-5' => 'in:status_array',
'Testsome-5' => 'out:status_array:*v3',
'Get_count' => '1', 'Get_count-1' => 'in:status',
'Type_contiguous' => '2:3',
'Type_contiguous-2' => 'in:handle::MPI_Datatype',
'Type_contiguous-3' => 'out:handle::MPI_Datatype',
'Type_vector' => '4:5',
'Type_vector-4' => 'in:handle::MPI_Datatype',
'Type_vector-5' => 'out:handle::MPI_Datatype',
'Type_hvector' => '3:4:5',
'Type_hvector-3' => 'in:intToAint',
'Type_hvector-4' => 'in:handle::MPI_Datatype',
'Type_hvector-5' => 'out:handle::MPI_Datatype',
'Type_indexed' => '4:5',
'Type_indexed-4' => 'in:handle::MPI_Datatype',
'Type_indexed-5' => 'out:handle::MPI_Datatype',
'Type_hindexed' => '3:4:5',
'Type_hindexed-3' => 'in:intToAintArr:*v1',
'Type_hindexed-4' => 'in:handle::MPI_Datatype',
'Type_hindexed-5' => 'out:handle::MPI_Datatype',
'Type_struct' => '2:3:4:5',
'Type_struct-2' => 'in:fint2int_array:*v1',
'Type_struct-3' => 'in:intToAintArr:*v1',
'Type_struct-4' => 'in:handle_array:*v1:MPI_Datatype',
'Type_struct-5' => 'out:handle::MPI_Datatype',
'Type_commit' => '1',
'Type_commit-1' => 'inout:handle::MPI_Datatype',
'Type_free' => '1',
'Type_free-1' => 'inout:handle::MPI_Datatype',
'Type_dup' => '2',
'Type_dup-2' => 'out:handle::MPI_Datatype',
'Get_elements' => 1,
'Get_elements-1' => 'in:status',
'Type_create_hvector' => 3, 'Type_create_hvector-3' => 'in:aintToVal',
'Type_create_resized' => '2:3',
'Type_create_resized-2' => 'in:aintToVal',
'Type_create_resized-3' => 'in:aintToVal',
'Type_create_struct' => '2:4',
'Type_create_struct-2' => 'in:fint2int_array:*v1',
'Type_create_struct-4' => 'in:handle_array:*v1:MPI_Datatype',
'Type_create_subarray' => '2:3:4:7',
'Type_create_subarray-2' => 'in:fint2int_array:*v1',
'Type_create_subarray-3' => 'in:fint2int_array:*v1',
'Type_create_subarray-4' => 'in:fint2int_array:*v1',
'Type_create_subarray-7' => 'out:handle::MPI_Datatype',
'Type_get_name' => '2', 'Type_get_name-2' => 'out:blankpad',
'Type_set_name' => '2', 'Type_set_name-2' => 'in:addnull',
'Type_get_contents' => '5:7',
'Type_get_contents-5' => 'out:fint2int_array:*v2',
'Type_get_contents-7' => 'out:handle_array:*v4:MPI_Datatype',
'Type_extent' => '2', 'Type_extent-2' => 'out:aintToInt',
'Type_lb' => '2', 'Type_lb-2' => 'out:aintToInt',
'Type_ub' => '2', 'Type_ub-2' => 'out:aintToInt',
'Type_struct' => '3', 'Type_struct-3' => 'in:intToAintArr:*v1',
'Type_hindexed' => '3', 'Type_hindexed-3' => 'in:intToAintArr:*v1',
# also need
'Type_hvector' => '3', 'Type_hvector-3' => 'in:intToAint',
'Unpack_external' => '1:3', 'Unpack_external-1' => 'in:addnull',
'Unpack_external-3' => 'in:aintToVal',
'Unpublish_name' => '1:3', 'Unpublish_name-1' => 'in:addnull',
......@@ -532,12 +621,19 @@ foreach $_ (@ARGV) {
'Alloc_mem' => '1', 'Alloc_mem-1' => 'in:aintToVal',
'Win_get_name' => '2', 'Win_get_name-2' => 'out:blankpad',
'Win_set_name' => '2', 'Win_set_name-2' => 'in:addnull',
'Wait' => '2', 'Wait-2' => 'in:status',
'Waitall' => '3', 'Waitall-3' => 'in:status_array',
'Waitany' => '3:4', 'Waitany-3' => 'out:index',
'Waitany-4' => 'in:status',
'Waitsome' => '4:5', 'Waitsome-4' => 'out:index_array:*v3',
'Waitsome-5' => 'in:status_array',
'Wait' => '1:2', 'Wait-1' => 'inout:handle::MPI_Request',
'Wait-2' => 'out:status',
'Waitall' => '2:3', 'Waitall-2' => 'inout:handle_array:*v1:MPI_Request',
'Waitall-3' => 'out:status_array:*v1',
'Waitany' => '2:3:4', 'Waitany-2' => 'inout:handle_array:*v1:MPI_Request',
'Waitany-3' => 'out:index',
'Waitany-4' => 'out:status',
'Waitsome' => '2:4:5',
'Waitsome-2' => 'inout:handle_array:*v1:MPI_Request',
'Waitsome-4' => 'out:index_array:*v3',
'Waitsome-5' => 'out:status_array:*v3',
'Startall' => '2',
'Startall-2' => 'in:handle_array:*v1:MPI_Request',
# File routines are separate
'File_open' => '2:5', 'File_open-2' => 'in:addnull',
'File_open-5' => 'out:FileToFint',
......@@ -552,18 +648,26 @@ foreach $_ (@ARGV) {
'Register_datarep-3' => 'in:checkdatarep',
# MPI-2.2 Functions
'Op_commutative' => '2', 'Op_commutative-2' => 'out:logical',
'Dist_graph_create_adjacent' => '4:7:9',
'Dist_graph_create_adjacent-4' => 'in:unweighted',
'Dist_graph_create_adjacent-7' => 'in:unweighted',
'Dist_graph_create_adjacent' => '3:4:6:7:9',
'Dist_graph_create_adjacent-3' => 'in:fint2int_array:*v2',
'Dist_graph_create_adjacent-4' => 'in:unweighted:*v2',
'Dist_graph_create_adjacent-6' => 'in:fint2int_array:*v5',
'Dist_graph_create_adjacent-7' => 'in:unweighted:*v5',
'Dist_graph_create_adjacent-9' => 'in:logical',
'Dist_graph_create' => '6:8',
'Dist_graph_create-6' => 'in:unweighted',
'Dist_graph_create' => '3:4:5:6:8:9',
'Dist_graph_create-3' => 'in:fint2int_array:*v2',
'Dist_graph_create-4' => 'in:fint2int_array:*v2',
'Dist_graph_create-5' => 'in:fint2int_array:_sum(v4,*v2)',
'Dist_graph_create-6' => 'in:unweighted:_ssize',
'Dist_graph_create-8' => 'in:logical',
'Dist_graph_create-9' => 'out:handle::MPI_Comm',
'Dist_graph_neighbors_count' => '4',
'Dist_graph_neighbors_count-4' => 'out:logical',
'Dist_graph_neighbors' => '4:7',
'Dist_graph_neighbors-4' => 'in:unweighted',
'Dist_graph_neighbors-7' => 'in:unweighted',
'Dist_graph_neighbors' => '3:4:6:7',
'Dist_graph_neighbors-3' => 'out:fint2int_array:*v2',
'Dist_graph_neighbors-4' => 'out:unweighted:*v2',
'Dist_graph_neighbors-6' => 'out:fint2int_array:*v5',
'Dist_graph_neighbors-7' => 'out:unweighted:*v5',
);
#
......@@ -690,8 +794,9 @@ maint-clean:\
print MAKEFD "install_INCLUDE = mpif.h\n";
# Add the documentation
# Note that the mpif77 script is now in src/env
print MAKEFD "# Documentation sources
doc_sources = mpif77.txt
doc_sources =
DOCDESTDIRS = html:www/www1,man:man/man1,latex:doc/refman
doc_HTML_SOURCES = \${doc_sources}
doc_MAN_SOURCES = \${doc_sources}
......@@ -1121,7 +1226,7 @@ sub print_args {
# $star_count++;
# }
# If we have an array, and a type mapping to fortran
# We want to simply pretend that all is well (like int
# we want to simply pretend that all is well (like int
# above)
$star_count = 0;
$arg_addresses[$count] = $star_count;
......@@ -1179,8 +1284,10 @@ sub print_args {
# Handle the special arguments
sub print_call_args {
my @parms = split(/\s*,\s*/, $_[0] );
my $fintFix = 0;
my $count = 1;
my $first = 1;
if (defined($_[1])) { $fintFix = 1; }
print $OUTFD "( ";
# Special case: if the only parm is "void", remove it from the list
if ($#parms == 0 && $parms[0] eq "void") {
......@@ -1199,7 +1306,7 @@ sub print_call_args {
if (defined($special_args{"${routine_name}-$count"})) {
# We must handle this argument specially
&print_special_call_arg( $routine_name, $count );
&print_special_call_arg( $routine_name, $count, $parm );
}
elsif ($parm =~ /!/) {
# This parameter is a special case; the exclamation point
......@@ -1211,7 +1318,7 @@ sub print_call_args {
# Convert to/from object type as required.
#print "TMP: parm = $arg_qualifiers[$count]$parm\n";
$fullparm="$arg_qualifiers[$count]$parm";
if (defined($argsneedcast{$fullparm})) {
if (!$fintFix && defined($argsneedcast{$fullparm})) {
$argval = "v$count";
if ($arg_addresses[$count] > 0) {
$argval = "*$argval";
......@@ -1220,6 +1327,18 @@ sub print_call_args {
$callparm =~ s/ARG/$argval/;
print $OUTFD "$callparm";
}
elsif ($fintFix && $parm =~ /^\s*([\w_]+)\s*\*\s*$/) {
$parmtype = $1;
if (defined($fintToHandle{$parmtype})) {
print $OUTFD "\&l$count";
}
else {
if ($arg_addresses[$count] > 0) {
print $OUTFD "*";
}
print $OUTFD "v$count";
}
}
else {
# Since MPICH objects are ints, we don't need to do
# anything unless MPI_Fint and int are different.
......@@ -1284,8 +1403,12 @@ sub print_weak_decl {
# {
# /* Special declarations needed for the variables */
# <name>_<direction>_decl( <argnum> )
# /* Special processing need for in variables */
# /* Special processing needed for in and inout variables */
# <name>_ftoc( <argnum> )
# /* Special processing needed for out variables that may take a null value
# E.g., converting MPI_F_STATUS_IGNORE to MPI_STATUS_IGNORE
# May also be used to allocate arrays needed for in variables
# <name>_<direction>_fnulltoc( <argnum> )
# /* Call the function. Replace special arguments with the output from */
# <name>_<direction>_arg( <argnum> )
# /* Special post call processing (for out variables) */
......@@ -1293,6 +1416,7 @@ sub print_weak_decl {
#
# Special case: For parameters that are arrays, the size of the
# array is in $Array_size.
# The fourth argument can be used for the native type
#
#
# --------------------------------------------------------------------------
......@@ -1337,18 +1461,59 @@ sub inplace_ctof {
my $outvar = $_[1];
}
# --------------------------------------------------------------------------
# MPI_UNWEIGHTED pointers
sub unweighted_ftoc {
# MPI_UNWEIGHTED pointers. Note that unweighted is only used to indicate
# that an array is not provided - thus, if the array is provided and MPI_Fint
# and int are not the same size, we need to include that processing as well.
sub unweighted_in_ftoc {
my $count = $_[0];
&specialInitStatement( $OUTFD );
print $OUTFD " if (v$count == MPIR_F_MPI_UNWEIGHTED) v$count = MPI_UNWEIGHTED;\n";
if ($within_fint) {
print $OUTFD " if (v$count == MPIR_F_MPI_UNWEIGHTED) l$count = MPI_UNWEIGHTED;
else {
int li;
l$count = (int *)$malloc( $Array_size * sizeof(int) );
for (li=0; li<$Array_size; li++) l$count\[li\] = v$count\[li\];
}\n";
$clean_up .= " if (l$count != MPI_UNWEIGHTED) {$free(l$count);}\n";
}
else {
print $OUTFD " if (v$count == MPIR_F_MPI_UNWEIGHTED) v$count = MPI_UNWEIGHTED;\n";
}
}
sub unweighted_out_ftoc {
my $count = $_[0];
&specialInitStatement( $OUTFD );
if ($within_fint) {
print $OUTFD " if (v$count == MPIR_F_MPI_UNWEIGHTED) l$count = MPI_UNWEIGHTED;\n";
}
else {
print $OUTFD " if (v$count == MPIR_F_MPI_UNWEIGHTED) v$count = MPI_UNWEIGHTED;\n";
}
}
sub unweighted_in_decl {
my $count = $_[0];
if ($within_fint) {
print $OUTFD " int *l$count;\n";
}
}
sub unweighted_out_decl {
my $count = $_[0];
if ($within_fint) {
print $OUTFD " int *l$count;\n";
}
}
sub unweighted_in_arg {
my $count = $_[0];
print $OUTFD "v$count";
if ($within_fint) {
print $OUTFD "l$count";
}
else {
print $OUTFD "v$count";
}
}
sub unweighted_out_arg {
my $count = $_[0];
&unweighted_in_arg( $count );
}
# unweighted_ctof( cvar, fvar )
sub unweighted_ctof {
......@@ -1377,7 +1542,7 @@ sub logical_in_arg {
}
}
# logical_ctof( cvar, fvar )
sub logical_ctof {
sub logical_out_ctof {
my $coutvar = $_[0];
my $outvar = $_[1];
if ($do_logical) {
......@@ -1403,7 +1568,8 @@ sub logical_out_arg {
#
# Logical variables, but for an array.
# Array args can use the global $Array_size and $Array_typedef if necessary
sub logical_array_ftoc {
sub logical_array_in_ftoc {
my $count = $_[0];
print $OUTFD "\
{int li;
for (li=0; li<$Array_size; li++) {
......@@ -1422,22 +1588,37 @@ sub logical_array_in_arg {
print $OUTFD "l$count";
}
sub logical_array_ctof {
sub logical_array_out_ctof {
my $coutvar = $_[0];
my $outvar = $_[1];
# Special case if MPI_Fint == int: we use the input variable
# for space.
if (!$within_fint) {
$coutvar = $outvar;
}
print $OUTFD "\
{int li;
for (li=0; li<$Array_size; li++) {
$outvar\[li\] = MPIR_TO_FLOG($outvar\[li\]);
$outvar\[li\] = MPIR_TO_FLOG($coutvar\[li\]);
}
}
";
}
sub logical_array_out_decl {
my $count = $_[0];
if ($within_fint) {
print $OUTFD " int *l$count = (int *)$malloc($Array_size * sizeof(int));\n";
$clean_up .= " $free( l$count );\n";
}
else {
; # Nothing required
}
}
sub logical_array_out_arg {
my $count = $_[0];
print $OUTFD "v$count";
my $varname = "v$count";
if ($within_fint) { $varname = "l$count"; }
print $OUTFD $varname;
}
# --------------------------------------------------------------------------
#
......@@ -1467,22 +1648,267 @@ sub index_out_arg {
sub index_array_ftoc {
my $count = $_[0];
}
sub index_array_out_ftoc {
my $count = $_[0];
if ($within_fint) {
print $OUTFD " l$count = (int *)$malloc( $Array_size * sizeof(int) );\n";
}
}
sub index_array_ctof {
my $coutvar = $_[0];
my $outvar = $_[1];
print $OUTFD "\
if ($within_fint) {
print $OUTFD "\
{int li;
for (li=0; li<$Array_size; li++) {
if ($coutvar\[li\] >= 0) $outvar\[li\] = $coutvar\[li\] + 1;
}
}
";
$clean_up .= " $free( $coutvar );\n";
}
else {
print $OUTFD "\
{int li;
for (li=0; li<$Array_size; li++) {
if ($outvar\[li\] >= 0) $outvar\[li\] += 1;
}
}
"
}
}
sub index_array_out_decl {
my $count = $_[0];
if ($within_fint) {
print $OUTFD " int *l$count=0;\n";
}
}
sub index_array_out_arg {
my $count = $_[0];
print $OUTFD "v$count";
if ($within_fint) {
print $OUTFD "l$count";
}
else {
print $OUTFD "v$count";
}
}
# --------------------------------------------------------------------------
#
# Handle variables.
# Index variables are not optional, since the values of the variable
# are changed.
sub handle_ftoc {
my $count = $_[0];
my $parm = $_[1];
if ($within_fint) {
my $basetype = $nativeType;
$basetype =~ s/MPI_//;
if ($basetype eq "Datatype") { $basetype = "Type"; }
print $OUTFD " l$count = MPI_".$basetype."_f2c( *v$count );\n";
}
}
sub handle_in_ftoc {
my $count = $_[0];
my $parm = $_[1];
if ($within_fint) {
my $basetype = $nativeType;
$basetype =~ s/MPI_//;
if ($basetype eq "Datatype") { $basetype = "Type"; }
print $OUTFD " l$count = MPI_".$basetype."_f2c( *v$count );\n";
}
}
sub handle_inout_ftoc {
my $count = $_[0];
my $parm = $_[1];
&handle_in_ftoc( $count, $parm );
}
sub handle_out_ctof {
my $coutvar = $_[0];
my $outvar = $_[1];
if ($within_fint) {
print $OUTFD " *$outvar = (MPI_Fint)$coutvar;\n";
}
}
sub handle_out_decl {
my $count = $_[0];
if ($within_fint) {
print $OUTFD " $nativeType l$count;\n";
}
}
sub handle_inout_decl {
my $count = $_[0];
if ($within_fint) {
print $OUTFD " $nativeType l$count;\n";
}
}
sub handle_in_decl {
my $count = $_[0];
if ($within_fint) {
print $OUTFD " $nativeType l$count;\n";
}
}
sub handle_out_arg {
my $count = $_[0];
my $parm = $_[1];
if ($within_fint) {
print $OUTFD " \&l$count";
}
else {
print $OUTFD "($parm)(v$count)";
}
}
sub handle_inout_arg {
my $count = $_[0];
my $parm = $_[1];
&handle_out_arg( $count, $parm );
}