pro get_dz_twaters, fname, hgt_bins, log_total_water_bins, dz_twater_total ; check to see if the file exists OPENR, 1, fname, ERROR = err if err eq 0 then begin close, 1 ; file exists, read the data cdfid=ncdf_open(fname,/nowrite) print, 'reading ',fname dz_twater_total_id=ncdf_varid(cdfid, 'dz_twater_total') ncdf_varget, cdfid, dz_twater_total_id, dz_twater_total_id NCDF_CLOSE, cdfid endif else begin ;OPENR, 1, fname, ERROR = err ; file does not exist, create it write_dz_twaters, fname, hgt_bins, log_total_water_bins, dz_twater_total endelse ;OPENR, 1, fname, ERROR = err return end