!
! $Header$
!
      SUBROUTINE hgardfou (t,tsol,text)
      IMPLICIT none
c======================================================================
c Verifier la temperature
c======================================================================
#include "dimensions.h"
#include "dimphy.h"
#include "YOMCST.h"
#include "indicesol.h"
      REAL t(klon,klev), tsol(klon,nbsrf)
      CHARACTER*(*) text
C
      INTEGER i, k, nsrf
      REAL zt(klon)
      INTEGER jadrs(klon), jbad
      LOGICAL ok
c
      LOGICAL firstcall
      SAVE firstcall
      DATA firstcall /.TRUE./
      IF (firstcall) THEN
         PRINT*, 'hgardfou garantit la temperature dans [100,370] K'
         firstcall = .FALSE.
      ENDIF
c
      ok = .TRUE.
      DO k = 1, klev
         DO i = 1, klon
            zt(i) = t(i,k)
         ENDDO
#ifdef CRAY
         CALL WHENFGT(klon, zt, 1, 370.0, jadrs, jbad)
#else
         jbad = 0
         DO i = 1, klon
         IF (zt(i).GT.370.0) THEN
            jbad = jbad + 1
            jadrs(jbad) = i
         ENDIF
         ENDDO
#endif
         IF (jbad .GT. 0) THEN
           ok = .FALSE.
           DO i = 1, jbad
             PRINT *,'i,k,temperature =',jadrs(i),k,zt(jadrs(i))
           ENDDO
         ENDIF
#ifdef CRAY
         CALL WHENFLT(klon, zt, 1, 100.0, jadrs, jbad)
#else
         jbad = 0
         DO i = 1, klon
!         IF (zt(i).LT.100.0) THEN
         IF (zt(i).LT.50.0) THEN
            jbad = jbad + 1
            jadrs(jbad) = i
         ENDIF
         ENDDO
#endif
         IF (jbad .GT. 0) THEN
           ok = .FALSE.
           DO i = 1, jbad
             PRINT *,'i,k,temperature =',jadrs(i),k,zt(jadrs(i))
           ENDDO
         ENDIF
      ENDDO
c
      DO nsrf = 1, nbsrf
         DO i = 1, klon
            zt(i) = tsol(i,nsrf)
         ENDDO
#ifdef CRAY
         CALL WHENFGT(klon, zt, 1, 370.0, jadrs, jbad)
#else
         jbad = 0
         DO i = 1, klon
         IF (zt(i).GT.370.0) THEN
            jbad = jbad + 1
            jadrs(jbad) = i
         ENDIF
         ENDDO
#endif
         IF (jbad .GT. 0) THEN
           ok = .FALSE.
           DO i = 1, jbad
             PRINT *,'i,nsrf,temperature =',jadrs(i),nsrf,zt(jadrs(i))
           ENDDO
         ENDIF
#ifdef CRAY
         CALL WHENFLT(klon, zt, 1, 100.0, jadrs, jbad)
#else
         jbad = 0
         DO i = 1, klon
!         IF (zt(i).LT.100.0) THEN
         IF (zt(i).LT.50.0) THEN
            jbad = jbad + 1
            jadrs(jbad) = i
         ENDIF
         ENDDO
#endif
         IF (jbad .GT. 0) THEN
           ok = .FALSE.
           DO i = 1, jbad
             PRINT *,'i,nsrf,temperature =',jadrs(i),nsrf,zt(jadrs(i))
           ENDDO
         ENDIF
      ENDDO
c
      IF (.NOT. ok) THEN
         PRINT*, 'hgardfou s arrete ', text
         CALL abort
      ENDIF

      RETURN
      END
