source: trunk/SRC/Interpolation/angle.pro @ 200

Last change on this file since 200 was 157, checked in by navarro, 18 years ago

header improvements + xxx doc

  • Property svn:keywords set to Id
File size: 6.5 KB
Line 
1;---------
2;+
3; @file_comments
4; north stereographic polar projection
5;
6; @categories
7; Interpolation
8;
9; @param plam {in}{required}
10;
11; @param pphi {in}{required}
12;
13; @keyword DOUBLE {default=0}
14; use double precision (default is float)
15;
16; @returns
17;       gsinu,gcosu : sinus and cosinus of the angle
18;       gsinv,gcosv   between north-south direction
19;       gsint,gcost   and the j-direction of the mesh
20;
21; @restrictions
22; to compute the lateral boundary conditions, we assume that:
23;     (1) the first line is similar to the second line
24;       =>    gcosu[*, 0] = gcosu[*, 1]
25;       =>    gsinu[*, 0] = gsinu[*, 1]
26;     (2) the grid follows OPA x periodicity rule, first column is
27;     equal to the next to last column
28;       =>    gcosv[0, *] = gcosv[jpj-2, *]
29;       =>    gsinv[0, *] = gsinv[jpj-2, *]
30;
31;
32; @history
33;       Original :  96-07 (O. Marti)
34;                   98-06 (G. Madec)
35;       Feb 2005: IDL adaptation S. Masson
36;
37; @version $Id$
38;
39;-
40;
41FUNCTION fsnspp, plam, pphi, DOUBLE = double
42;
43  compile_opt idl2, strictarrsubs
44;
45  IF keyword_set(double) THEN BEGIN
46    a = 2.d * tan( !dpi/4.d - !dpi/180.d*pphi/2.d )
47    x = cos( !dpi/180.d*plam ) * a
48    y = sin( !dpi/180.d*plam ) * a
49  ENDIF ELSE BEGIN
50    a = 2. * tan( !pi/4. - !pi/180.*float(pphi)/2. )
51    x = cos( !pi/180.*float(plam) ) * a
52    y = sin( !pi/180.*float(plam) ) * a
53  ENDELSE
54  RETURN, {x:x, y:y}
55END
56;---------
57;+
58; @file_comments Compute angles between grid lines and direction of the North
59;(fom angle.F,v 2.2 in OPA8.2)
60;
61; @param fileocemesh {in}{required} a netcdf file that contains (at least):
62;        glamu, gphiu: longitudes and latitudes at U-points
63;        glamv, gphiv: longitudes and latitudes at V-points
64;        glamf, gphif: longitudes and latitudes at F-points
65;
66; @param gcosu {in}{required}
67; @param gsinu {in}{required}
68; @param gcosv {in}{required}
69; @param gsinv {in}{required}
70; @param gcost {in}{required}
71; @param gsint {in}{required}
72; @keyword IODIRECTORY the directory path where is located fileocemesh
73; @keyword DOUBLE {default=0} use double precision (default is float)
74;-
75;---------
76;
77PRO angle, fileocemesh, gcosu, gsinu, gcosv, gsinv, gcost, gsint $
78           , IODIRECTORY = iodirectory, DOUBLE = double
79;
80; 0. read oceanic grid parameters
81; ================================
82;
83;
84  compile_opt idl2, strictarrsubs
85;
86  IF keyword_set(IODIRECTORY) THEN BEGIN
87    IF  strpos(iodirectory,'/',/reverse_search) NE (strlen(iodirectory)-1) THEN $
88      iodirectory = iodirectory+'/'
89  ENDIF ELSE iodirectory = ''
90  fileoce = iodirectory+fileocemesh
91;
92  fileoce = findfile(fileoce, count = okfile)
93  IF okfile NE 1 THEN BEGIN
94    print, 'the file '+fileoce+' is not found... we stop'
95    stop
96  ENDIF
97;
98  cdfido = ncdf_open(fileoce[0])
99  ncdf_varget, cdfido, 'glamt', glamt
100  ncdf_varget, cdfido, 'glamu', glamu
101  ncdf_varget, cdfido, 'glamv', glamv
102  ncdf_varget, cdfido, 'glamf', glamf
103  ncdf_varget, cdfido, 'gphit', gphit
104  ncdf_varget, cdfido, 'gphiu', gphiu
105  ncdf_varget, cdfido, 'gphiv', gphiv
106  ncdf_varget, cdfido, 'gphif', gphif
107  ncdf_close, cdfido
108;
109  glamt = reform(glamt, /over)
110  glamu = reform(glamu, /over)
111  glamv = reform(glamv, /over)
112  glamf = reform(glamf, /over)
113  gphit = reform(gphit, /over)
114  gphiu = reform(gphiu, /over)
115  gphiv = reform(gphiv, /over)
116  gphif = reform(gphif, /over)
117  jpj = (size(glamf, /dimension))[1]
118;
119; I. Compute the cosinus and sinus
120; ================================
121; (computation done on the north stereographic polar plan
122;
123;   ... north pole direction & modulous (at t-point)
124  znpt = fsnspp( glamt, gphit, DOUBLE = double )
125  glamt = -1 & gphit = -1; free memory
126  znpt.x = - znpt.x
127  znpt.y = - znpt.y
128  znnpt = znpt.x*znpt.x + znpt.y*znpt.y
129;   ... north pole direction & modulous (at u-point)
130  znpu = fsnspp( glamu, gphiu, DOUBLE = double )
131  glamu = -1 & gphiu = -1; free memory
132  znpu.x = - znpu.x
133  znpu.y = - znpu.y
134  znnpu = znpu.x*znpu.x + znpu.y*znpu.y
135;   ... north pole direction & modulous (at v-point)
136  znpv = fsnspp( glamv, gphiv, DOUBLE = double )
137  znpv00 = znpv
138  znpv01 = fsnspp( shift(glamv, 0, 1), shift(gphiv, 0, 1), DOUBLE = double )
139  glamv = -1 & gphiv = -1; free memory
140  znpv.x = - znpv.x
141  znpv.y = - znpv.y
142  znnpv = znpv.x*znpv.x + znpv.y*znpv.y
143;   ... f-point
144  znpf00 = fsnspp( glamf, gphif, DOUBLE = double )
145  znpf01 = fsnspp( shift(glamf, 0, 1), shift(gphif, 0, 1), DOUBLE = double )
146  znpf10 = fsnspp( shift(glamf, 1, 0), shift(gphif, 1, 0), DOUBLE = double )
147  glamf = -1 & gphif = -1; free memory
148;   ... j-direction: v-point segment direction (t-point)
149  zxvvt = znpv00.x - znpv01.x
150  zyvvt = znpv00.y - znpv01.y
151  zmnpvt = sqrt ( temporary(znnpt) * ( zxvvt*zxvvt + zyvvt*zyvvt )  )
152  znpv00 = -1; free memory
153  znpv01 = -1; free memory
154  IF keyword_set(double) THEN zmnpvt = 1.e-14 > zmnpvt $
155  ELSE zmnpvt = 1.e-6 > zmnpvt
156;   ... j-direction: f-point segment direction (u-point)
157  zxffu = znpf00.x - znpf01.x
158  zyffu = znpf00.y - znpf01.y
159  zmnpfu = sqrt ( temporary(znnpu) * ( zxffu*zxffu + zyffu*zyffu )  )
160  znpf01 = -1; free memory
161  IF keyword_set(double) THEN zmnpfu = 1.e-14 > zmnpfu $
162  ELSE zmnpfu = 1.e-6 > zmnpfu
163;   ... i-direction: f-point segment direction (v-point)
164  zxffv = znpf00.x - znpf10.x
165  zyffv = znpf00.y - znpf10.y
166  znpf00 = -1 &  znpf10 = -1; free memory
167  zmnpfv = sqrt ( temporary(znnpv) * ( zxffv*zxffv + zyffv*zyffv )  )
168  IF keyword_set(double) THEN zmnpfv = 1.e-14 > zmnpfv $
169  ELSE zmnpfv = 1.e-6 > zmnpfv
170;   ... cosinus and sinus using scalar and vectorial products
171  gsint = ( znpt.x*zyvvt - znpt.y*zxvvt ) / zmnpvt
172  gcost = ( znpt.x*zxvvt + znpt.y*zyvvt ) / zmnpvt
173;   ... cosinus and sinus using scalar and vectorial products
174  gsinu = ( znpu.x*zyffu - znpu.y*zxffu ) / zmnpfu
175  gcosu = ( znpu.x*zxffu + znpu.y*zyffu ) / zmnpfu
176;   ... cosinus and sinus using scalar and vectorial products
177;       (caution, rotation of 90 degres)
178  gsinv =  ( znpv.x*zxffv + znpv.y*zyffv ) / zmnpfv
179  gcosv = -( znpv.x*zyffv - znpv.y*zxffv ) / zmnpfv
180;
181; II. Geographic mesh
182; ===================
183;
184;       bad = where(abs(glamf-shift(glamf, 0, 1)) LT 1.e-8)
185;       IF bad[0] NE -1 THEN BEGIN
186;         gcosu[bad] = 1.
187;         gsinu[bad] = 0.
188;       ENDIF
189;       bad = where(abs(gphif-shift(gphif, 1, 0)) LT 1.e-8)
190;       IF bad[0] NE -1 THEN BEGIN
191;         gcosv[bad] = 1.
192;         gsinv[bad] = 0.
193;       ENDIF
194;
195; III. Lateral boundary conditions
196; ================================
197;
198  gcost[*, 0] = gcost[*, 1]
199  gsint[*, 0] = gsint[*, 1]
200  gcosu[*, 0] = gcosu[*, 1]
201  gsinu[*, 0] = gsinu[*, 1]
202  gcosv[0, *] = gcosv[jpj-2, *]
203  gsinv[0, *] = gsinv[jpj-2, *]
204;
205  RETURN
206END
Note: See TracBrowser for help on using the repository browser.