concept custom module in category fortran

appears as: custom module
Modern Fortran: Building efficient parallel applications

This is an excerpt from Manning's book Modern Fortran: Building efficient parallel applications.

4.2.1 The structure of a custom module

Before we begin, let’s see what a custom module may look like on the inside, and how its building blocks work (figure 4.3).

Listing 4.12. Defining the set_gaussian subroutine in a custom module, and storing it in the mod_initial.f90 source file
language="fortran" linenumbering="unnumbered">module mod_initial

  use iso_fortran_env, only: int32, real32 #1
  implicit none                            #2

contains

  pure subroutine set_gaussian(x, icenter, decay) #3
    real(real32), intent(in out) :: x(:)
    integer(int32), intent(in) :: icenter
    real(real32), intent(in) :: decay
    integer(int32) :: i
    do concurrent(i = 1:size(x))
      x(i) = exp(-decay * (i - icenter)**2)
    end do
  end subroutine set_gaussian

end module mod_initial