37 use,
intrinsic :: iso_fortran_env, only: stdout => output_unit, &
46 integer :: section_id_
79 class(
log_t),
intent(inout) :: this
80 character(len=255) :: log_level
81 character(len=255) :: log_file
87 call get_environment_variable(
"NEKO_LOG_LEVEL", log_level, envvar_len)
88 if (envvar_len .gt. 0)
then
89 read(log_level(1:envvar_len), *) this%level_
94 call get_environment_variable(
"NEKO_LOG_FILE", log_file, envvar_len)
95 if (envvar_len .gt. 0)
then
97 open(unit = this%unit_,
file = trim(log_file), status =
'replace', &
107 class(
log_t),
intent(inout) :: this
110 this%indent_ = this%indent_ + 1
117 class(
log_t),
intent(inout) :: this
120 this%indent_ = this%indent_ - 1
127 class(
log_t),
intent(in) :: this
130 write(this%unit_,
'(A)', advance =
'no') repeat(
' ', this%indent_)
137 class(
log_t),
intent(in) :: this
138 integer,
optional :: lvl
142 if (
present(lvl))
then
148 if (lvl_ .gt. this%level_)
then
153 write(this%unit_,
'(A)')
''
160 class(
log_t),
intent(in) :: this
161 character(len=*),
intent(in) :: msg
162 integer,
optional :: lvl
165 if (
present(lvl))
then
171 if (lvl_ .gt. this%level_)
then
177 write(this%unit_,
'(A)') trim(msg)
184 class(
log_t),
intent(in) :: this
185 character(len=*),
intent(in) :: version
186 character(len=*),
intent(in) :: build_info
189 write(this%unit_,
'(A)')
''
190 write(this%unit_,
'(1X,A)')
' _ __ ____ __ __ ____ '
191 write(this%unit_,
'(1X,A)')
' / |/ / / __/ / //_/ / __ \ '
192 write(this%unit_,
'(1X,A)')
' / / / _/ / ,< / /_/ / '
193 write(this%unit_,
'(1X,A)')
'/_/|_/ /___/ /_/|_| \____/ '
194 write(this%unit_,
'(A)')
''
195 write(this%unit_,
'(1X,A,A,A)')
'(version: ', trim(version),
')'
196 write(this%unit_,
'(1X,A)') trim(build_info)
197 write(this%unit_,
'(A)')
''
204 class(
log_t),
intent(in) :: this
205 character(len=*),
intent(in) :: msg
209 write(stderr,
'(A,A,A)')
'*** ERROR: ', trim(msg),
' ***'
216 class(
log_t),
intent(in) :: this
217 character(len=*),
intent(in) :: msg
221 write(this%unit_,
'(A,A,A)')
'*** WARNING: ', trim(msg),
' ***'
228 class(
log_t),
intent(inout) :: this
229 character(len=*),
intent(in) :: msg
230 integer,
optional :: lvl
235 if (
present(lvl))
then
241 if (lvl_ .gt. this%level_)
then
247 this%indent_ = this%indent_ + this%section_id_
248 this%section_id_ = this%section_id_ + 1
250 pre = (30 - len_trim(msg)) / 2
251 pos = 30 - (len_trim(msg) + pre)
253 write(this%unit_,
'(A)')
''
255 write(this%unit_,
'(A,A,A)') &
256 repeat(
'-', pre), trim(msg), repeat(
'-', pos)
264 class(
log_t),
intent(inout) :: this
265 character(len=*),
intent(in),
optional :: msg
266 integer,
optional :: lvl
269 if (
present(lvl))
then
275 if (lvl_ .gt. this%level_)
then
279 if (
present(msg))
then
284 this%section_id_ = this%section_id_ - 1
285 this%indent_ = this%indent_ - this%section_id_
293 class(
log_t),
intent(in) :: this
294 real(kind=
rp),
intent(in) :: t
295 real(kind=
rp),
intent(in) :: t_end
296 character(len=LOG_SIZE) :: log_buf
297 real(kind=
rp) :: t_prog
299 t_prog = 100d0 * t / t_end
300 write(log_buf,
'(A4,E15.7,34X,A2,F6.2,A3)')
't = ', t,
'[ ', t_prog,
'% ]'
315 use,
intrinsic :: iso_c_binding
316 character(kind=c_char),
dimension(*),
intent(in) :: c_msg
317 character(len=LOG_SIZE) :: msg
323 if (c_msg(len+1) .eq. c_null_char)
exit
325 msg(len:len) = c_msg(len)
329 write(
neko_log%unit_,
'(A)') trim(msg(1:len))
337 use,
intrinsic :: iso_c_binding
338 character(kind=c_char),
dimension(*),
intent(in) :: c_msg
339 character(len=LOG_SIZE) :: msg
345 if (c_msg(len+1) .eq. c_null_char)
exit
347 msg(len:len) = c_msg(len)
351 write(stderr,
'(A,A,A)')
'*** ERROR: ', trim(msg(1:len)),
' ***'
359 use,
intrinsic :: iso_c_binding
360 character(kind=c_char),
dimension(*),
intent(in) :: c_msg
361 character(len=LOG_SIZE) :: msg
367 if (c_msg(len+1) .eq. c_null_char)
exit
369 msg(len:len) = c_msg(len)
374 '*** WARNING: ', trim(msg(1:len)),
' ***'
382 use,
intrinsic :: iso_c_binding
383 character(kind=c_char),
dimension(*),
intent(in) :: c_msg
384 character(len=LOG_SIZE) :: msg
390 if (c_msg(len+1) .eq. c_null_char)
exit
392 msg(len:len) = c_msg(len)
395 call neko_log%section(trim(msg(1:len)))
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_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.
subroutine log_status(this, t, t_end)
Write status banner.
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_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.