#include <synthesis/ImagerObjects/CubeMajorCycleAlgorithm.h>
#include <synthesis/TransformMachines2/test/MakeMS.h>
#include <synthesis/ImagerObjects/SynthesisImagerVi2.h>
#include <synthesis/ImagerObjects/SynthesisUtilMethods.h>
extern casa::Applicator casa::applicator;
int main(int argc, char **argv)
{
using namespace casa;
using namespace casacore;
using namespace casa::test;
casa::applicator.init(argc, argv);
if(casa::applicator.isController()){
for (int lala=0; lala <2; ++lala){
CubeMajorCycleAlgorithm *cmc=new CubeMajorCycleAlgorithm();
Int numprocs = applicator.numProcs();
cerr << "Number of procs: " << numprocs << endl;
String msname("TestCube.ms");
const Int numchan=20;
MDirection phasecenter;
Quantity freqBeg;
Quantity freqWidth;
cerr << "#####CONTROLLER ?" << applicator.isController() << " worker? " << applicator.isWorker() << endl;
if(casa::applicator.isController())
{
{
MDirection thedir(Quantity(20.0, "deg"), Quantity(20.0, "deg"));
const Int numchan=20;
MakeMS::makems(msname, thedir, 1.0e9, 5e7, numchan, 20);
MeasurementSet thems(msname, Table::Update);
MSColumns(thems).data().fillColumn(Matrix<Complex>(4,numchan, Complex(6.66e-2)));
MSColumns(thems).correctedData().fillColumn(Matrix<Complex>(4,numchan, Complex(6.66e-2)));
phasecenter=MSFieldColumns(thems.field()).phaseDirMeas(0,0.0);
freqBeg=MSSpWindowColumns(thems.spectralWindow()).chanFreqQuant()(0)(IPosition(1,0));
Int ndataChan=MSSpWindowColumns(thems.spectralWindow()).numChan()(0);
freqWidth=MSSpWindowColumns(thems.spectralWindow()).chanFreqQuant()(0)(IPosition(1,ndataChan-1));
freqWidth-=freqBeg;
freqWidth /= Double(numchan);
thems.flush();
}
SynthesisParamsSelect datSel;
{datSel.msname=msname;datSel.spw="0";datSel.freqbeg="";datSel.freqend="";
datSel.freqframe=MFrequency::LSRK;datSel.field="0";datSel.antenna=""; datSel.timestr="";datSel.scan="";datSel.obs="";datSel.state="";datSel.uvdist="";
datSel.taql="";datSel.usescratch=false;datSel.readonly=true;datSel.incrmodel=false;
datSel.datacolumn="corrected";
}
Record selparsRec = datSel.toRecord();
Record vecSelParsRec, vecImParsRec, vecGridParsRec;
vecSelParsRec.defineRecord(String::toString(0), selparsRec);
SynthesisParamsImage imSel;
{
imSel.imageName = "mpiCube_procs_"+String::toString(numprocs);
imSel.imsize.resize(2); imSel.imsize.set(100);
imSel.cellsize.resize(2); imSel.cellsize.set( Quantity(10.0,"arcsec") );
imSel.stokes="I";imSel.phaseCenter=phasecenter;imSel.phaseCenterFieldId=-1;