source: trunk/SRC/Interpolation/lbcorca.pro @ 295

Last change on this file since 295 was 262, checked in by pinsard, 17 years ago

corrections of some headers and parameters and keywords case. change of pro2href to replace proidl

  • Property svn:keywords set to Id
File size: 7.0 KB
Line 
1;+
2;
3; @file_comments
4; check the lateral boundaries condition (east-west and north) of a 2D/3D/4D array
5; located on a grif of the orca grid familly.
6;
7; @categories
8; ORCA grid
9;
10; @param arr {in}{required}{type=2D/3D/4D array}
11; array to be checked (and corrected if CORRECTION keyword is activated)
12;
13; @param grid {in}{required}{type=scalar string}
14; type of grid-point on which is located the array: 'T', 'U', 'V' or 'F'
15;
16; @param psign {in}{optional}{type=1. or -1.}{default=1.}
17;
18; @keyword VERBOSE {optional}{type=0 or 1}{default=0}
19; Activate to get error information when getting a wrong lateral boundaries condition
20;
21; @keyword CORRECTION {optional}{type=0 or 1}{default=0}
22; Activate to correct the wrong lateral boundary condition in arr (in that case arr is changed)
23;
24; @returns
25; the number of wrong lateral boundary condition found in arr (-> 0 means arr is OK)
26;
27; @restrictions
28; only ORCA2, ORCA05 and ORCA025 are coded (but others are very easy to add...)
29;
30; @examples
31;    IDL> \@tst_initorca2
32;    IDL> a = dist(jpiglo, jpjglo)
33;    IDL> print, lbcorca(a, 'T')
34;    IDL> dummy = lbcorca(a, 'T', /correction)
35;    IDL> print, lbcorca(a, 'T')
36
37; @history
38;    Mai 2007: Creation, smasson\@locean-ipsl.upmc.fr
39;
40; @version
41; $Id$
42;
43;-
44FUNCTION lbcorca, arr, grid, psign, VERBOSE = verbose, CORRECTION = correction
45;
46  compile_opt idl2, strictarrsubs
47;
48  IF n_elements(psign) EQ 0  THEN psign = 1.
49  sz = size(arr)
50  jpi = sz[1]
51  jpj = sz[2]
52
53  res = 0
54
55; est-west periodicity checks
56
57  IF array_equal(arr[0, *, *, *], arr[jpi-2, *, *, *]) NE 1 THEN BEGIN
58    IF keyword_set(verbose) THEN print, 'east-west periodicity (1) error'
59    IF keyword_set(correction) THEN arr[0, *, *, *] = arr[jpi-2, *, *, *]
60    res = res + 1
61  ENDIF
62  IF array_equal(arr[1, *, *, *], arr[jpi-1, *, *, *]) NE 1 THEN BEGIN
63    IF keyword_set(verbose) THEN print, 'east-west periodicity (2) error'
64    IF keyword_set(correction) THEN arr[jpi-1, *, *, *] = arr[1, *, *, *]
65    res = res + 1
66  ENDIF
67
68; north pole periodicity
69 
70  CASE 1 OF
71    (jpi EQ 182 AND jpj EQ 149) OR (jpi EQ 1442 AND jpj EQ 1021):BEGIN ; this is ORCA2...
72      CASE grid OF
73        'T':BEGIN
74          IF array_equal(arr[1:jpi-1, jpj-1, *, *], psign * reverse(arr[1:jpi-1, jpj-3, *, *])) NE 1 THEN BEGIN
75            IF keyword_set(verbose) THEN print, grid + 'grid: north pole periodicity (1) error'
76            IF keyword_set(correction) THEN arr[1:jpi-1, jpj-1, *, *] = psign * reverse(arr[1:jpi-1, jpj-3, *, *])
77            res = res + 1
78          ENDIF
79          IF array_equal(arr[1:jpi/2, jpj-2, *, *], psign * reverse(arr[jpi/2:jpi-1, jpj-2, *, *])) NE 1 THEN BEGIN
80            IF keyword_set(verbose) THEN print, grid + 'grid: north pole periodicity (2) error'
81            IF keyword_set(correction) THEN arr[1:jpi/2, jpj-2, *, *] = psign * reverse(arr[jpi/2:jpi-1, jpj-2, *, *])
82            res = res + 1
83          ENDIF
84        END
85        'U':BEGIN
86          IF array_equal(arr[1:jpi-1, jpj-1, *, *], psign * reverse(arr[0:jpi-2, jpj-3, *, *])) NE 1 THEN BEGIN
87            IF keyword_set(verbose) THEN print, grid + 'grid: north pole periodicity (1) error'
88            IF keyword_set(correction) THEN arr[1:jpi-1, jpj-1, *, *] = psign * reverse(arr[0:jpi-2, jpj-3, *, *])
89            res = res + 1
90          ENDIF
91          IF array_equal(arr[1:jpi/2, jpj-2, *, *], psign * reverse(arr[jpi/2-1:jpi-2, jpj-2, *, *])) NE 1 THEN BEGIN
92            IF keyword_set(verbose) THEN print, grid + 'grid: north pole periodicity (2) error'
93            IF keyword_set(correction) THEN arr[1:jpi/2, jpj-2, *, *] = psign * reverse(arr[jpi/2-1:jpi-2, jpj-2, *, *])
94            res = res + 1
95          ENDIF
96        END
97        'V':BEGIN
98          IF array_equal(arr[1:jpi-1, jpj-1, *, *], psign * reverse(arr[1:jpi-1, jpj-4, *, *])) NE 1 THEN BEGIN
99            IF keyword_set(verbose) THEN print, grid + 'grid: north pole periodicity (1) error'
100            IF keyword_set(correction) THEN arr[1:jpi-1, jpj-1, *, *] = psign * reverse(arr[1:jpi-1, jpj-4, *, *])
101            res = res + 1
102          ENDIF
103          IF array_equal(arr[1:jpi/2, jpj-2, *, *], psign * reverse(arr[jpi/2:jpi-1, jpj-3, *, *])) NE 1 THEN BEGIN
104            IF keyword_set(verbose) THEN print, grid + 'grid: north pole periodicity (2) error'
105            IF keyword_set(correction) THEN arr[1:jpi/2, jpj-2, *, *] = psign * reverse(arr[jpi/2:jpi-1, jpj-3, *, *])
106            res = res + 1
107          ENDIF
108        END
109        'F':BEGIN
110          IF array_equal(arr[1:jpi-1, jpj-1, *, *], psign * reverse(arr[0:jpi-2, jpj-4, *, *])) NE 1 THEN BEGIN
111            IF keyword_set(verbose) THEN print, grid + 'grid: north pole periodicity (1) error'
112            IF keyword_set(correction) THEN arr[1:jpi-1, jpj-1, *, *] = psign * reverse(arr[0:jpi-2, jpj-4, *, *])
113            res = res + 1
114          ENDIF
115          IF array_equal(arr[1:jpi/2, jpj-2, *, *], psign * reverse(arr[jpi/2-1:jpi-2, jpj-3, *, *])) NE 1 THEN BEGIN
116            IF keyword_set(verbose) THEN print, grid + 'grid: north pole periodicity (2) error'
117            IF keyword_set(correction) THEN arr[1:jpi/2, jpj-2, *, *] = psign * reverse(arr[jpi/2-1:jpi-2, jpj-3, *, *])
118            res = res + 1
119          ENDIF
120        END
121      ENDCASE
122    END
123
124    jpi EQ 722 AND jpj EQ 511:BEGIN ; this is ORCA05...
125      CASE grid OF
126        'T':BEGIN
127          IF array_equal(arr[1:jpi-2, jpj-1, *, *], psign * reverse(arr[1:jpi-2, jpj-2, *, *])) NE 1 THEN BEGIN
128            IF keyword_set(verbose) THEN print, grid + 'grid: north pole periodicity error'
129            IF keyword_set(correction) THEN arr[1:jpi-2, jpj-1, *, *] = psign * reverse(arr[1:jpi-2, jpj-2, *, *])
130            res = res + 1
131          ENDIF
132        END
133        'U':BEGIN
134          IF array_equal(arr[1:jpi-2, jpj-1, *, *], psign * reverse(arr[0:jpi-3, jpj-2, *, *])) NE 1 THEN BEGIN
135            IF keyword_set(verbose) THEN print, grid + 'grid: north pole periodicity error'
136            IF keyword_set(correction) THEN arr[1:jpi-2, jpj-1, *, *] = psign * reverse(arr[0:jpi-3, jpj-2, *, *])
137            res = res + 1
138          ENDIF
139        END
140        'V':BEGIN
141          IF array_equal(arr[1:jpi-2, jpj-1, *, *], psign * reverse(arr[1:jpi-2, jpj-3, *, *])) NE 1 THEN BEGIN
142            IF keyword_set(verbose) THEN print, grid + 'grid: north pole periodicity error'
143            IF keyword_set(correction) THEN arr[1:jpi-2, jpj-1, *, *] = psign * reverse(arr[1:jpi-2, jpj-3, *, *])
144            res = res + 1
145          ENDIF
146        END
147        'F':BEGIN
148          IF array_equal(arr[1:jpi-2, jpj-1, *, *], psign * reverse(arr[0:jpi-3, jpj-3, *, *])) NE 1 THEN BEGIN
149            IF keyword_set(verbose) THEN print, grid + 'grid: north pole periodicity error'
150            IF keyword_set(correction) THEN arr[1:jpi-2, jpj-1, *, *] = psign * reverse(arr[0:jpi-3, jpj-3, *, *])
151            res = res + 1
152          ENDIF
153        END
154      ENDCASE
155    END
156  ENDCASE
157
158; est-west periodicity correction (again)
159
160  IF keyword_set(correction) THEN BEGIN
161    arr[0    , *, *, *] = arr[jpi-2, *, *, *]
162    arr[jpi-1, *, *, *] = arr[1    , *, *, *]
163  ENDIF
164
165
166  RETURN,  res
167END
Note: See TracBrowser for help on using the repository browser.