This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!Copyright 2024 Paolo Lampitella | |
!This code is licensed under the terms of the MIT license | |
MODULE mod_fint | |
IMPLICIT NONE | |
INTEGER, PARAMETER :: IP4 = SELECTED_INT_KIND(9) | |
INTEGER, PARAMETER :: WP = SELECTED_REAL_KIND(15,307) | |
CONTAINS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program myreduce | |
!Program to show a simple implementation of mpi_reduce, with only mpi_send/recv | |
!Useful for cases where one would need mpi_type_create_struct and mpi_op_create to achieve the same result | |
!Here it is tested against the simple MPI intrinsic MPI_SUM on a single real variable | |
use, intrinsic :: iso_fortran_env, only : int32, real64 | |
use mpi | |
implicit none | |
integer(int32) :: i, nstep, pp2, ppd, nproc, myid, mpi_err, mpi_stat(mpi_status_size) | |
real(real64) :: x, xr1, xr2, xr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program myalltoall | |
!Program to show a simple implementation of a deadlock avoiding mpi loop among all processes which, | |
!in principle, is similar to an alltoall loop. However, the main purpose of the technique shown here is to | |
!properly reorder shortest (i.e., each process with just few others) non-blocking communication loops, | |
!in order to alleviate the burden on the communication side (as each exchange is matched, everything | |
!is exchanged very quickly). Here, it is tested against the the mpi_allreduce intrinsic with MPI_SUM | |
!on a single real variable, but IT IS NOT a replacement for allreduce (nor alltoall or any other intrinsic). | |
use, intrinsic :: iso_fortran_env, only : int32, real64 | |
use mpi | |
implicit none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program myreduce2 | |
!Program to show a simple implementation of mpi_reduce, with only mpi_send/recv | |
!Useful for cases where one would need mpi_type_create_struct and mpi_op_create to achieve the same result | |
!This version uses the same MPICH binomial tree algorithm (order from 0 to nproc-1), which allows an easy | |
!customization of the processing order (just map each process to a different id) | |
!Here it is tested against the simple MPI intrinsic MPI_SUM on a single real variable | |
use, intrinsic :: iso_fortran_env, only : int32, real64 | |
use mpi | |
implicit none | |
integer(int32) :: i, nstep, ppd, myp, nproc, myid, mpi_err, mpi_stat(mpi_status_size) |