38 use,
intrinsic :: iso_fortran_env, only: stdout => output_unit, &
49 integer,
private :: indent_
50 integer,
private :: section_id_
51 integer,
private :: tab_size_
52 integer,
private :: level_
53 integer,
private :: unit_
55 character(len=LOG_SIZE),
private :: section_header =
""
71 procedure,
private, pass(this) :: print_section_header => &
90 class(
log_t),
intent(inout) :: this
91 character(len=255) :: log_level
92 character(len=255) :: log_tab_size
93 character(len=255) :: log_file
99 call get_environment_variable(
"NEKO_LOG_TAB_SIZE", log_tab_size, envvar_len)
100 if (envvar_len .gt. 0)
then
101 read(log_tab_size(1:envvar_len), *) this%tab_size_
106 call get_environment_variable(
"NEKO_LOG_LEVEL", log_level, envvar_len)
107 if (envvar_len .gt. 0)
then
108 read(log_level(1:envvar_len), *) this%level_
113 call get_environment_variable(
"NEKO_LOG_FILE", log_file, envvar_len)
114 if (envvar_len .gt. 0)
then
115 open(newunit = this%unit_,
file = trim(log_file), status =
'replace', &
125 class(
log_t),
intent(inout) :: this
127 if (this%section_id_ .ne. 0)
then
131 if (this%unit_ .ne. stdout)
then
143 class(
log_t),
intent(inout) :: this
146 this%section_id_ = this%section_id_ + 1
147 this%indent_ = this%indent_ + this%tab_size_
154 class(
log_t),
intent(inout) :: this
157 if (this%section_id_ .eq. 0)
then
160 this%section_id_ = this%section_id_ - 1
161 this%indent_ = this%indent_ - this%tab_size_
164 this%section_header =
""
170 class(
log_t),
intent(in) :: this
173 write(this%unit_,
'(A)', advance =
'no') repeat(
' ', this%indent_)
180 class(
log_t),
intent(in) :: this
181 integer,
optional :: lvl
185 if (
present(lvl))
then
191 if (lvl_ .gt. this%level_)
then
196 write(this%unit_,
'(A)')
''
203 class(
log_t),
intent(inout) :: this
204 character(len=*),
intent(in) :: msg
205 integer,
optional :: lvl
208 if (
present(lvl))
then
214 if (lvl_ .gt. this%level_)
then
218 if (len_trim(this%section_header) .gt. 0)
then
219 call this%print_section_header(lvl)
224 write(this%unit_,
'(A)') trim(msg)
231 class(
log_t),
intent(in) :: this
232 character(len=*),
intent(in) :: version
233 character(len=*),
intent(in) :: build_info
236 write(this%unit_,
'(A)')
''
237 write(this%unit_,
'(1X,A)')
' _ __ ____ __ __ ____ '
238 write(this%unit_,
'(1X,A)')
' / |/ / / __/ / //_/ / __ \ '
239 write(this%unit_,
'(1X,A)')
' / / / _/ / ,< / /_/ / '
240 write(this%unit_,
'(1X,A)')
'/_/|_/ /___/ /_/|_| \____/ '
241 write(this%unit_,
'(A)')
''
242 write(this%unit_,
'(1X,A,A,A)')
'(version: ', trim(version),
')'
243 write(this%unit_,
'(1X,A)') trim(build_info)
244 write(this%unit_,
'(A)')
''
251 class(
log_t),
intent(in) :: this
252 character(len=*),
intent(in) :: msg
256 write(stderr,
'(A,A,A)')
'*** ERROR: ', trim(msg),
' ***'
263 class(
log_t),
intent(in) :: this
264 character(len=*),
intent(in) :: msg
268 write(this%unit_,
'(A,A,A)')
'*** WARNING: ', trim(msg),
' ***'
275 class(
log_t),
intent(inout) :: this
276 character(len=*),
intent(in) :: msg
277 integer,
optional :: lvl
281 if (len_trim(this%section_header) .gt. 0)
then
282 call this%print_section_header(lvl)
288 pre = (30 - len_trim(msg)) / 2
289 pos = 30 - (len_trim(msg) + pre)
291 write(this%section_header,
'(A,A,A)') &
292 repeat(
'-', pre), trim(msg), repeat(
'-', pos)
299 class(
log_t),
intent(inout) :: this
300 integer,
optional :: lvl
303 if (
present(lvl))
then
309 if (lvl_ .gt. this%level_)
then
314 call this%newline(lvl)
316 write(this%unit_,
'(A)') trim(this%section_header)
317 this%section_header =
""
324 class(
log_t),
intent(inout) :: this
325 character(len=*),
intent(in),
optional :: msg
326 integer,
optional :: lvl
329 if (
present(msg))
then
330 call this%message(msg, lvl)
344 use,
intrinsic :: iso_c_binding
345 character(kind=c_char),
dimension(*),
intent(in) :: c_msg
346 character(len=LOG_SIZE) :: msg
352 if (c_msg(len+1) .eq. c_null_char)
exit
354 msg(len:len) = c_msg(len)
357 call neko_log%message(trim(msg(1:len)))
365 use,
intrinsic :: iso_c_binding
366 character(kind=c_char),
dimension(*),
intent(in) :: c_msg
367 character(len=LOG_SIZE) :: msg
373 if (c_msg(len+1) .eq. c_null_char)
exit
375 msg(len:len) = c_msg(len)
379 write(stderr,
'(A,A,A)')
'*** ERROR: ', trim(msg(1:len)),
' ***'
387 use,
intrinsic :: iso_c_binding
388 character(kind=c_char),
dimension(*),
intent(in) :: c_msg
389 character(len=LOG_SIZE) :: msg
395 if (c_msg(len+1) .eq. c_null_char)
exit
397 msg(len:len) = c_msg(len)
402 '*** WARNING: ', trim(msg(1:len)),
' ***'
410 use,
intrinsic :: iso_c_binding
411 character(kind=c_char),
dimension(*),
intent(in) :: c_msg
412 character(len=LOG_SIZE) :: msg
418 if (c_msg(len+1) .eq. c_null_char)
exit
420 msg(len:len) = c_msg(len)
423 call neko_log%section(trim(msg(1:len)))
integer, public pe_rank
MPI rank.
Module for file I/O operations.
subroutine log_end_section_c()
End a log section (from C)
subroutine log_end(this)
Decrease indention level.
subroutine log_print_section_header(this, lvl)
Print a section header.
subroutine log_header(this, version, build_info)
Write the Neko header to a log.
integer, parameter, public neko_log_verbose
Verbose log level.
subroutine log_message(this, msg, lvl)
Write a message to a log.
integer, parameter, public neko_log_quiet
Always logged.
subroutine log_begin(this)
Increase indention level.
subroutine log_message_c(c_msg)
Write a message to a log (from C)
subroutine log_end_section(this, msg, lvl)
End a log section.
subroutine log_init(this)
Initialize a log.
subroutine log_warning(this, msg)
Write a warning message to a log.
subroutine log_error_c(c_msg)
Write an error message to a log (from C)
subroutine log_indent(this)
Indent a log.
subroutine log_warning_c(c_msg)
Write a warning message to a log (from C)
subroutine log_newline(this, lvl)
Write a new line to a log.
subroutine log_section_c(c_msg)
Begin a new log section (from C)
integer, parameter, public neko_log_debug
Debug log level.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
integer, parameter, public neko_log_info
Default log level.
subroutine log_free(this)
Free a log.
subroutine log_section(this, msg, lvl)
Begin a new log section.
subroutine log_error(this, msg)
Write an error message to a log.
integer, parameter, public rp
Global precision used in computations.