da_max_error_qc.inc
References to this file elsewhere.
1 subroutine da_max_error_qc (it, info, n, field, max_error, ix, ixf, iunit, var, failed, print)
2
3 !-----------------------------------------------------------------------
4 ! Purpose: TBD
5 !-----------------------------------------------------------------------
6
7 implicit none
8
9 integer, intent(in) :: it
10 type(infa_type), intent(in) :: info
11 integer, intent(in) :: n
12 type(field_type), intent(inout) :: field
13 real, intent(in) :: max_error
14 integer, intent(inout) :: ix, ixf
15 integer, intent(in) :: iunit
16 character (len=*), intent(in) :: var
17 logical, intent(out) :: failed
18 logical, intent(in) :: print
19
20 real :: err, err_max
21 integer :: qc_flag
22
23 if (trace_use_frequent) call da_trace_entry("da_max_error_qc")
24
25 failed = .false.
26
27 qc_flag = field % qc
28 err_max = field % error * max_error
29 err = field % inv
30 err = ABS (err)
31
32 ix = ix + 1
33 if (it > 1 .and. qc_flag == fails_error_max) field%qc = 0
34 if (err > err_max) then
35 if (field % qc > fails_error_max) field % qc = fails_error_max
36
37 ixf = ixf + 1
38 failed = .true.
39
40 if (print .and. failed) then
41 if (err_max .LE. 0.0) then
42 write (unit=iunit , fmt = '(A,3(F10.1,1X),A,A,A,A5,A,A,3f10.2)') &
43 "Err_max < 0 ==> ",err,err_max,max_error, " for ", var, &
44 " OBS ID: ", info%id(n), info%platform(n), &
45 " LA/LON/ELV:", info%lat(1,n), info%lon(1,n), info%elv(n)
46 ! call da_error(__FILE__,__LINE__,(/"Erk"/))
47 end if
48
49 write (unit=iunit , fmt = '(A,A5,A,A,I5,A,I3,A,F4.1,A,A,A,2e13.6)') &
50 "Err_max failed:ID=", info%id(n), info%platform(n),&
51 "Ix=", ix, " Ixf=", ixf, " Err_max ratio =",err/err_max, &
52 " for ", var, " inv, error:",field % inv, field % error
53 end if
54 field % inv = 0.0
55 end if
56
57 if (trace_use_frequent) call da_trace_exit("da_max_error_qc")
58
59 end subroutine da_max_error_qc
60
61