Changeset 80 in lmdz_wrf


Ignore:
Timestamp:
Jul 25, 2014, 10:08:38 AM (10 years ago)
Author:
lfita
Message:

Adding check_var

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/LMDZ_WRFmeas/WRFV3/lmdz/physiq.F90

    r69 r80  
    43854385      END SUBROUTINE gr_fi_ecrit
    43864386
     4387SUBROUTINE check_var(funcn, varn, var, sizev, bigvalue, stoprun)
     4388!  Subroutine to check the consistency of a variable
     4389!    * NaN value: by definition is variable /= variable
     4390!    * bigvalue: threshold for the variable
     4391
     4392  IMPLICIT NONE
     4393
     4394#include "dimensions.h"
     4395
     4396  INTEGER, INTENT(IN)                                    :: sizev
     4397  CHARACTER(LEN=50), INTENT(IN)                          :: funcn, varn
     4398  REAL, DIMENSION(sizev), INTENT(IN)                     :: var
     4399  REAL, INTENT(IN)                                       :: bigvalue
     4400  LOGICAL, INTENT(IN)                                    :: stoprun
     4401
     4402! Local
     4403  INTEGER                                                :: i, wrongi, xpt, ypt
     4404  CHARACTER(LEN=50)                                      :: errmsg
     4405  LOGICAL                                                :: found
     4406  REAL, DIMENSION(sizev)                                 :: wrongvalues
     4407  INTEGER, DIMENSION(sizev)                              :: wronggridpt
     4408
     4409!!!!!!! Variables
     4410! funcn: at which functino of part of the program variable is checked
     4411! varn: name of the variable
     4412! var: variable to check
     4413! sizev: size of the variable
     4414! bigvalue: biggest attenaible value for the variable
     4415! stoprun: Should the run stop if it founds a problem?
     4416
     4417  errmsg = 'ERROR -- error -- ERROR -- error'
     4418
     4419  found = .FALSE.
     4420  wrongi = 0
     4421  DO i=1,sizev
     4422    IF (var(i) /= var(i) .OR. ABS(var(i)) > bigvalue ) THEN
     4423      IF (wrongi == 0) found = .TRUE.
     4424      wrongi = wrongi + 1
     4425      wrongvalues(wrongi) = var(i)
     4426      wronggridpt(wrongi) = i
     4427    END IF
     4428  END DO
     4429
     4430  IF (found) THEN
     4431    PRINT *,TRIM(errmsg)
     4432    PRINT *,"  at '" // TRIM(funcn) // "' variable '" //TRIM(varn)//                 &
     4433      "' is wrong in Nvalues= ",wrongi,' at i (x, y) value___'
     4434    DO i=1,wrongi
     4435       ypt = INT(wronggridpt(i)/wiim) + 1
     4436       xpt = wronggridpt(i) - (ypt-1)*wiim
     4437      PRINT *,wronggridpt(i), '(',xpt,', ',ypt,')', wrongvalues(i)
     4438    END DO
     4439    IF (stoprun) THEN
     4440      STOP
     4441    END IF
     4442  END IF
     4443
     4444  RETURN
     4445
     4446END SUBROUTINE check_var
     4447
    43874448SUBROUTINE check_var3D(funcn, varn, var, sizev, zsize, bigvalue, stoprun)
    43884449!  Subroutine to check the consistency of a 3D LMDSZ - variable (klon, klev) !
Note: See TracChangeset for help on using the changeset viewer.