Ignore:
Timestamp:
Sep 9, 2021, 3:50:44 PM (3 years ago)
Author:
Laurent Fairhead
Message:

Adds a routine 'prt_alerte' to enable developpers to print out informative messages on the first pass through physics
and from the master process only. This can be used to remind oneself of potential problems or further enhancements.
Messages can be differentiated by a 'priority' code 0/1/2 (corresponding to GREEN/ORANGE/RED alerts)
By default, the messages are output in a file called ALERTES.txt but changing the unit number to 6 in the
print_control_mod.F90 file allows you to print out your messages to the screen.

To use you simply need to:

  • have this USE statement at the start of your routine:

USE print_control_mod, ONLY: prt_level, lunout, call_alert, prt_alerte

  • ensure that the modname variable is defined and contains the name of your routine
  • then you just need to add the following lines in your routine wherever you want to ouput your message (preferably not in a do loop)

message='your informative message'
IF (call_alert) CALL prt_alerte(message,modname,CODE)

where

  • message is the message to print out
  • modname is the routine name
  • CODE is an integer representing your priority code (0/1/2)

and you should get messages of the form

ALERTE ROUGE cva_driver! ym missing init, need to have a look by developpers
ALERTE VERTE orosetup_strato! ym correction en attendant mieux


in your output file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/phy_common/print_control_mod.F90

    r3435 r3981  
    55  INTEGER,SAVE :: prt_level ! debug output level
    66  LOGICAL,SAVE :: debug ! flag to specify if in "debug mode"
    7 !$OMP THREADPRIVATE(lunout,prt_level,debug)
     7  LOGICAL,SAVE :: alert_first_call = .TRUE. ! for printing alerts on first call to routine only           
     8  LOGICAL,SAVE :: call_alert ! (combination of is_master and alert_first_call for easier use     
     9!$OMP THREADPRIVATE(lunout,prt_level,debug, alert_first_call, call_alert)
    810
    911  ! NB: Module variable Initializations done by set_print_control
     
    1517  SUBROUTINE set_print_control(lunout_,prt_level_,debug_)
    1618  IMPLICIT NONE
    17     INTEGER :: lunout_
    18     INTEGER :: prt_level_
    19     LOGICAL :: debug_
     19    INTEGER, INTENT(IN) :: lunout_
     20    INTEGER, INTENT(IN) :: prt_level_
     21    LOGICAL, INTENT(IN) :: debug_
    2022     
    2123    lunout = lunout_
     
    2527  END SUBROUTINE set_print_control
    2628
     29  SUBROUTINE prt_alerte(message, modname, niv_alerte)
     30    ! Function to print different values of alarms when first encountered
     31    ! Meant for informative purposee
     32    IMPLICIT NONE
     33    ! Arguments:
     34    ! message: message to print out
     35    ! modname: module/routine name
     36    ! niv_alerte: alert level (0/1/2)
     37    CHARACTER(LEN=*), INTENT(IN) :: modname
     38    CHARACTER(LEN=*) :: message
     39    INTEGER :: niv_alerte
     40    ! local variables
     41    CHARACTER(LEN=7), DIMENSION(0:2) :: alarm_color = (/ 'VERTE  ','ORANGE ','ROUGE  ' /)
     42    CHARACTER(LEN=7) :: alarm_couleur
     43    INTEGER :: alarm_file=15 ! in case we want/need to print out the special alarms in a separate file     
     44
     45    IF ( alert_first_call) then
     46       IF ( alarm_file .ne. lunout ) THEN
     47          OPEN(unit = alarm_file, file = "ALERTES.txt")
     48       ENDIF
     49    ENDIF
     50
     51    alarm_couleur = alarm_color(niv_alerte)
     52    IF (niv_alerte < 0 .OR. niv_alerte > 3) then
     53       message = 'NIVEAU ALERTE INVALIDE  '//message
     54       alarm_couleur='NOIRE  '
     55    ENDIF
     56
     57    WRITE(alarm_file, *)' ALERTE ',alarm_couleur, trim(modname),  trim(message)
     58   
     59  END SUBROUTINE prt_alerte
     60
     61 
    2762END MODULE print_control_mod
Note: See TracChangeset for help on using the changeset viewer.