SUBROUTINE REDATE

!     Mise a jour de la date pour la finalisation
!     D. Giard 98-09-22

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK

USE YOMCST   , ONLY : RDAY
USE YOMLUN   , ONLY : NULOUT
USE YOMRIP   , ONLY : NSSSSS   ,NINDAT

IMPLICIT NONE

INTEGER(KIND=JPIM) :: ILMOIS(12)

INTEGER(KIND=JPIM) :: IA, ID, IDAT, IDAY, IDEC, IM, ISSS
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "updcal.intfb.h"

#include "fcttim.h"

IF (LHOOK) CALL DR_HOOK('REDATE',0,ZHOOK_HANDLE)
IDAT= NINDAT
ISSS= NSSSSS

ID= NDD(IDAT)
IM= NMM(IDAT)
IA= NCCAA(IDAT)
IDAY= NINT(RDAY)
IDEC= ISSS/IDAY
IF (IDEC /= 0) THEN
  CALL UPDCAL(ID,IM,IA,IDEC,ID,IM,IA,ILMOIS,NULOUT)
  IDAT= IA*10000+IM*100+ID
  ISSS= MOD(ISSS,IDAY)
ENDIF

NINDAT= IDAT
NSSSSS= ISSS

IF (LHOOK) CALL DR_HOOK('REDATE',1,ZHOOK_HANDLE)
END SUBROUTINE REDATE
