------------------------
Program Constarray(input,output);
{Uses
CRT,Dos;}
Const
A:array[1..12] of Integer =
(17,47,75,105,135,162,198,228,258,288,318,344);
degree=(180.0/pi);{change rad into deg}
rad=(pi/180.0); {change deg into rad}
Gsc=1367; {Solar Constant}
day=(24*3600);{day in second}
{pies=-33.57;}
type
mystring = string[127];
{windata = array [1..12] of Real;}
Var X:Integer;
pies:Real;
i:1..12;
Delta:Real;
Deltadeg:Real;
Sinrad:Real;
Sindeg:Real;
Comegar,Omegar,Omega,thetar,theta,Part1,Part2,Part3,H0:Real;
deltar,piesr:real;
Hbar:array[1..12] of Integer;{monthly average daily radiation of a
particular day's radiation}
Kt
:Real;
house,{weather description climatic data}
results{echo of description then results for each run}
:text;
Function Tand(deltar:Real):Real;
Begin
Tand:=Sin(deltar)/Cos(deltar);
end;
Function Tanp(piesr:Real):Real;
Begin
Tanp:=Sin(piesr)/Cos(piesr);
end;
Function ArcCos (Comegar : DOUBLE) : DOUBLE; (* inverse cosine using TP
arctan *)
Begin (* answer returned in
radians *)
If Comegar = 0.00 THEN
ArcCos := Pi / 2.00
Else
If Comegar < 0.00 THEN
ArcCos := Pi - Arctan(Sqrt(1.00 - Sqr(Comegar)) / Abs(Comegar))
Else
ArcCos := Arctan(Sqrt(1.00 - Sqr(Comegar)) / Abs(Comegar))
end;
Procedure outstring(str:mystring);
{Writes string to line of standard output and results.}
begin
writeln(str);writeln(results,str);
end;{outstring}
Procedure getwritedata;
{Get name of location file from command line, find and read house file,
find and read
weather file, if results file exists read to end else create results
file, write data to results
file}
var
temp,
location
:Real;
locate,
resultsfile,
weatherfile
:mystring;
weather: text;
begin {getwritedata}
{If no house file prompt for it.}
if ParamCount < 1 then
begin
writeln('Usage:');
writeln(' ',ParamStr(0),' ','filename');
writeln('where the data in filename describes a climatic data.');
Halt;
end;
{Check if house file exist.}
assign(house, ParamStr(1));
reset(house);
if IOResult <> 0 then
begin
writeln('House data file, ' , ParamStr(1), ', not found.');
Halt;
end;
if Eof(house) then
begin
{Read then close weather file.}
readln(house,pies);
for i:=1 to 12 do read(house,Hbar[X]);readln(house);
writeln(Hbar[X]:2);
close(house);
end;{getweather}
end;
{Procedure Calculate;
Begin
For X := 1 to 12 do
Begin
Sinrad:=(360*((284+A[X])/365))*rad;
Delta := 23.45*rad*sin(Sinrad);
Deltadeg:=Delta*degree;
{deltar:=delta*rad;
piesr:=pies*rad;
Comegar:=-Tanp(piesr)*Tand(Delta);
Omegar:=ArcCos(Comegar);
Omega:=Omegar*180.0/pi;
Part1:=(day*Gsc)/pi;
Part2:=(1+0.033*cos(360*A[X]*rad/365));
Part3:=((cos(piesr)*cos(Delta)*sin(Omegar))+(Omegar*sin(piesr)*sin(Delta)));
H0:=Part1*Part2*Part3/1e6;
Kt:=Hbar[i]/H0;
end;
end;}
Begin{calculation for Kt}
writeln('This is calculation program to calculate Kt');
for i:=1 to 12 do
begin
getwritedata;
end;
Writeln('Results for Kt at this location');
Writeln('Jan Feb Mac Apr Mei Jun Jul Aug Sept Oct Nov Dis');
{Begin
For X := 1 to 12 do
Begin
Sinrad:=(360*((284+A[X])/365))*rad;
Delta := 23.45*rad*sin(Sinrad);
Deltadeg:=Delta*degree;
deltar:=delta*rad;
piesr:=pies*rad;
Comegar:=-Tanp(piesr)*Tand(Delta);
Omegar:=ArcCos(Comegar);
Omega:=Omegar*180.0/pi;
Part1:=(day*Gsc)/pi;
Part2:=(1+0.033*cos(360*A[X]*rad/365));
Part3:=((cos(piesr)*cos(Delta)*sin(Omegar))+(Omegar*sin(piesr)*sin(Delta)));
H0:=Part1*Part2*Part3/1e6;
for i:=1 to 12 do
begin
Kt:=Hbar[i]/H0;
end;
end;
end;
{Writeln ('Month',' ',X,' = ',Deltadeg:6:2, ' ''Ho = ',H0:6:6,'
','Omega','=',Omega:6:6);}
Writeln ('Month',' ',X,'= ',Kt:6:6);
Readln;
end.
-------------------------------------------------------------------------------------------------------
Above is my code for my program.
and below is the input file for my program :
syd.dat
-33.57{pies}
22.3 21.2 18.5 15.5 12.0 10.0 11.3 13.3 17.1 19.4 22.6 22.9{Hbar[X]}
the way this program works is just at the command line type the name of
the program which is program1 syd.dat(data file)
I hope the output will be the values for each month.
I really approciate if somebody out there can help me with this problem,
because I've been doing this for 2 months and still no good. At least
give me some idea how this input and output procedure works.Please
help...
Thanx
Afrezal