Fortran

Guide To Learn

1. Going parallel with Fortran coarrays

Sending and receiving data

The key to sending or receiving data with coarrays is understanding how to reference values on remote images. There are two ways to do this: When indexing a coarray, the number inside the square brackets is called a coindex. A coindex must be within the bounds of existing images. If we run a program with images [1, 2, 3, 4], […]

Allocating dynamic coarrays

Like with regular (noncoarray) variables, coarrays can be made allocatable, which is necessary whenever we don’t know the size or shape of the variable at compile time. For example, you’d declare an allocatable array coarray like this: Or, in shorter form: The same rules apply as with allocating regular variables. The following snippet will allocate a with […]

Declaring coarrays

Recall from chapter 2 how we declared a regular array: or, in shorter form: The snippet declares a real array, a, of size 10. The attribute dimension here is key. Declaration of coarrays works the same way, except that you’ll use the attribute codimension instead: Or shorter: This snippet declares a scalar coarray, a, a copy of which will be created on every image […]

Coarrays and synchronization, explained

In the previous section, you learned how to decompose the input data and parallelize a simple data processing and analysis program. However, parallelizing the tsunami simulator will present us with a unique challenge, because there we’ll need to send and receive data between images at every time step, and carefully synchronize the images as we […]

Gathering all data to a single image

Let’s look at how the data gathering pattern is implemented in code, as shown in the following listing. Listing 7.3 Gathering distributed data to image 1 ❶ Allocates a full-size coarray ❷ Sends max_wind from each image into a subrange of gather on image 1 ❸ This forces all images to wait for each other. ❹ Only image 1 […]

Telling images what to do

So far, we’ve used this_image and num_images to instruct each image to tell us who it is and how many total images there are. This is useful information, but we still haven’t done anything with it yet. How can we use this information to split the weather buoy data between images? Recall from listing 7.1 that we define the list of […]

Getting information about the images

To tell the images what to work on, we first need to know more about the images themselves, specifically how many there are and who they are. Fortran provides the functions this_image and num_images to do exactly this. Here’s how we write the image number and total number of images to screen: Let’s store this into a file, hello_images.f 90, compile […]

Fortran images

When writing a parallel Fortran program, you don’t have to worry about whether you’re writing a multithreaded concurrent application that’s meant to run on a single core, a shared-memory multicore application, or a distributed memory application. The code that you write is independent of the underlying architecture. Fortran introduces the concept of image, which identifies parallel […]

Parallel processing with images and coarrays

What is the smallest change required to convert Fortran into a robust and efficient parallel language? Our answer is a simple syntactic extension. It looks and feels like Fortran and requires Fortran programmers to learn only a few new rules.  –John Reid, Coarrays in the next Fortran Standard You need to grasp two concepts to […]

Serial implementation of the program

Before we devise our parallelization strategy, let’s first go over the serial program, as shown in the following listing, so we understand how each step works. Listing 7.1 Serial implementation of the weather buoy processing program ❶ Helper functions for working with arrays ❷ Subroutine to read the buoy CSV data ❸ Dynamic arrays for timestamps and wind […]

Scroll to top