HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
MPIPartition1D.c File Reference

Compute the local size. More...

#include <stdio.h>
#include <mpivars.h>

Go to the source code of this file.

Functions

int MPIPartition1D (int nglobal, int nproc, int rank)
 

Detailed Description

Compute the local size.

Author
Debojyoti Ghosh

Definition in file MPIPartition1D.c.

Function Documentation

◆ MPIPartition1D()

int MPIPartition1D ( int  nglobal,
int  nproc,
int  rank 
)

Given a 1D array of a given global size nglobal, and the total number of MPI ranks nproc on which it will be partitioned, this function computes the size of the local part of the 1D array on rank.

Parameters
nglobalGlobal size
nprocTotal number of ranks
rankRank

Definition at line 14 of file MPIPartition1D.c.

19 {
20  int nlocal;
21  if (nglobal%nproc == 0) nlocal = nglobal/nproc;
22  else {
23  if (rank == nproc-1) nlocal = nglobal/nproc + nglobal%nproc;
24  else nlocal = nglobal/nproc;
25  }
26  return(nlocal);
27 }