SUBROUTINE OPDIS(CDCONF,CDCALLER,PCP,PVCP,PRT,PACP,PAVCP,PART)

!***  *OPDIS* - SUBROUTINE TO GENERATE AN OPERATOR DISPLAY

!     PURPOSE.
!     -------

!     *OPDIS* PREPARES A TEXT ARRAY CONTAINING RELEVANT INFORMATION
!     ABOUT THE CURRENT STATE OF MODEL EXECUTION.
!     THE TEXT IS WRITTEN TO A FILE SO THAT THE BUFFER IS IMMEDIATELY
!     FLUSHED.

!     INTERFACE
!     ---------

!     *CALL OPDIS*

!     CHARACTER*9 CDCONF
!   1 : configuration of IOPACK     IO handling
!   2 : configuration of LTINV      inverse Legendre transform
!   3 : configuration of FTINV      inverse Fourier transform (under SCAN2M*)
!   4 : configuration of CPG        grid point computations   (under SCAN2M*)
!   5 : configuration of POS        post processing           (under SCAN2M*)
!   6 : configuration of OBS        comparison to observations(under SCAN2M*)
!   7 : configuration of FTDIR      direct Fourier transform  (under SCAN2M*)
!   8 : configuration of LTDIR      direct Legendre transform
!   9 : configuration of SPC,SPHDG  spectral space computations

!     Reference.
!     ----------
!        ECMWF Research Department documentation of the IFS

!     Author.
!     -------
!        D.Dent    ECMWF

!     Modifications.
!     --------------
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        M.Hamrud      01-Dec-2003 CY28R1 Cleaning
!        G.Mozdzynski  09-Dec-2004 Remove ifs.disp

!     ------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
USE YOMCT0   , ONLY : CNDISPP
USE YOMCT3   , ONLY : NSTEP
USE YOMSPNRM , ONLY : AVNRMDIV
USE YOMLUN   , ONLY : NULSTAT
USE YOMMP    , ONLY : MYPROC

IMPLICIT NONE

CHARACTER(LEN=9)  ,INTENT(IN)    :: CDCONF 
CHARACTER(LEN=8)  ,INTENT(IN)    :: CDCALLER 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCP 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVCP 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRT 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PACP 
REAL(KIND=JPRB)                  :: PAVCP ! Argument NOT used
REAL(KIND=JPRB)   ,INTENT(IN)    :: PART 
!     CDCONF: current configuration flags
!     CDCALLER: name of calling routine
!     PCP:   cp time of last step
!     PVCP:  vector cp time of last step
!     PRT:   real time of last step
!     PACP:  accumulated cp time
!     PAVCP: accumulated vector cp time
!     PART:  accumulated real time

CHARACTER (LEN = 100) ::  CLMESS
CHARACTER (LEN = 10) ::   CLCP,CLTIME
INTEGER(KIND=JPIM) :: IVALUES(8)

CHARACTER (LEN = 10) ::  CLDATEOD,CLTIMEOD,CLZONEOD
INTEGER(KIND=JPIM)      :: IFIRST=0

INTEGER(KIND=JPIM) :: IB, IMCP, IMIT, ISCP, ISIT, JSTEP  

REAL(KIND=JPRB) :: ZCP, ZIT
REAL(KIND=JPRB) :: ZHOOK_HANDLE

!*         1.     CHECK SWITCHES AND BLANK DISPLAY ARRAY
!                 ----- -------- --- ----- ------- -----

IF (LHOOK) CALL DR_HOOK('OPDIS',0,ZHOOK_HANDLE)

IF (MYPROC == 1) THEN

  CALL GSTATS(1930,0)

  IF(IFIRST == 0) THEN
    IFIRST=1
    IB=INDEX(CNDISPP,' ') -1
    IF(IB >= 1) THEN
      OPEN(NULSTAT,FILE=CNDISPP(1:IB)//'ifs.stat',ACTION='WRITE')
    ELSE
      OPEN(NULSTAT,FILE='ifs.stat',ACTION='WRITE')
    ENDIF
    JSTEP=0
  ENDIF

  IF(IFIRST /= 0) THEN
    JSTEP=NSTEP
  ELSE
    JSTEP=0
  ENDIF

!     ---------------------------------------------------------------------

!*         0.5     FIND STEP TYPE

  CLMESS=' '
  CALL DATE_AND_TIME(CLDATEOD,CLTIMEOD,CLZONEOD,IVALUES)
  WRITE(CLMESS(2:9),'(A,'':'',A,'':'',A)')&
   & CLTIMEOD(1:2),CLTIMEOD(3:4),CLTIMEOD(5:6)
  CLMESS(11:19)=CDCONF

  WRITE(CLMESS(21:),'(A,I6)') CDCALLER,JSTEP

!*         WRITE TIMING STATISTICS

  ZIT=PART
  IMIT=ZIT/60._JPRB
  ISIT=ZIT-60._JPRB*IMIT
  WRITE(CLTIME,'(I7,":",I2.2)') IMIT,ISIT
  ZCP=PACP
  IMCP=ZCP/60._JPRB
  ISCP=ZCP-60._JPRB*IMCP
  WRITE(CLCP  ,'(I7,":",I2.2)') IMCP,ISCP
  WRITE(CLMESS(36:),209) PVCP,PCP,PRT,CLCP,CLTIME,AVNRMDIV
209 FORMAT(3F8.2,2A10,E21.14)
  WRITE(NULSTAT,'(A)') CLMESS
  CALL FLUSH(NULSTAT)

  CALL GSTATS(1930,1)
ENDIF

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