fork download
  1. program SCSProject;
  2.  
  3.  
  4.  
  5. var
  6. A, Hmax ,Hmin, L, Cn : real;
  7. wName : String;
  8. Tc, Tp, Qp, wi, D,
  9. y , De, TC1, TC2, TC3,
  10. Tl, S : real;
  11.  
  12. fif : TextFile;
  13.  
  14. tcSelector : integer;
  15. p : Array [1..6] of real;
  16. const tpArr :array [1..33] of real = (0.0,
  17. 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0,
  18. 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0,
  19. 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0,
  20. 4.5, 5.0);
  21. const qpArr :array [1..33] of real = (0.0,
  22. 0.03, 0.1, 0.19, 0.31, 0.47, 0.66, 0.82, 0.93,0.99,
  23. 1.0, 0.99, 0.93, 0.86, 0.78, 0.68, 0.56, 0.46, 0.39,
  24. 0.33, 0.28, 0.207, 0.147, 0.107, 0.077, 0.055, 0.04,
  25. 0.029, 0.021, 0.015, 0.011, 0.005, 0.0);
  26.  
  27. procedure Create();
  28.  
  29. function clcQp():real;
  30. function clcQMax(Pi : real):real;
  31. function clcRe(Pi : real):real;
  32. function clcV(Pi : real): real;
  33. function clcCoef(Pi : real): real;
  34. procedure piPrinter();
  35. procedure tablePrinter();
  36. procedure calculation();
  37. procedure writeToFile(fileName: String);
  38.  
  39. procedure getInput();
  40. procedure PrintValues();
  41. procedure fileManager();
  42.  
  43.  
  44. procedure calculation;
  45. begin
  46. getInput();
  47. clcQp();
  48. end;
  49.  
  50. function clcCoef(Pi: real): real;
  51. begin
  52. clcCoef := (clcRe(Pi) / Pi) * 100;
  53. end;
  54.  
  55. function clcQMax(Pi: real): real;
  56. begin
  57. clcQMax := Qp * clcRe(Pi);
  58. end;
  59.  
  60. function clcQp: Real;
  61. begin
  62. // clc Wi value
  63. Wi := (Hmax - Hmin) / (10 * L);
  64. // clc Y value
  65. y := (Hmax - Hmin) / (1000 * L);
  66. // clc De value
  67. De := sqrt(4 * A / 3.1416);
  68. // clc S value
  69. S := (1000 / Cn) - 10;
  70. // clc Tc1 value
  71. TC1 := (0.666 * (L / De)) * power(((A * A) / Wi) , 0.2);
  72. // clc Tc2 value
  73. TC2 := 0.0003 * (power((L * 1000) , 0.77) * power(y , -0.385));
  74. // clc Tc3 value
  75. TC3 := 0.057 * power(L , 0.8) * power(S + 1 , 0.7) / power(y , 0.5);
  76. // clc Tc value for TC (1 , 2 , 3)
  77. writeln(format('1. TC1= %5.2f', [TC1]));
  78. writeln(format('2. TC2= %5.2f', [TC2]));
  79. writeln(format('3. TC3= %5.2f', [TC3]));
  80. write('Select TC from 1..3: ');
  81. readln(tcSelector);
  82. case tcSelector of
  83. 1 : Tc := TC1;
  84. 2 : Tc := TC2;
  85. 3 : Tc := TC3
  86. else
  87. Tc := 0;
  88. end;
  89. // clc Tl value
  90. Tl := 0.6 * Tc;
  91. // clc D value
  92. D := 0.13 * Tc;
  93. // clc Tp value
  94. Tp := (D / 2) + Tl;
  95. // clc Qp value
  96. Qp := (0.2083 * A) / Tp;
  97. clcQp := Qp;
  98. end;
  99.  
  100. function clcRe(Pi: real): real;
  101. var
  102. reV: real;
  103. begin
  104. reV := power(Pi - (0.2 * S * 25.4) , 2.0) / (Pi + (0.8 * S * 25.4));
  105. if (pi < (0.2 * S * 25.4)) then
  106. clcRe := 0
  107. else
  108. clcRe := reV;
  109. end;
  110.  
  111. function clcV(Pi: real): real;
  112. begin
  113. clcV := A * clcRe(Pi);
  114. end;
  115.  
  116. procedure Create;
  117. begin
  118. writeln('************************** S.C.S Caculator **************************');
  119. writeln('Version: 1.00 feb-2010');
  120. writeln('Programming: Ahmad daneshvar (ahmad.daneshvar@gmail.com)');
  121. writeln('*********************************************************************');
  122. writeln;
  123. end;
  124.  
  125. procedure fileManager;
  126. var
  127. sel: String;
  128. begin
  129. writeln;
  130. writeln('>> To exit just press enter key');
  131. writeln('>> To save data to file enter, file name');
  132. writeln('>> To select watershed name as file name enter "*"');
  133. readln(sel);
  134. sel := trim(sel);
  135. if sel = '' then
  136. halt;
  137. if sel = '*' then
  138. sel := wName;
  139. writeToFile(sel);
  140. writeln('File successful saved as name "' + sel + '.txt". Enter key to exit...');
  141. readln;
  142. halt;
  143. end;
  144.  
  145. procedure getInput;
  146. var
  147. ind : integer;
  148. begin
  149. write('Enter watershed name: ');
  150. readln(wName);
  151. write('Enter A value: ');
  152. readln(A);
  153. write('Enter Hmax: ');
  154. readln(Hmax);
  155. write('Enter Hmin: ');
  156. readln(Hmin);
  157. write('Enter L value: ');
  158. readln(L);
  159. write('Enter Cn value: ');
  160. readln(Cn);
  161.  
  162. writeln('Now you must enter six value for P:');
  163. for ind := 1 to 6 do
  164. begin
  165. write('P[' + inttostr(ind) + ']: ');
  166. readln(P[ind]);
  167. end;
  168.  
  169. end;
  170.  
  171. procedure piPrinter;
  172. var
  173. ind: Integer;
  174. begin
  175. writeln;
  176. writeln('==========================[ Calculation ]============================');
  177. writeln;
  178. writeln('----------+---------+---------+---------+---------+---------+--------');
  179. writeln('TR(year) | 2 | 5 | 10 | 25 | 50 | 100');
  180. writeln('----------+---------+---------+---------+---------+---------+--------');
  181. // print QMax valus;
  182. write(format('Qmax cms%2s',[' ']));
  183. for ind := 1 to 6 do
  184. write(format('| %7.2f ',[clcQMax(p[ind])]));
  185. writeln;
  186. // print V/1000 valus;
  187. write(format('V/1000 m3%1s',[' ']));
  188. for ind := 1 to 6 do
  189. write(format('| %7.2f ',[clcV(p[ind])]));
  190. writeln;
  191. // print RE valus;
  192. write(format('RE mm%5s',[' ']));
  193. for ind := 1 to 6 do
  194. write(format('| %7.2f ',[clcRe(p[ind])]));
  195. writeln;
  196. // print P valus;
  197. write(format('P mm%6s',[' ']));
  198. for ind := 1 to 6 do
  199. write(format('| %7.2f ',[p[ind]]));
  200. writeln;
  201. // print Coef valus;
  202. write(format('Coef %%%4s',[' ']));
  203. for ind := 1 to 6 do
  204. write(format('| %7.2f ',[clcCoef(p[ind])]));
  205. writeln;
  206. writeln('----------+---------+---------+---------+---------+---------+--------');
  207. writeln;
  208. end;
  209.  
  210. procedure PrintValues;
  211. begin
  212. writeln;
  213. writeln('Watershed name: ' + wName);
  214. writeln;
  215. writeln('============================[ Summery ]==============================');
  216. writeln(format('Watershed area:%15s A = %5.2f km2',[' ', A]));
  217. writeln(format('Maximum hight:%16s Hmax= %5.2f m',[' ', Hmax]));
  218. writeln(format('Minimum hight:%16s Hmin= %5.2f m',[' ', Hmin]));
  219. writeln(format('Hydraulic length:%13s L = %5.2f km',[' ', L]));
  220. writeln(format('Curve number:%17s CN = %5.2f km2',[' ', Cn]));
  221. writeln(format('Time of consenteration:%7s TC = %5.2f hrs',[' ', TC]));
  222. writeln(format('Time of peak discharge:%7s TP = %5.2f hrs',[' ', TP]));
  223. writeln(format('Peak discharge for U.H:%7s Qp = %5.2f cms',[' ', Qp]));
  224. piPrinter();
  225. tablePrinter();
  226. end;
  227.  
  228. procedure tablePrinter;
  229. var
  230. ind: Integer;
  231. Qre : real;
  232. begin
  233. writeln('=======================[ Flood hydrograph ]==========================');
  234. writeln;
  235. writeln('-------+--------+--------+--------+--------+--------+--------+-------');
  236. writeln('t(hrs) | U.H | 2 | 5 | 10 | 25 | 50 | 100');
  237. writeln('-------+--------+--------+--------+--------+--------+--------+-------');
  238. for ind := 1 to 33 do
  239. begin
  240. Qre := Qp * qpArr[ind];
  241. writeln(format('%6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f',
  242. [Tp * tpArr[ind], Qre, clcRe(p[1]) * Qre, clcRe(p[2]) * Qre,
  243. clcRe(p[3]) * Qre, clcRe(p[4]) * Qre, clcRe(p[5]) * Qre, clcRe(p[6]) * Qre]));
  244. end;
  245. writeln('-------+--------+--------+--------+--------+--------+--------+-------');
  246. end;
  247.  
  248. procedure writeToFile(fileName: String);
  249. var
  250. ind : Integer;
  251. Qre : real;
  252. begin
  253. assign(fif , fileName + '.txt');
  254. reWrite(fif);
  255. // C: Part 1 ********************************************
  256. writeln(fif, 'Calculation hydrograph by S.C.S method');
  257. writeln(fif);
  258. writeln(fif, 'Watershed name: ' + wName);
  259. writeln(fif, '============================[ Summery ]==============================');
  260. writeln(fif, format('Watershed area:%15s A = %5.2f km2',[' ', A]));
  261. writeln(fif, format('Maximum hight:%16s Hmax= %5.2f m',[' ', Hmax]));
  262. writeln(fif, format('Minimum hight:%16s Hmin= %5.2f m',[' ', Hmin]));
  263. writeln(fif, format('Hydraulic length:%13s L = %5.2f km',[' ', L]));
  264. writeln(fif, format('Curve number:%17s CN = %5.2f km2',[' ', Cn]));
  265. writeln(fif, format('Time of consenteration:%7s TC = %5.2f hrs',[' ', TC]));
  266. writeln(fif, format('Time of peak discharge:%7s TP = %5.2f hrs',[' ', TP]));
  267. writeln(fif, format('Peak discharge for U.H:%7s Qp = %5.2f cms',[' ', Qp]));
  268.  
  269. // C: Part 2 *********************************************
  270. writeln(fif);
  271. writeln(fif, '==========================[ Calculation ]============================');
  272. writeln(fif);
  273. writeln(fif, '----------+---------+---------+---------+---------+---------+--------');
  274. writeln(fif, 'TR(year) | 2 | 5 | 10 | 25 | 50 | 100');
  275. writeln(fif, '----------+---------+---------+---------+---------+---------+--------');
  276. // print QMax valus;
  277. write(fif, format('Qmax cms%2s',[' ']));
  278. for ind := 1 to 6 do
  279. write(fif, format('| %7.2f ',[clcQMax(p[ind])]));
  280. writeln(fif);
  281. // print V/1000 valus;
  282. write(fif, format('V/1000 m3%1s',[' ']));
  283. for ind := 1 to 6 do
  284. write(fif, format('| %7.2f ',[clcV(p[ind])]));
  285. writeln(fif);
  286. // print RE valus;
  287. write(fif, format('RE mm%5s',[' ']));
  288. for ind := 1 to 6 do
  289. write(fif, format('| %7.2f ',[clcRe(p[ind])]));
  290. writeln(fif);
  291. // print P valus;
  292. write(fif, format('P mm%6s',[' ']));
  293. for ind := 1 to 6 do
  294. write(fif, format('| %7.2f ',[p[ind]]));
  295. writeln(fif);
  296. // print Coef valus;
  297. write(fif, format('Coef %%%4s',[' ']));
  298. for ind := 1 to 6 do
  299. write(fif, format('| %7.2f ',[clcCoef(p[ind])]));
  300. writeln(fif);
  301. writeln(fif, '----------+---------+---------+---------+---------+---------+--------');
  302. writeln(fif);
  303.  
  304. // C: part 3 **************************************************************
  305. writeln(fif, '=======================[ Flood hydrograph ]==========================');
  306. writeln(fif);
  307. writeln(fif, '-------+--------+--------+--------+--------+--------+--------+-------');
  308. writeln(fif, 't(hrs) | U.H | 2 | 5 | 10 | 25 | 50 | 100');
  309. writeln(fif, '-------+--------+--------+--------+--------+--------+--------+-------');
  310. for ind := 1 to 33 do
  311. begin
  312. Qre := Qp * qpArr[ind];
  313. writeln(fif, format('%6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f | %6.2f',
  314. [Tp * tpArr[ind], Qre, clcRe(p[1]) * Qre, clcRe(p[2]) * Qre,
  315. clcRe(p[3]) * Qre, clcRe(p[4]) * Qre, clcRe(p[5]) * Qre, clcRe(p[6]) * Qre]));
  316. end;
  317. writeln(fif, '-------+--------+--------+--------+--------+--------+--------+-------');
  318. close(fif);
  319. end;
  320.  
  321. BEGIN
  322. Create;
  323. calculation();
  324. PrintValues();
  325. fileManager()
  326. END.
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.pas:7: warning: missing string capacity -- assuming 255
prog.pas:12: error: unknown identifier `TextFile'
prog.pas: In procedure `calculation':
prog.pas:47: error: function call used as a statement
prog.pas: In procedure `fileManager':
prog.pas:60: error: identifier `clcQp' redeclared in a scope where an outer value was used
prog.pas: In function `clcQp':
prog.pas:71: error: undeclared identifier `power' (first use in this routine)
prog.pas:71: error:  (Each undeclared identifier is reported only once
prog.pas:71: error:  for each routine it appears in.)
prog.pas:77: error: undeclared identifier `format' (first use in this routine)
prog.pas:77: error: set constructor elements must be of ordinal type
prog.pas:78: error: set constructor elements must be of ordinal type
prog.pas:79: error: set constructor elements must be of ordinal type
prog.pas: In procedure `fileManager':
prog.pas:100: error: identifier `clcRe' redeclared in a scope where an outer value was used
prog.pas: In function `clcRe':
prog.pas:104: error: undeclared identifier `power' (first use in this routine)
prog.pas: In procedure `fileManager':
prog.pas:127: warning: missing string capacity -- assuming 255
prog.pas: In procedure `fileManager':
prog.pas:145: error: identifier `getInput' redeclared in a scope where an outer value was used
prog.pas: In procedure `getInput':
prog.pas:165: error: undeclared identifier `inttostr' (first use in this routine)
prog.pas: In procedure `piPrinter':
prog.pas:182: error: undeclared identifier `format' (first use in this routine)
prog.pas:184: error: set constructor elements must be of ordinal type
prog.pas:189: error: set constructor elements must be of ordinal type
prog.pas:194: error: set constructor elements must be of ordinal type
prog.pas:199: error: set constructor elements must be of ordinal type
prog.pas:204: error: set constructor elements must be of ordinal type
prog.pas: In procedure `PrintValues':
prog.pas:216: error: undeclared identifier `format' (first use in this routine)
prog.pas:216: error: set constructor elements must be of ordinal type
prog.pas:217: error: set constructor elements must be of ordinal type
prog.pas:218: error: set constructor elements must be of ordinal type
prog.pas:219: error: set constructor elements must be of ordinal type
prog.pas:220: error: set constructor elements must be of ordinal type
prog.pas:221: error: set constructor elements must be of ordinal type
prog.pas:222: error: set constructor elements must be of ordinal type
prog.pas:223: error: set constructor elements must be of ordinal type
prog.pas: In procedure `fileManager':
prog.pas:228: error: identifier `tablePrinter' redeclared in a scope where an outer value was used
prog.pas: In procedure `tablePrinter':
prog.pas:241: error: undeclared identifier `format' (first use in this routine)
prog.pas:243: error: set constructor elements must be of ordinal type
prog.pas: In procedure `fileManager':
prog.pas:248: error: identifier `writeToFile' redeclared in a scope where an outer value was used
prog.pas: In procedure `writeToFile':
prog.pas:253: error: undeclared identifier `fif' (first use in this routine)
prog.pas:260: error: undeclared identifier `format' (first use in this routine)
prog.pas:260: error: set constructor elements must be of ordinal type
prog.pas:261: error: set constructor elements must be of ordinal type
prog.pas:262: error: set constructor elements must be of ordinal type
prog.pas:263: error: set constructor elements must be of ordinal type
prog.pas:264: error: set constructor elements must be of ordinal type
prog.pas:265: error: set constructor elements must be of ordinal type
prog.pas:266: error: set constructor elements must be of ordinal type
prog.pas:267: error: set constructor elements must be of ordinal type
prog.pas:279: error: set constructor elements must be of ordinal type
prog.pas:284: error: set constructor elements must be of ordinal type
prog.pas:289: error: set constructor elements must be of ordinal type
prog.pas:294: error: set constructor elements must be of ordinal type
prog.pas:299: error: set constructor elements must be of ordinal type
prog.pas:315: error: set constructor elements must be of ordinal type
prog.pas: In procedure `fileManager':
prog.pas:326: error: syntax error before `.'
stdout
Standard output is empty