    SUBROUTINE EXIT(NAME,IRET)
!--------------------------------------------------------------
    INCLUDE "parmeta.f90"
    INCLUDE "parm.tbl.f90"
    INCLUDE "cuparm.f90"
    INCLUDE "parmsoil.f90"
    INCLUDE "mpp.h"
    INCLUDE "mpif.h"
!--------------------------------------------------------------
    PARAMETER (JAM=6+2*(JM-10),LB=2*IM+JM-3 &
    ,          LM1=LM-1,LP1=LM+1,IMT=2*IM-1)
!--------------------------------------------------------------
    CHARACTER NAME*(*)
!--------------------------------------------------------------

!     INCLUDE COMMON BLOCKS.

    INCLUDE "COMM_CTLBLK.f90"
    INCLUDE "COMM_LOOPS.f90"
    INCLUDE "COMM_MASKS.f90"
    INCLUDE "COMM_DYNAM.f90"
    INCLUDE "COMM_PHYS2.f90"
    INCLUDE "COMM_MAPOT1.f90"
    INCLUDE "COMM_VRBLS.f90"
    INCLUDE "COMM_CONTIN.f90"
    INCLUDE "COMM_PVRBLS.f90"
    INCLUDE "COMM_BOCO.f90"
    INCLUDE "COMM_ACMCLH.f90"
    INCLUDE "COMM_ACMCLD.f90"
    INCLUDE "COMM_ACMPRE.f90"
    INCLUDE "COMM_ACMRDL.f90"
    INCLUDE "COMM_ACMRDS.f90"
    INCLUDE "COMM_ACMSFC.f90"
    INCLUDE "COMM_CLDWTR.f90"
    INCLUDE "COMM_CNVCLD.f90"
    INCLUDE "COMM_SOIL.f90"
    INCLUDE "COMM_INDX.f90"
    INCLUDE "COMM_Z0EFFT.f90"
    INCLUDE "COMM_TEMPV.f90"
!--------------------------------------------------------------
    IRET=0
    100 FORMAT(' EXIT ',A)
    IEND=MYIE
    IF(MOD(MYPE+1,INPES) == 0)IEND=MYIE-1

    DO J=MYJS,MYJE
        DO I=MYIS,IEND
            IF(PD(I,J) > 110000 .OR. PD(I,J) < 40000.)THEN
                WRITE(6,100)NAME
                WRITE(6,120)I,J,PD(I,J),MYPE
                120 FORMAT(' I=',I3,' J=',I3,' PD=',E12.5 &
                ,          ' MYPE=',I3)
                IRET=666
                CALL MPI_ABORT(MPI_COMM_WORLD,1,IERR)
            ENDIF
        ENDDO
    ENDDO

    DO 500 L=1,LM
        DO 490 J=MYJS,MYJE
            DO 490 I=MYIS,IEND
                IF(HTM(I,J,L) > 0.5)THEN
                    IF(T(I,J,L) < 150. .OR. T(I,J,L) > 325.)THEN
                        WRITE(6,100)NAME
                        WRITE(6,200)I,J,L,T(I,J,L),MYPE
                        200 FORMAT(' I=',I3,' J=',I3,' L=',I2,' T=',E12.5 &
                        ,          ' MYPE=',I3)
                        IRET=666
                        CALL MPI_ABORT(MPI_COMM_WORLD,1,IERR)
                    ELSEIF(Q(I,J,L) < -1.E-4 .OR. Q(I,J,L) > 30.E-3)THEN
                        WRITE(6,100)NAME
                        WRITE(6,210)I,J,L,Q(I,J,L),MYPE
                        210 FORMAT(' I=',I3,' J=',I3,' L=',I2,' Q=',E12.5 &
                        ,          ' MYPE=',I3)
                        IRET=666
                        CALL MPI_ABORT(MPI_COMM_WORLD,1,IERR)
                    ELSEIF(Q2(I,J,L) > 200.)THEN
                        WRITE(6,100)NAME
                        WRITE(6,220)I,J,L,Q2(I,J,L),MYPE
                        220 FORMAT(' I=',I3,' J=',I3,' L=',I2,' Q2=',E12.5 &
                        ,          ' MYPE=',I3)
                        IRET=666
                        CALL MPI_ABORT(MPI_COMM_WORLD,1,IERR)
                    ELSEIF(CWM(I,J,L) > 1.E-2)THEN
                        WRITE(6,100)NAME
                        WRITE(6,230)I,J,L,CWM(I,J,L),MYPE
                        230 FORMAT(' I=',I3,' J=',I3,' L=',I2,' CWM=',E12.5 &
                        ,          ' MYPE=',I3)
                        IRET=666
                        CALL MPI_ABORT(MPI_COMM_WORLD,1,IERR)
                    ENDIF
                ENDIF
        490 END DO
    500 END DO
    DO 700 L=1,LM
        DO 690 J=MYJS,MYJE
            DO 690 I=MYIS,IEND
                IF(ABS(U(I,J,L)) > 125. .OR. ABS(V(I,J,L)) > 125.)THEN
                    WRITE(6,100)NAME
                    WRITE(6,610)I,J,L,U(I,J,L),V(I,J,L),MYPE
                    610 FORMAT(' I=',I3,' J=',I3,' L=',I2,' U=',E12.5,' V=',E12.5 &
                    ,          ' MYPE=',I3)
                    IRET=666
                    CALL MPI_ABORT(MPI_COMM_WORLD,1,IERR)
                ENDIF
        690 END DO
    700 END DO

    RETURN
    END SUBROUTINE EXIT
