C
C**************************  CHECK *************************************
C
C  controlla alcune dimensioni ammissibili 
C
C***********************************************************************
C
      SUBROUTINE CHECK(N,NMAX,NT,NTEMAX,NNOD,NODMAX,NTRI,NTRMAX,
     1                 NZONE,MAXZON,NPRT,MAXPRT,NSTR,MAXSTR,NR,NRMAX,
     2                 N1,NTPMAX,NTERM,MAXTRM,NP,NPMAX,NQ,NQMAX,
     3                 NDIR,NP2MAX,ITUNS,MAXIT,NUMVP,MAXVP,
     4                 NUM_QOUT,MAXQOUT,NSF,NSFMAX,NSFNUM,NNSFMX,
     5                 NROW,ROWMAX,NCOL,COLMAX,
     6                 NCELL,MAXCEL,NUMRES,MAXRES,NLKP,MAXLKP,
     7                 NUDN,MAXNUDN,NUDT,MAXNUDT,NUDC,MAXNUDC)
C
      IMPLICIT NONE
      INTEGER  I
      INTEGER  N,NMAX,NT,NTEMAX,NNOD,NODMAX,NTRI,NTRMAX
      INTEGER  NZONE,MAXZON,NPRT,MAXPRT,NSTR,MAXSTR,NR,NRMAX
      INTEGER  N1,NTPMAX,NTERM,MAXTRM,NP,NPMAX,NQ,NQMAX
      INTEGER  NDIR,NP2MAX,ITUNS,MAXIT,NUMVP,MAXVP
      INTEGER  NUM_QOUT,MAXQOUT,NSF,NSFMAX,NNSFMX
      INTEGER  NROW,ROWMAX,NCOL,COLMAX
      INTEGER  NCELL,MAXCEL,NUMRES,MAXRES,NLKP,MAXLKP
      INTEGER  NUDN,MAXNUDN,NUDT,MAXNUDT,NUDC,MAXNUDC
      INTEGER  NSFNUM(*)
      LOGICAL  IFLAG
      INCLUDE 'IOUNITS.H'
C
      IFLAG=.FALSE.
      IF(NPRT.GT.MAXPRT) THEN
       WRITE(IOUT2,1)NPRT,MAXPRT
    1  FORMAT(' N. OUTPUT TEMP. =',I7,2X,'MAX. CONSENTITO=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NT.GT.NTEMAX) THEN
       WRITE(IOUT2,2)NT,NTEMAX
    2  FORMAT(' N. TETRAEDRI =',I7,2X,'MAX. CONSENTITO=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NNOD.GT.NODMAX) THEN
       WRITE(IOUT2,3)NNOD,NODMAX
    3  FORMAT(' N.NODI  (MESH 2-D) =',I7,2X,'MAX. CONSENTITO=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NTRI.GT.NTRMAX) THEN
       WRITE(IOUT2,4)NTRI,NTRMAX
    4  FORMAT(' N.TRIANGOLI =',I7,2X,'MAX. CONSENTITO=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NZONE.GT.MAXZON) THEN
       WRITE(IOUT2,5)NZONE,MAXZON
    5  FORMAT(' N.ZONE =',I7,2X,'MAX. CONSENTITO=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NSTR.GT.MAXSTR) THEN
       WRITE(IOUT2,6)NSTR,MAXSTR
    6  FORMAT(' N.STRATI =',I7,2X,'MAX. CONSENTITO=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NR.GT.NRMAX) THEN
       WRITE(IOUT2,8)NR,NRMAX
    8  FORMAT(' N.NODI OUTPUT =',I7,2X,'MAX. CONSENTITO=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(N1*N.GT.NTPMAX)THEN
       WRITE(IOUT2,9)N1*N,NTPMAX
    9  FORMAT(' DIM. DI JA =',I10,2X,'MAX. CONSENTITO=',I10)
       IFLAG=.TRUE.
      ENDIF
      IF(NTERM.GT.MAXTRM) THEN
       WRITE(IOUT2,11)NTERM,MAXTRM
   11  FORMAT(' N. TERM. NON NULLI MAT. =',I8,2X,'MAX. CONSENTITO=',I8)
       IFLAG=.TRUE.
      ENDIF
      IF(NP.GT.NPMAX) THEN
       WRITE(IOUT2,13)NP,NPMAX
   13  FORMAT(' NODI  DIRICH. NONATM. =',I7,2X,'MAX. CONSENTITO=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NQ.GT.NQMAX) THEN
       WRITE(IOUT2,14)NQ,NQMAX
   14  FORMAT(' NODI  NEUMANN NONATM. =',I7,2X,'MAX. CONSENTITO=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NDIR.GT.NP2MAX) THEN
       WRITE(IOUT2,18)NDIR,NP2MAX
   18  FORMAT(' NODI DIR. 2-D NONATM. =',I7,2X,'MAX. CONSENTITO=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(ITUNS.GT.MAXIT) THEN
       WRITE(IOUT2,19)ITUNS,MAXIT
   19  FORMAT(' N. ITER. NONLINEARE =',I7,2X,'MAX. CONSENTITO=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(N.GT.NMAX) THEN
       WRITE(IOUT2,20)N,NMAX
   20  FORMAT(' N. NODI MESH 3D=',I7,2X,'MAX. CONSENTITO=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NUMVP.GT.MAXVP) THEN
       WRITE(IOUT2,21)NUMVP,MAXVP
   21  FORMAT(' N. SURF. NODES FOR VP OUTPUT=',I7,2X,'MAX. ALLOWED=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NUM_QOUT.GT.MAXQOUT) THEN
       WRITE(IOUT2,22)NUM_QOUT,MAXQOUT
   22  FORMAT(' N. SURF. CELLS FOR DETAILED OUTPUT=',I7,2X,
     1      'MAX. ALLOWED=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NSF.GT.NSFMAX) THEN
       WRITE(IOUT2,23)NSF,NSFMAX
   23    FORMAT(' N. SEEPAGE FACES=',I7,2X,'MAX. ALLOWED=',I7)
       IFLAG=.TRUE.
      ENDIF
      DO I=1,NSF
         IF (NSFNUM(I) .GT. NNSFMX) THEN
          WRITE(IOUT2,24) I,NSFNUM(I),NNSFMX
   24     FORMAT(' N. NODES ON SEEPAGE FACE',I7,'=',I7,2X,
     1           'MAX. ALLOWED=',I7)
          IFLAG=.TRUE.
         ENDIF
      END DO
      IF(NROW.GT.ROWMAX) THEN
       WRITE(IOUT2,25)NROW,ROWMAX
   25  FORMAT(' NROW=',I7,2X,'ROWMAX=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NCOL.GT.COLMAX) THEN
       WRITE(IOUT2,26)NCOL,COLMAX
   26  FORMAT(' NCOL=',I7,2X,'COLMAX=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NCELL.GT.MAXCEL) THEN
       WRITE(IOUT2,27)NCELL,MAXCEL
   27  FORMAT(' NCELL=',I7,2X,'MAXCEL=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NUMRES.GT.MAXRES) THEN
       WRITE(IOUT2,28)NUMRES,MAXRES
   28  FORMAT(' NUMRES=',I7,2X,'MAXRES=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NUDN.GT.MAXNUDN) THEN
       WRITE(IOUT2,29)NUDN,MAXNUDN
   29  FORMAT(' NUDN=',I7,2X,'MAXNUDN=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NUDT.GT.MAXNUDT) THEN
       WRITE(IOUT2,30)NUDT,MAXNUDT
   30  FORMAT(' NUDT=',I7,2X,'MAXNUDT=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(NUDC.GT.MAXNUDC) THEN
       WRITE(IOUT2,31)NUDC,MAXNUDC
   31  FORMAT(' NUDC=',I7,2X,'MAXNUDC=',I7)
       IFLAG=.TRUE.
      ENDIF
      IF(MAXLKP.LT.3) THEN
       WRITE(IOUT2,32)
   32  FORMAT(' VALUE OF MAXLKP MUST BE AT LEAST 3')
       IFLAG=.TRUE.
      ENDIF
      IF(NLKP.GT.MAXLKP) THEN
       WRITE(IOUT2,8)NLKP,MAXLKP
   33  FORMAT(' NLKP =',I7,2X,'MAXLKP=',I7)
       IFLAG=.TRUE.
      ENDIF
C
      IF (IFLAG) THEN
         CALL CLOSIO
         STOP
      END IF
      RETURN
      END
