@echo off

:first
if exist ..\mpi.exe goto fmpi2
	if exist mpi.exe goto fmpi1
		@echo Error : Can't find file MPI.exe
		goto end
:fmpi1
	mpi.exe "FIRST" %1 %2
	goto execute
:fmpi2
        ..\mpi.exe "FIRST" %1 %2
	goto execute

:notfirst
if exist ..\mpi.exe goto mpi1
	mpi.exe %1 %2
	goto execute
:mpi1
	..\mpi.exe %1 %2

:execute
if errorlevel 1 goto end
if exist ..\run.bat goto run1
	call run.bat
	goto notfirst
:run1
	call ..\run.bat
	goto notfirst

:end
