C   12/05/80 211031454  MEMBER NAME  WALLOK   (JADEGS)      FORTRAN
      SUBROUTINE WALLOK
      IMPLICIT INTEGER*2 (H)
C---
C---   ALLOCATE OUTPUT DATA SET IN GRAPHICS, JADE ROUTINE
C---
      COMMON/CBSTR/MODE,MAXRL
#include "cgraph.for"
#include "ciouni.for"
      REAL*8 DDN
      COMMON/CSVCW1/NDDSVE,NRWR
      COMMON/CWALLK/IOUTSV(11)
      DIMENSION IDATAL(11),HVOLSR(4)
      DATA ICONT /'CONT'/
      DATA HBLANK/'  '/
C---
C---     LAST CHANGE 3.11.82   J.OLSSON
C---
    1 CONTINUE
      CALL TRMOUT(80,'PLEASE ENTER FULL NAME OF CATALOGUED DATA SET FOR
     $OUTPUT EVENTS:^')
      CALL TRMIN(44,IDATAL)
C---
C---     TEST FOR THE STRING CONTINUE.
C---
      IF(IDATAL(1).NE.ICONT) GO TO 9
      NDDOUT = 0
      GO TO 200
C---
C---     ALLOCATE FORTRAN REFERENCE NUMBER TO OUTPUT DATA SET.
C---
9     CONTINUE
      DO 111  I = 1,11
111   IOUTSV(I) = IDATAL(I)
   16 CONTINUE
      DO 3 I=1,4
    3 HVOLSR(I)=HBLANK
      NDDOUT=0
      CALL TRMOUT(80,'THE DATA SET WILL NOW BE ALLOCATED, PLEASE WAIT A
     $LITTLE...^')
      CALL GETPDD(IDATAL,HVOLSR,DDN,NDDOUT,HERR)
      IF(HERR.EQ.0) GO TO 5
C---
C---     ERROR HAS OCCURRED ON ALLOCATION.
C---
      CALL TRMOUT(80,'THE NAME IS INCORRECT OR HMS/MSS IS JAMMED.^')
44    CALL TRMOUT(80,'PLEASE TRY AGAIN OR CONTINUE SESSION BY "CONTINUE"
     $.^')
      GO TO 1
C---
C---     SUCCESSFULLY ALLOCATED DATA SET. NOW COUNT THE RECORDS
C---     AND LOAD THE FORTRAN REFERENCE NUMBER AND NUMBER OF RECORDS
C---     INTO THE TRANSFER COMMON FOR THE USE OF OTHER ROUTINES.
C---
    5 JUNIT = NDDOUT
      CALL TRMOUT(80,' OUTPUT DATA SET ALLOCATED.^')
      CALL TRMOUT(80,
     $'DO YOU WANT TO OVERWRITE THE RECORDS ON THIS DS?^')
      CALL TRMOUT(80,'IF NOT YOU WILL ADD RECORDS TO THE EXISTING DS.^')
      CALL DECIDE(IANSW)
      IF(IANSW.EQ.1) GO TO 12
      CALL TRMOUT(80,' THIS OPTION IS PRESENTLY NOT WORKING, UNFORTUNATE
     $LY^')
      CALL TRMOUT(80,' DO YOU WISH ANOTHER OUTPUT FILE? IF NOT, YOU WILL
     $OVERWRITE THIS ONE.^')
      CALL DECIDE(IANSW)
      IF(IANSW.EQ.1) GO TO 1
C     CALL TRMOUT(80,
C    $'IF YOU CHOOSE TO ADD EVENTS TO THE EXISTING ONES,^')
C     CALL TRMOUT(80,
C    $'THEN THE CURRENT EVENT WILL NOT BE WRITTEN. IS THIS OK?^')
C     CALL DECIDE(IANSW)
C     IF(IANSW.EQ.2) GO TO 12
C     CALL GNUREC(NDDOUT,NUMEVN,NUMREC)
C     NRWR = NUMEVN
C     WRITE(JUSCRN,101) NUMEVN,NUMREC
C 101 FORMAT(' DATA SET HAS NUMBER OF EVENTS, NUMBER OF RECORDS = ',2I4)
C     CALL TRMOUT(80,'EVENTS WILL BE ADDED TO THE ALREADY EXISTING ONES.
C    $^')
C     CALL STWADD(NDDOUT,&4)
C     GO TO 100
C4     CALL TRMOUT(80,'THE DATA SET GIVES READ ERROR OR IS EMPTY.^')
C      GO TO 44
C100   CALL BWRO(JUNIT,MAXRL,MODE)
12    CALL TRMOUT(80,'EVENTS WILL BE OVERWRITTEN. BOS S FORMAT IS DEFAUL
     $T.^')
      MODE = 0
      MAXRL = 33000
      NRWR = 0
      CALL BWRO(JUNIT,MAXRL,MODE)
200   CONTINUE
      RETURN
      END
