source: trunk/netcdf_input.pro

Last change on this file was 48, checked in by pinsard, 10 years ago

fix thanks to coding rules

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