      SUBROUTINE POPREAL8(px)
 
      USE PARKIND1  ,ONLY : JPIM, JPRB
      USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK

      USE YOEADBUFFER

      IMPLICIT NONE

      REAL(KIND=JPRB), INTENT(OUT) :: px

      INTEGER(KIND=JPIM) :: i_adr8ilbuf 
      LOGICAL :: ll_adr8inlbuf 

      REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

      IF (i_adr8ilbuf /= -1) THEN
         i_adr8ilbuf = -1
         ll_adr8inlbuf = .FALSE.
      ENDIF
      IF (adr8ibuf <= 1) THEN
         CALL POPREAL8ARRAY(adr8buf, 512)
         adr8ibuf = 512
         px = adr8buf(512)
      ELSE
         adr8ibuf = adr8ibuf-1
         px = adr8buf(adr8ibuf)
      ENDIF

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