forked from NOAA-GFDL/SIS2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SIS_error_checking.F90
525 lines (441 loc) · 23 KB
/
SIS_error_checking.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
module SIS_error_checking
!***********************************************************************
!* GNU General Public License *
!* This file is a part of SIS2. *
!* *
!* SIS2 is free software; you can redistribute it and/or modify it and *
!* are expected to follow the terms of the GNU General Public License *
!* as published by the Free Software Foundation; either version 2 of *
!* the License, or (at your option) any later version. *
!* *
!* SIS2 is distributed in the hope that it will be useful, but WITHOUT *
!* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
!* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public *
!* License for more details. *
!* *
!* For the full text of the GNU General Public License, *
!* write to: Free Software Foundation, Inc., *
!* 675 Mass Ave, Cambridge, MA 02139, USA. *
!* or see: http://www.gnu.org/licenses/gpl.html *
!***********************************************************************
use MOM_coms, only : PE_here, root_PE, num_PEs, sum_across_PEs
use MOM_coms, only : min_across_PEs, max_across_PEs, reproducing_sum
use MOM_domains, only : pass_vector, pass_var, pe_here
use MOM_domains, only : BGRID_NE, AGRID, To_All, Scalar_Pair
use MOM_error_handler, only : MOM_error, FATAL, WARNING, is_root_pe
use MOM_file_parser, only : log_version, param_file_type
use SIS_hor_grid, only : SIS_hor_grid_type
use MOM_hor_index, only : hor_index_type
implicit none ; private
public :: check_redundant_C, check_redundant_B, check_redundant_T
public :: SIS_error_checking_init
interface check_redundant_C
module procedure check_redundant_vC3d, check_redundant_vC2d
end interface check_redundant_C
interface check_redundant_B
module procedure check_redundant_vB3d, check_redundant_vB2d
module procedure check_redundant_sB3d, check_redundant_sB2d
end interface check_redundant_B
interface check_redundant_T
module procedure check_redundant_sT3d, check_redundant_sT2d
module procedure check_redundant_vT3d, check_redundant_vT2d
end interface check_redundant_T
integer :: max_redundant_prints = 100
integer :: redundant_prints(3) = 0
contains
! =====================================================================
!> SIS_error_checking_init initializes the SIS_error_checking module. As it
!! happens, the only thing that it does is to log the version of this module.
subroutine SIS_error_checking_init(param_file)
type(param_file_type), intent(in) :: param_file
! This include declares and sets the variable "version".
#include "version_variable.h"
character(len=40) :: mod = "SIS_error_checking" ! This module's name.
call log_version(param_file, mod, version)
end subroutine SIS_error_checking_init
subroutine check_redundant_vC3d(mesg, u_comp, v_comp, G, is, ie, js, je, &
direction)
character(len=*), intent(in) :: mesg
type(SIS_hor_grid_type), intent(inout) :: G
real, dimension(G%IsdB:,G%jsd:,:), intent(in) :: u_comp
real, dimension(G%isd:,G%JsdB:,:), intent(in) :: v_comp
integer, optional, intent(in) :: is, ie, js, je
integer, optional, intent(in) :: direction
! Arguments: u_comp - The u-component of the vector being checked.
! (in) v_comp - The v-component of the vector being checked.
! (in) mesg - A message indicating what is being checked.
! (in) G - The ocean's grid structure.
! (in/opt) is, ie, js, je - the i- and j- range of indices to check.
! (in/opt) direction - the direction flag to be passed to pass_vector.
character(len=24) :: mesg_k
integer :: k
do k=1,size(u_comp,3)
if (k < 10) then ; write(mesg_k,'(" Layer",i2," ")') k
elseif (k < 100) then ; write(mesg_k,'(" Layer",i3," ")') k
elseif (k < 1000) then ; write(mesg_k,'(" Layer",i4," ")') k
else ; write(mesg_k,'(" Layer",i9," ")') k ; endif
call check_redundant_vC2d(trim(mesg)//trim(mesg_k), u_comp(:,:,k), &
v_comp(:,:,k), G, is, ie, js, je, direction)
enddo
end subroutine check_redundant_vC3d
subroutine check_redundant_vC2d(mesg, u_comp, v_comp, G, is, ie, js, je, &
direction)
character(len=*), intent(in) :: mesg
type(SIS_hor_grid_type), intent(inout) :: G
real, dimension(G%IsdB:,G%jsd:), intent(in) :: u_comp
real, dimension(G%isd:,G%JsdB:), intent(in) :: v_comp
integer, optional, intent(in) :: is, ie, js, je
integer, optional, intent(in) :: direction
! Arguments: u_comp - The u-component of the vector being checked.
! (in) v_comp - The v-component of the vector being checked.
! (in) mesg - A message indicating what is being checked.
! (in) G - The ocean's grid structure.
! (in/opt) is, ie, js, je - the i- and j- range of indices to check.
! (in/opt) direction - the direction flag to be passed to pass_vector.
real :: u_nonsym(G%isd:G%ied,G%jsd:G%jed)
real :: v_nonsym(G%isd:G%ied,G%jsd:G%jed)
real :: u_resym(G%IsdB:G%IedB,G%jsd:G%jed)
real :: v_resym(G%isd:G%ied,G%JsdB:G%JedB)
character(len=128) :: mesg2
integer :: i, j, is_ch, ie_ch, js_ch, je_ch
integer :: Isq, Ieq, Jsq, Jeq, isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB
Isq = G%IscB ; Ieq = G%IecB ; Jsq = G%JscB ; Jeq = G%JecB
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
IsdB = G%IsdB ; IedB = G%IedB ; JsdB = G%JsdB ; JedB = G%JedB
if (.not.(present(is) .or. present(ie) .or. present(js) .or. present(je))) then
! This only works with symmetric memory, so otherwise return.
if ((isd == IsdB) .and. (jsd == JsdB)) return
endif
do i=isd,ied ; do j=jsd,jed
u_nonsym(i,j) = u_comp(i,j) ; v_nonsym(i,j) = v_comp(i,j)
enddo ; enddo
if (.not.associated(G%Domain_aux)) call MOM_error(FATAL," check_redundant"//&
" called with a non-associated auxiliary domain the grid type.")
call pass_vector(u_nonsym, v_nonsym, G%Domain_aux, direction)
do I=IsdB,IedB ; do j=jsd,jed ; u_resym(I,j) = u_comp(I,j) ; enddo ; enddo
do i=isd,ied ; do J=JsdB,JedB ; v_resym(i,J) = v_comp(i,J) ; enddo ; enddo
do i=isd,ied ; do j=jsd,jed
u_resym(i,j) = u_nonsym(i,j) ; v_resym(i,j) = v_nonsym(i,j)
enddo ; enddo
call pass_vector(u_resym, v_resym, G%Domain, direction)
is_ch = Isq ; ie_ch = Ieq ; js_ch = Jsq ; je_ch = Jeq
if (present(is)) is_ch = is ; if (present(ie)) ie_ch = ie
if (present(js)) js_ch = js ; if (present(js)) je_ch = je
do i=is_ch,ie_ch ; do j=js_ch+1,je_ch
if (u_resym(i,j) /= u_comp(i,j) .and. &
redundant_prints(3) < max_redundant_prints) then
write(mesg2,'(" redundant u-components",2(1pe12.4)," differ by ", &
& 1pe12.4," at i,j = ",2i4," on pe ",i4)') &
u_comp(i,j), u_resym(i,j),u_comp(i,j)-u_resym(i,j),i,j,pe_here()
write(0,'(A130)') trim(mesg)//trim(mesg2)
redundant_prints(3) = redundant_prints(3) + 1
endif
enddo ; enddo
do i=is_ch+1,ie_ch ; do j=js_ch,je_ch
if (v_resym(i,j) /= v_comp(i,j) .and. &
redundant_prints(3) < max_redundant_prints) then
write(mesg2,'(" redundant v-comps",2(1pe12.4)," differ by ", &
& 1pe12.4," at i,j = ",2i4," x,y = ",2(1pe12.4)" on pe ",i4)') &
v_comp(i,j), v_resym(i,j),v_comp(i,j)-v_resym(i,j),i,j, &
G%geoLonBu(i,j), G%geoLatBu(i,j), pe_here()
write(0,'(A155)') trim(mesg)//trim(mesg2)
redundant_prints(3) = redundant_prints(3) + 1
endif
enddo ; enddo
end subroutine check_redundant_vC2d
subroutine check_redundant_sB3d(mesg, array, G, is, ie, js, je)
character(len=*), intent(in) :: mesg
type(SIS_hor_grid_type), intent(inout) :: G
real, dimension(G%IsdB:,G%JsdB:,:), intent(in) :: array
integer, optional, intent(in) :: is, ie, js, je
! Arguments: array - The array being checked.
! (in) mesg - A message indicating what is being checked.
! (in) G - The ocean's grid structure.
! (in/opt) is, ie, js, je - the i- and j- range of indices to check.
character(len=24) :: mesg_k
integer :: k
do k=1,size(array,3)
if (k < 10) then ; write(mesg_k,'(" Layer",i2," ")') k
elseif (k < 100) then ; write(mesg_k,'(" Layer",i3," ")') k
elseif (k < 1000) then ; write(mesg_k,'(" Layer",i4," ")') k
else ; write(mesg_k,'(" Layer",i9," ")') k ; endif
call check_redundant_sB2d(trim(mesg)//trim(mesg_k), array(:,:,k), &
G, is, ie, js, je)
enddo
end subroutine check_redundant_sB3d
subroutine check_redundant_sB2d(mesg, array, G, is, ie, js, je)
character(len=*), intent(in) :: mesg
type(SIS_hor_grid_type), intent(inout) :: G
real, dimension(G%IsdB:,G%JsdB:), intent(in) :: array
integer, optional, intent(in) :: is, ie, js, je
! Arguments: array - The array being checked.
! (in) mesg - A message indicating what is being checked.
! (in) G - The ocean's grid structure.
! (in/opt) is, ie, js, je - the i- and j- range of indices to check.
real :: a_nonsym(G%isd:G%ied,G%jsd:G%jed)
real :: a_resym(G%IsdB:G%IedB,G%JsdB:G%JedB)
character(len=128) :: mesg2
integer :: i, j, is_ch, ie_ch, js_ch, je_ch
integer :: Isq, Ieq, Jsq, Jeq, isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB
Isq = G%IscB ; Ieq = G%IecB ; Jsq = G%JscB ; Jeq = G%JecB
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
IsdB = G%IsdB ; IedB = G%IedB ; JsdB = G%JsdB ; JedB = G%JedB
if (.not.(present(is) .or. present(ie) .or. present(js) .or. present(je))) then
! This only works with symmetric memory, so otherwise return.
if ((isd == IsdB) .and. (jsd == JsdB)) return
endif
do i=isd,ied ; do j=jsd,jed
a_nonsym(i,j) = array(i,j)
enddo ; enddo
if (.not.associated(G%Domain_aux)) call MOM_error(FATAL," check_redundant"//&
" called with a non-associated auxiliary domain the grid type.")
call pass_vector(a_nonsym, a_nonsym, G%Domain_aux, &
direction=To_All+Scalar_Pair, stagger=BGRID_NE)
do I=IsdB,IedB ; do J=JsdB,JedB ; a_resym(I,J) = array(I,J) ; enddo ; enddo
do i=isd,ied ; do j=jsd,jed
a_resym(i,j) = a_nonsym(i,j)
enddo ; enddo
call pass_vector(a_resym, a_resym, G%Domain, direction=To_All+Scalar_Pair, &
stagger=BGRID_NE)
is_ch = Isq ; ie_ch = Ieq ; js_ch = Jsq ; je_ch = Jeq
if (present(is)) is_ch = is ; if (present(ie)) ie_ch = ie
if (present(js)) js_ch = js ; if (present(js)) je_ch = je
do i=is_ch,ie_ch ; do j=js_ch,je_ch
if (a_resym(i,j) /= array(i,j) .and. &
redundant_prints(2) < max_redundant_prints) then
write(mesg2,'(" Redundant points",2(1pe12.4)," differ by ", &
& 1pe12.4," at i,j = ",2i4," on pe ",i4)') &
array(i,j), a_resym(i,j),array(i,j)-a_resym(i,j),i,j,pe_here()
write(0,'(A130)') trim(mesg)//trim(mesg2)
redundant_prints(2) = redundant_prints(2) + 1
endif
enddo ; enddo
end subroutine check_redundant_sB2d
subroutine check_redundant_vB3d(mesg, u_comp, v_comp, G, is, ie, js, je, &
direction)
character(len=*), intent(in) :: mesg
type(SIS_hor_grid_type), intent(inout) :: G
real, dimension(G%IsdB:,G%JsdB:,:), intent(in) :: u_comp
real, dimension(G%IsdB:,G%JsdB:,:), intent(in) :: v_comp
integer, optional, intent(in) :: is, ie, js, je
integer, optional, intent(in) :: direction
! Arguments: u_comp - The u-component of the vector being checked.
! (in) v_comp - The v-component of the vector being checked.
! (in) mesg - A message indicating what is being checked.
! (in) G - The ocean's grid structure.
! (in/opt) is, ie, js, je - the i- and j- range of indices to check.
! (in/opt) direction - the direction flag to be passed to pass_vector.
character(len=24) :: mesg_k
integer :: k
do k=1,size(u_comp,3)
if (k < 10) then ; write(mesg_k,'(" Layer",i2," ")') k
elseif (k < 100) then ; write(mesg_k,'(" Layer",i3," ")') k
elseif (k < 1000) then ; write(mesg_k,'(" Layer",i4," ")') k
else ; write(mesg_k,'(" Layer",i9," ")') k ; endif
call check_redundant_vB2d(trim(mesg)//trim(mesg_k), u_comp(:,:,k), &
v_comp(:,:,k), G, is, ie, js, je, direction)
enddo
end subroutine check_redundant_vB3d
subroutine check_redundant_vB2d(mesg, u_comp, v_comp, G, is, ie, js, je, &
direction)
character(len=*), intent(in) :: mesg
type(SIS_hor_grid_type), intent(inout) :: G
real, dimension(G%IsdB:,G%JsdB:), intent(in) :: u_comp
real, dimension(G%IsdB:,G%JsdB:), intent(in) :: v_comp
integer, optional, intent(in) :: is, ie, js, je
integer, optional, intent(in) :: direction
! Arguments: u_comp - The u-component of the vector being checked.
! (in) v_comp - The v-component of the vector being checked.
! (in) mesg - A message indicating what is being checked.
! (in) G - The ocean's grid structure.
! (in/opt) is, ie, js, je - the i- and j- range of indices to check.
! (in/opt) direction - the direction flag to be passed to pass_vector.
real :: u_nonsym(G%isd:G%ied,G%jsd:G%jed)
real :: v_nonsym(G%isd:G%ied,G%jsd:G%jed)
real :: u_resym(G%IsdB:G%IedB,G%JsdB:G%JedB)
real :: v_resym(G%IsdB:G%IedB,G%JsdB:G%JedB)
character(len=128) :: mesg2
integer :: i, j, is_ch, ie_ch, js_ch, je_ch
integer :: Isq, Ieq, Jsq, Jeq, isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB
Isq = G%IscB ; Ieq = G%IecB ; Jsq = G%JscB ; Jeq = G%JecB
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
IsdB = G%IsdB ; IedB = G%IedB ; JsdB = G%JsdB ; JedB = G%JedB
if (.not.(present(is) .or. present(ie) .or. present(js) .or. present(je))) then
! This only works with symmetric memory, so otherwise return.
if ((isd == IsdB) .and. (jsd == JsdB)) return
endif
do i=isd,ied ; do j=jsd,jed
u_nonsym(i,j) = u_comp(i,j) ; v_nonsym(i,j) = v_comp(i,j)
enddo ; enddo
if (.not.associated(G%Domain_aux)) call MOM_error(FATAL," check_redundant"//&
" called with a non-associated auxiliary domain the grid type.")
call pass_vector(u_nonsym, v_nonsym, G%Domain_aux, direction, stagger=BGRID_NE)
do I=IsdB,IedB ; do J=JsdB,JedB
u_resym(I,J) = u_comp(I,J) ; v_resym(I,J) = v_comp(I,J)
enddo ; enddo
do i=isd,ied ; do j=jsd,jed
u_resym(i,j) = u_nonsym(i,j) ; v_resym(i,j) = v_nonsym(i,j)
enddo ; enddo
call pass_vector(u_resym, v_resym, G%Domain, direction, stagger=BGRID_NE)
is_ch = Isq ; ie_ch = Ieq ; js_ch = Jsq ; je_ch = Jeq
if (present(is)) is_ch = is ; if (present(ie)) ie_ch = ie
if (present(js)) js_ch = js ; if (present(js)) je_ch = je
do i=is_ch,ie_ch ; do j=js_ch,je_ch
if (u_resym(i,j) /= u_comp(i,j) .and. &
redundant_prints(2) < max_redundant_prints) then
write(mesg2,'(" redundant u-components",2(1pe12.4)," differ by ", &
& 1pe12.4," at i,j = ",2i4," on pe ",i4)') &
u_comp(i,j), u_resym(i,j),u_comp(i,j)-u_resym(i,j),i,j,pe_here()
write(0,'(A130)') trim(mesg)//trim(mesg2)
redundant_prints(2) = redundant_prints(2) + 1
endif
enddo ; enddo
do i=is_ch,ie_ch ; do j=js_ch,je_ch
if (v_resym(i,j) /= v_comp(i,j) .and. &
redundant_prints(2) < max_redundant_prints) then
write(mesg2,'(" redundant v-comps",2(1pe12.4)," differ by ", &
& 1pe12.4," at i,j = ",2i4," x,y = ",2(1pe12.4)" on pe ",i4)') &
v_comp(i,j), v_resym(i,j),v_comp(i,j)-v_resym(i,j),i,j, &
G%geoLonBu(i,j), G%geoLatBu(i,j), pe_here()
write(0,'(A155)') trim(mesg)//trim(mesg2)
redundant_prints(2) = redundant_prints(2) + 1
endif
enddo ; enddo
end subroutine check_redundant_vB2d
subroutine check_redundant_sT3d(mesg, array, G, is, ie, js, je)
character(len=*), intent(in) :: mesg
type(SIS_hor_grid_type), intent(inout) :: G
real, dimension(G%IsdB:,G%JsdB:,:), intent(in) :: array
integer, optional, intent(in) :: is, ie, js, je
! Arguments: array - The array being checked.
! (in) mesg - A message indicating what is being checked.
! (in) G - The ocean's grid structure.
! (in/opt) is, ie, js, je - the i- and j- range of indices to check.
character(len=24) :: mesg_k
integer :: k
do k=1,size(array,3)
if (k < 10) then ; write(mesg_k,'(" Layer",i2," ")') k
elseif (k < 100) then ; write(mesg_k,'(" Layer",i3," ")') k
elseif (k < 1000) then ; write(mesg_k,'(" Layer",i4," ")') k
else ; write(mesg_k,'(" Layer",i9," ")') k ; endif
call check_redundant_sT2d(trim(mesg)//trim(mesg_k), array(:,:,k), &
G, is, ie, js, je)
enddo
end subroutine check_redundant_sT3d
subroutine check_redundant_sT2d(mesg, array, G, is, ie, js, je)
character(len=*), intent(in) :: mesg
type(SIS_hor_grid_type), intent(inout) :: G
real, dimension(G%IsdB:,G%JsdB:), intent(in) :: array
integer, optional, intent(in) :: is, ie, js, je
! Arguments: array - The array being checked.
! (in) mesg - A message indicating what is being checked.
! (in) G - The ocean's grid structure.
! (in/opt) is, ie, js, je - the i- and j- range of indices to check.
real :: a_nonsym(G%isd:G%ied,G%jsd:G%jed)
character(len=128) :: mesg2
integer :: i, j, is_ch, ie_ch, js_ch, je_ch
integer :: Isq, Ieq, Jsq, Jeq, isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB
Isq = G%IscB ; Ieq = G%IecB ; Jsq = G%JscB ; Jeq = G%JecB
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
IsdB = G%IsdB ; IedB = G%IedB ; JsdB = G%JsdB ; JedB = G%JedB
is_ch = G%isc ; ie_ch = G%iec ; js_ch = G%jsc ; je_ch = G%jec
if (present(is)) is_ch = is ; if (present(ie)) ie_ch = ie
if (present(js)) js_ch = js ; if (present(js)) je_ch = je
! This only works on points outside of the standard computational domain.
if ((is_ch == G%isc) .and. (ie_ch == G%iec) .and. &
(js_ch == G%jsc) .and. (je_ch == G%jec)) return
do i=isd,ied ; do j=jsd,jed
a_nonsym(i,j) = array(i,j)
enddo ; enddo
call pass_var(a_nonsym, G%Domain)
do i=is_ch,ie_ch ; do j=js_ch,je_ch
if (a_nonsym(i,j) /= array(i,j) .and. &
redundant_prints(1) < max_redundant_prints) then
write(mesg2,'(" Redundant points",2(1pe12.4)," differ by ", &
& 1pe12.4," at i,j = ",2i4," on pe ",i4)') &
array(i,j), a_nonsym(i,j),array(i,j)-a_nonsym(i,j),i,j,pe_here()
write(0,'(A130)') trim(mesg)//trim(mesg2)
redundant_prints(1) = redundant_prints(1) + 1
endif
enddo ; enddo
end subroutine check_redundant_sT2d
subroutine check_redundant_vT3d(mesg, u_comp, v_comp, G, is, ie, js, je, &
direction)
character(len=*), intent(in) :: mesg
type(SIS_hor_grid_type), intent(inout) :: G
real, dimension(G%isd:,G%jsd:,:), intent(in) :: u_comp
real, dimension(G%isd:,G%jsd:,:), intent(in) :: v_comp
integer, optional, intent(in) :: is, ie, js, je
integer, optional, intent(in) :: direction
! Arguments: u_comp - The u-component of the vector being checked.
! (in) v_comp - The v-component of the vector being checked.
! (in) mesg - A message indicating what is being checked.
! (in) G - The ocean's grid structure.
! (in/opt) is, ie, js, je - the i- and j- range of indices to check.
! (in/opt) direction - the direction flag to be passed to pass_vector.
character(len=24) :: mesg_k
integer :: k
do k=1,size(u_comp,3)
if (k < 10) then ; write(mesg_k,'(" Layer",i2," ")') k
elseif (k < 100) then ; write(mesg_k,'(" Layer",i3," ")') k
elseif (k < 1000) then ; write(mesg_k,'(" Layer",i4," ")') k
else ; write(mesg_k,'(" Layer",i9," ")') k ; endif
call check_redundant_vT2d(trim(mesg)//trim(mesg_k), u_comp(:,:,k), &
v_comp(:,:,k), G, is, ie, js, je, direction)
enddo
end subroutine check_redundant_vT3d
subroutine check_redundant_vT2d(mesg, u_comp, v_comp, G, is, ie, js, je, &
direction)
character(len=*), intent(in) :: mesg
type(SIS_hor_grid_type), intent(inout) :: G
real, dimension(G%isd:,G%jsd:), intent(in) :: u_comp
real, dimension(G%isd:,G%jsd:), intent(in) :: v_comp
integer, optional, intent(in) :: is, ie, js, je
integer, optional, intent(in) :: direction
! Arguments: u_comp - The u-component of the vector being checked.
! (in) v_comp - The v-component of the vector being checked.
! (in) mesg - A message indicating what is being checked.
! (in) G - The ocean's grid structure.
! (in/opt) is, ie, js, je - the i- and j- range of indices to check.
! (in/opt) direction - the direction flag to be passed to pass_vector.
real :: u_nonsym(G%isd:G%ied,G%jsd:G%jed)
real :: v_nonsym(G%isd:G%ied,G%jsd:G%jed)
character(len=128) :: mesg2
integer :: i, j, is_ch, ie_ch, js_ch, je_ch
integer :: Isq, Ieq, Jsq, Jeq, isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB
Isq = G%IscB ; Ieq = G%IecB ; Jsq = G%JscB ; Jeq = G%JecB
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
IsdB = G%IsdB ; IedB = G%IedB ; JsdB = G%JsdB ; JedB = G%JedB
is_ch = G%isc ; ie_ch = G%iec ; js_ch = G%jsc ; je_ch = G%jec
if (present(is)) is_ch = is ; if (present(ie)) ie_ch = ie
if (present(js)) js_ch = js ; if (present(js)) je_ch = je
! This only works on points outside of the standard computational domain.
if ((is_ch == G%isc) .and. (ie_ch == G%iec) .and. &
(js_ch == G%jsc) .and. (je_ch == G%jec)) return
do i=isd,ied ; do j=jsd,jed
u_nonsym(i,j) = u_comp(i,j) ; v_nonsym(i,j) = v_comp(i,j)
enddo ; enddo
call pass_vector(u_nonsym, v_nonsym, G%Domain, direction, stagger=AGRID)
do i=is_ch,ie_ch ; do j=js_ch+1,je_ch
if (u_nonsym(i,j) /= u_comp(i,j) .and. &
redundant_prints(1) < max_redundant_prints) then
write(mesg2,'(" redundant u-components",2(1pe12.4)," differ by ", &
& 1pe12.4," at i,j = ",2i4," on pe ",i4)') &
u_comp(i,j), u_nonsym(i,j),u_comp(i,j)-u_nonsym(i,j),i,j,pe_here()
write(0,'(A130)') trim(mesg)//trim(mesg2)
redundant_prints(1) = redundant_prints(1) + 1
endif
enddo ; enddo
do i=is_ch+1,ie_ch ; do j=js_ch,je_ch
if (v_nonsym(i,j) /= v_comp(i,j) .and. &
redundant_prints(1) < max_redundant_prints) then
write(mesg2,'(" redundant v-comps",2(1pe12.4)," differ by ", &
& 1pe12.4," at i,j = ",2i4," x,y = ",2(1pe12.4)" on pe ",i4)') &
v_comp(i,j), v_nonsym(i,j),v_comp(i,j)-v_nonsym(i,j),i,j, &
G%geoLonBu(i,j), G%geoLatBu(i,j), pe_here()
write(0,'(A155)') trim(mesg)//trim(mesg2)
redundant_prints(1) = redundant_prints(1) + 1
endif
enddo ; enddo
end subroutine check_redundant_vT2d
end module SIS_error_checking