Index: branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/TOOLS/SIREN/src/date.f90
===================================================================
--- branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/TOOLS/SIREN/src/date.f90	(revision 4810)
+++ branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/TOOLS/SIREN/src/date.f90	(revision 5600)
@@ -7,70 +7,122 @@
 ! DESCRIPTION:
 !> @brief This module provide the calculation of Julian dates, and
-!> do many manipulations with dates.<br/>
-!> Actually we use Modified Julian Dates, with origin the 
-!> 17 Nov 1858 at 00:00:00
-!
+!> do many manipulations with dates.
+!>
 !> @details
+!> Actually we use Modified Julian Dates, with  
+!> 17 Nov 1858 at 00:00:00 as origin.<br/>
+!>
 !>   define type TDATE:<br/>
-!>   TYPE(TDATE) :: tl_date1<br/>
+!> @code
+!>   TYPE(TDATE) :: tl_date1
+!> @endcode
 !>   default date is 17 Nov 1858 at 00:00:00<br/>
 !>
 !>   to intialise date : <br/>
-!>   - from date of the day at 12:00:00 : tl_date1=date_today()<br/>
-!>   - from date and time of the day    : tl_date1=date_now()<br/>
-!>   - from julian day                  : tl_date1=date_init(1.)<br/>  
-!>   - from year month day              : tl_date1=date_init(2012,12,10)<br/>
+!>   - from date of the day at 12:00:00 : 
+!> @code
+!> tl_date1=date_today()
+!> @endcode
+!>   - from date and time of the day    : 
+!> @code
+!> tl_date1=date_now()
+!> @endcode
+!>   - from julian day                  : 
+!> @code
+!> tl_date1=date_init(dd_jd)
+!> @endcode
+!>      - dd_jd julian day (double precision) 
+!>   - from number of second since julian day origin   : 
+!> @code
+!> tl_date1=date_init(kd_nsec)
+!> @endcode
+!>      - kd_nsec number of second (integer 8) 
+!>   - from year month day              : 
+!> @code
+!> tl_date1=date_init(2012,12,10)
+!> @endcode
+!>   - from string character formatted date  : 
+!> @code
+!> tl_date1=date_init(cd_fmtdate)
+!> @endcode
+!>      - cd_fmtdate date in format YYYY-MM-DD hh:mm:ss
 !>
 !>   to print date in format YYYY-MM-DD hh:mm:ss<br/>
 !>   CHARACTER(LEN=lc) :: cl_date<br/>
-!>   cl_date=date_print(tl_date1)<br/>
-!>   PRINT *, TRIM(cl_date)<br/>
-!>
-!>   to print day if the week:<br/>
-!>   PRINT *,"dow ", tl_date1\%i_dow<br/>
+!> @code
+!>   cl_date=date_print(tl_date1)
+!>   PRINT *, TRIM(cl_date)
+!> @endcode
+!>    
+!>   to print date in another format (only year, month, day):
+!> @code
+!>   cl_date=date_print(tl_date1, cd_fmt)
+!>   PRINT *, TRIM(cl_date)
+!> @endcode
+!>       - cd_fmt ouput format (ex: cd_fmt="('y',i0.4,'m',i0.2,'d',i0.2)" ) 
+!>
+!>   to print day of the week:<br/>
+!> @code
+!>   PRINT *,"dow ", tl_date1\%i_dow
+!> @endcode
 !>   to print last day of the month:<br/>
-!>   PRINT *,"last day ", tl_date1\%i_lday<br/>
+!> @code
+!>   PRINT *,"last day ", tl_date1\%i_lday
+!> @endcode
+!>
 !>   to know if year is a leap year:<br/>
-!>   LOGICAL :: ll_isleap<br/>
-!>   ll_isleap=date_leapyear(tl_date1)<br/>
-!>
-!>   to compute difference between to dates:<br/>
-!>   tl_date2=date_init(2010,12,10)<br/>
-!>   print *,"diff ",tl_date1-tl_date2<br/>
+!> @code
+!>   ll_isleap=date_leapyear(tl_date1)
+!> @endcode
+!>    - ll_isleap is logical
+!>
+!>   to compute number of days between two dates:<br/>
+!> @code
+!>   tl_date2=date_init(2010,12,10)
+!>   dl_diff=tl_date1-tl_date2
+!> @endcode
+!>    - dl_diff is the number of days between date1 and date2 (double precision)
 !>
 !>   to add or substract nday to a date:<br/>
-!>   tl_date2=tl_date1+2.<br/>
-!>   print *,"add ",trim(date_print(tl_date2))<br/>
-!>   tl_date2=tl_date1-2.6<br/>
-!>   print *,"sub ",trim(date_print(tl_date2))<br/>
+!> @code
+!>   tl_date2=tl_date1+2.
+!>   tl_date2=tl_date1-2.6
+!> @endcode
+!>    - number of day (double precision)
 !>
 !>   to print julian day:<br/>
-!>   print *," julian day",tl_date1\%r_jd<br/>
+!> @code
+!>   PRINT *," julian day",tl_date1\%r_jd
+!> @endcode
 !>
 !>   to print CNES julian day (origin 1950-01-01 00:00:00)<br/>
-!>   print *," CNES julian day",tl_date1\%r_jc<br/>
+!> @code
+!>   PRINT *," CNES julian day",tl_date1\%r_jc
+!> @endcode
 !>
 !>   to create pseudo julian day with origin date_now:<br/>
-!>   tl_date1=date_init(2012,12,10,td_dateo=date_now())<br/>
-!>   print *," new julian day",tl_date1\%r_jc<br/>
-!>   Note that you erase CNES julian day when doing so<br/> 
+!> @code
+!>   tl_date1=date_init(2012,12,10,td_dateo=date_now())
+!> @endcode
+!>   @note you erase CNES julian day when doing so<br/> 
 !>
 !>   to print julian day in seconds:<br/>
-!>   print *, tl_date1\%k_jdsec<br/>
+!> @code
+!>   PRINT *, tl_date1\%k_jdsec
+!> @endcode
 !>   to print CNES or new julian day in seconds:<br/>
-!>   print *, tl_date1\%k_jcsec<br/>
-!>
-!> @author
-!> J.Paul
+!> @code
+!>   PRINT *, tl_date1\%k_jcsec
+!> @endcode
+!>
+!> @author J.Paul
 ! REVISION HISTORY:
-!> @date Nov, 2013 - Initial Version
+!> @date November, 2013 - Initial Version
 !
 !> @note This module is based on Perderabo's date calculator (ksh)
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+!>
 !> @todo
-!> - check if real(sp), integer(i8) is enough
 !> - see calendar.f90 and select Gregorian, NoLeap, or D360 calendar
-!> - add suffix to number
-!> - add log message
 !----------------------------------------------------------------------
 MODULE date
@@ -78,28 +130,30 @@
    USE kind                            ! F90 kind parameter
    USE fct                             ! basic useful function
-   USE logger                             ! log file manager
+   USE logger                          ! log file manager
    IMPLICIT NONE
-   PRIVATE
    ! NOTE_avoid_public_variables_if_possible
 
    ! type and variable
-   PUBLIC :: TDATE              ! date structure
+   PUBLIC :: TDATE              !< date structure
+
+   PRIVATE :: cm_fmtdate        !< date and time format
+   PRIVATE :: im_secbyday       !< number of second by day
 
    ! function and subroutine
-   PUBLIC :: OPERATOR(-)        ! substract two dates or n days to a date
-   PUBLIC :: OPERATOR(+)        ! add n days to a date
-   PUBLIC :: date_init          ! initiazed date structure form julian day or year month day
-   PUBLIC :: date_now           ! return the date and time
-   PUBLIC :: date_today         ! return the date of the day at 12:00:00
-   PUBLIC :: date_print         ! print the date with format YYYY-MM-DD hh:mm:ss
-   PUBLIC :: date_leapyear      ! check if year is a leap year
-
-   PRIVATE :: date__init_fmtdate ! initiazed date structure from character YYYY-MM-DD hh:mm:ss
-   PRIVATE :: date__init_jd      ! initiazed date structure from julian day
-   PRIVATE :: date__init_nsec    ! initiazed date structure from number of second since origin of julian day
-   PRIVATE :: date__init_ymd     ! initiazed date structure from year month day
+   PUBLIC :: date_today         !< return the date of the day at 12:00:00
+   PUBLIC :: date_now           !< return the date and time
+   PUBLIC :: date_init          !< initialized date structure form julian day or year month day
+   PUBLIC :: date_print         !< print the date with format YYYY-MM-DD hh:mm:ss
+   PUBLIC :: date_leapyear      !< check if year is a leap year
+   PUBLIC :: OPERATOR(-)        !< substract two dates or n days to a date
+   PUBLIC :: OPERATOR(+)        !< add n days to a date
+
+   PRIVATE :: date__init_fmtdate ! initialized date structure from character YYYY-MM-DD hh:mm:ss
+   PRIVATE :: date__init_jd      ! initialized date structure from julian day
+   PRIVATE :: date__init_nsec    ! initialized date structure from number of second since origin of julian day
+   PRIVATE :: date__init_ymd     ! initialized date structure from year month day
    PRIVATE :: date__addnday      ! add nday to a date
    PRIVATE :: date__subnday      ! substract nday to a date
-   PRIVATE :: date__diffdate     ! compute number of day between two dates 
+   PRIVATE :: date__diffdate     ! compute number of days between two dates 
    PRIVATE :: date__lastday      ! compute last day of the month
    PRIVATE :: date__ymd2jd       ! compute julian day from year month day
@@ -115,10 +169,8 @@
    PRIVATE :: date__sec2jd       ! convert seconds since julian day origin in julian day
 
-   !> @struct TDATE
-   TYPE TDATE
+   TYPE TDATE !< date structure
       INTEGER(i4) :: i_year  = 1858   !< year
       INTEGER(i4) :: i_month = 11     !< month
       INTEGER(i4) :: i_day   = 17     !< day
-      INTEGER(i4) :: i_hms   = 0      !< fraction of the day
       INTEGER(i4) :: i_hour  = 0      !< hour
       INTEGER(i4) :: i_min   = 0      !< min
@@ -126,6 +178,6 @@
       INTEGER(i4) :: i_dow   = 0      !< day of week
       INTEGER(i4) :: i_lday  = 0      !< last day of the month
-      REAL(sp)    :: r_jd = 0         !< julian day (origin : 1858/11/17 00:00:00)
-      REAL(sp)    :: r_jc = 0         !< CNES julian day or pseudo julian day with new date origin    
+      REAL(dp)    :: d_jd = 0         !< julian day (origin : 1858/11/17 00:00:00)
+      REAL(dp)    :: d_jc = 0         !< CNES julian day or pseudo julian day with new date origin    
       INTEGER(i8) :: k_jdsec  = 0     !< number of seconds since julian day origin
       INTEGER(i8) :: k_jcsec  = 0     !< number of seconds since CNES or pseudo julian day origin
@@ -133,5 +185,5 @@
 
    !  module variable   
-   CHARACTER(LEN=lc), PARAMETER :: cm_fmtdate = &  !< date format
+   CHARACTER(LEN=lc), PARAMETER :: cm_fmtdate = &  !< date and time format
    &  "(i0.4,'-',i0.2,'-',i0.2,1x,i0.2,':',i0.2,':',i0.2)"
 
@@ -139,8 +191,8 @@
 
    INTERFACE date_init
-      MODULE PROCEDURE date__init_jd    ! initiazed date structure from julian day
-      MODULE PROCEDURE date__init_nsec  ! initiazed date structure from number of second since origin of julian day
-      MODULE PROCEDURE date__init_ymd   ! initiazed date structure from year month day
-      MODULE PROCEDURE date__init_fmtdate   ! initiazed date structure from character YYYY-MM-DD hh:mm:ss
+      MODULE PROCEDURE date__init_jd    ! initialized date structure from julian day
+      MODULE PROCEDURE date__init_nsec  ! initialized date structure from number of second since origin of julian day
+      MODULE PROCEDURE date__init_ymd   ! initialized date structure from year month day
+      MODULE PROCEDURE date__init_fmtdate   ! initialized date structure from character YYYY-MM-DD hh:mm:ss
    END INTERFACE date_init
 
@@ -156,36 +208,43 @@
 CONTAINS
    !-------------------------------------------------------------------
-   !> @brief This function print the date with 
-   !> format YYYY/MM/DD hh:mm:ss
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] td_date : date strutcutre
+   !> @brief This function print the date and time with 
+   !> format YYYY/MM/DD hh:mm:ss.
+   !> @details
+   !> Optionally, you could specify output format. However it will be only apply
+   !> to year, month, day.
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[in] td_date   date strutcutre
+   !> @param[in] cd_fmt    ouput format (only for year,month,day)
    !> @return date in format YYYY-MM-DD hh:mm:ss
    !-------------------------------------------------------------------
-   ! @code
-   CHARACTER(LEN=lc) FUNCTION date_print(td_date)
-      IMPLICIT NONE
-      ! Argument   
-      TYPE(TDATE), INTENT(IN) :: td_date
-      !----------------------------------------------------------------
-
-      WRITE(date_print,cm_fmtdate) &
-      &    td_date%i_year,td_date%i_month,td_date%i_day, &
-      &    td_date%i_hour,td_date%i_min,td_date%i_sec
+   CHARACTER(LEN=lc) FUNCTION date_print(td_date, cd_fmt)
+      IMPLICIT NONE
+      ! Argument   
+      TYPE(TDATE)     , INTENT(IN) :: td_date
+      CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: cd_fmt
+      !----------------------------------------------------------------
+
+      IF( PRESENT(cd_fmt) )THEN
+         WRITE(date_print,TRIM(cd_fmt)) &
+         &    td_date%i_year,td_date%i_month,td_date%i_day
+      ELSE
+         WRITE(date_print,cm_fmtdate) &
+         &    td_date%i_year,td_date%i_month,td_date%i_day, &
+         &    td_date%i_hour,td_date%i_min,td_date%i_sec
+      ENDIF
 
    END FUNCTION date_print
-   ! @endcode
    !-------------------------------------------------------------------
    !> @brief This function check if year is a leap year.
    !>
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] td_date : date strutcutre
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[in] td_date   date strutcutre
    !> @return true if year is leap year
    !-------------------------------------------------------------------
-   ! @code
    LOGICAL FUNCTION date_leapyear(td_date)
       IMPLICIT NONE
@@ -206,14 +265,12 @@
 
    END FUNCTION date_leapyear
-   ! @endcode
-   !-------------------------------------------------------------------
-   !> @brief This function return the date and time 
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @return date and time of the day in a date structure
-   !-------------------------------------------------------------------
-   ! @code
+   !-------------------------------------------------------------------
+   !> @brief This function return the current date and time.
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !
+   !> @return current date and time in a date structure
+   !-------------------------------------------------------------------
    TYPE(TDATE) FUNCTION date_now()
       IMPLICIT NONE
@@ -228,14 +285,12 @@
 
    END FUNCTION date_now
-   ! @endcode
-   !-------------------------------------------------------------------
-   !> @brief This function return the date of the day at 12:00:00 
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
+   !-------------------------------------------------------------------
+   !> @brief This function return the date of the day at 12:00:00.
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
    !
    !> @return date of the day at 12:00:00 in a date structure
    !-------------------------------------------------------------------
-   ! @code
    TYPE(TDATE) FUNCTION date_today()
       IMPLICIT NONE
@@ -249,25 +304,28 @@
 
    END FUNCTION date_today
-   ! @endcode
-   !-------------------------------------------------------------------
-   !> @brief This function initiazed date structure from a character 
-   !> date with format YYYY-MM-DD hh:mm:ss
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] cd_date : date in format YYYY-MM-DD hh:mm:ss
-   !> @param[in] td_dateo : new date origin for pseudo julian day
+   !-------------------------------------------------------------------
+   !> @brief This function initialized date structure from a character 
+   !> date with format YYYY-MM-DD hh:mm:ss.<br/>
+   !> @details
+   !> Optionaly create pseudo julian day with new origin.<br/>
+   !> julian day origin is 17 Nov 1858 at 00:00:00
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[in] cd_date   date in format YYYY-MM-DD hh:mm:ss
+   !> @param[in] td_dateo  new date origin for pseudo julian day
    !> @return date structure
    !-------------------------------------------------------------------
-   ! @code
-   TYPE(TDATE) FUNCTION date__init_fmtdate(cd_date, td_dateo)
-      IMPLICIT NONE
-      ! Argument   
-      CHARACTER(LEN=*), INTENT(IN)  :: cd_date
+   TYPE(TDATE) FUNCTION date__init_fmtdate(cd_datetime, td_dateo)
+      IMPLICIT NONE
+      ! Argument   
+      CHARACTER(LEN=*), INTENT(IN)  :: cd_datetime
       TYPE(TDATE),      INTENT(IN), OPTIONAL :: td_dateo
 
       ! local variable
+      CHARACTER(LEN=lc) :: cl_datetime
       CHARACTER(LEN=lc) :: cl_date
+      CHARACTER(LEN=lc) :: cl_time
       CHARACTER(LEN=lc) :: cl_year
       CHARACTER(LEN=lc) :: cl_month
@@ -285,17 +343,20 @@
       !----------------------------------------------------------------
 
-      cl_date=TRIM(ADJUSTL(cd_date))
-
-      cl_year=cl_date(1:4)
+      cl_datetime=TRIM(ADJUSTL(cd_datetime))
+
+      cl_date=fct_split(cl_datetime,1,' ')
+      cl_time=fct_split(cl_datetime,2,' ')
+
+      cl_year = fct_split(cl_date,1,'-')
       READ(cl_year,*) il_year
-      cl_month=cl_date(6:7)
+      cl_month= fct_split(cl_date,2,'-')
       READ(cl_month, *) il_month
-      cl_day=cl_date(9:10)
+      cl_day  = fct_split(cl_date,3,'-')
       READ(cl_day, *) il_day
-      cl_hour=cl_date(12:13)
+      cl_hour = fct_split(cl_time,1,':')
       READ(cl_hour, *) il_hour
-      cl_min=cl_date(15:16)
+      cl_min  = fct_split(cl_time,2,':')
       READ(cl_min, *) il_min
-      cl_sec=cl_date(18:19)
+      cl_sec  = fct_split(cl_time,3,':')
       READ(cl_sec, *) il_sec
 
@@ -304,23 +365,22 @@
 
    END FUNCTION date__init_fmtdate
-   ! @endcode   
-   !-------------------------------------------------------------------
-   !> @brief This function initiazed date structure from julian day<br/>
-   !> optionaly create pseudo julian day with new origin<br/>
+   !-------------------------------------------------------------------
+   !> @brief This function initialized date structure from julian day.<br/>
+   !> @details
+   !> Optionaly create pseudo julian day with new origin.<br/>
    !> julian day origin is 17 Nov 1858 at 00:00:00
    !>
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] rd_jd : julian day
-   !> @param[in] td_dateo : new date origin for pseudo julian day
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[in] dd_jd     julian day
+   !> @param[in] td_dateo  new date origin for pseudo julian day
    !
    !> @return date structure of julian day
    !-------------------------------------------------------------------
-   ! @code
-   TYPE(TDATE) FUNCTION date__init_jd(rd_jd, td_dateo)
+   TYPE(TDATE) FUNCTION date__init_jd(dd_jd, td_dateo)
       IMPLICIT NONE
       !Argument
-      REAL(sp),    INTENT(IN)  :: rd_jd
+      REAL(dp),    INTENT(IN)  :: dd_jd
       TYPE(TDATE), INTENT(IN), OPTIONAL :: td_dateo
       !----------------------------------------------------------------
@@ -329,12 +389,12 @@
 
          ! pseudo julian day with origin dateo
-         date__init_jd%r_jc=rd_jd
-         date__init_jd%k_jcsec=date__jd2sec(rd_jd)
+         date__init_jd%d_jc=dd_jd
+         date__init_jd%k_jcsec=date__jd2sec(dd_jd)
 
          ! convert to truly julian day
          CALL date__jc2jd(date__init_jd, td_dateo)
       ELSE
-         date__init_jd%r_jd=rd_jd
-         date__init_jd%k_jdsec=date__jd2sec(rd_jd)
+         date__init_jd%d_jd=dd_jd
+         date__init_jd%k_jdsec=date__jd2sec(dd_jd)
 
          ! compute CNES julian day
@@ -355,19 +415,18 @@
 
    END FUNCTION date__init_jd
-   ! @endcode
-   !-------------------------------------------------------------------
-   !> @brief This function initiazed date structure from number of 
-   !> second since julian day origin<br/>
-   !> optionaly create pseudo julian day with new origin
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] rd_jd : julian day
-   !> @param[in] td_dateo : new date origin for pseudo julian day
+   !-------------------------------------------------------------------
+   !> @brief This function initialized date structure from number of 
+   !> second since julian day origin.<br/>
+   !> @details
+   !> Optionaly create pseudo julian day with new origin.
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[in] kd_nsec   number of second since julian day origin
+   !> @param[in] td_dateo  new date origin for pseudo julian day
    !
    !> @return date structure of julian day
    !-------------------------------------------------------------------
-   ! @code
    TYPE(TDATE) FUNCTION date__init_nsec(kd_nsec, td_dateo)
       IMPLICIT NONE
@@ -383,13 +442,13 @@
 
    END FUNCTION date__init_nsec
-   ! @endcode   
-   !-------------------------------------------------------------------
-   !> @brief This function initiazed date structure form year month day
-   !> and optionnaly hour min sec<br/>
-   !> optionaly create pseudo julian day with new origin
-   !
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
+   !-------------------------------------------------------------------
+   !> @brief This function initialized date structure form year month day
+   !> and optionnaly hour min sec.<br/>
+   !> @details
+   !> Optionaly create pseudo julian day with new origin.
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !>
    !> @param[in] id_year
    !> @param[in] id_month
@@ -398,9 +457,8 @@
    !> @param[in] id_min
    !> @param[in] id_sec
-   !> @param[in] td_dateo : new date origin for pseudo julian day
+   !> @param[in] td_dateo  new date origin for pseudo julian day
    !
    !> @return date structure of year month day
    !-------------------------------------------------------------------
-   ! @code
    TYPE(TDATE) FUNCTION date__init_ymd(id_year, id_month, id_day,  &
    &                                   id_hour, id_min, id_sec, &
@@ -450,18 +508,16 @@
 
    END FUNCTION date__init_ymd
-   ! @endcode
-   !-------------------------------------------------------------------
-   !> @brief This function compute number of day between two dates<br/> 
+   !-------------------------------------------------------------------
+   !> @brief This function compute number of day between two dates: 
    !> nday= date1 - date2
    !
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] td_date1 : first date strutcutre
-   !> @param[in] td_date2 : second date strutcutre
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[in] td_date1  first date strutcutre
+   !> @param[in] td_date2  second date strutcutre
    !> @return nday
    !-------------------------------------------------------------------
-   ! @code
-   REAL(sp) FUNCTION date__diffdate(td_date1, td_date2)
+   REAL(dp) FUNCTION date__diffdate(td_date1, td_date2)
       IMPLICIT NONE
        
@@ -475,25 +531,23 @@
       CALL date__check(td_date2)   
 
-      date__diffdate = td_date1%r_jd - td_date2%r_jd
+      date__diffdate = td_date1%d_jd - td_date2%d_jd
 
    END FUNCTION date__diffdate
-   ! @endcode
-   !-------------------------------------------------------------------
-   !> @brief This function substract nday to a date 
+   !-------------------------------------------------------------------
+   !> @brief This function substract nday to a date:
    !> date2 = date1 - nday
    !>
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] td_date : date strutcutre
-   !> @param[in] rd_nday : number of day
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[in] td_date   date strutcutre
+   !> @param[in] dd_nday   number of day
    !> @return date strutcutre of date - nday
    !-------------------------------------------------------------------
-   ! @code
-   TYPE(TDATE) FUNCTION date__subnday(td_date, rd_nday)
+   TYPE(TDATE) FUNCTION date__subnday(td_date, dd_nday)
       IMPLICIT NONE
       !Argument
       TYPE(TDATE), INTENT(IN) :: td_date
-      REAL(sp),    INTENT(IN) :: rd_nday
+      REAL(dp),    INTENT(IN) :: dd_nday
       !----------------------------------------------------------------
 
@@ -501,25 +555,23 @@
       CALL date__check(td_date)   
 
-      date__subnday=date__init_jd(td_date%r_jd-rd_nday)
+      date__subnday=date__init_jd(td_date%d_jd-dd_nday)
 
    END FUNCTION date__subnday
-   ! @endcode
-   !-------------------------------------------------------------------
-   !> @brief This function add nday to a date  
+   !-------------------------------------------------------------------
+   !> @brief This function add nday to a date:
    !> date2 = date1 + nday
    !>
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] td_date : date strutcutre
-   !> @param[in] rd_nday : number of day
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[in] td_date   date strutcutre
+   !> @param[in] dd_nday   number of day
    !> @return date strutcutre of date + nday
    !-------------------------------------------------------------------
-   ! @code
-   TYPE(TDATE) FUNCTION date__addnday(td_date, rd_nday)
+   TYPE(TDATE) FUNCTION date__addnday(td_date, dd_nday)
       IMPLICIT NONE
       !Argument
       TYPE(TDATE), INTENT(IN) :: td_date
-      REAL(sp),    INTENT(IN) :: rd_nday
+      REAL(dp),    INTENT(IN) :: dd_nday
       !----------------------------------------------------------------
 
@@ -527,17 +579,16 @@
       CALL date__check(td_date)   
 
-      date__addnday=date__init_jd(td_date%r_jd+rd_nday)
+      date__addnday=date__init_jd(td_date%d_jd+dd_nday)
 
    END FUNCTION date__addnday
-   ! @endcode
    !-------------------------------------------------------------------
    !> @brief This subroutine compute last day of the month
    !
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[inout] td_date : date strutcutre
-   !-------------------------------------------------------------------
-   ! @code
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[in] td_date   date strutcutre
+   !> @return last day of the month
+   !-------------------------------------------------------------------
    INTEGER(i4) FUNCTION date__lastday(td_date)
       IMPLICIT NONE
@@ -562,15 +613,13 @@
 
    END FUNCTION date__lastday
-   ! @endcode   
-   !-------------------------------------------------------------------
-   !> @brief This subroutine compute julian day from year month day
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[inout] td_date : date strutcutre
-   !> @return julian day in the date strutcutre
-   !-------------------------------------------------------------------
-   ! @code
+   !-------------------------------------------------------------------
+   !> @brief This subroutine compute julian day from year month day , and fill
+   !> input date strutcutre.
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[inout] td_date   date strutcutre
+   !-------------------------------------------------------------------
    SUBROUTINE date__ymd2jd(td_date)
       IMPLICIT NONE
@@ -579,34 +628,32 @@
 
       ! local variable
-      REAL(sp) :: rl_standard_jd
-      REAL(sp) :: rl_frac
-      !----------------------------------------------------------------
-
-      rl_standard_jd= td_date%i_day - 32075                               & 
+      REAL(dp) :: dl_standard_jd
+      REAL(dp) :: dl_frac
+      !----------------------------------------------------------------
+
+      dl_standard_jd= td_date%i_day - 32075                               & 
           & + 1461 * (td_date%i_year + 4800 - (14 - td_date%i_month)/12)/4  &
           & + 367 * (td_date%i_month - 2 + (14 - td_date%i_month)/12*12)/12 &
           & - 3 * ((td_date%i_year + 4900 - (14 - td_date%i_month)/12)/100)/4
       
-      td_date%r_jd = rl_standard_jd-2400001 ! origin : 17 nov 1858 h00m00s00
+      td_date%d_jd = dl_standard_jd-2400001 ! origin : 17 nov 1858 h00m00s00
 
       ! compute fraction of day
-      rl_frac=date__hms2jd(td_date)
-
-      td_date%r_jd = td_date%r_jd + rl_frac
-
-      td_date%k_jdsec = date__jd2sec( td_date%r_jd ) 
+      dl_frac=date__hms2jd(td_date)
+
+      td_date%d_jd = td_date%d_jd + dl_frac
+
+      td_date%k_jdsec = date__jd2sec( td_date%d_jd ) 
 
    END SUBROUTINE date__ymd2jd
-   ! @endcode   
-   !-------------------------------------------------------------------
-   !> @brief This subroutine compute year month day from julian day
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[inout] td_date : date strutcutre
-   !> @return year month day in the date strutcutre
-   !-------------------------------------------------------------------
-   ! @code
+   !-------------------------------------------------------------------
+   !> @brief This subroutine compute year month day from julian day, and fill
+   !> input date strutcutre.
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[inout] td_date   date strutcutre
+   !-------------------------------------------------------------------
    SUBROUTINE date__jd2ymd(td_date)
       IMPLICIT NONE
@@ -615,5 +662,4 @@
 
       ! local variable
-      REAL(sp) :: rl_frac
       INTEGER(i4) :: il_standard_jd
       INTEGER(i4) :: il_temp1
@@ -624,6 +670,5 @@
       CALL date__check(td_date)   
 
-      il_standard_jd=INT( td_date%r_jd+2400001, i4 )
-      rl_frac=(td_date%r_jd+2400001)-il_standard_jd
+      il_standard_jd=INT( td_date%d_jd+2400001, i4 )
 
       il_temp1=il_standard_jd + 68569
@@ -645,16 +690,14 @@
 
    END SUBROUTINE date__jd2ymd
-   ! @endcode
    !-------------------------------------------------------------------
    !> @brief This subroutine compute julian day from pseudo julian day 
-   !> with new date origin<br/>
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[inout] td_date : date
-   !> @return julian day inside input date structure
-   !-------------------------------------------------------------------
-   ! @code
+   !> with new date origin, and fill input date strutcutre.
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[inout] td_date   date
+   !> @param[in]    td_dateo  new date origin for pseudo julian day
+   !-------------------------------------------------------------------
    SUBROUTINE date__jc2jd(td_date, td_dateo)
       IMPLICIT NONE
@@ -665,30 +708,28 @@
       ! local variable
       TYPE(TDATE) :: tl_date
-      REAL(sp)    :: rl_nday
+      REAL(dp)    :: dl_nday
       !----------------------------------------------------------------
       ! origin julian day
       tl_date=date_init(1858,11,17)
 
-      rl_nday=td_dateo-tl_date
+      dl_nday=td_dateo-tl_date
 
       ! compute julian day
-      td_date%r_jd = td_date%r_jc + rl_nday
+      td_date%d_jd = td_date%d_jc + dl_nday
       ! compute number of second since julian day origin
-      td_date%k_jdsec = date__jd2sec(td_date%r_jd)
+      td_date%k_jdsec = date__jd2sec(td_date%d_jd)
 
    END SUBROUTINE date__jc2jd
-   ! @endcode   
-   !-------------------------------------------------------------------
-   !> @brief This subroutine compute pseudo julian day with new date origin<br/>
-   !>  default new origin is CNES julian day origin: 1950/01/01
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[inout] td_date : date
-   !> @param[in] td_dateo : new origin date
-   !> @return pseudo julian day inside input date structure
-   !-------------------------------------------------------------------
-   ! @code
+   !-------------------------------------------------------------------
+   !> @brief This subroutine compute pseudo julian day with new date origin, and
+   !> fill input date structure.<br/>
+   !>  default new origin is CNES julian day origin: 1950-01-01 00:00:00
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[inout] td_date   date
+   !> @param[in] td_dateo     new origin date
+   !-------------------------------------------------------------------
    SUBROUTINE date__jd2jc(td_date, td_dateo)
       IMPLICIT NONE
@@ -701,5 +742,5 @@
       !----------------------------------------------------------------
       IF( PRESENT(td_dateo) )THEN
-         td_date%r_jc=td_date%r_jd-td_dateo%r_jd
+         td_date%d_jc=td_date%d_jd-td_dateo%d_jd
       ELSE
          ! CNES julian day origin
@@ -710,23 +751,21 @@
          CALL date__ymd2jd(tl_dateo)
 
-         td_date%r_jc = td_date%r_jd-tl_dateo%r_jd
-      ENDIF
-
-      td_date%k_jcsec = date__jd2sec(td_date%r_jc)
+         td_date%d_jc = td_date%d_jd-tl_dateo%d_jd
+      ENDIF
+
+      td_date%k_jcsec = date__jd2sec(td_date%d_jc)
 
    END SUBROUTINE date__jd2jc
-   ! @endcode   
-   !-------------------------------------------------------------------
-   !> @brief This subroutine compute the day of week from julian day<br/>
+   !-------------------------------------------------------------------
+   !> @brief This subroutine compute the day of week from julian day, and fill
+   !> input date structure.<br/>
    !>  days   : Sunday Monday Tuesday Wednesday Thursday Friday Saturday<br/>
    !>  numday : 0      1      2       3         4        5      6<br/>
    !>
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[inout] td_date : date strutcutre
-   !> @return day of week inside input date structure 
-   !-------------------------------------------------------------------
-   ! @code
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[inout] td_date   date strutcutre
+   !-------------------------------------------------------------------
    SUBROUTINE date__jd2dow(td_date)
       IMPLICIT NONE
@@ -735,20 +774,18 @@
       !----------------------------------------------------------------
 
-      td_date%i_dow=MOD((INT(AINT(td_date%r_jd))+3),7)
+      td_date%i_dow=MOD((INT(AINT(td_date%d_jd))+3),7)
 
    END SUBROUTINE date__jd2dow
-   ! @endcode   
    !-------------------------------------------------------------------
    !> @brief This function compute fraction of a day from 
-   !> hour, minute, second 
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] td_date : date strutcutre
+   !> hour, minute, second. 
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[in] td_date   date strutcutre
    !> @return fraction of the day
    !-------------------------------------------------------------------
-   ! @code
-   REAL(sp) FUNCTION date__hms2jd(td_date)
+   REAL(dp) FUNCTION date__hms2jd(td_date)
       IMPLICIT NONE
       ! Argument   
@@ -757,25 +794,22 @@
 
       !  compute real seconds
-      date__hms2jd = REAL( td_date%i_sec, sp )   
+      date__hms2jd = REAL( td_date%i_sec, dp )   
       !  compute real minutes
-      date__hms2jd = REAL( td_date%i_min, sp ) + date__hms2jd/60.0
+      date__hms2jd = REAL( td_date%i_min, dp ) + date__hms2jd/60.0
       !  compute real hours
-      date__hms2jd = REAL( td_date%i_hour, sp ) + date__hms2jd/60.0
+      date__hms2jd = REAL( td_date%i_hour, dp ) + date__hms2jd/60.0
       !  julian fraction of a day
       date__hms2jd = date__hms2jd/24.0
 
    END FUNCTION date__hms2jd
-   ! @endcode 
-   !-------------------------------------------------------------------
-   !> @brief This function compute hour, minute, second from julian 
-   !> fraction
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] td_date : date strutcutre
-   !> @return date strutcutre
-   !-------------------------------------------------------------------
-   ! @code
+   !-------------------------------------------------------------------
+   !> @brief This subroutine compute hour, minute, second from julian 
+   !> fraction, and fill date structure.
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[inout] td_date   date strutcutre
+   !-------------------------------------------------------------------
    SUBROUTINE date__jd2hms(td_date)
       IMPLICIT NONE
@@ -784,28 +818,26 @@
 
       !local variable
-      REAL(sp) :: rl_fract
-      !----------------------------------------------------------------
-
-      rl_fract=(td_date%r_jd)-AINT(td_date%r_jd)
+      REAL(dp) :: dl_fract
+      !----------------------------------------------------------------
+
+      dl_fract=(td_date%d_jd)-AINT(td_date%d_jd)
       !  compute hour
-      td_date%i_hour = INT( rl_fract * 24.0, i4 )
-      rl_fract = ( rl_fract - REAL( td_date%i_hour, sp ) / 24.0) * 24.0
+      td_date%i_hour = INT( dl_fract * 24.0, i4 )
+      dl_fract = ( dl_fract - REAL( td_date%i_hour, dp ) / 24.0) * 24.0
       !  compute minute
-      td_date%i_min = INT( rl_fract * 60.0, i4 )
-      rl_fract = ( rl_fract - REAL( td_date%i_min, sp ) / 60.0) * 60.0
+      td_date%i_min = INT( dl_fract * 60.0, i4 )
+      dl_fract = ( dl_fract - REAL( td_date%i_min, dp ) / 60.0) * 60.0
       !  compute second
-      td_date%i_sec = NINT( rl_fract * 60.0, i4 )
+      td_date%i_sec = NINT( dl_fract * 60.0, i4 )
 
    END SUBROUTINE date__jd2hms
-   ! @endcode   
    !-------------------------------------------------------------------
    !> @brief This subroutine check date express in date structure
    !>
    !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] td_date : date strutcutre
-   !-------------------------------------------------------------------
-   ! @code
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[in] td_date   date strutcutre
+   !-------------------------------------------------------------------
    SUBROUTINE date__check(td_date)
       IMPLICIT NONE
@@ -819,60 +851,67 @@
       !----------------------------------------------------------------
 
+      ! init
+      il_status=0
+
       ! check year
       IF( td_date%i_year < 1858_i4 .OR. td_date%i_year > 39999_i4 )THEN
+         il_status=il_status+1
          WRITE(cl_msg,*) "year ",td_date%i_year," out of range"
          CALL logger_error(cl_msg)
-         CALL fct_err(il_status)
       ENDIF
       ! check month
       IF( td_date%i_month < 1_i4 .OR. td_date%i_month > 12_i4 )THEN
+         il_status=il_status+1
          WRITE(cl_msg,*) "month ",td_date%i_month," out of range"
          CALL logger_error(cl_msg)
-         CALL fct_err(il_status)
       ENDIF
       ! check day
       il_lastday=date__lastday(td_date)
       IF( td_date%i_day < 1_i4 .OR. td_date%i_day > il_lastday )THEN
+         il_status=il_status+1
          WRITE(cl_msg,*) "day ",td_date%i_day," out of range"
          CALL logger_error(cl_msg)
-         CALL fct_err(il_status)
       ENDIF
       ! check hour
       IF( td_date%i_hour < 0_i4 .OR. td_date%i_hour > 23_i4 )THEN
+         il_status=il_status+1
          WRITE(cl_msg,*) "hour ",td_date%i_hour," out of range"
          CALL logger_error(cl_msg)
-         CALL fct_err(il_status)
       ENDIF
       ! check minutes
       IF( td_date%i_min < 0_i4 .OR. td_date%i_min > 59_i4 )THEN
+         il_status=il_status+1
          WRITE(cl_msg,*) "minutes ",td_date%i_min," out of range"
          CALL logger_error(cl_msg)
-         CALL fct_err(il_status)
       ENDIF   
       ! check seconds
       IF( td_date%i_sec < 0_i4 .OR. td_date%i_sec > 59_i4 )THEN
+         il_status=il_status+1
          WRITE(cl_msg,*) "seconds ",td_date%i_sec," out of range"
          CALL logger_error(cl_msg)
-         CALL fct_err(il_status)
       ENDIF
 
       ! check julian day
-      IF( td_date%r_jd < 0_sp .OR. td_date%r_jd > 782028_sp )THEN
-         WRITE(cl_msg,*) "julian day ",td_date%r_jd," out of range"
+      IF( td_date%d_jd < 0_sp .OR. td_date%d_jd > 782028_sp )THEN
+         il_status=il_status+1
+         WRITE(cl_msg,*) "julian day ",td_date%d_jd," out of range"
          CALL logger_error(cl_msg)
-         CALL fct_err(il_status)
+      ENDIF
+
+      IF( il_status/= 0 )THEN
+         WRITE(cl_msg,*) " date error"
+         CALL logger_fatal(cl_msg)
       ENDIF
 
    END SUBROUTINE date__check
-   ! @endcode   
-   !-------------------------------------------------------------------
-   !> @brief This subroutine adjust date
-   !>
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[inout] td_date : date strutcutre
-   !-------------------------------------------------------------------
-   ! @code
+   !-------------------------------------------------------------------
+   !> @brief This subroutine adjust date (correct hour, minutes, and seconds
+   !> value if need be)
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[inout] td_date   date strutcutre
+   !-------------------------------------------------------------------
    SUBROUTINE date__adjust(td_date)
       IMPLICIT NONE
@@ -893,40 +932,36 @@
       IF( td_date%i_hour == 24 )THEN
          td_date%i_hour=0
-         td_date=date__addnday(td_date,1._sp)
+         td_date=date__addnday(td_date,1._dp)
       ENDIF
 
    END SUBROUTINE date__adjust
-   ! @endcode   
    !-------------------------------------------------------------------
    !> @brief This function convert julian day in seconds
-   !> since julian day origin
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] td_date : date strutcutre
+   !> since julian day origin.
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[in] td_date   date strutcutre
    !> @return number of seconds since julian day origin
    !-------------------------------------------------------------------
-   ! @code
-   INTEGER(i8) FUNCTION date__jd2sec(rd_jul)
-      IMPLICIT NONE
-      ! Argument   
-      REAL(sp), INTENT(IN) :: rd_jul
-      !----------------------------------------------------------------
-
-      date__jd2sec = NINT( rd_jul * im_secbyday, i8 )
+   INTEGER(i8) FUNCTION date__jd2sec(dd_jul)
+      IMPLICIT NONE
+      ! Argument   
+      REAL(dp), INTENT(IN) :: dd_jul
+      !----------------------------------------------------------------
+
+      date__jd2sec = NINT( dd_jul * im_secbyday, i8 )
 
    END FUNCTION date__jd2sec
-   ! @endcode   
    !-------------------------------------------------------------------
    !> @brief This function convert seconds since julian day origin in 
-   !> julian day
-   !> @author J.Paul
-   !> - Nov, 2013- Initial Version
-   !
-   !> @param[in] td_date : date strutcutre
-   !> @return number of seconds since julian day origin
-   !-------------------------------------------------------------------
-   ! @code
-   REAL(sp) FUNCTION date__sec2jd(kd_nsec)
+   !> julian day.
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !
+   !> @param[in] kd_nsec   number of second since julian day origin
+   !> @return julian day
+   !-------------------------------------------------------------------
+   REAL(dp) FUNCTION date__sec2jd(kd_nsec)
       IMPLICIT NONE
       ! Argument   
@@ -934,8 +969,7 @@
       !----------------------------------------------------------------
 
-      date__sec2jd = REAL( REAL( kd_nsec , sp ) / im_secbyday, sp )
+      date__sec2jd = REAL( REAL( kd_nsec , dp ) / im_secbyday, dp )
 
    END FUNCTION date__sec2jd
-   ! @endcode   
 END MODULE date
 
