function writeCRCH(basename,crch)
% writeCRCH(basename,crch) -- write conduit recharge package file
% TO 090708 090713 090715


% Copyright 2009 Theo Olsthoorn, TU-Delft and Waternet, without any warranty
% under free software foundation GNU license version 3 or later

%0
fprintf('# MATLAB writeCRCH %s\n',datestr(now));
fid=fopen([basename,'.',crch.ext],'wt');

for iPer=1:crch.NPER
    %1
    fprintf(fid,'Conduit recharge file\n');
    fprintf(fid,'%d\n',crch.IFLAG_CRCH(iPer));

    %2
    if crch.IFLAG_CRCH(iPer)~=-1
        for i=1:crch.NNODES
            fprintf(fid,'%d     %f\n',crch.P_CRCH(iPer).CRCH(i,:));
        end
    end
end
fclose(fid);
