# blacs_gridinit

Assigns available processes into BLACS process grid.

## Syntax

call blacs_gridinit( icontxt, order, nprow, npcol )

## Input Parameters

icontxt | INTEGER. Integer handle indicating the system context to be used in creating the BLACS context. Call blacs_get to obtain a default system context.
order | CHARACTER*1. Indicates how to map processes to BLACS grid. Options are: `'R'` : Use row-major natural ordering `'C'` : Use column-major natural ordering `ELSE` : Use row-major natural ordering
nprow | INTEGER. Indicates how many process rows the process grid should contain.
npcol | INTEGER. Indicates how many process columns the process grid should contain.

## Output Parameters

icontxt | INTEGER. Integer handle to the created BLACS context.

## Description

All BLACS codes must call this routine, or its sister routine blacs_gridmap. These routines take the available processes, and assign, or map, them into a BLACS process grid. In other words, they establish how the BLACS coordinate system maps into the native machine process numbering system. Each BLACS grid is contained in a context, so that it does not interfere with distributed operations that occur within other grids/contexts. These grid creation routines may be called repeatedly to define additional contexts/grids.

The creation of a grid requires input from all processes that are defined to be in this grid. Processes belonging to more than one grid have to agree on which grid formation will be serviced first, much like the globally blocking sum or broadcast.

These grid creation routines set up various internals for the BLACS, and one of them must be called before any calls are made to the non-initialization BLACS.

Note that these routines map already existing processes to a grid: the processes are not created dynamically. On most parallel machines, the processes are actual processors (hardware), and they are "created" when you run your executable. When using the PVM BLACS, if the virtual machine has not been set up yet, the routine blacs_setup should be used to create the virtual machine.

This routine creates a simple `nprow x npcol` process grid. This process grid uses the first `nprow * npcol` processes, and assigns them to the grid in a row- or column-major natural ordering. If these process-to-grid mappings are unacceptable, call blacs_gridmap.

## See Also

BLACS Routines Usage Example
blacs_get Gets values that BLACS use for internal defaults.
blacs_gridmap Maps available processes into BLACS process grid.
blacs_setup Allocates virtual machine and spawns processes.
Parent topic: Initialization Routines