Reader small image

You're reading from  Raspberry Pi Super Cluster

Product typeBook
Published inNov 2013
Reading LevelBeginner
PublisherPackt
ISBN-139781783286195
Edition1st Edition
Languages
Right arrow
Author (1)
Andrew K. Dennis
Andrew K. Dennis
author image
Andrew K. Dennis

Andrew K. Dennis is a full stack and cybersecurity architect with over 17 years' experience who currently works for Modus Create in Reston, VA. He holds two undergraduate degrees in software engineering and creative computing and a master's degree in information security. Andy has worked in the US, Canada, and the UK in software engineering, e-learning, data science, and cybersecurity across his career, and has written four books on IoT, the Raspberry Pi, and supercomputing. His interests range from the application of pataphysics in computing to security threat modeling. Andy lives in New England and is an organizer of Security BSides CT.
Read more about Andrew K. Dennis

Right arrow

Experimenting with MPI and Fortran


The following Fortran program is an adaptation of the hello_rpi.c application from Chapter 3, Parallel Computing – MPI on the Raspberry Pi .

Create a new file called hello_rpi.f in the Fortran directory that you created earlier as follows:

vim /home/pi/Fortran/hello_rpi.f

Next add the following code to the file:

  program hellorpi
  include 'mpif.h'

  integer rpi, totalrpi, ierr

  call MPI_INIT(ierr)
  call MPI_COMM_RANK(MPI_COMM_WORLD, rpi, ierr)
  call MPI_COMM_SIZE(MPI_COMM_WORLD, totalrpi, ierr)

  print *, 'This is Raspberry Pi ',(rpi+1),' of ',totalrpi

  call MPI_FINALIZE(ierr)
  end

You can see this program is very similar to the C one.

To start with, we include the mpif.h header. Following this we declare a number of integer variables to store the current Raspberry Pi executing the program, the total number of RPi's in the cluster, and an additional variable for an error code.

After this are the three MPI calls we made in the hello_rpi.c application...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Raspberry Pi Super Cluster
Published in: Nov 2013Publisher: PacktISBN-13: 9781783286195

Author (1)

author image
Andrew K. Dennis

Andrew K. Dennis is a full stack and cybersecurity architect with over 17 years' experience who currently works for Modus Create in Reston, VA. He holds two undergraduate degrees in software engineering and creative computing and a master's degree in information security. Andy has worked in the US, Canada, and the UK in software engineering, e-learning, data science, and cybersecurity across his career, and has written four books on IoT, the Raspberry Pi, and supercomputing. His interests range from the application of pataphysics in computing to security threat modeling. Andy lives in New England and is an organizer of Security BSides CT.
Read more about Andrew K. Dennis