#This subroutine is used to make needed preparations before portion processing
sub gcprepare
{
 #Preparation is successful, returning 1
 return 1;
}
#This subroutine processes the portion
sub gctask
{
	#$task is the name of current task
	#$taskarg is task arguments
	#$portion is current portion number
	#$din the name of current portion data file
	#$dout the name of current portion result data file
	my ($task,$taskarg,$portion,$din,$dout) = @_;
	#$n is total number of portions
	#$expo is power of 10, the number of drops inside square (0,0)-(1,1) per portion
	my ($n,$expo) = split (/ /, $taskarg);
	#Preparing to run TestPi executable
	#$cmd is command string	
	my $cmd = "TestPi $expo";
	$cmd = "./$cmd" if ($^O ne 'MSWin32');
	#$s will be number of drops that have fallen inside the circle, multiplied by 4
	my $s = readpipe($cmd);
	#Indicate about the failure if TestPi prints -1
	if ($s==-1) 
	{
		return 0;
	}
	#Writing the result
	open (F,">$dout");
	print F "$s";
	close (F);
	#Indicating that portion processing is successfull
	return 1;
}
1;
