MPI-SCATCI  2.0
An MPI version of SCATCI
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 
31 
32  use mpi_mod, only: check_mpi_running, myrank, nprocs
33 
34  implicit none
35 
36  public basempi
37 
38  private
39 
44  type, abstract :: basempi
45  private
47  integer :: rank
49  integer :: nprocs
50  contains
51  !Constructor function
52  procedure, pass(this) :: basempi_ctor
54  procedure, public :: log_message
56  procedure, public :: verbose_log_message
58  generic, public :: construct => basempi_ctor
59  end type basempi
60 
61 contains
62 
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 
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 
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 
106 end module basempi_module
basempi_module::basempi_ctor
subroutine basempi_ctor(this)
Constructs the BaseMPI object by assigning rank and nProcs.
Definition: BaseMPI_module.f90:70
basempi_module::basempi
Base MPI type.
Definition: BaseMPI_module.f90:44
basempi_module::verbose_log_message
subroutine verbose_log_message(this, message)
Will log a message whilst attaching a number in the beginning.
Definition: BaseMPI_module.f90:84
basempi_module
Base MPI module.
Definition: BaseMPI_module.f90:30
basempi_module::log_message
subroutine log_message(this, message)
Will only log if the rank is zero.
Definition: BaseMPI_module.f90:97