-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswanrun.bat
86 lines (73 loc) · 1.96 KB
/
swanrun.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
@echo off
rem
rem swanrun.bat
rem
rem Run the SWAN program by means of the SWAN input file
rem Note: it is assumed that the extension of the input file is '.swn'
rem
rem Usage: swanrun inputfile [nprocs]
rem
set nprocs=1
if not "%1"=="" goto OK1
echo.
echo Usage: swanrun inputfile [nprocs]
goto END
:OK1
set inputfile=%1
shift
if exist %inputfile%.swn goto OK2
echo.
echo Error: file %inputfile%.swn does not exist
goto END
:OK2
if "%1"=="" goto OK3
set nprocs=%1
:OK3
copy %inputfile%.swn INPUT >> nul
if not %nprocs%==1 goto PARALLEL1
swan.exe
goto OK4
:PARALLEL1
mpiexec -n %nprocs% swan.exe
:OK4
if errorlevel 1 goto END
if not %nprocs%==1 goto PARALLEL2
if exist PRINT copy PRINT %inputfile%.prt >> nul
if exist PRINT del PRINT
goto OK5
:PARALLEL2
if not exist PRINT-001 goto OK5
if %nprocs% GTR 9 goto RANGE1
for /L %%i in (1,1,%nprocs%) do copy PRINT-00%%i %inputfile%.prt-00%%i >> nul
for /L %%i in (1,1,%nprocs%) do del PRINT-00%%i
goto OK5
:RANGE1
if %nprocs% GTR 99 goto RANGE2
for /L %%i in (1,1,9) do copy PRINT-00%%i %inputfile%.prt-00%%i >> nul
for /L %%i in (1,1,9) do del PRINT-00%%i
for /L %%i in (10,1,%nprocs%) do copy PRINT-0%%i %inputfile%.prt-0%%i >> nul
for /L %%i in (10,1,%nprocs%) do del PRINT-0%%i
goto OK5
:RANGE2
if %nprocs% GTR 999 goto ERR
for /L %%i in (1,1,9) do copy PRINT-00%%i %inputfile%.prt-00%%i >> nul
for /L %%i in (1,1,9) do del PRINT-00%%i
for /L %%i in (10,1,99) do copy PRINT-0%%i %inputfile%.prt-0%%i >> nul
for /L %%i in (10,1,99) do del PRINT-0%%i
for /L %%i in (100,1,%nprocs%) do copy PRINT-%%i %inputfile%.prt-%%i >> nul
for /L %%i in (100,1,%nprocs%) do del PRINT-%%i
goto OK5
:ERR
echo Error: too many processes
goto END
:OK5
if exist Errfile copy Errfile %inputfile%.erf >> nul
if exist Errfile del Errfile
if exist ERRPTS copy ERRPTS %inputfile%.erp >> nul
if exist ERRPTS del ERRPTS
del INPUT
if not exist norm_end goto END
type norm_end
:END
set inputfile=
set nprocs=