Ignore:
Timestamp:
Dec 22, 2019, 1:10:51 AM (5 years ago)
Author:
dubos
Message:

simple_physics : rewrite convective adjustment

File:
1 edited

Legend:

Unmodified
Added
Removed
  • dynamico_lmdz/simple_physics/phyparam/physics/logging.F90

    r4199 r4206  
    11MODULE logging
    22
    3   ! see also logging.h
     3  ! see also use_logging.h
    44  ! 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.
    75
    86  IMPLICIT NONE
     
    108  PRIVATE
    119
    12   INTERFACE
     10  INTERFACE  ! Explicit interfaces for plugins
     11
     12     ! Plugin that typically prints all lines in the loggin buffer 'buf' and prepends tags (log level, timestamp, ...)
    1313     SUBROUTINE plugin(lev, tag, buf)
    1414       INTEGER, INTENT(IN) :: lev
    1515       CHARACTER(*), INTENT(IN) :: tag, buf(:)
    1616     END SUBROUTINE plugin
     17
     18     ! Plugin that writes into string 'line' information about the gridpoint of index 'index'
     19     SUBROUTINE plugin_log_gridpoint(index, line)
     20       INTEGER, INTENT(IN) :: index ! index of gridpoint
     21       CHARACTER(*), INTENT(OUT) :: line
     22     END SUBROUTINE plugin_log_gridpoint
     23
    1724  END INTERFACE
    1825
    19   PROCEDURE(plugin), POINTER :: flush_plugin => default_flush_plugin
     26  ! This module provides a default implementation of flush_plugin but the top-level driver is welcome to override it. 
     27  PROCEDURE(plugin), POINTER :: flush_plugin => default_flush
     28
     29  ! The top-level driver MUST provide an implementation for log_gridpoint_plugin
     30  PROCEDURE(plugin_log_gridpoint), POINTER :: log_gridpoint_plugin => NULL()
    2031
    2132  INTEGER, PARAMETER :: bufsize=10000
     
    2435  INTEGER :: logging_lineno=0
    2536
    26   INTEGER, PARAMETER, PUBLIC :: log_level_dbg=0, log_level_info=1
     37  INTEGER, PARAMETER, PUBLIC :: log_level_fatal=0, log_level_error=1, log_level_warn=2, log_level_info=3, log_level_dbg=4
    2738
    28   PUBLIC :: logging_buf, logging_lineno, flush_log, flush_plugin
     39  PUBLIC :: logging_buf, logging_lineno, flush_log, log_gridpoint, &
     40       flush_plugin, log_gridpoint_plugin
    2941
    3042CONTAINS
     
    3749  END SUBROUTINE flush_log
    3850
    39   SUBROUTINE default_flush_plugin(lev, tag, buf)
     51  SUBROUTINE default_flush(lev, tag, buf)
    4052    INTEGER, INTENT(IN) :: lev
    4153    CHARACTER(*), INTENT(IN) :: tag, buf(:)
     
    4456       PRINT *, '[INFO ',tag,']', TRIM(buf(i))
    4557    END DO
    46   END SUBROUTINE default_flush_plugin
    47  
     58  END SUBROUTINE default_flush
     59
     60  SUBROUTINE log_gridpoint(index)
     61    INTEGER, INTENT(IN) :: index
     62    logging_lineno = logging_lineno+1
     63    CALL log_gridpoint_plugin(index, logging_buf(logging_lineno))
     64  END SUBROUTINE log_gridpoint
     65
    4866END MODULE logging
Note: See TracChangeset for help on using the changeset viewer.