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

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

change *.pro file properties (del eof-style, del executable, set keywords Id

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