I have an application that I would like to keep track of the calculation for the user to see that calculation is being done (specially for deploying CDF). I can use the ProgressIndicator with ParallelTable to do that. My code will be in a package and I will use an user interface for the calculation. In current version the status bar appear outside the Manipulate box (or Panel) , I am trying to put that inside the box.
For that I tried to transfer the tracking variable outside the ParallelTable and user progressindicator there but I was not successful. I want to do this because in a cdf file the bar does not disappear after the computation.
This is a just a "toy" calculation to mimic what I need to do.
Get[FileNameJoin[{NotebookDirectory[EvaluationNotebook[]],
"DummyPackage.m"}]];
Panel[DynamicModule[{np = 100, nd = 30, Res = 1.0},
Column[{Style["Random", "Function"] ,
Row[{"Digits ", InputField[Dynamic[nd]]}, Spacer[5]],
Row[{"Precision ", InputField[Dynamic[np]]}, Spacer[5]],
Button[Style["Calculate", Green, Bold],
Res = DummyPackage`myDummyF[nd, np], Method -> "Queued"],
Row[{Style["Result ", 12, Red],
InputField[Dynamic[Res], FieldSize -> 30, Enabled -> False]},
Spacer[15]],
Button[Style["Save", Green, Bold],
NotebookSave[EvaluationNotebook[], Interactive -> True]]
}],
Initialization :> (
Get[FileNameJoin[{NotebookDirectory[EvaluationNotebook[]],
"DummyPackage.m"}]];)]]
and the package is
BeginPackage["DummyPackage`"]
myDummyF[nd_,np_]:=Module[{mat,mat2,aI,dl,d=0},
ns=200;
mat=SetAccuracy[RandomReal[{-100,100},ns],nd];
mat2=SetAccuracy[RandomReal[{-200,200},ns],nd];
aI=ConstantArray[0,np];
(*SetSharedVariable[aI,d];*)
SetSharedVariable[d];
ParallelEvaluate[dl = 0];
Time=AbsoluteTiming[
Monitor[aI=ParallelTable[If[Mod[dl++, Ceiling[nd/75]] == 0, d += Ceiling[nd/75]];
If[iC==2,Print[" ParallelDo Loop"]];
aI=SetAccuracy[mat.(mat2/iC^0.5),nd]
,{iC,np}];,
ProgressIndicator[d/np]]];
Print["Do loop time = ",Time[[1]],", np = ",np,", nd = ",nd];
aInum=Apply[Plus,(aI/np)];
Print["Total = ",aInum];
Return[aInum]];
SetAttributes[{myDummyF},{ReadProtected,Protected,Locked}];
EndPackage[];