1 subroutine da_check_xtovptox_errors(xa, xa2_u, xa2_v, xa2_w, xa2_t, &
2 xa2_p, xa2_q, xa2_rho, &
3 xa2_qt, xa2_qcw, xa2_qrn)
5 !---------------------------------------------------------------------------
6 ! Purpose: Test invertibility of v = U^{-1} x followed by x = Uv.
8 ! Method: Perform statistics on differences in initial and final x.
9 !---------------------------------------------------------------------------
13 type (x_type), intent(in) :: xa ! Test input
15 real, dimension(ims:ime, jms:jme, kms:kme), &
16 intent(in) :: xa2_u, xa2_v, xa2_t, &
17 xa2_p, xa2_q, xa2_rho, &
18 xa2_qt, xa2_qcw, xa2_qrn
19 real, dimension(ims:ime, jms:jme, kms:kme), &
20 intent(in) :: xa2_w !xiao
23 real :: rms_fild ! RMS of field.
24 real :: rms_diff ! RMS of differnce.
26 real, dimension(ims:ime, jms:jme, kms:kme) :: diff ! Difference
28 if (trace_use) call da_trace_entry("da_check_xtovpx_errors")
30 !----------------------------------------------------------------------
31 ! [1.0]: Check u differences:
32 !----------------------------------------------------------------------
34 diff(its:ite, jts:jte, kts:kte) = xa2_u(its:ite, jts:jte, kts:kte) &
35 - xa% u(its:ite, jts:jte, kts:kte)
37 rms_fild = sqrt(sum(xa % u(its:ite, jts:jte, kts:kte) &
38 * xa % u(its:ite, jts:jte, kts:kte)))
39 rms_diff = sqrt(sum(diff(its:ite, jts:jte, kts:kte) &
40 * diff(its:ite, jts:jte, kts:kte)))
42 if (rms_fild == 0.0) then
43 write(unit=stdout, fmt='(a)') ' u is zero '
45 write(unit=stdout, fmt='(a,1pe10.4)') ' u RMS error = ', rms_diff
46 write(unit=stdout, fmt='(a,1pe10.4)') ' u RMS field = ', rms_fild
47 write(unit=stdout, fmt='(a,1pe10.4)') ' u RMS error/RMS field = ', &
51 !----------------------------------------------------------------------
52 ! [2.0]: Check v differences:
53 !----------------------------------------------------------------------
55 diff(its:ite, jts:jte, kts:kte) = xa2_v(its:ite, jts:jte, kts:kte) &
56 - xa% v(its:ite, jts:jte, kts:kte)
58 rms_fild = sqrt(sum(xa % v(its:ite, jts:jte, kts:kte) &
59 * xa % v(its:ite, jts:jte, kts:kte)))
60 rms_diff = sqrt(sum(diff(its:ite, jts:jte, kts:kte) &
61 * diff(its:ite, jts:jte, kts:kte)))
63 if (rms_fild == 0.0) then
64 write(unit=stdout, fmt='(a)') ' v is zero '
66 write(unit=stdout, fmt='(a,1pe10.4)') ' v RMS error = ', rms_diff
67 write(unit=stdout, fmt='(a,1pe10.4)') ' v RMS field = ', rms_fild
68 write(unit=stdout, fmt='(a,1pe10.4)') ' v RMS error/RMS field = ', &
72 !----------------------------------------------------------------------
73 ! [3.0]: Check t differences:
74 !----------------------------------------------------------------------
76 diff(its:ite, jts:jte, kts:kte) = xa2_t(its:ite, jts:jte, kts:kte) &
77 - xa% t(its:ite, jts:jte, kts:kte)
79 rms_fild = sqrt(sum(xa % t(its:ite, jts:jte, kts:kte) &
80 * xa % t(its:ite, jts:jte, kts:kte)))
81 rms_diff = sqrt(sum(diff(its:ite, jts:jte, kts:kte) &
82 * diff(its:ite, jts:jte, kts:kte)))
84 if (rms_fild == 0.0) then
85 write(unit=stdout, fmt='(a)') ' t is zero '
87 write(unit=stdout, fmt='(a,1pe10.4)') ' t RMS error = ', rms_diff
88 write(unit=stdout, fmt='(a,1pe10.4)') ' t RMS field = ', rms_fild
89 write(unit=stdout, fmt='(a,1pe10.4)') ' t RMS error/RMS field = ', &
93 !----------------------------------------------------------------------
94 ! [4.0]: Check p differences:
95 !----------------------------------------------------------------------
97 diff(its:ite, jts:jte, kts:kte) = xa2_p(its:ite, jts:jte, kts:kte) &
98 - xa% p(its:ite, jts:jte, kts:kte)
100 rms_fild = sqrt(sum(xa % p(its:ite, jts:jte, kts:kte) &
101 * xa % p(its:ite, jts:jte, kts:kte)))
102 rms_diff = sqrt(sum(diff(its:ite, jts:jte, kts:kte) &
103 * diff(its:ite, jts:jte, kts:kte)))
105 if (rms_fild == 0.0) then
106 write(unit=stdout, fmt='(a)') ' p is zero '
108 write(unit=stdout, fmt='(a,1pe10.4)') ' p RMS error = ', rms_diff
109 write(unit=stdout, fmt='(a,1pe10.4)') ' p RMS field = ', rms_fild
110 write(unit=stdout, fmt='(a,1pe10.4)') ' p RMS error/RMS field = ', &
114 !----------------------------------------------------------------------
115 ! [5.0]: Check q differences:
116 !----------------------------------------------------------------------
118 diff(its:ite, jts:jte, kts:kte) = xa2_q(its:ite, jts:jte, kts:kte) &
119 - xa% q(its:ite, jts:jte, kts:kte)
121 rms_fild = sqrt(sum(xa % q(its:ite, jts:jte, kts:kte) &
122 * xa % q(its:ite, jts:jte, kts:kte)))
123 rms_diff = sqrt(sum(diff(its:ite, jts:jte, kts:kte) &
124 * diff(its:ite, jts:jte, kts:kte)))
126 if (rms_fild == 0.0) then
127 write(unit=stdout, fmt='(a)') ' q is zero '
129 write(unit=stdout, fmt='(a,1pe10.4)') ' q RMS error = ', rms_diff
130 write(unit=stdout, fmt='(a,1pe10.4)') ' q RMS field = ', rms_fild
131 write(unit=stdout, fmt='(a,1pe10.4)') ' q RMS error/RMS field = ', &
135 !----------------------------------------------------------------------
136 ! [6.0]: Check rho differences:
137 !----------------------------------------------------------------------
139 diff(its:ite, jts:jte, kts:kte) = xa2_rho(its:ite, jts:jte, kts:kte) &
140 - xa% rho(its:ite, jts:jte, kts:kte)
142 rms_fild = sqrt(sum(xa % rho(its:ite, jts:jte, kts:kte) &
143 * xa % rho(its:ite, jts:jte, kts:kte)))
144 rms_diff = sqrt(sum(diff(its:ite, jts:jte, kts:kte) &
145 * diff(its:ite, jts:jte, kts:kte)))
147 if (rms_fild == 0.0) then
148 write(unit=stdout, fmt='(a)') ' rho is zero '
150 write(unit=stdout, fmt='(a,1pe10.4)') ' rho RMS error = ', rms_diff
151 write(unit=stdout, fmt='(a,1pe10.4)') ' rho RMS field = ', rms_fild
152 write(unit=stdout, fmt='(a,1pe10.4)') ' rho RMS error/RMS field = ', &
156 !----------------------------------------------------------------------
157 ! [7.0]: Check w differences:
158 !----------------------------------------------------------------------
160 diff(its:ite, jts:jte, kts:kte+1) = xa2_w(its:ite, jts:jte, kts:kte+1) &
161 - xa% w(its:ite, jts:jte, kts:kte+1)
163 rms_fild = sqrt(sum(xa % w(its:ite, jts:jte, kts:kte+1) &
164 * xa % w(its:ite, jts:jte, kts:kte+1)))
165 rms_diff = sqrt(sum(diff(its:ite, jts:jte, kts:kte+1) &
166 * diff(its:ite, jts:jte, kts:kte+1)))
168 if (rms_fild == 0.0) then
169 write(unit=stdout, fmt='(a)') ' w is zero '
171 write(unit=stdout, fmt='(a,1pe10.4)') ' w RMS error = ', rms_diff
172 write(unit=stdout, fmt='(a,1pe10.4)') ' w RMS field = ', rms_fild
173 write(unit=stdout, fmt='(a,1pe10.4)') ' w RMS error/RMS field = ', &
177 if (trace_use) call da_trace_exit("da_check_xtovpx_errors")
179 end subroutine da_check_xtovptox_errors