1 function [d,hours]=make_moisture_input(times,t2,psfc,q2,rainc)
2 % usage: ncload moisture100.nc;
3 % make_moisture_input(times,t2,psfc,q2,rainc)
5 % input: arrays from reading WRF nc files
6 % times: (:,k) character string for tiime at step k
7 % t2 surface temperature (K)
8 % psfc surface pressure (Pa)
9 % q2 surface air moisture contents (kg/kg)
10 % rainc accumulated rain (mm)
11 % i1,i2 indices of a point to take the values from, defaut 1,1
14 % d list of time steps to omit
15 % hours time from beginning of sim
17 if ~exist('i2','var'),i2=1;end
18 if ~exist('i1','var'),i1=1;end
27 hours(i)=24*datenum(ctimes(i,:));
31 % make sure time increases and delete extra steps if not
33 fmt='step %i %s from start %i hours\n';
40 fprintf(fmt,i-1,ctimes(i-1,:),hours(i-1))
42 fprintf(fmt,i,ctimes(i,:),hours(i))
43 warning(['Time does not increase, deleting step ',num2str(i)])
45 elseif i<steps-1 && hours(i)-hours(i-1) ~= hours(i+1)-hours(i),
46 fprintf(fmt,i,ctimes(i,:),hours(i))
47 fprintf(fmt,i+1,ctimes(i+1,:),hours(i+1))
48 fprintf(fmt,i+2,ctimes(i+2,:),hours(i+2))
49 warning('Time step is not uniform')
61 % create the input file for moisture_test.exe
63 mm=[hours,t2,psfc,q2,rainc];
64 save('moisture_input.txt','mm','-ascii')