Home > custom > glimmer > write_glimmer_ts.m

write_glimmer_ts

PURPOSE ^

Usage: write_glimmer_ts(times,fname)

SYNOPSIS ^

function write_glimmer_ts(times,fname)

DESCRIPTION ^

 Usage: write_glimmer_ts(times,fname)
 function to write a glimmer timeseries file
 times can be an array with time/value pairs of 
 size (n,2)  
 or a vector of size [tstart,tend,value] containing
 model start and end time and value

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function write_glimmer_ts(times,fname)
0002 % Usage: write_glimmer_ts(times,fname)
0003 % function to write a glimmer timeseries file
0004 % times can be an array with time/value pairs of
0005 % size (n,2)
0006 % or a vector of size [tstart,tend,value] containing
0007 % model start and end time and value
0008 t='';
0009 if ~exist('fname','var')
0010     fname=['gen_pdd_ts.txt'];
0011 end
0012 if size(times,1)>1
0013     %write out every single timestep
0014     for i=1:size(times,2)
0015         t=[t,num2str(times(i,1)),'    ',num2str(times(i,2)),'\n'];
0016     end        
0017 else
0018     %write out start and endtime with same temp
0019     t=[num2str(times(1)),'\t',num2str(times(3)),'\n'];
0020     t=[t,num2str(times(2)),'\t',num2str(times(3)),'\n'];
0021 end
0022 
0023 %% open file print out
0024 fid = fopen(fname,'wt');
0025 t=sprintf(t);
0026 fprintf(fid,'%s',t);
0027 fclose(fid);

Generated on Tue 24-Feb-2009 19:14:50 by m2html © 2003