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

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

start to modify headers of Interpolation *.pro files for better idldoc output

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