MPI-SCATCI 2.0
An MPI version of SCATCI
Loading...
Searching...
No Matches
BaseMPI_module.f90
Go to the documentation of this file.
1! Copyright 2019
2!
3! For a comprehensive list of the developers that contributed to these codes
4! see the UK-AMOR website.
5!
6! This file is part of UKRmol-in (UKRmol+ suite).
7!
8! UKRmol-in is free software: you can redistribute it and/or modify
9! it under the terms of the GNU General Public License as published by
10! the Free Software Foundation, either version 3 of the License, or
11! (at your option) any later version.
12!
13! UKRmol-in is distributed in the hope that it will be useful,
14! but WITHOUT ANY WARRANTY; without even the implied warranty of
15! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16! GNU General Public License for more details.
17!
18! You should have received a copy of the GNU General Public License
19! along with UKRmol-in (in source/COPYING). Alternatively, you can also visit
20! <https://www.gnu.org/licenses/>.
21
22!> \brief Base MPI module
23!> \authors A Al-Refaie
24!> \date 2017
25!>
26!> Uses MPI module from GBTOlib.
27!>
28!> \note 16/01/2019 - Jakub Benda: Unifom coding style and expanded documentation.
29!>
30module basempi_module
31
32 use mpi_mod, only: check_mpi_running, myrank, nprocs
33
34 implicit none
35
36 public basempi
37
38 private
39
40 !> \brief Base MPI type
41 !>
42 !> This abstract class that most will inherit from to gain automatic information on rank and number of processes
43 !>
44 type, abstract :: basempi
45 private
46 !> MPI Rank
47 integer :: rank
48 !> Number of processes
49 integer :: nprocs
50 contains
51 !Constructor function
52 procedure, pass(this) :: basempi_ctor
53 !>Only allows process 0 to print
54 procedure, public :: log_message
55 !> Any process prints
56 procedure, public :: verbose_log_message
57 !> Which constructor is invoked
58 generic, public :: construct => basempi_ctor
59 end type basempi
60
61contains
62
63 !> \brief Constructs the BaseMPI object by assigning rank and nProcs
64 !> \authors A Al-Refaie
65 !> \date 2017
66 !>
67 !> Checks if MPI is running; if it is then assign values.
68 !>
69 subroutine basempi_ctor (this)
70 class(basempi) :: this
71
72 call check_mpi_running
73
74 this % rank = myrank
75 this % nProcs = nprocs
76
77 end subroutine basempi_ctor
78
79 !> \brief Will log a message whilst attaching a number in the beginning
80 !> \authors A Al-Refaie
81 !> \date 2017
82 !>
83 subroutine verbose_log_message (this, message)
84 class(basempi), intent(in) :: this
85 character(len=*), intent(in) :: message
86
87 print *, '[', this % rank, ']', message
88
89 end subroutine verbose_log_message
90
91
92 !> \brief Will only log if the rank is zero
93 !> \authors A Al-Refaie
94 !> \date 2017
95 !>
96 subroutine log_message (this, message)
97 class(basempi) :: this
98 character(len=*), intent(in) :: message
99
100 if (this % rank == 0 ) then
101 call this % verbose_log_message(message)
102 end if
103
104 end subroutine log_message
105
106end module basempi_module