      SUBROUTINE LODFIL (XXX, YYY, M, N, NAME, INCTRL, IOCTRL, IZ)
      IMPLICIT NONE
C
C ***      LOAD PLOT DEFINITIONS
C
      INTEGER M, N, INCTRL, IOCTRL
      REAL XXX(M,N), YYY(M,N)
      CHARACTER*4 NAME(32)
C
      INCLUDE MATLAB$KOM:SIZEPARMS.INC
C
      CHARACTER*1 IZ(VARSIZE)
C
      INCLUDE MATLAB$KOM:IOP.KOM
      INCLUDE MATLAB$KOM:MATPLT.KOM
      INCLUDE MATLAB$KOM:SAV.KOM
C
      CHARACTER*8 ICURS
      LOGICAL GOTONE
      INTEGER I, J, KK, IPL, IERR
C
      DATA ICURS / 'PLTLOD>>' /
C
C
      IPL = 45
      GOTONE = .FALSE.
5     CONTINUE
      IF (INCTRL.EQ.0) THEN
        CALL CHKEND
        CALL DSSTRN (' PLEASE ENTER THE FILE NAME TO BE LOADED.', 1)
        CALL DSCURS (ICURS)
        READ (RTE, 15) NAME
15      FORMAT (32A1)
        IF (WIO.NE.0) WRITE (WIO, 20) NAME
20      FORMAT (1X, 32A1)
      ENDIF
      DO 22 I = 1, 10
        IPLTYP(I) = 0
22    CONTINUE
      CALL FILES (IPL, NAME)
      IF (FE.EQ.0) THEN
        READ (IPL, 25, END = 55) PLTCNT, PLTMAX
25      FORMAT (2I2)
C
C ***      CHECK THE HEADER FOR VALIDITY
        IF (PLTCNT.GT.10 .OR. PLTCNT.LT.1 .OR.
     .      PLTMAX.GT.10 .OR. PLTMAX.LT.1) THEN
          CALL DSERR ('ERROR IN PLOT DEFINITION FILE')
          CALL DSERR ('NOT A VALID PLOT DEFINITION')
          CALL FILES (-1*IPL, NAME)
          GO TO 5
        ENDIF
C
C ***      READ IN THE DEFINITION
        DO 50 J = 1, PLTMAX
          READ (IPL, 30, END = 55) IPLTYP(J)
30        FORMAT (I1)
          READ (IPL, 35, END = 55) (ISAV(J, KK), KK = 1, 360)
          READ (IPL, 35, END = 55) (ISAV(J, KK), KK = 361, XYSIZ)
35        FORMAT (360Z2)
          GOTONE = .TRUE.
50      CONTINUE
55      CONTINUE
        CALL FILES (-1*IPL, NAME)
        IF (GOTONE) CALL PLREST (XXX, YYY, M, N, 0, IERR, IZ)
      ENDIF
C
      RETURN
      END
