SUBROUTINE RDVAPARAM(param,K_NPARAM,CD_CFILE)

!   Purpose.
!   --------
!     Read estimated parameters.

!   Author.
!   -------
!     Y. Tremolet

!   Modifications.
!   --------------
!     Original   03-02-21
!     D. Dee     03-11-05 : Wrapped by upvaparam
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
! ------------------------------------------------------------------

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

USE yomlun, ONLY :  nulerr
USE yommsc, ONLY : nrealen

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: K_NPARAM 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PARAM(K_NPARAM) 
CHARACTER(LEN=*)  ,INTENT(IN)    :: CD_CFILE 
INTEGER(KIND=JPIM)                    :: iunit,ierr,ilen
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"

IF (LHOOK) CALL DR_HOOK('RDVAPARAM',0,ZHOOK_HANDLE)
CALL PBOPEN(iunit,CD_CFILE,'r',ierr)
IF (ierr/=0) THEN
  write(nulerr,*) 'RDVAPARAM: PBOPEN returned error code ',ierr
  CALL ABOR1 ('RDVAPARAM: error in PBOPEN')
ENDIF

ilen = K_NPARAM * nrealen
CALL PBREAD(iunit,param,ilen,ierr)
IF (ierr/=ilen) THEN
  WRITE(nulerr,*)'RDVAPARAM: PBREAD returned error code',ierr
  CALL ABOR1('RDVAPARAM: error in PBREAD')
ENDIF

CALL PBCLOSE(iunit,ierr)
IF (ierr/=0) THEN
  write(nulerr,*) 'RDVAPARAM: PBCLOSE returned error code ',ierr
  CALL ABOR1 ('RDVAPARAM: error in PBCLOSE')
ENDIF

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