pro write_tau_cldtopP_histos, fname, tau_bins, cldtopP_bins, tau_cldtopP_histo_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,/write) print, 'writing to ',fname tau_cldtopP_histo_total_id=ncdf_varid(cdfid, 'tau_cldtopP_histo_total') ncdf_varput, cdfid, tau_cldtopP_histo_total_id, tau_cldtopP_histo_total endif else begin ;OPENR, 1, fname, ERROR = err ; file does not exist, create it cdfid=ncdf_create(fname,/clobber) print, 'created ',fname tau_bins_did=ncdf_dimdef(cdfid,'tau_bins',n_elements(tau_bins)) cldtopP_bins_did=ncdf_dimdef(cdfid,'cldtopP_bins',n_elements(cldtopP_bins)) tau_bins_id=ncdf_vardef(cdfid,'tau_bins',$ [tau_bins_did],/float) cldtopP_bins_id=ncdf_vardef(cdfid,'cldtopP_bins',$ [cldtopP_bins_did],/float) tau_cldtopP_histo_total_id=ncdf_vardef(cdfid,'tau_cldtopP_histo_total',$ [tau_bins_did,cldtopP_bins_did],/long) ncdf_control, cdfid, /endef ncdf_varput, cdfid, tau_bins_id, tau_bins ncdf_varput, cdfid, cldtopP_bins_id, cldtopP_bins ncdf_varput, cdfid, tau_cldtopP_histo_total_id, tau_cldtopP_histo_total endelse ;OPENR, 1, fname, ERROR = err NCDF_CLOSE, cdfid return end