source: trunk/Interpolation/angle.pro @ 59

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

upgrade of Interpolation according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/

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