@echo off
cd Medvedev
copy Fortran\Empty\fcnp.fi Fortran\fcnp.fi >NUL
copy Fortran\Empty\fcnp.fi OUTPUT\fcnp.fi >NUL
copy Fortran\Empty\fcnp.fi Fortran\fcnp_N.fi >NUL
copy Fortran\Empty\fcnp.fi OUTPUT\fcnp_N.fi >NUL
if EXIST OUTPUT\fcn.fi del /q OUTPUT\fcn.fi >NUL
if EXIST OUTPUT\fcnp.fi del /q OUTPUT\fcnp.fi >NUL
if EXIST OUTPUT\fcnp_N.fi del /q OUTPUT\fcnp_N.fi >NUL
if EXIST OUTPUT\risolve.dll del /q OUTPUT\risolve.dll >NUL
cd jacobian
UnRAR.exe x -pJune1963 -y Jacobian.rar %TEMP%\Jacobian\ >NUL
cd ..
cd INPUT
copy Neq.mpl %TEMP%\Jacobian\Neq.mpl >NUL
copy Nparam.mpl %TEMP%\Jacobian\Nparam.mpl >NUL
copy Nmatrix.mpl %TEMP%\Jacobian\Nmatrix.mpl >NUL
copy fcn.mpl %TEMP%\Jacobian\ffcn.mpl >NUL
copy %TEMP%\Jacobian\Comment.mpl+%TEMP%\Jacobian\ffcn.mpl %TEMP%\Jacobian\fcn.mpl >NUL
copy %TEMP%\Jacobian\Analytic_1.mpl+%TEMP%\Jacobian\Neq.mpl+%TEMP%\Jacobian\Analytic_2.mpl+%TEMP%\Jacobian\Nparam.mpl+%TEMP%\Jacobian\Analytic_2_1.mpl %TEMP%\Jacobian\A1.mpl >NUL
copy %TEMP%\Jacobian\NJacobian_21.mpl+%TEMP%\Jacobian\Analytic_2_2.mpl %TEMP%\Jacobian\A2.mpl >NUL
if %1==0 copy %TEMP%\Jacobian\NMatrix_0.mpl+%TEMP%\Jacobian\Analytic_3.mpl+%TEMP%\Jacobian\fcn.mpl+%TEMP%\Jacobian\Analytic_4.mpl %TEMP%\Jacobian\A3.mpl >NUL
if %1 NEQ 0 copy %TEMP%\Jacobian\NMatrix.mpl+%TEMP%\Jacobian\Analytic_3.mpl+%TEMP%\Jacobian\fcn.mpl+%TEMP%\Jacobian\Analytic_4.mpl %TEMP%\Jacobian\A3.mpl >NUL
copy %TEMP%\Jacobian\A1.mpl+%TEMP%\Jacobian\A2.mpl+%TEMP%\Jacobian\A3.mpl %TEMP%\Jacobian\BIN\Analytic.mpl >NUL
cd ..
setlocal	
path=%TEMP%\Jacobian\BIN;%TEMP%\Jacobian\LIB;%TEMP%\Jacobian\LICENSE;%path%
call mapledos.exe %TEMP%\Jacobian\BIN\analytic.mpl
endlocal
if EXIST %TEMP%\Jacobian\LICENSE\fcn.fi move /y %TEMP%\Jacobian\LICENSE\fcn.fi OUTPUT\fcn.fi
if EXIST fcn.fi move /y fcn.fi OUTPUT\fcn.fi
if EXIST %TEMP%\Jacobian\LICENSE\fcnj.fi move /y %TEMP%\Jacobian\LICENSE\fcnj.fi OUTPUT\fcnj.fi
if EXIST fcnj.fi move /y fcnj.fi OUTPUT\fcnj.fi
if EXIST %TEMP%\Jacobian\LICENSE\fcnp.fi move /y %TEMP%\Jacobian\LICENSE\fcnp.fi OUTPUT\fcnp.fi
if EXIST fcnp.fi move /y fcnp.fi OUTPUT\fcnp.fi
if EXIST %TEMP%\Jacobian\LICENSE\fcnp_N.fi move /y %TEMP%\Jacobian\LICENSE\fcnp_N.fi OUTPUT\fcnp_N.fi
if EXIST fcnp_N.fi move /y fcnp_N.fi OUTPUT\fcnp_N.fi
rmdir /s /q %TEMP%\Jacobian 
copy OUTPUT\fcn.fi Fortran\fcn.fi >NUL
copy OUTPUT\fcnj.fi Fortran\fcnj.fi >NUL
copy OUTPUT\fcnp.fi Fortran\fcnp.fi >NUL
copy OUTPUT\fcnp_N.fi Fortran\fcnp_N.fi >NUL
if EXIST fcn.fi del /q fcn.fi >NUL
if EXIST fcnj.fi del /q fcnj.fi >NUL
if EXIST fcnp.fi del /q fcnp.fi >NUL
if EXIST fcnp_N.fi del /q fcnp_N.fi >NUL
if EXIST Fortran\fcnp.for del /q Fortran\fcnp.for >NUL
copy Fortran\number_equations.1fi+INPUT\neq.mpl Fortran\number_equations.fi >NUL
copy Fortran\param_model.1fi+INPUT\nparam.mpl Fortran\param_model.fi >NUL
if %1==0 copy Fortran\fcnp_0.for  Fortran\fcnp.for >NUL
if %1 NEQ 0 copy Fortran\fcnp_N.for  Fortran\fcnp.for >NUL
cd Fortran 
cd Test 
call ready_risolve_DLL.exe 
cd ..
if EXIST fcn.fi del /q fcn.fi >NUL
if EXIST fcnj.fi del /q fcnj.fi >NUL
if EXIST fcnp.fi del /q fcnp.fi >NUL
if EXIST fcnp_N.fi del /q fcnp_N.fi >NUL
if EXIST number_equations.fi del /q number_equations.fi >NUL
if EXIST param_model.fii del /q param_model.fi >NUL 
cd .. 
copy Fortran\Test\Solve_VBasic\Release\RiSolve.dll OUTPUT\RiSolve.dll >NUL
cd ..
Dismount.exe %~d0
copy Medvedev\Output\RiSolve.dll RiSolve.dll /Y >NUL
pause