source: Roms_tools/mexcdf/snctools/nc_addhist.m @ 1

Last change on this file since 1 was 1, checked in by cholod, 13 years ago

import Roms_Agrif

File size: 1.3 KB
Line 
1function nc_addhist ( ncfile, attval )
2% NC_ADDHIST:  adds text to a global history attribute
3%
4% NC_ADDHIST(NCFILE,TEXT) adds the TEXT string to the standard convention
5% "history" global attribute of the netCDF file NCFILE.  The string is
6% prepended, rather than appended.
7
8%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9%
10% $Id: nc_addhist.m 2659 2009-04-01 17:38:36Z johnevans007 $
11% $LastChangedDate: 2009-04-01 13:38:36 -0400 (Wed, 01 Apr 2009) $
12% $LastChangedRevision: 2659 $
13% $LastChangedBy: johnevans007 $
14%
15%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16
17error(nargchk(2,2,nargin,'struct'));
18
19if ~exist(ncfile,'file')
20        error ( 'SNCTOOLS:NC_ADDHIST:badFilename', '%s does not exist', ncfile );
21end
22if ~ischar(attval)
23        error ( 'SNCTOOLS:NC_ADDHIST:badDatatype', ...
24                'history attribute addition must be character.' );
25end
26
27
28try
29        old_hist = nc_attget ( ncfile, nc_global, 'history' );
30catch %#ok<CTCH>
31        %
32        % The history attribute must not have existed.  That's ok.
33        old_hist = '';
34end
35
36
37if isempty(old_hist)
38        new_history = sprintf ( '%s:  %s', datestr(now), attval );
39else
40        new_history = sprintf ( '%s:  %s\n%s', datestr(now), attval, old_hist );
41end
42nc_attput ( ncfile, nc_global, 'history', new_history );
43
44
45
Note: See TracBrowser for help on using the repository browser.