source: dynamico_lmdz/simple_physics/phyparam/physics/logging.F90 @ 4198

Last change on this file since 4198 was 4194, checked in by dubos, 6 years ago

simple_physics : created plugin for logging

File size: 1.1 KB
Line 
1MODULE logging
2
3  ! see also logging.h
4  ! macro LOGBUF accumulates log output into logging_buffer
5  ! flush_plugin points to a procedure pointer that typically prints all lines in the buffer and prepends tags
6  ! This module provides a default implementation of flush_plugin but the top-level driver is welcome to override it.
7
8  IMPLICIT NONE
9  SAVE
10  PRIVATE
11
12  INTERFACE
13     SUBROUTINE plugin(buf)
14       CHARACTER(*), INTENT(IN) :: buf(:)
15     END SUBROUTINE plugin
16  END INTERFACE
17
18  PROCEDURE(plugin), POINTER :: flush_plugin => default_flush_plugin
19
20  INTEGER, PARAMETER :: bufsize=10000
21  CHARACTER(bufsize) :: logging_buf(100)
22
23  INTEGER :: logging_lineno=0
24
25  PUBLIC :: logging_buf, logging_lineno, flush_log, flush_plugin
26
27CONTAINS
28
29  SUBROUTINE flush_log
30    CALL flush_plugin(logging_buf(1:logging_lineno))
31    logging_lineno=0
32  END SUBROUTINE flush_log
33
34  SUBROUTINE default_flush_plugin(buf)
35    CHARACTER(*), INTENT(IN) :: buf(:)
36    INTEGER :: i
37    DO i=1, SIZE(buf)
38       PRINT *, 'INFO : ', TRIM(buf(i))
39    END DO
40  END SUBROUTINE default_flush_plugin
41 
42END MODULE logging
Note: See TracBrowser for help on using the repository browser.