Fortran/parallel processing

Parallelism is included in the Fortran 2008 standard. To use parallel features, a Fortran program must be compiled with parallelism enabled. For example, the Intel ifort compiler uses the flag.

Images
Fortran uses a Partitioned Global Address Space (PGAS) model for parallelism. For each processor, the program is executed as a separate duplicate "image" of the program, each with their own separate memory partition. Consider the following program: The intrinsic function  returns the number of the image that is being executed, and the intrinsic function   returns the total number of images for the program. If the program is compiled and executed with 4 processors, the output might look something like this: Hello from image 1 of 4 Hello from image 4 of 4 Hello from image 2 of 4 Hello from image 3 of 4 Note that the images are executed asynchronously and so the output may not appear in the order 1, 2, 3 then 4.

Coarrays
Coarrays are a way of communicating data in arrays across images. A coarray is just like a normal array but it has extra codimensions for each image. Codimensions can be declared and indexed using the square brackets. For example to declare a rank 1 coarray with size of 10 and a codimension of size 4: Scalar variables can also be coarrays: Here, * denotes the maximum number of available processors. The codimensions can have multiple axes just like normal dimensions, however, there is a limit of rank 15 for codimensions. Transferring data between images is as simple as indexing on the codimensions.