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

Last change on this file since 136 was 136, checked in by pinsard, 18 years ago

some improvements and corrections in some .pro file according to
aspell and idldoc log file

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