;+ ; NAME: netcdf_input.pro ; ; PURPOSE: Reads coordinates, data and mask ; ; CATEGORY: Subroutine ; ; CALLING SEQUENCE: netcdf_input, mask ; ; INPUTS: ; ; maskfile : name of mask file ; gridfile : name of grid file ; mask_name : mask name ; SCALAR FIELD : ; datafile : name of input data file ; lon_name : name of output longitude variable ; lat_name : name of output latitude variable ; VECTOR FIELD : ; data_u_file : name of input data x-component file ; data_v_file : name of input data y-component file ; lon_u_name : name of output longitude variable at u-point ; lat_u_name : name of output latitude variable at u-point ; lon_v_name : name of output longitude variable at v-point ; lat_v_name : name of output latitude variable at v-point ; lon_f_name : name of output longitude variable at f-point ; lat_f_name : name of output latitude variable at f-point ; ; KEYWORD PARAMETERS: None ; ; OUTPUTS: ; mask : mask of the origin grid ; nummsk : ID of input mask file ; nummsh : ID of output coordinates and mask file ; SCALAR FIELD : ; lon_t : longitudes of target grid at t-point ; lat_t : latitudes of target grid at t-point ; numdta : ID of input data file ; VECTOR FIELD : ; lon_u : longitudes of target grid at u-point ; lat_u : latitudes of target grid at u-point ; lon_v : longitudes of target grid at v-point ; lat_v : latitudes of target grid at v-point ; lon_f : longitudes of target grid at f-point ; lat_f : latitudes of target grid at f-point ; numdta_u : ID of input data x-component file ; numdta_v : ID of input data y-component file ; ; COMMON BLOCKS: ; common_interp.pro ; ; SIDE EFFECTS: ; ; RESTRICTIONS: ; ; EXAMPLE: ; ; MODIFICATION HISTORY: 11/99 A. Jouzeau ; 08/00 A. Jouzeau ; 03/2003 R.Hordoir Added reading of meridian ; axis in input file ; ;- ;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ PRO netcdf_input, mask @common_interp ; ; 0. Opening files ; ================ ; printf, 40, '' IF keyword_set(key_mask) THEN nummsk = ncdf_open(input_dir+ '/'+ maskfile) IF keyword_set(key_mask) THEN printf, 40, maskfile, ' opening OK' IF keyword_set(nscal) THEN BEGIN numdta_u = ncdf_open(string(input_dir, '/', data_u_file)) printf, 40, data_u_file, ' opening OK' numdta_v = ncdf_open(string(input_dir, '/', data_v_file)) IF data_u_file NE data_v_file THEN printf, 40, data_v_file, ' opening OK' ENDIF ELSE BEGIN numdta = ncdf_open(input_dir+ '/'+ datafile) printf, 40, datafile, ' opening OK' ENDELSE nummsh = ncdf_open(input_dir+ '/'+ gridfile) printf, 40, gridfile, ' opening OK' ; ; 1. Reading coordinates of output grid ; ===================================== ; IF keyword_set(nscal) THEN BEGIN ncdf_varget, nummsh, lon_u_name, lon_u ncdf_varget, nummsh, lat_u_name, lat_u ncdf_varget, nummsh, lon_f_name, lon_f ncdf_varget, nummsh, lat_f_name, lat_f ncdf_varget, nummsh, lon_v_name, lon_v ncdf_varget, nummsh, lat_v_name, lat_v IF keyword_set(modlam) THEN BEGIN ii=where(lon_f gt 360) lon_f(ii)=lon_f(ii)-360 ii=where(lon_u gt 360) lon_u(ii)=lon_u(ii)-360 ii=where(lon_v gt 360) lon_v(ii)=lon_v(ii)-360 ENDIF ENDIF ELSE BEGIN ncdf_varget, nummsh, lon_name, lon_t ncdf_varget, nummsh, lat_name, lat_t IF keyword_set(modlam) THEN BEGIN ii=where(lon_t gt 360) lon_t(ii)=lon_t(ii)-360 ENDIF ENDELSE printf, 40, '' printf, 40, 'Coordinates of output grid reading OK' ; ; 2. Reading the Input Axis and data mask ; ======================================= ; ; Input Axis Vertical Axis (Horizontal Axis is supposed to be fully regular) phi_input=replicate(0,jpiatm,jpjatm) IF keyword_set(nscal) THEN BEGIN ncdf_varget, numdta_u,y_axis_u,phi_input_u, count = [jpiatm, jpjatm] ncdf_varget, numdta_v,y_axis_v,phi_input_v, count = [jpiatm, jpjatm] phi_input_u=phi_input_u(0,*) phi_input_v=phi_input_v(0,*) ENDIF ELSE BEGIN ncdf_varget, numdta ,y_axis ,phi_input , count = [ jpjatm] ; modif FRED phi_input=reverse(phi_input) ; fin modif FRED ;stop ; phi_input=phi_input(0,*) ENDELSE ; Data Mask IF keyword_set(key_mask) THEN BEGIN IF keyword_set(ndim) THEN $ ncdf_varget, nummsk, mask_name, mask, count = [jpiatm, jpjatm, jpkatm, 1] ELSE BEGIN IF keyword_set(key_2d) THEN $ ncdf_varget, nummsk, mask_name, mask, count = [jpiatm, jpjatm] ELSE $ ncdf_varget, nummsk, mask_name, mask, count = [jpiatm, jpjatm, 1, 1] ENDELSE printf, 40, '' printf, 40, 'Data mask reading OK' ENDIF ELSE BEGIN IF keyword_set(ndim) THEN mask = replicate(1., jpiatm, jpjatm, jpkatm) ELSE $ mask = replicate(1., jpiatm, jpjatm) ENDELSE ; ; 3. Reading depths of input and output grids (3D field) ; ====================================================== ; IF keyword_set(ndim) THEN BEGIN IF keyword_set(ndep) THEN $ ncdf_varget, numdta, datadept_name, datadept ELSE $ ncdf_varget, nummsk, datadept_name, datadept ncdf_varget, nummsh, outdept_name, outdept datadept = float(datadept) outdept = float(outdept) ENDIF ; return END