Index: branches/2014/dev_r4765_CNRS_agrif/NEMOGCM/TOOLS/SIREN/src/logger.f90
===================================================================
--- branches/2014/dev_r4765_CNRS_agrif/NEMOGCM/TOOLS/SIREN/src/logger.f90	(revision 4766)
+++ branches/2014/dev_r4765_CNRS_agrif/NEMOGCM/TOOLS/SIREN/src/logger.f90	(revision 5581)
@@ -6,6 +6,7 @@
 !
 ! DESCRIPTION:
-!> @brief This module create logger file and inform it depending 
-!>  of verbosity choose between :
+!> @brief This module create logger file and allow to fill it depending of verbosity.
+!> @details
+!> verbosity could be choosen between :
 !>    - trace : Most detailed information.
 !>    - debug : Detailed information on the flow through the system.
@@ -18,82 +19,108 @@
 !>  default verbosity is warning
 !
-!> @details
-!>    If total number of error exceeded maximum number 
-!>    authorized, program stop.
-!>
-!>    to open/create logger file:<br/>
+!> If total number of error exceeded maximum number 
+!> authorized, program stop.
+!>
+!> to open/create logger file:<br/>
+!> @code
 !>    CALL logger_open(cd_file, [cd_verbosity,] [id_loggerid,] [id_maxerror])
-!>       - cd_file is logger file name
-!>       - cd_verbosity is verbosity to be used (optional, default 'warning')
-!>       - id_loggerid is file id (optional, use only to flush)
-!>       - id_maxerror is the mximum number of error authorized before stop program (optional, default 5)
-!>
-!>    to close logger file:<br/>
-!>    CALL logger_close()
-!>
-!>    to write header in logger file:<br/>
-!>    CALL logger_header()
-!>
-!>    to write footer in logger file:<br/>
-!>    CALL logger_footer()
-!>
-!>    to flushing output:<br/>
-!>    CALL logger_flush()
-!>
-!>    to write TRACE message in logger file:<br/>
-!>    CALL logger_trace(cd_msg)
-!>       - cd_msg is TRACE message
-!>
-!>    to write DEBUG message in logger file:<br/>
-!>    CALL logger_debug(cd_msg)
-!>       - cd_msg is DEBUG message
-!>
-!>    to write INFO message in logger file:<br/>
-!>    CALL logger_info(cd_msg)
-!>       - cd_msg is INFO message
-!>
-!>    to write WARNING message in logger file:<br/>
-!>    CALL logger_warn(cd_msg)
-!>       - cd_msg is WARNING message
-!>
-!>    to write ERROR message in logger file:<br/>
-!>    CALL logger_error(cd_msg)
-!>       - cd_msg is ERROR message
-!>
-!>    to write FATAL message in logger file:<br/>
-!>    CALL logger_fatal(cd_msg)
-!>       - cd_msg is FATAL message
-!>
-!>  Examples :<br />
+!> @endcode
+!> - cd_file is logger file name
+!> - cd_verbosity is verbosity to be used [optional, default 'warning']
+!> - id_loggerid is file id [optional, use only to flush]
+!> - id_maxerror is the maximum number of error authorized before program stop [optional, default 5]
+!>
+!> to close logger file:<br/>
+!> @code
+!> CALL logger_close()
+!> @endcode
+!>
+!> to write header in logger file:<br/>
+!> @code
+!> CALL logger_header()
+!> @endcode
+!>
+!> to write footer in logger file:<br/>
+!> @code
+!> CALL logger_footer()
+!> @endcode
+!>
+!> to flushing output:<br/>
+!> @code
+!> CALL logger_flush()
+!> @endcode
+!>
+!> to write TRACE message in logger file:<br/>
+!> @code
+!> CALL logger_trace(cd_msg [,ld_flush])
+!> @endcode
+!>    - cd_msg is TRACE message
+!>    - ld_flush to flush output [optional]
+!>
+!> to write DEBUG message in logger file:<br/>
+!> @code
+!> CALL logger_debug(cd_msg [,ld_flush])
+!> @endcode
+!>    - cd_msg is DEBUG message
+!>    - ld_flush to flush output [optional]
+!>
+!> to write INFO message in logger file:<br/>
+!> @code
+!> CALL logger_info(cd_msg [,ld_flush])
+!> @endcode
+!>    - cd_msg is INFO message
+!>    - ld_flush to flush output [optional]
+!>
+!> to write WARNING message in logger file:<br/>
+!> @code
+!> CALL logger_warn(cd_msg [,ld_flush])
+!> @endcode
+!>    - cd_msg is WARNING message
+!>    - ld_flush to flush output [optional]
+!>
+!> to write ERROR message in logger file:<br/>
+!> @code
+!> CALL logger_error(cd_msg [,ld_flush])
+!> @endcode
+!>    - cd_msg is ERROR message
+!>    - ld_flush to flush output [optional]
+!>
+!> to write FATAL message in logger file:<br/>
+!> @code
+!> CALL logger_fatal(cd_msg)
+!> @endcode
+!>    - cd_msg is FATAL message
+!>
+!> Examples :<br />
+!> @code
 !>   CALL logger_open('loggerfile.txt','info')
 !>
-!>   CALL logger_header()<br />
-!>   CALL logger_info('une petite info')<br />
-!>   CALL logger_debug('une info de debug')<br />
-!>   CALL logger_warn('une info de warning')<br />
-!>   CALL logger_error('une info d erreur')<br />
-!>   CALL logger_footer()<br />
-!>   CALL logger_close()<br />
-!>
-!> !--------------------------------------------------------------------<br />
+!>   CALL logger_header()
+!>   CALL logger_debug('une info de debug')
+!>   CALL logger_info('une info')
+!>   CALL logger_warn('un warning')
+!>   CALL logger_error('une erreur')
+!>   CALL logger_footer()
+!>   CALL logger_close()
+!> @endcode
+!>
+!> @code
 !>   CALL logger_open('loggerfile.txt')
 !>
-!>   CALL logger_header()<br />
-!>   CALL logger_info('une petite info')<br />
-!>   CALL logger_debug('une info de debug')<br />
-!>   CALL logger_warn('une info de warning')<br />
-!>   CALL logger_error('une info d erreur')<br />
-!>   CALL logger_footer()<br />
-!>   CALL logger_close()<br />
+!>   CALL logger_header()
+!>   CALL logger_debug('une info de debug')
+!>   CALL logger_info('une info')
+!>   CALL logger_warn('un warning')
+!>   CALL logger_error('une erreur')
+!>   CALL logger_footer()
+!>   CALL logger_close()
+!> @endcode
 !
 !> @author
 !> J.Paul
 ! REVISION HISTORY:
-!> @date Nov, 2013- Initial Version
+!> @date November, 2013- Initial Version
 !>
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-!>
-!> @todo
-!> - verifier flush remet pas compteur error à zero
 !----------------------------------------------------------------------
 MODULE logger
@@ -101,31 +128,33 @@
    USE fct                             ! basic useful function
    IMPLICIT NONE
-   PRIVATE
    ! NOTE_avoid_public_variables_if_possible
 
    ! type and variable
-   !PUBLIC :: TLOGGER            ! logger structure
+   PRIVATE :: TLOGGER            !< logger structure
+
+   PRIVATE :: tm_logger          !< logger structure
+   PRIVATE :: im_nverbosity      !< number of log level
+   PRIVATE :: cm_verbosity       !< verbosity array
 
    ! function and subroutine
-   PUBLIC :: logger_open        ! create a log file with given verbosity
-   PUBLIC :: logger_close       ! close log file
-   PUBLIC :: logger_flush       ! flushing output
-   PUBLIC :: logger_header      ! write header on log file
-   PUBLIC :: logger_footer      ! write footer on log file
-   PUBLIC :: logger_trace       ! write trace    message in log file
-   PUBLIC :: logger_debug       ! write debug    message in log file 
-   PUBLIC :: logger_info        ! write info     message in log file
-   PUBLIC :: logger_warn        ! write warning  message in log file
-   PUBLIC :: logger_error       ! write error    message in log file
-   PUBLIC :: logger_fatal       ! write fatal    message in log file, and stop
+   PUBLIC :: logger_open        !< create a log file with given verbosity
+   PUBLIC :: logger_close       !< close log file
+   PUBLIC :: logger_header      !< write header on log file
+   PUBLIC :: logger_footer      !< write footer on log file
+   PUBLIC :: logger_flush       !< flushing output
+   PUBLIC :: logger_trace       !< write trace    message in log file
+   PUBLIC :: logger_debug       !< write debug    message in log file 
+   PUBLIC :: logger_info        !< write info     message in log file
+   PUBLIC :: logger_warn        !< write warning  message in log file
+   PUBLIC :: logger_error       !< write error    message in log file
+   PUBLIC :: logger_fatal       !< write fatal    message in log file, and stop
 
    PRIVATE :: logger__write     ! cut message to get maximum of 80 character by line in log file
 
-   !> @struct TLOG
-   TYPE TLOGGER
+   TYPE TLOGGER   !< logger structure
       INTEGER(i4)       :: i_id = 0                 !< log file id
       CHARACTER(LEN=lc) :: c_name                   !< log file name
       CHARACTER(LEN=lc) :: c_verbosity = "warning"  !< verbosity choose
-      CHARACTER(LEN=lc) :: c_verb = ""              !< table of "verbosities" to used 
+      CHARACTER(LEN=lc) :: c_verb = ""              !< array of "verbosities" to used 
       INTEGER(i4)       :: i_nerror   = 0           !< number of error
       INTEGER(i4)       :: i_nfatal   = 0           !< number of fatal error
@@ -135,5 +164,5 @@
    !  module variable
    INTEGER(i4), PARAMETER :: im_nverbosity=6     !< number of log level
-   CHARACTER(len=*), DIMENSION(im_nverbosity), PARAMETER :: cm_verbosity= & !< verbosity table 
+   CHARACTER(len=*), DIMENSION(im_nverbosity), PARAMETER :: cm_verbosity= & !< verbosity array 
    &               (/ 'trace   ',&
    &                  'debug   ',&
@@ -147,15 +176,19 @@
 CONTAINS
    !-------------------------------------------------------------------
-   !> @brief This subroutine create a log file with given verbosity.
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] cd_file : log file name
-   !> @param[in] cd_verbosity : log file verbosity
-   !> @param[in] id_logid : log file id (use to flush)
-   !> @param[in] id_maxerror : maximum number of error
-   !-------------------------------------------------------------------
-   ! @code
+   !> @brief This subroutine create a log file with default verbosity
+   !> ('warning').
+   !> @details
+   !> Optionally verbosity could be change to 
+   !> ('trace','debug','info',warning','error','fatal').<br/>
+   !> Optionally maximum number of error allowed could be change.
+   !>
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
+   !
+   !> @param[in] cd_file      log file name
+   !> @param[in] cd_verbosity log file verbosity
+   !> @param[in] id_logid     log file id (use to flush)
+   !> @param[in] id_maxerror  maximum number of error
+   !-------------------------------------------------------------------
    SUBROUTINE logger_open(cd_file, cd_verbosity, id_logid, id_maxerror)
       IMPLICIT NONE
@@ -212,13 +245,10 @@
 
    END SUBROUTINE logger_open
-   ! @endcode
    !-------------------------------------------------------------------
    !> @brief This subroutine close a log file.
    !>
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !-------------------------------------------------------------------
-   ! @code
+   !> - November, 2013- Initial Version
+   !-------------------------------------------------------------------
    SUBROUTINE logger_close()
       IMPLICIT NONE
@@ -227,4 +257,5 @@
       !----------------------------------------------------------------
       IF( tm_logger%i_id /= 0 )THEN
+         tm_logger%i_id = 0
          CLOSE( tm_logger%i_id, &
          &      IOSTAT=il_status)      
@@ -237,13 +268,10 @@
 
    END SUBROUTINE logger_close
-   ! @endcode
    !-------------------------------------------------------------------
    !> @brief This subroutine flushing output into log file.
    !>
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !-------------------------------------------------------------------
-   ! @code
+   !> - November, 2013- Initial Version
+   !-------------------------------------------------------------------
    SUBROUTINE logger_flush()
       IMPLICIT NONE
@@ -260,25 +288,22 @@
 
    END SUBROUTINE logger_flush
-   ! @endcode   
    !-------------------------------------------------------------------
    !> @brief This subroutine write header on log file.
    !>
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !-------------------------------------------------------------------
-   ! @code
+   !> - November, 2013- Initial Version
+   !-------------------------------------------------------------------
    RECURSIVE SUBROUTINE logger_header()
       IMPLICIT NONE
       ! local variable
-      INTEGER(i4) :: il_status
+      INTEGER(i4)       :: il_status
       !----------------------------------------------------------------
       IF( tm_logger%i_id /= 0 )THEN
          WRITE( tm_logger%i_id,    &
-            &   FMT='(a/a/a)',     &
+            &   FMT='(4(a/))',     &
             &   IOSTAT=il_status ) &
-            &   "--------------------------------------------------", &
-            &   "INIT     : log start with verbosity "//&
-            &   TRIM(tm_logger%c_verbosity), &
+            &   "--------------------------------------------------",&
+            &   "INIT     : verbosity "//TRIM(tm_logger%c_verbosity),&
+            &   "INIT     : max error "//TRIM(fct_str(tm_logger%i_maxerror)), &
             &   "--------------------------------------------------"
          CALL fct_err(il_status)
@@ -290,24 +315,21 @@
 
    END SUBROUTINE logger_header
-   ! @endcode   
    !-------------------------------------------------------------------
    !> @brief This subroutine write footer on log file.
    !>
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !-------------------------------------------------------------------
-   ! @code
+   !> - November, 2013- Initial Version
+   !-------------------------------------------------------------------
    SUBROUTINE logger_footer()
       IMPLICIT NONE
       ! local variable
-      INTEGER(i4) :: il_status
+      INTEGER(i4)       :: il_status
       !----------------------------------------------------------------
       IF( tm_logger%i_id /= 0 )THEN
          WRITE( tm_logger%i_id,    &
-            &   FMT='(a/a/a/a/a)',     &
+            &   FMT='(4(/a))',     &
             &   IOSTAT=il_status ) &
             &   "--------------------------------------------------",&
-            &   "END      : log ended ",                             &
+            &   "END      : log ended ",              &
             &   "END      : "//TRIM(fct_str(tm_logger%i_nerror))//   &
             &   " ERROR detected ",                                  &
@@ -322,16 +344,15 @@
       ENDIF
    END SUBROUTINE logger_footer
-   ! @endcode   
    !-------------------------------------------------------------------
    !> @brief This subroutine write trace message on log file.
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] cd_msg : message to write
-   !> @param[in] ld_flush : flushing ouput
-   !
-   !-------------------------------------------------------------------
-   ! @code
+   !> @details
+   !> Optionally you could flush output.
+   !>
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
+   !
+   !> @param[in] cd_msg    message to write
+   !> @param[in] ld_flush  flushing ouput
+   !-------------------------------------------------------------------
    SUBROUTINE logger_trace(cd_msg, ld_flush)
       IMPLICIT NONE
@@ -357,16 +378,15 @@
       ENDIF
    END SUBROUTINE logger_trace
-   ! @endcode   
    !-------------------------------------------------------------------
    !> @brief This subroutine write debug message on log file.
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] cd_msg : message to write
-   !> @param[in] ld_flush : flushing ouput
-   !
-   !-------------------------------------------------------------------
-   ! @code
+   !> @details
+   !> Optionally you could flush output.
+   !>
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
+   !
+   !> @param[in] cd_msg    message to write
+   !> @param[in] ld_flush  flushing ouput
+   !-------------------------------------------------------------------
    SUBROUTINE logger_debug(cd_msg, ld_flush)
       IMPLICIT NONE
@@ -392,16 +412,15 @@
       ENDIF
    END SUBROUTINE logger_debug
-   ! @endcode   
    !-------------------------------------------------------------------
    !> @brief This subroutine write info message on log file.
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] cd_msg : message to write
-   !> @param[in] ld_flush : flushing ouput
-   !
-   !-------------------------------------------------------------------
-   ! @code
+   !> @details
+   !> Optionally you could flush output.
+   !>
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
+   !
+   !> @param[in] cd_msg    message to write
+   !> @param[in] ld_flush  flushing ouput
+   !-------------------------------------------------------------------
    SUBROUTINE logger_info(cd_msg, ld_flush)
       IMPLICIT NONE
@@ -427,16 +446,15 @@
       ENDIF
    END SUBROUTINE logger_info
-   ! @endcode    
    !-------------------------------------------------------------------
    !> @brief This subroutine write warning message on log file.
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] cd_msg : message to write
-   !> @param[in] ld_flush : flushing ouput
-   !
-   !-------------------------------------------------------------------
-   ! @code
+   !> @details
+   !> Optionally you could flush output.
+   !>
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
+   !
+   !> @param[in] cd_msg    message to write
+   !> @param[in] ld_flush  flushing ouput
+   !-------------------------------------------------------------------
    SUBROUTINE logger_warn(cd_msg, ld_flush)
       IMPLICIT NONE
@@ -462,16 +480,15 @@
       ENDIF
    END SUBROUTINE logger_warn
-   ! @endcode   
    !-------------------------------------------------------------------
    !> @brief This subroutine write error message on log file.
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] cd_msg : message to write
-   !> @param[in] ld_flush : flushing ouput
-   !
-   !-------------------------------------------------------------------
-   ! @code
+   !> @details
+   !> Optionally you could flush output.
+   !>
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
+   !
+   !> @param[in] cd_msg    message to write
+   !> @param[in] ld_flush  flushing ouput
+   !-------------------------------------------------------------------
    SUBROUTINE logger_error(cd_msg, ld_flush)
       IMPLICIT NONE
@@ -510,5 +527,4 @@
 
    END SUBROUTINE logger_error
-   ! @endcode   
    !-------------------------------------------------------------------
    !> @brief This subroutine write fatal error message on log file, 
@@ -516,10 +532,8 @@
    !>
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] cd_msg : message to write
-   !
-   !-------------------------------------------------------------------
-   ! @code
+   !> - November, 2013- Initial Version
+   !
+   !> @param[in] cd_msg message to write
+   !-------------------------------------------------------------------
    RECURSIVE SUBROUTINE logger_fatal(cd_msg)
       IMPLICIT NONE
@@ -537,4 +551,5 @@
             CALL logger_close()
 
+            WRITE(*,*) 'FATAL ERROR'
             STOP
          ENDIF
@@ -545,5 +560,4 @@
       ENDIF
    END SUBROUTINE logger_fatal
-   ! @endcode   
    !-------------------------------------------------------------------
    !> @brief This subroutine cut message to get maximum of 80 character 
@@ -551,10 +565,9 @@
    !>
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] cd_verb : verbosity of the message to write
-   !> @param[in] cd_msg : message to write
-   !-------------------------------------------------------------------
-   ! @code
+   !> - November, 2013- Initial Version
+   !
+   !> @param[in] cd_verb   verbosity of the message to write
+   !> @param[in] cd_msg    message to write
+   !-------------------------------------------------------------------
    SUBROUTINE logger__write(cd_verb, cd_msg)
       IMPLICIT NONE
@@ -602,5 +615,4 @@
 
    END SUBROUTINE logger__write
-   ! @endcode   
 END MODULE logger
 
