Fortran

Guide To Learn

1. Going parallel with Fortran coarrays

Exercise 2: Writing a function that returns the indices of neighbor images

If you’ve practiced using the this_image and num_images built-in functions long enough, the solution will be straightforward. For any image that calls this function, its left neighbor will be this_image() – 1, and its right neighbor this_image() + 1. (Except when this_image() is at the boundary, that is, this_image() == 1 or this_image() == num_images().) The following listing provides the solution. Listing 7.9 Calculating the index of neighbor images ❶ Two-element integer array to store the result […]

Exercise 1: Finding the array subranges on each image

We need a function that returns a start and end index for each image, given the integer size of the global array to be decomposed. For example, for an input 100 and total number of images 2, the result should be [1, 50] on image 1 and [51, 100] on image 2. When the input is divisible by num_images(), the solution is straightforward. […]

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

Scroll to top