Fortran

Guide To Learn

Advanced Fortran use

Implementation strategy

Before we start refactoring the solver for parallel execution, let’s refresh our memory about where we left off. Relative to the top-level directory of the project, the main program is located in src/ch04/tsunami.f 90. The core of our solver is the do loop to integrate the solution in time: ❶ Iterates in time ❷ Solves for velocity ❸ Solves for […]

Toward the parallel tsunami simulator

If you’re reading this book in order, you know that we’ve been building a tsunami simulator from scratch, and adding more to it in each chapter. In this chapter, we’ll still refactor the tsunami code and apply what we’ve just learned. However, unlike in previous chapters, this time our simulation results will be exactly the […]

Controlling the order of image execution

When executing the program on multiple images, there’s no imposed order in which the images execute–they all run at their own pace and independently from each other. Any program that requires an exchange of data between processors will also require synchronization at one or more times during the calculation. This is true of the tsunami […]

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 […]

Scroll to top