| [3872] | 1 | // Utilisation de SOPHYA pour faciliter les tests ... | 
|---|
|  | 2 | #include "sopnamsp.h" | 
|---|
|  | 3 | #include "machdefs.h" | 
|---|
|  | 4 |  | 
|---|
|  | 5 | /* ---------------------------------------------------------- | 
|---|
|  | 6 | Programme de lecture multifibres, calcul de spectres | 
|---|
|  | 7 | BAORadio -   LAL/IRFU      R. Ansari, C. Magneville | 
|---|
|  | 8 | Septembre 2010 | 
|---|
|  | 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 "brdiskw.h" | 
|---|
|  | 29 |  | 
|---|
|  | 30 | #include "branap.h" | 
|---|
|  | 31 |  | 
|---|
|  | 32 |  | 
|---|
|  | 33 |  | 
|---|
|  | 34 | //---------------------------------------------------- | 
|---|
|  | 35 | //---------------------------------------------------- | 
|---|
|  | 36 | int main(int narg, char* arg[]) | 
|---|
|  | 37 | { | 
|---|
|  | 38 |  | 
|---|
|  | 39 | TArrayInitiator  _inia; | 
|---|
|  | 40 |  | 
|---|
|  | 41 | int rc = 0; | 
|---|
|  | 42 | try { | 
|---|
|  | 43 | // Decodage parametres | 
|---|
|  | 44 | BRAnaParam par; | 
|---|
|  | 45 | par.action_="mspec"; | 
|---|
|  | 46 | cout << " ===> specmfib.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_!="mspec")) { | 
|---|
|  | 53 | cout << " !!! specmfib.cc  BAD action = " << par.action_ << " possible values: mspec,cube3d" << endl; | 
|---|
|  | 54 | return 5; | 
|---|
|  | 55 | } | 
|---|
|  | 56 |  | 
|---|
|  | 57 | cout << " ---------- specmfib.cc Start - Action= " << par.action_ << " ------------- " << endl; | 
|---|
|  | 58 | ResourceUsage resu; | 
|---|
|  | 59 | BRPaquet paq(par.paqsize_); | 
|---|
|  | 60 | uint_4 procsz=sizeof(float)*(paq.DataSize()+4); | 
|---|
|  | 61 | if ((par.fgdatafft_)||(par.action_=="cube3d")) procsz = 0; | 
|---|
|  | 62 | cout << " specmfib: Creating MemZoneMgr/threads - PaqSz= " << par.paqsize_ | 
|---|
|  | 63 | << " ProcPaqSz=" << procsz << endl; | 
|---|
|  | 64 | RAcqMemZoneMgr mmgr(par.nzones_, par.dirlist_.size(), par.npaqinzone_, par.paqsize_, procsz); | 
|---|
|  | 65 | if (par.action_ == "cube3d")  mmgr.SetFinalizedMask((uint_4)MemZS_Saved); | 
|---|
|  | 66 | else { | 
|---|
|  | 67 | if (par.fgdatafft_)  mmgr.SetFinalizedMask((uint_4)MemZS_ProcA); | 
|---|
|  | 68 | else mmgr.SetFinalizedMask((uint_4)MemZS_ProcB); | 
|---|
|  | 69 | } | 
|---|
| [3883] | 70 | BRMultiFitsReader reader(mmgr, par.dirlist_, par.rdsamefc_, par.imin_, par.imax_, par.istep_); | 
|---|
|  | 71 | reader.SetPrintLevel(par.prtlevel_,par.prtmodulo_); | 
|---|
| [3872] | 72 |  | 
|---|
|  | 73 | BRMeanSpecCalculator procms(mmgr, par.outpath_, par.nmean_, par.fgdatafft_, par.fgsinglechannel_); | 
|---|
| [3886] | 74 | procms.SetVarianceLimits(par.vmin_, par.vmax_); | 
|---|
| [3888] | 75 | if (par.gainfile_.length()>0) procms.ReadGainFitsFile(par.gainfile_); | 
|---|
|  | 76 |  | 
|---|
| [3872] | 77 | BRFFTCalculator procfft(mmgr, par.fgsinglechannel_); | 
|---|
|  | 78 | if (!par.fgdatafft_) procms.SetMemZAction(MemZA_ProcB); | 
|---|
|  | 79 |  | 
|---|
|  | 80 | FitsCubeWriter wrt(mmgr, par.outpath_, par.nbloc_); | 
|---|
|  | 81 |  | 
|---|
|  | 82 | cout << " specmfib: Starting threads (reader meanSpecCalculator ...) ... " << endl; | 
|---|
|  | 83 | reader.start(); | 
|---|
|  | 84 | if (par.action_ == "cube3d")   wrt.start(); | 
|---|
|  | 85 | else {  // Calcul spectre moyenne | 
|---|
|  | 86 | if (!par.fgdatafft_)  procfft.start(); | 
|---|
|  | 87 | procms.start(); | 
|---|
|  | 88 | } | 
|---|
|  | 89 | usleep(200000); | 
|---|
|  | 90 | reader.join(); | 
|---|
|  | 91 | if (par.action_ == "cube3d")  wrt.join(); | 
|---|
|  | 92 | else { | 
|---|
|  | 93 | if (!par.fgdatafft_)  procfft.join(); | 
|---|
|  | 94 | procms.join(); | 
|---|
|  | 95 | } | 
|---|
|  | 96 | mmgr.Print(cout); | 
|---|
|  | 97 | cout << resu ; | 
|---|
|  | 98 | } | 
|---|
|  | 99 | catch (std::exception& sex) { | 
|---|
|  | 100 | cerr << "\n specmfib.cc std::exception :"  << (string)typeid(sex).name() | 
|---|
|  | 101 | << "\n msg= " << sex.what() << endl; | 
|---|
|  | 102 | rc = 78; | 
|---|
|  | 103 | } | 
|---|
|  | 104 | catch (...) { | 
|---|
|  | 105 | cerr << " specmfib.cc catched unknown (...) exception  " << endl; | 
|---|
|  | 106 | rc = 79; | 
|---|
|  | 107 | } | 
|---|
|  | 108 |  | 
|---|
|  | 109 | cout << ">>>> specmfib.cc ------- END ----------- RC=" << rc << endl; | 
|---|
|  | 110 | return rc; | 
|---|
|  | 111 |  | 
|---|
|  | 112 | } | 
|---|
|  | 113 |  | 
|---|
|  | 114 |  | 
|---|