name  = 'run_delftflow';
runid = 'chan_M1e4_pm03';
for i=0:10;
    filename = [name,'_',runid,'_',num2str(i),'.bat'];
    rd = [runid,'_',num2str(i)];
    file = fopen(filename,'w');
    fprintf(file, '%s\n', '@ echo off');
    fprintf(file, '%s\n', '');
    fprintf(file, '%s\n', 'rem ###################################################################');
    fprintf(file, '%s\n', '');
    fprintf(file, '%s%s\n', 'set runid=',rd);
    fprintf(file, '%s\n', 'set argfile=config.ini');
    fprintf(file, '%s\n', 'set logfile=simulate.log');
    fprintf(file, '%s\n', 'set version=bin\w32\flow\bin\');
    fprintf(file, '%s\n', 'rem set version=20110201-BwN-mud_dynamics\engines_gpl\deltares_hydro\bin\Debug');
    fprintf(file, '%s\n', '');
    fprintf(file, '%s\n', 'echo ============ set srcdir');
    fprintf(file, '%s\n', 'set srcdir=D:\sources\opendelft3d\branches\research\Deltares\');
    fprintf(file, '%s\n', '');
    fprintf(file, '%s\n', 'rem ###################################################################');
    fprintf(file, '%s\n', '');
    fprintf(file, '%s\n', 'echo ============ set exedir');
    fprintf(file, '%s\n', 'set exedir=%srcdir%\%version%');
    fprintf(file, '%s\n', 'echo =================================================================== ');
    fprintf(file, '%s\n', 'echo === runid  = %runid%');
    fprintf(file, '%s\n', 'echo === exedir = %exedir%');
    fprintf(file, '%s\n', 'echo ===================================================================');
    fprintf(file, '%s\n', '');
    fprintf(file, '%s\n', 'rem pause');
    fprintf(file, '%s\n', '');
    fprintf(file, '%s\n', 'echo ============ remove output files');
    fprintf(file, '%s\n', 'call run_delft3d_init.bat %runid%');
    fprintf(file, '%s\n', '');
    fprintf(file, '%s\n', 'echo ============ put arguments in file');
    fprintf(file, '%s\n', 'echo [FileInformation]  >%argfile%');
    fprintf(file, '%s\n', 'echo    FileCreatedBy    = batch file  >>%argfile%');
    fprintf(file, '%s\n', 'echo    FileCreationDate = %date% %time% >>%argfile%');
    fprintf(file, '%s\n', 'echo    FileVersion      = 00.01  >>%argfile%');
    fprintf(file, '%s\n', 'echo [Component] >>%argfile%');
    fprintf(file, '%s\n', 'echo    Name    = flow2d3d >>%argfile%');
    fprintf(file, '%s\n', 'echo    MdfFile = %runid% >>%argfile%');
    fprintf(file, '%s\n', '');
    fprintf(file, '%s\n', 'set D3D_HOME=C:\');
    fprintf(file, '%s\n', 'set PATH=%exedir%;%PATH%');
    fprintf(file, '%s\n', '');
    fprintf(file, '%s\n', 'echo === start deltares_hydro.exe ===');
    fprintf(file, '%s\n', '%exedir%\deltares_hydro.exe %argfile% ');
    fprintf(file, '%s\n', 'rem > %logfile%');
    fprintf(file, '%s\n', '');
    fprintf(file, '%s\n', 'pause');
   fclose(file);
end
