1 | // Utilisation de SOPHYA pour faciliter les tests ...
|
---|
2 | #include "sopnamsp.h"
|
---|
3 | #include "machdefs.h"
|
---|
4 |
|
---|
5 | /* ----------------------------------------------------------
|
---|
6 | Programme de lecture / calcul de visibilite multi-canaux
|
---|
7 | BAORadio - LAL/IRFU R. Ansari, C. Magneville
|
---|
8 | V1 : Nov 2009
|
---|
9 | ---------------------------------------------------------- */
|
---|
10 |
|
---|
11 | // include standard c/c++
|
---|
12 | #include <iostream>
|
---|
13 | #include <string>
|
---|
14 | #include <exception>
|
---|
15 |
|
---|
16 | // include sophya mesure ressource CPU/memoire ...
|
---|
17 | #include "resusage.h"
|
---|
18 | #include "ctimer.h"
|
---|
19 | #include "timing.h"
|
---|
20 | #include "timestamp.h"
|
---|
21 | #include "strutilxx.h"
|
---|
22 | #include "tarrinit.h"
|
---|
23 | #include "histinit.h"
|
---|
24 |
|
---|
25 | #include "brpaqu.h"
|
---|
26 | #include "brfitsrd.h"
|
---|
27 | #include "brproc.h"
|
---|
28 | #include "brviscalc.h"
|
---|
29 | #include "brdiskw.h"
|
---|
30 |
|
---|
31 | #include "branap.h"
|
---|
32 |
|
---|
33 |
|
---|
34 |
|
---|
35 | //----------------------------------------------------
|
---|
36 | //----------------------------------------------------
|
---|
37 | int main(int narg, char* arg[])
|
---|
38 | {
|
---|
39 |
|
---|
40 | TArrayInitiator _inia;
|
---|
41 |
|
---|
42 | int rc = 0;
|
---|
43 | try {
|
---|
44 | // Decodage parametres
|
---|
45 | BRAnaParam par;
|
---|
46 | cout << " ===> visimfib.cc: decoding command line arguments " << endl;
|
---|
47 | rc = par.DecodeArgs(narg, arg);
|
---|
48 | if (rc) return rc;
|
---|
49 | rc = par.PaqSizeFromFits();
|
---|
50 | if (rc) return rc;
|
---|
51 | par.Print(cout);
|
---|
52 | if ((par.action_!="cube3d")&&(par.action_!="vis")&&(par.action_!="viscktt")) {
|
---|
53 | cout << " !!! visimfib.cc BAD action = " << par.action_ << " possible values: vis,viscktt,cube3d" << endl;
|
---|
54 | return 5;
|
---|
55 | }
|
---|
56 |
|
---|
57 | cout << " ---------- visimfib.cc Start - Action= " << par.action_ << " ------------- " << endl;
|
---|
58 | ResourceUsage resu;
|
---|
59 |
|
---|
60 | BRPaquet paq(par.paqsize_);
|
---|
61 | uint_4 procsz=sizeof(float)*(paq.DataSize()+4);
|
---|
62 | if ((par.fgdatafft_)||(par.action_=="cube3d")) procsz = 0;
|
---|
63 | cout << " visimfib: Creating MemZoneMgr/processing threads - PaqSz= " << par.paqsize_
|
---|
64 | << " ProcPaqSz=" << procsz << endl;
|
---|
65 |
|
---|
66 | RAcqMemZoneMgr mmgr(par.nzones_, par.dirlist_.size(), par.npaqinzone_, par.paqsize_, procsz);
|
---|
67 |
|
---|
68 | BRMultiFitsReader reader(mmgr, par.dirlist_, par.rdsamefc_, par.imin_, par.imax_, par.istep_);
|
---|
69 | reader.SetPrintLevel(par.prtlevel_,par.prtmodulo_);
|
---|
70 |
|
---|
71 | /* BRVisibilityCalculator proc(mmgr, par.outpath_, par.nmean_, par.nthreads_);
|
---|
72 | proc.SelectFreqBinning(par.freqmin_, par.freqmax_, par.nbinfreq_); */
|
---|
73 | BRVisCalcGroup procg(par.nbcalgrp_, mmgr, par.outpath_, par.nmean_, 0, 999999999, false, par.nthreads_);
|
---|
74 | procg.SelectFreqBinning(par.freqmin_, par.freqmax_, par.nbinfreq_);
|
---|
75 |
|
---|
76 | if (par.action_ == "viscktt") procg.ActivateTimeTagCheck(par.TotalNPaquets());
|
---|
77 | if (par.fgfitsout_) procg.SetFitsOutput();
|
---|
78 |
|
---|
79 | BRFFTCalculator procfft(mmgr, par.fgsinglechannel_);
|
---|
80 |
|
---|
81 | // On determine MemZaction pour chaque processeur et le finalizemask en fonction du traitement demande
|
---|
82 | if (par.action_ == "cube3d") mmgr.SetFinalizedMask((uint_4)MemZS_Saved);
|
---|
83 | else {
|
---|
84 | MemZStatus mfmask=MemZS_ProcA;
|
---|
85 | if (par.fgdatafft_) mfmask=procg.SetMemZAction(MemZA_ProcA);
|
---|
86 | else mfmask=procg.SetMemZAction(MemZA_ProcB);
|
---|
87 | mmgr.SetFinalizedMask((uint_4)mfmask);
|
---|
88 | }
|
---|
89 |
|
---|
90 | FitsCubeWriter wrt(mmgr, par.outpath_, par.nbloc_);
|
---|
91 | // BRBaseProcessor proc(mmgr);
|
---|
92 |
|
---|
93 | cout << " visimfib: Starting threads (reader procVisi) ... " << endl;
|
---|
94 | reader.start();
|
---|
95 | if (par.action_ == "cube3d") wrt.start();
|
---|
96 | else {
|
---|
97 | if (!par.fgdatafft_) procfft.start();
|
---|
98 | procg.start();
|
---|
99 | }
|
---|
100 | usleep(200000);
|
---|
101 | reader.join();
|
---|
102 | if (par.action_ == "cube3d") wrt.join();
|
---|
103 | else {
|
---|
104 | if (!par.fgdatafft_) procfft.join();
|
---|
105 | procg.join();
|
---|
106 | }
|
---|
107 | mmgr.Print(cout);
|
---|
108 | cout << resu ;
|
---|
109 | }
|
---|
110 | catch (std::exception& sex) {
|
---|
111 | cerr << "\n visimfib.cc std::exception :" << (string)typeid(sex).name()
|
---|
112 | << "\n msg= " << sex.what() << endl;
|
---|
113 | rc = 78;
|
---|
114 | }
|
---|
115 | catch (...) {
|
---|
116 | cerr << " visimfib.cc catched unknown (...) exception " << endl;
|
---|
117 | rc = 79;
|
---|
118 | }
|
---|
119 |
|
---|
120 | cout << ">>>> visimfib.cc ------- END ----------- RC=" << rc << endl;
|
---|
121 | return rc;
|
---|
122 |
|
---|
123 | }
|
---|
124 |
|
---|
125 |
|
---|