59 CHARACTER(LEN=32) :: mod_name
60 INTEGER,
PUBLIC :: err
61 LOGICAL :: isinitialized = .false.
63 INTEGER,
POINTER ::
ppnum => null()
89 INTEGER,
SAVE,
TARGET ::
ppnum = 1
90 LOGICAL,
SAVE,
TARGET ::
parinit = .false.
91 CHARACTER(LEN=1),
SAVE ::
prefix =
' ' 114 use,
INTRINSIC :: ieee_arithmetic
117 CLASS(logging_base),
INTENT(INOUT) :: this
119 CHARACTER(LEN=*) :: n
130 CALL mpi_comm_rank(mpi_comm_world,this%myrank,this%err)
131 CALL mpi_comm_size(mpi_comm_world,this%ppnum,this%err)
132 this%parinit = .true.
134 SELECT CASE (selected_real_kind(precision(
dummy)))
142 CALL warning(this,
"InitCommon",
"Cannot determine default MPI real types.")
148 this%isinitialized = .true.
157 TYPE(logging_base),
INTENT(INOUT) :: this
159 this%isinitialized = .false.
165 PURE FUNCTION gettype(this)
RESULT(t)
180 CHARACTER(LEN=1),
INTENT(IN) :: val
188 PURE FUNCTION getname(this)
RESULT(n)
192 CHARACTER(LEN=32) :: n
204 PURE FUNCTION getrank(this)
RESULT(r)
238 i = this%isinitialized
240 IF (
ASSOCIATED(this%parinit))
THEN 241 i = i.AND.this%parinit
259 SUBROUTINE info(this,msg,rank,node_info,tostderr)
262 CLASS(logging_base),
INTENT(IN) :: this
263 CHARACTER(LEN=*),
INTENT(IN) :: msg
264 INTEGER,
OPTIONAL,
INTENT(IN) :: rank
265 LOGICAL,
OPTIONAL,
INTENT(IN) :: node_info
266 LOGICAL,
OPTIONAL,
INTENT(IN) :: tostderr
271 INTEGER :: print_rank,output_unit
272 LOGICAL :: print_node_info
274 IF (
PRESENT(rank))
THEN 279 IF (
PRESENT(node_info))
THEN 280 print_node_info = node_info
282 print_node_info = .false.
286 IF (
PRESENT(tostderr))
THEN 287 IF (tostderr) output_unit =
stderr 290 IF (.NOT.
parinit)
CALL mpi_comm_rank(mpi_comm_world,
myrank,ierr)
294 IF (
myrank.EQ.print_rank)
THEN 295 WRITE (output_unit,
'(A)',advance=
'NO')
prefix 297 IF (print_node_info) &
298 WRITE (output_unit,
'(A,I4.4,A)',advance=
'NO')
"NODE [",
myrank,
"] " 300 WRITE (output_unit,
'(A)') trim(msg)
315 SUBROUTINE warning(this,modproc,msg,rank)
318 CLASS(logging_base),
INTENT(IN) :: this
319 CHARACTER(LEN=*),
INTENT(IN) :: modproc
320 CHARACTER(LEN=*),
INTENT(IN) :: msg
321 INTEGER,
OPTIONAL,
INTENT(IN) :: rank
323 CALL info(this,
"WARNING in " // trim(modproc) //
": " // trim(msg),&
324 rank,node_info=.true.,tostderr=.true.)
333 SUBROUTINE error(this,modproc,msg,rank,node_info)
336 CLASS(logging_base),
INTENT(IN) :: this
337 CHARACTER(LEN=*),
INTENT(IN) :: modproc
338 CHARACTER(LEN=*),
INTENT(IN) :: msg
339 INTEGER,
OPTIONAL,
INTENT(IN) :: rank
340 LOGICAL,
OPTIONAL,
INTENT(IN) :: node_info
346 CALL info(this,
"ERROR in " // trim(modproc) //
": " // trim(msg),&
347 rank=rank,node_info=node_info,tostderr=.true.)
350 CALL mpi_abort(mpi_comm_world,1,ierr)
subroutine finalize(this)
Destructor of common class.
subroutine error(this, modproc, msg, rank, node_info)
Print error message on standard error and terminate the program.
integer, save default_mpi_complex
default real type for MPI
integer, save default_mpi_2real
default 2real type for MPI
integer, save default_mpi_real
default real type for MPI
subroutine setprefix(val)
Set character preceding the info output.
integer, target, save ppnum
MPI number of processes.
real, save nan_default_real
NaN real constant.
subroutine warning(this, modproc, msg, rank)
Print warning message on standard error.
pure character(len=32) function getname(this)
Get the module name.
integer, parameter stderr
fortran stderr unit
integer, target, save myrank
MPI rank.
pure integer function getnumprocs(this)
Get the total number of MPI processes.
pure integer function gettype(this)
Get the module type number.
integer, parameter stdout
fortran stdout unit
pure integer function getrank(this)
Get the MPI rank.
pure logical function initialized(this)
Query initialization status.
logical, target, save parinit
MPI initialization status.
subroutine initlogging(this, t, n)
Constructor of common class.
real, parameter dummy
check default real type
character(len=1), save prefix
preceds info output
subroutine info(this, msg, rank, node_info, tostderr)
Print information on standard output.