function h = nc_change_history( ncf, his_text, postpend ) % nc_change_history - Add text to nc file history field % h = nc_change_history( ncf, his_text, postpend ) % % Also adds date/time string to beginning of his_text % % Input: % ncf - name of target netCDF file % his_text - character string of text to be inserted % postpend (optional): 0 = prepend the text (default) % : 1 = postpend the text % % Returned: % h - new character string with history % % csherwood@usgs.gov % $Rev$ % $LastChangedDate$ % % This program intended for use in adjusting metadata terms in % netCDF files from the USGS CMGP Oceanographic time-series data % archive. % % Program written in Matlab (R2009a) % Program ran on Windows XP PC. % % "Although this program has been used by the USGS, no warranty, % expressed or implied, is made by the USGS or the United States % Government as to the accuracy and functioning of the program % and related program material nor shall the fact of distribution % constitute any such warranty, and no responsibility is assumed % by the USGS in connection therewith." if(nargin<3),postpend=0;,end nc = netcdf(ncf, 'write'); if isempty(nc) disp([' ## Unable to open: ',ncf]) return end nowstr = datestr(now); % add info to the history hist = nc.history(:); if(postpend), cmnt = sprintf(': %s %s',nowstr,his_text); nc.history = ncchar([hist cmnt]); else cmnt = sprintf('%s %s :',nowstr,his_text); nc.history = ncchar([cmnt hist]); end h = char(nc.history(:)); close(nc) return