1 | ;------------------------------------------------------------ |
---|
2 | ;------------------------------------------------------------ |
---|
3 | ;------------------------------------------------------------ |
---|
4 | ;+ |
---|
5 | ; NAME: netcdf_input.pro |
---|
6 | ; |
---|
7 | ; PURPOSE: Reads coordinates, data and mask |
---|
8 | ; |
---|
9 | ; CATEGORY: Subroutine |
---|
10 | ; |
---|
11 | ; CALLING SEQUENCE: netcdf_input, mask |
---|
12 | ; |
---|
13 | ; INPUTS: |
---|
14 | ; |
---|
15 | ; maskfile : name of mask file |
---|
16 | ; gridfile : name of grid file |
---|
17 | ; mask_name : mask name |
---|
18 | ; SCALAR FIELD : |
---|
19 | ; datafile : name of input data file |
---|
20 | ; lon_name : name of output longitude variable |
---|
21 | ; lat_name : name of output latitude variable |
---|
22 | ; VECTOR FIELD : |
---|
23 | ; data_u_file : name of input data x-component file |
---|
24 | ; data_v_file : name of input data y-component file |
---|
25 | ; lon_u_name : name of output longitude variable at u-point |
---|
26 | ; lat_u_name : name of output latitude variable at u-point |
---|
27 | ; lon_v_name : name of output longitude variable at v-point |
---|
28 | ; lat_v_name : name of output latitude variable at v-point |
---|
29 | ; lon_f_name : name of output longitude variable at f-point |
---|
30 | ; lat_f_name : name of output latitude variable at f-point |
---|
31 | ; |
---|
32 | ; KEYWORD PARAMETERS: None |
---|
33 | ; |
---|
34 | ; OUTPUTS: |
---|
35 | ; mask : mask of the origin grid |
---|
36 | ; nummsk : ID of input mask file |
---|
37 | ; nummsh : ID of output coordinates and mask file |
---|
38 | ; SCALAR FIELD : |
---|
39 | ; lon_t : longitudes of target grid at t-point |
---|
40 | ; lat_t : latitudes of target grid at t-point |
---|
41 | ; numdta : ID of input data file |
---|
42 | ; VECTOR FIELD : |
---|
43 | ; lon_u : longitudes of target grid at u-point |
---|
44 | ; lat_u : latitudes of target grid at u-point |
---|
45 | ; lon_v : longitudes of target grid at v-point |
---|
46 | ; lat_v : latitudes of target grid at v-point |
---|
47 | ; lon_f : longitudes of target grid at f-point |
---|
48 | ; lat_f : latitudes of target grid at f-point |
---|
49 | ; numdta_u : ID of input data x-component file |
---|
50 | ; numdta_v : ID of input data y-component file |
---|
51 | ; |
---|
52 | ; COMMON BLOCKS: |
---|
53 | ; common_interp.pro |
---|
54 | ; |
---|
55 | ; SIDE EFFECTS: |
---|
56 | ; |
---|
57 | ; RESTRICTIONS: |
---|
58 | ; |
---|
59 | ; EXAMPLE: |
---|
60 | ; |
---|
61 | ; MODIFICATION HISTORY: 11/99 A. Jouzeau |
---|
62 | ; 08/00 A. Jouzeau |
---|
63 | ; 03/2003 R.Hordoir Added reading of meridian |
---|
64 | ; axis in input file |
---|
65 | ; |
---|
66 | ;- |
---|
67 | ;------------------------------------------------------------ |
---|
68 | ;------------------------------------------------------------ |
---|
69 | ;------------------------------------------------------------ |
---|
70 | PRO netcdf_input, mask |
---|
71 | @common_interp |
---|
72 | ; |
---|
73 | ; 0. Opening files |
---|
74 | ; ================ |
---|
75 | ; |
---|
76 | printf, 40, '' |
---|
77 | IF keyword_set(key_mask) THEN nummsk = ncdf_open(input_dir+ '/'+ maskfile) |
---|
78 | IF keyword_set(key_mask) THEN printf, 40, maskfile, ' opening OK' |
---|
79 | IF keyword_set(nscal) THEN BEGIN |
---|
80 | numdta_u = ncdf_open(string(input_dir, '/', data_u_file)) |
---|
81 | printf, 40, data_u_file, ' opening OK' |
---|
82 | numdta_v = ncdf_open(string(input_dir, '/', data_v_file)) |
---|
83 | IF data_u_file NE data_v_file THEN printf, 40, data_v_file, ' opening OK' |
---|
84 | ENDIF ELSE BEGIN |
---|
85 | numdta = ncdf_open(input_dir+ '/'+ datafile) |
---|
86 | printf, 40, datafile, ' opening OK' |
---|
87 | ENDELSE |
---|
88 | nummsh = ncdf_open(input_dir+ '/'+ gridfile) |
---|
89 | printf, 40, gridfile, ' opening OK' |
---|
90 | ; |
---|
91 | ; 1. Reading coordinates of output grid |
---|
92 | ; ===================================== |
---|
93 | ; |
---|
94 | IF keyword_set(nscal) THEN BEGIN |
---|
95 | ncdf_varget, nummsh, lon_u_name, lon_u |
---|
96 | ncdf_varget, nummsh, lat_u_name, lat_u |
---|
97 | ncdf_varget, nummsh, lon_f_name, lon_f |
---|
98 | ncdf_varget, nummsh, lat_f_name, lat_f |
---|
99 | ncdf_varget, nummsh, lon_v_name, lon_v |
---|
100 | ncdf_varget, nummsh, lat_v_name, lat_v |
---|
101 | IF keyword_set(modlam) THEN BEGIN |
---|
102 | ii=where(lon_f gt 360) |
---|
103 | lon_f(ii)=lon_f(ii)-360 |
---|
104 | ii=where(lon_u gt 360) |
---|
105 | lon_u(ii)=lon_u(ii)-360 |
---|
106 | ii=where(lon_v gt 360) |
---|
107 | lon_v(ii)=lon_v(ii)-360 |
---|
108 | ENDIF |
---|
109 | ENDIF ELSE BEGIN |
---|
110 | ncdf_varget, nummsh, lon_name, lon_t |
---|
111 | ncdf_varget, nummsh, lat_name, lat_t |
---|
112 | IF keyword_set(modlam) THEN BEGIN |
---|
113 | ii=where(lon_t gt 360) |
---|
114 | lon_t(ii)=lon_t(ii)-360 |
---|
115 | ENDIF |
---|
116 | ENDELSE |
---|
117 | printf, 40, '' |
---|
118 | printf, 40, 'Coordinates of output grid reading OK' |
---|
119 | ; |
---|
120 | ; 2. Reading the Input Axis and data mask |
---|
121 | ; ======================================= |
---|
122 | ; |
---|
123 | ; Input Axis Vertical Axis (Horizontal Axis is supposed to be fully regular) |
---|
124 | phi_input=replicate(0,jpiatm,jpjatm) |
---|
125 | |
---|
126 | IF keyword_set(nscal) THEN BEGIN |
---|
127 | |
---|
128 | ncdf_varget, numdta_u,y_axis_u,phi_input_u, count = [jpiatm, jpjatm] |
---|
129 | ncdf_varget, numdta_v,y_axis_v,phi_input_v, count = [jpiatm, jpjatm] |
---|
130 | |
---|
131 | phi_input_u=phi_input_u(0,*) |
---|
132 | phi_input_v=phi_input_v(0,*) |
---|
133 | |
---|
134 | ENDIF ELSE BEGIN |
---|
135 | |
---|
136 | |
---|
137 | ncdf_varget, numdta ,y_axis ,phi_input , count = [ jpjatm] |
---|
138 | ; modif FRED |
---|
139 | phi_input=reverse(phi_input) |
---|
140 | ; fin modif FRED |
---|
141 | ;stop |
---|
142 | ; phi_input=phi_input(0,*) |
---|
143 | |
---|
144 | ENDELSE |
---|
145 | |
---|
146 | ; Data Mask |
---|
147 | |
---|
148 | IF keyword_set(key_mask) THEN BEGIN |
---|
149 | IF keyword_set(ndim) THEN $ |
---|
150 | ncdf_varget, nummsk, mask_name, mask, count = [jpiatm, jpjatm, jpkatm, 1] ELSE BEGIN |
---|
151 | |
---|
152 | IF keyword_set(key_2d) THEN $ |
---|
153 | ncdf_varget, nummsk, mask_name, mask, count = [jpiatm, jpjatm] ELSE $ |
---|
154 | ncdf_varget, nummsk, mask_name, mask, count = [jpiatm, jpjatm, 1, 1] |
---|
155 | ENDELSE |
---|
156 | |
---|
157 | printf, 40, '' |
---|
158 | printf, 40, 'Data mask reading OK' |
---|
159 | ENDIF ELSE BEGIN |
---|
160 | IF keyword_set(ndim) THEN mask = replicate(1., jpiatm, jpjatm, jpkatm) ELSE $ |
---|
161 | mask = replicate(1., jpiatm, jpjatm) |
---|
162 | ENDELSE |
---|
163 | ; |
---|
164 | ; 3. Reading depths of input and output grids (3D field) |
---|
165 | ; ====================================================== |
---|
166 | ; |
---|
167 | IF keyword_set(ndim) THEN BEGIN |
---|
168 | IF keyword_set(ndep) THEN $ |
---|
169 | ncdf_varget, numdta, datadept_name, datadept ELSE $ |
---|
170 | ncdf_varget, nummsk, datadept_name, datadept |
---|
171 | ncdf_varget, nummsh, outdept_name, outdept |
---|
172 | datadept = float(datadept) |
---|
173 | outdept = float(outdept) |
---|
174 | ENDIF |
---|
175 | ; |
---|
176 | return |
---|
177 | END |
---|