📄 buildiface
字号:
print $OUTFD " *ierr = MPI_$routine_name"; print "Printing call arguments for mpi_${lcname}_\n" if $debug; &print_call_args( $args ); # Print any post call processing &print_post_call( $routine_name, $args ); print $OUTFD "}\n"; if ($buildfiles) { close ($OUTFD); } if ($build_prototypes) { if ($do_subdecls) { print PROTOFD "FORTRAN_API void FORT_CALL mpi_${lcname}_ "; } else { print PROTOFD "void mpi_${lcname}_ "; } &print_args( PROTOFD, $args ); print PROTOFD ";\n"; } } }}# Build the special routines&build_specials;## This block can be used to create the Makefileopen ( MAKEFD, ">Makefile.sm" ) || die "Cannot create Makefile.sm";print MAKEFD "# DO NOT EDIT\n# This file created by buildiface $arg_string\n";# Check to see if autoconf works. Autoconf 2.13 has a bug in the Fortran # language support that will break this module. Since some sites have # corrected the bug in autoconf 2.13, CheckAutoconf test for this bug.if (&CheckAutoconf) { # Autoconf does not work print MAKEFD "smvar_autoconf = autoconf:autoconf-2.52:/home/gropp/bin/linux/autoconf\n"; print MAKEFD "smvar_autoconf_version = 2.52\n";}else { # just use the regular autoconf ;}#print MAKEFD "smvar_debug = 1\n";print MAKEFD "smvar_do_dependencies = 0\n";&print_line( MAKEFD, "mpi_sources = ", 80, "\\\n\t", 8 );for ($i=0; $i<=$#files; $i++) { $name = $files[$i]; &print_line( MAKEFD, "$name ", 80, "\\\n\t", 8 );}&print_endline( MAKEFD );print MAKEFD "lib\${MPILIBNAME}_a_SOURCES = \${mpi_sources} setbotf.f \\profilelib_\${MPILIBNAME} = p\${MPILIBNAME}\INCLUDES = -I../../include -I\${master_top_srcdir}/src/include\maint-clean:\\trm -f \${mpi_sources} fproto.h\n";print MAKEFD "install_INCLUDE = mpif.h\n";close( MAKEFD );## ------------------------------------------------------------------------# Procedures# print_line( FD, line, count, continue, continuelen )# Print line to FD; if line size > count, output continue string and# continue. Use print_endline to finish a linesub print_line { my $FD = $_[0]; my $line = $_[1]; my $count = $_[2]; my $continue = $_[3]; my $continue_len = $_[4]; $linelen = length( $line ); #print "linelen = $linelen, print_line_len = $print_line_len\n"; if ($print_line_len + $linelen > $count) { print $FD $continue; $print_line_len = $continue_len; } print $FD $line; $print_line_len += $linelen;}sub print_endline { my $FD = $_[0]; print $FD "\n"; $print_line_len = 0;}# Print the header of the file, containing the definitions etc.sub print_header { my $routine_name = $_[0]; my $lcname = $_[1]; &print_copyright( ); &print_profiling_block( $routine_name, $lcname ); &print_name_map_block( $routine_name, $lcname );}sub print_copyright { print $OUTFD "/* -*- Mode: C; c-basic-offset:4 ; -*- */\/* \ * (C) 2001 by Argonne National Laboratory.\ * See COPYRIGHT in top-level directory.\ *\ * This file is automatically generated by buildiface $arg_string\ * DO NOT EDIT\ */\#include \"mpi_fortimpl.h\"\n\n";}## Print the (ugly) profiling name definition block.sub print_profiling_block { my $routine_name = $_[0]; my $lcname = $_[1]; my $ucname = uc($lcname); if ($do_weak) { print $OUTFD "\/* Begin MPI profiling block */\#if defined(HAVE_WEAK_SYMBOLS)\#if defined(HAVE_PRAGMA_WEAK)\#if defined(F77_NAME_UPPER)\#pragma weak MPI_$ucname = PMPI_$ucname\#elif defined(F77_NAME_LOWER_2USCORE)\#pragma weak mpi_${lcname}__ = pmpi_${lcname}__\#elif !defined(F77_NAME_LOWER_USCORE)\#pragma weak mpi_$lcname = pmpi_$lcname\#else\#pragma weak mpi_${lcname}_ = pmpi_${lcname}_\#endif\\#elif defined(HAVE_PRAGMA_HP_SEC_DEF)\#if defined(F77_NAME_UPPER)\#pragma _HP_SECONDARY_DEF PMPI_$ucname MPI_$ucname\#elif defined(F77_NAME_LOWER_2USCORE)\#pragma _HP_SECONDARY_DEF pmpi_${lcname}__ MPI_${ucname}__\#elif !defined(F77_NAME_LOWER_USCORE)\#pragma _HP_SECONDARY_DEF pmpi_$lcname mpi_$ucname\#else\#pragma _HP_SECONDARY_DEF pmpi_${lcname}_ mpi_${ucname}_\#endif\\#elif defined(HAVE_PRAGMA_CRI_DUP)\#if defined(F77_NAME_UPPER)\#pragma _CRI duplicate MPI_$ucname as PMPI_$ucname\#elif defined(F77_NAME_LOWER_2USCORE)\#pragma _CRI duplicate mpi_${lcname}__ as pmpi_${lcname}__\#elif !defined(F77_NAME_LOWER_USCORE)\#pragma _CRI duplicate mpi_${lcname} as pmpi_${lcname}\#else\#pragma _CRI duplicate mpi_${lcname}_ as pmpi_${lcname}_\#endif\#endif /* HAVE_PRAGMA_WEAK */\#endif /* HAVE_WEAK_SYMBOLS */\/* End MPI profiling block */\n\n"; }}## Print the code that modifies the name# The function prototypes must be loaded *after* the name block so that the# name used in the function prototypes will match the one that is declared# in this file.sub print_name_map_block { my $routine_name = $_[0]; my $lcname = $_[1]; my $ucname = uc($lcname); # This include the code to map names for the profiling interface, # using the same macro as for the rest of the MPI code print $OUTFD "/* Map the name to the correct form */#ifndef MPICH_MPI_FROM_PMPI#ifdef F77_NAME_UPPER#define mpi_${lcname}_ PMPI_${ucname}#elif defined(F77_NAME_LOWER_2USCORE)#define mpi_${lcname}_ pmpi_${lcname}__#elif !defined(F77_NAME_LOWER_USCORE)#define mpi_${lcname}_ pmpi_${lcname}#else#define mpi_${lcname}_ pmpi_${lcname}_#endif#else#ifdef F77_NAME_UPPER#define mpi_${lcname}_ MPI_${ucname}#elif defined(F77_NAME_LOWER_2USCORE)#define mpi_${lcname}_ mpi_${lcname}__#elif !defined(F77_NAME_LOWER_USCORE)#define mpi_${lcname}_ mpi_${lcname}/* Else leave name alone */#endif#endif /* MPICH_MPI_FROM_PMPI *//* Prototypes for the Fortran interfaces */#include \"fproto.h\"";}# Print the arguments for the routine DEFINITION.sub print_args { my @parms = split(/\s*,\s*/, $_[1] ); my $OUTFD = $_[0]; my $count = 1; my $last_args = ""; # Clear the @arg_addresses array. $#arg_addresses = -1; # Special case: if the only parm is "void", remove it from the list print STDERR "Nparms = $#parms, parms = " . join(',',@parms) . "\n" if $debug; if ($#parms == 0 && $parms[0] eq "void") { $#parms = -1; } print $OUTFD "( "; foreach $parm (@parms) { # Match type to replacement print "parm = :$parm:\n" if $debug; # Remove blanks from the parm $parm =~ s/\s//; $arg_addresses[$count] = 0; if ($parm =~ /char\s*\*/) { # char's go out at char *v FORT_MIXED_LEN(d) # and FORT_END_LEN(d) at the end # FORT_END_LEN and FORT_MIXED_LEN contain the necessary comman # if they are prsent at all. print $OUTFD "char *v$count FORT_MIXED_LEN(d$count), "; $last_args .= "FORT_END_LEN(d$count) "; } elsif ($parm =~/\[/) { # Argument type is array, so we need to # a) mark as containing a star # b) place parameter correctly $star_count = 1; $arg_addresses[$count] = $star_count; # Split into raw type and [] $parm =~ /\s*([^\s]*)\s*(\[\s*\])/; $basetype = $1; print "\tparm is array of $basetype\n" if $debug; #$foundbrack = $2; if ($basetype eq "int") { # Do nothing because the [] added to the arg below # is all that is necessary. $star_count = 0; $arg_addresses[$count] = $star_count; } elsif (defined($tof77{$basetype})) { # Is this code correct? It isn't for ints $nstar_before = ($basetype =~ /\*/); $basetype = $tof77{$basetype}; print "\tparm has defined type of $basetype\n" if $debug; $nstar_after = ($basetype =~ /\*/); if ($nstar_before != $nstar_after) { $star_count++; } } print $OUTFD "$basetype v$count\[\], "; } else { $nstar_before = ($parm =~ /\*/); $nstar_after = $nstar_before; print "Nstar = $nstar_after\n" if $debug; if (defined($tof77{$parm})) { $parm = $tof77{$parm}; $nstar_after = ($parm =~ /\*/); } $leadspace = ""; if ($parm =~ /\w$/) { $leadspace = " "; } print $OUTFD "${parm}${leadspace}v$count, "; $star_count = 0; if ($nstar_before != $nstar_after) { $star_count = 1; } $arg_addresses[$count] = $star_count; } $count++; } # Add the new error return code print $OUTFD "MPI_Fint *ierr ${last_args}"; print $OUTFD ")\n";}# Print the arguments for the routine CALL. # Handle the special argumentssub print_call_args { my @parms = split(/\s*,\s*/, $_[0] ); my $count = 1; my $first = 1; print $OUTFD "( "; # Special case: if the only parm is "void", remove it from the list if ($#parms == 0 && $parms[0] eq "void") { $#parms = -1; } foreach $parm (@parms) { if (!$first) { print $OUTFD ", "; } else { $first = 0; } if (defined($special_args{"${routine_name}-$count"})) { # We must handle this argument specially &print_special_call_arg( $routine_name, $count ); } else { # Convert to/from object type as required. if (defined($argsneedcast{$parm})) { $argval = "v$count"; if ($arg_addresses[$count] > 0) { $argval = "*$argval"; } $callparm = $argsneedcast{$parm}; $callparm =~ s/ARG/$argval/; print $OUTFD "$callparm"; } else { # Since MPICH objects are ints, we don't need to do # anything unless MPI_Fint and int are different.# print STDERR "XXX $count $#arg_addresses XXX\n"; if ($arg_addresses[$count] > 0) { print $OUTFD "*"; } print $OUTFD "v$count"; } } $count++; } print $OUTFD " );\n";}# Print the option function attribute; this supports GCC, particularly # the __atribute__ weak option.sub print_attr { if ($do_weak) { print $OUTFD "FUNC_ATTRIBUTES\n"; }}## Special processing# Buffer pointerssub bufptr_ftoc { my $count = $_[0];}sub bufptr_in_decl { my $count = $_[0];}sub bufptr_in_arg { my $count = $_[0]; if ($do_bufptr) { print $OUTFD "MPIR_F_PTR(v$count)"; } else { print $OUTFD "v$count"; }}# bufptr_ctof( cvar, fvar )sub bufptr_ctof { my $coutvar = $_[0]; my $outvar = $_[1];}# Logical variablessub logical_ftoc { my $count = $_[0]; print $OUTFD " l$count = MPIR_FROM_FLOG(*v$count);\n";}sub logical_in_decl { my $count = $_[0]; if ($do_logical) { print $OUTFD " int l$count;\n"; }}sub logical_in_arg { my $count = $_[0]; if ($do_logical) { print $OUTFD "l$count"; } else { print $OUTFD "v$count"; }}# logical_ctof( cvar, fvar )sub logical_ctof { my $coutvar = $_[0]; my $outvar = $_[1]; if ($do_logical) { print $OUTFD " *$outvar = MPIR_TO_FLOG($coutvar);\n"; }}sub logical_out_decl { my $count = $_[0]; if ($do_logical) { print $OUTFD " int l$count;\n"; }}sub logical_out_arg { my $count = $_[0]; if ($do_logical) { print $OUTFD "\&l$count"; } else { print $OUTFD "v$count"; }}## Logical variables, but for an array. # Array args can use the global $Array_size and $Array_typedef if necessarysub logical_array_ftoc { print $OUTFD "\ {int li; for (li=0; li<$Array_size; li++) { l$count\[li\] = MPIR_FROM_FLOG(v$count\[li\]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -