function writeDROB(basename,drob)
% writeDROB(basename,drob)  --- writing drains observation file
% Tijs Dekker 170707

fid=fopen([basename,'.drob'],'wt');

%0.
fprintf(fid,'# MATLAB writeDROB %s\r\n',datestr(now));
fprintf(    '# MATLAB writeDROB %s\n'  ,datestr(now));

%1.
fprintf(fid,'%10g%10g%10g\r\n',drob.NQDR, drob.NQCDR, drob.NQTDR);

%2.
fprintf(fid,'%10g%10g%10g\r\n',drob.TOMULTDR,drob.EVFDR,drob.IOWTQDR);


for i=1:drob.NQDR
    %3.
    fprintf(fid,'%10g%10g\r\n',drob.NQOBDR(i),drob.NQCLDR(i));
    %4.
    fprintf(fid,'%11s%10g%10g%10g%10g%10g%10g\r\n',...
    drob.OBSNAM{i},drob.IREFSP{i},drob.TOFFSET(i),drob.HOBS(i),drob.STATISTIC(i),drob.STATFLAG(i),drob.PLOTSYMBOL(i));

    %5
    for iC=1:drob.NQCLDR(i)
        fprintf(fid,'%10g%10g%10g%10g\r\n',drob.Layer{i}(iC),drob.Row{i}(iC),drob.Column{i}(iC),drob.Factor{i}(iC));
    end

    if drob.IOWTQDR>0
        %6
        fprintf(fid,'%10g%10g\r\n',drob.FMTIN(i),drob.IPRN);
        %7
        warray(drob.WTQ)        
    end
end
fclose(fid);
