Beispiel #1
0
/*@C
   PetscInitializeFortran - Routine that should be called soon AFTER
   the call to PetscInitialize() if one is using a C main program
   that calls Fortran routines that in turn call PETSc routines.

   Collective on PETSC_COMM_WORLD

   Level: beginner

   Notes:
   PetscInitializeFortran() initializes some of the default viewers,
   communicators, etc. for use in the Fortran if a user's main program is
   written in C.  PetscInitializeFortran() is NOT needed if a user's main
   program is written in Fortran; in this case, just calling
   PetscInitialize() in the main (Fortran) program is sufficient.

.seealso:  PetscInitialize()

.keywords: Mixing C and Fortran, passing PETSc objects to Fortran
@*/
PetscErrorCode PetscInitializeFortran(void)
{
    MPI_Fint c1=0,c2=0;

    if (PETSC_COMM_WORLD) c1 =  MPI_Comm_c2f(PETSC_COMM_WORLD);
    c2 =  MPI_Comm_c2f(PETSC_COMM_SELF);
    petscsetcommonblock_(&c1,&c2);

#if defined(PETSC_USE_REAL___FLOAT128)
    {
        MPI_Fint freal,fscalar,fsum;
        freal   = MPI_Type_c2f(MPIU_REAL);
        fscalar = MPI_Type_c2f(MPIU_SCALAR);
        fsum    = MPI_Op_c2f(MPIU_SUM);
        petscsetcommonblockmpi_(&freal,&fscalar,&fsum);
    }
#endif

    {
        PetscReal pi = PETSC_PI;
        PetscReal maxreal = PETSC_MAX_REAL;
        PetscReal minreal = PETSC_MIN_REAL;
        PetscReal eps = PETSC_MACHINE_EPSILON;
        PetscReal seps = PETSC_SQRT_MACHINE_EPSILON;
        PetscReal small = PETSC_SMALL;
        PetscReal pinf = PETSC_INFINITY;
        PetscReal pninf = PETSC_NINFINITY;
        petscsetcommonblocknumeric_(&pi,&maxreal,&minreal,&eps,&seps,&small,&pinf,&pninf);
    }
    return 0;
}
void mpi_op_create_f(ompi_op_fortran_handler_fn_t* function, ompi_fortran_logical_t *commute,
		     MPI_Fint *op, MPI_Fint *ierr)
{
    MPI_Op c_op;

    /* See the note in src/mpi/f77/prototypes_mpi.h about the use of
       (void*) for function pointers in this function */

    *ierr = OMPI_INT_2_FINT(MPI_Op_create((MPI_User_function *) function,
                                          OMPI_LOGICAL_2_INT(*commute),
                                          &c_op));
    if (MPI_SUCCESS == OMPI_FINT_2_INT(*ierr)) {
        c_op->o_flags |= OMPI_OP_FLAGS_FORTRAN_FUNC;
        *op = MPI_Op_c2f(c_op);
    }
}
Beispiel #3
0
void f2cop_( MPI_Fint * op )
{
    *op = MPI_Op_c2f( MPI_SUM );
}