SUBROUTINE CONVDDR(KFLAG,PDDRS,KDDR1,PDDR1,CDDR1,KDDR2,PDDR2,CDDR2)

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

USE YOMCMDDR , ONLY : NLENCD1  ,NLEND1I  ,NLEND1R  ,NLEND1C  ,&
 & NLENCD2  ,NLEND2I  ,NLEND2R  ,NLEND2C  

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KFLAG 
REAL(KIND=JPRB)                  :: PDDRS(NLENCD1+NLENCD2) ! UNDETERMINED INTENT
INTEGER(KIND=JPIM)               :: KDDR1(NLEND1I) ! UNDETERMINED INTENT
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PDDR1(NLEND1R) 
CHARACTER(LEN=NLEND1C)               :: CDDR1 ! UNDETERMINED INTENT
INTEGER(KIND=JPIM)               :: KDDR2(NLEND2I) ! UNDETERMINED INTENT
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PDDR2(NLEND2R) 
CHARACTER(LEN=NLEND2C)               :: CDDR2 ! UNDETERMINED INTENT
INTEGER(KIND=JPIM) :: J
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"

IF (LHOOK) CALL DR_HOOK('CONVDDR',0,ZHOOK_HANDLE)
IF(KFLAG == -1) THEN
  CALL ITOR(KDDR1,PDDRS(1)        ,NLEND1I)
  CALL ITOR(KDDR2,PDDRS(1+NLENCD1),NLEND2I)

  DO J=1,NLEND1R
    PDDRS(NLEND1I+J)=PDDR1(J)
  ENDDO
  DO J=1,NLEND2R
    PDDRS(NLENCD1+NLEND2I+J)=PDDR2(J)
  ENDDO

  CALL CTOR(CDDR1,PDDRS(1+NLEND1I+NLEND1R)        ,NLEND1C)
  CALL CTOR(CDDR2,PDDRS(1+NLENCD1+NLEND2I+NLEND2R),NLEND2C)

ELSEIF (KFLAG == 1) THEN

!*      1.2   GET INTEGER SECTIONS OF DDRS

  CALL RTOI(PDDRS(1)        ,KDDR1,NLEND1I)
  CALL RTOI(PDDRS(1+NLENCD1),KDDR2,NLEND2I)

!*      1.3   GET REAL SECTIONS OF DDRS

  DO J=1,NLEND1R
    PDDR1(J)=PDDRS(NLEND1I+J)
  ENDDO
  DO J=1,NLEND2R
    PDDR2(J)=PDDRS(NLENCD1+NLEND2I+J)
  ENDDO

!*      1.4   GET CHARACTER SECTIONS OF DDRS

  CALL RTOC(PDDRS(1+NLEND1I+NLEND1R)        ,CDDR1,NLEND1C)
  CALL RTOC(PDDRS(1+NLENCD1+NLEND2I+NLEND2R),CDDR2,NLEND2C)

ELSE
  CALL ABOR1('CONVDDR:UNKNOWN KFLAG')
ENDIF

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

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

