%disp('idiss.m');

%x=[Ubar Us Tsea Tbar Qsea Qbar Rs Rl rain zi P zu zt zq];

vkon=0.4;
alphau=0.52;
c_coeff=4*vkon/alphau^.667;
g=9.82;
Cp=1004;
Cle=2500-2.274*x(4);
T=273.16+x(4);
Tv=T*(1+.61*Q);
rho=1013.25/287/Tv;
z_u=19.2;
z_q=17.5;
L=y(7);
zet_u=z_u/L;
zet_q=z_q/L;

us_ib=sqrt(Cu2*(z_u^(2/3))/psi_fu_c(zet_u));
ts_ib=sign(zet_u)*sqrt(Ct2*(z_u^(2/3))/psi_ft_c(zet_u));
%qs_ib=-sqrt(Cq2*(z_q^(2/3))/psi_ft_c(zet_q))/1000;
%ts_ib=ts_ib-0.00051*T*qs_ib/rho;
os_ib=-sqrt(Co2*(z_q^(2/3))/psi_ft_c(zet_q))/1000;
ts_ib=ts_ib-0.00051*T*os_ib/rho;
cs_ib=-sqrt(Cc2*(z_q^(2/3))/psi_ft_c(zet_q))/1000;

us0=us_ib;
ts0=ts_ib;
%qs0=qs_ib;
os0=os_ib;
cs0=cs_ib;

%disp(['                         '])
%disp(['day   ',num2str(ddd), '    hour',num2str(hhh)])
%disp(['U*(bulk)   ',num2str(y_1(8))])
%disp(['T*(bulk)   ',num2str(y_1(9))])
%disp(['Q*(bulk)   ',num2str(y_1(10))])
%disp(['L(bulk)   ',num2str(y_1(7))])

ts0=y(9);
qs0=y(10);

for iii=1:10,
   zet=vkon*z_u*g/Tv*(ts0+0.00061*T*qs0/rho)/(us0*us0);
   us0=sqrt(Cu2*(z_u^(2/3))/psi_fu_c(zet));
   %ts0=sign(zet)*sqrt(Ct2*(z^(2/3))/psi_ft_c(zet));
   %qs0=-sqrt(Cq2*(z^(2/3))/psi_ft_c(zet))/1000;
   %ts0=ts0-0.00051*T*qs_ib/rho;
end;

%disp(['                   '])
%disp(['U*(id)   ', num2str(us0)])
%disp(['T*(id)   ', num2str(ts0)])
%disp(['Q*(id)   ', num2str(qs0)])
%disp(['L(id)      ', num2str(zet/20)])
