[219] | 1 | #include "data_output.hpp" |
---|
| 2 | |
---|
[352] | 3 | #include "attribute_template.hpp" |
---|
| 4 | #include "group_template.hpp" |
---|
[219] | 5 | #include "context.hpp" |
---|
| 6 | |
---|
[335] | 7 | namespace xios |
---|
[219] | 8 | { |
---|
| 9 | /// ////////////////////// Définitions ////////////////////// /// |
---|
| 10 | |
---|
| 11 | CDataOutput::~CDataOutput(void) |
---|
| 12 | { /* Ne rien faire de plus */ } |
---|
| 13 | |
---|
| 14 | //---------------------------------------------------------------- |
---|
| 15 | |
---|
[676] | 16 | void CDataOutput::writeGrid(CGrid* grid, bool allowCompressedOutput /*= false*/) |
---|
[219] | 17 | { |
---|
[887] | 18 | this->writeGrid(grid->getDomains(), grid->getAxis(), grid->getScalars()); |
---|
[676] | 19 | |
---|
| 20 | if (allowCompressedOutput) |
---|
| 21 | writeGridCompressed_(grid); |
---|
[219] | 22 | } |
---|
| 23 | |
---|
| 24 | //---------------------------------------------------------------- |
---|
| 25 | |
---|
[347] | 26 | void CDataOutput::writeFile(CFile* file) |
---|
[219] | 27 | { |
---|
| 28 | this->writeFile_(file); |
---|
| 29 | } |
---|
[472] | 30 | |
---|
| 31 | void CDataOutput::writeAttribute(CVariable* var) |
---|
| 32 | { |
---|
| 33 | this->writeAttribute_(var) ; |
---|
| 34 | } |
---|
| 35 | |
---|
[321] | 36 | void CDataOutput::syncFile(void) |
---|
| 37 | { |
---|
| 38 | this->syncFile_(); |
---|
| 39 | } |
---|
[219] | 40 | |
---|
[286] | 41 | void CDataOutput::closeFile(void) |
---|
| 42 | { |
---|
| 43 | this->closeFile_(); |
---|
| 44 | } |
---|
| 45 | |
---|
[219] | 46 | //---------------------------------------------------------------- |
---|
| 47 | |
---|
[676] | 48 | void CDataOutput::writeGrid(CDomain* domain, CAxis* axis) |
---|
[1622] | 49 | TRY |
---|
[219] | 50 | { |
---|
| 51 | this->writeDomain_(domain); |
---|
| 52 | this->writeAxis_(axis); |
---|
| 53 | } |
---|
[1622] | 54 | CATCH |
---|
[219] | 55 | |
---|
[540] | 56 | void CDataOutput::writeGrid(std::vector<CDomain*> domains, std::vector<CAxis*> axis) |
---|
[1622] | 57 | TRY |
---|
[540] | 58 | { |
---|
| 59 | int domSize = domains.size(); |
---|
| 60 | int aSize = axis.size(); |
---|
| 61 | for (int i = 0; i < domSize; ++i) this->writeDomain_(domains[i]); |
---|
| 62 | for (int i = 0; i < aSize; ++i) this->writeAxis_(axis[i]); |
---|
| 63 | } |
---|
[1622] | 64 | CATCH |
---|
[540] | 65 | |
---|
[887] | 66 | void CDataOutput::writeGrid(std::vector<CDomain*> domains, std::vector<CAxis*> axis, std::vector<CScalar*> scalars) |
---|
[1622] | 67 | TRY |
---|
[887] | 68 | { |
---|
| 69 | int domSize = domains.size(); |
---|
| 70 | int aSize = axis.size(); |
---|
| 71 | int sSize = scalars.size(); |
---|
| 72 | for (int i = 0; i < domSize; ++i) this->writeDomain_(domains[i]); |
---|
| 73 | for (int i = 0; i < aSize; ++i) this->writeAxis_(axis[i]); |
---|
| 74 | for (int i = 0; i < sSize; ++i) this->writeScalar_(scalars[i]); |
---|
| 75 | } |
---|
[1622] | 76 | CATCH |
---|
[887] | 77 | |
---|
[219] | 78 | //---------------------------------------------------------------- |
---|
| 79 | |
---|
[347] | 80 | void CDataOutput::writeGrid(CDomain* domain) |
---|
[1622] | 81 | TRY |
---|
[219] | 82 | { |
---|
| 83 | this->writeDomain_(domain); |
---|
| 84 | } |
---|
[1622] | 85 | CATCH |
---|
[219] | 86 | |
---|
[391] | 87 | void CDataOutput::writeTimeDimension(void) |
---|
[1622] | 88 | TRY |
---|
[391] | 89 | { |
---|
| 90 | this->writeTimeDimension_(); |
---|
| 91 | } |
---|
[1622] | 92 | CATCH |
---|
[391] | 93 | |
---|
[219] | 94 | //---------------------------------------------------------------- |
---|
| 95 | |
---|
[1158] | 96 | void CDataOutput::writeFieldTimeAxis(CField* field) |
---|
[1622] | 97 | TRY |
---|
[219] | 98 | { |
---|
[347] | 99 | CContext* context = CContext::getCurrent() ; |
---|
[1542] | 100 | std::shared_ptr<CCalendar> calendar = context->getCalendar(); |
---|
[540] | 101 | |
---|
[219] | 102 | this->writeTimeAxis_(field, calendar); |
---|
| 103 | } |
---|
[1622] | 104 | CATCH |
---|
| 105 | |
---|
[1158] | 106 | void CDataOutput::writeField(CField* field) |
---|
[1622] | 107 | TRY |
---|
[1158] | 108 | { |
---|
| 109 | this->writeField_(field); |
---|
| 110 | } |
---|
[1622] | 111 | CATCH |
---|
[219] | 112 | |
---|
| 113 | //---------------------------------------------------------------- |
---|
| 114 | |
---|
[347] | 115 | void CDataOutput::writeFieldGrid(CField* field) |
---|
[1622] | 116 | TRY |
---|
[219] | 117 | { |
---|
[676] | 118 | this->writeGrid(field->getRelGrid(), |
---|
| 119 | !field->indexed_output.isEmpty() && field->indexed_output); |
---|
[219] | 120 | } |
---|
[1622] | 121 | CATCH |
---|
[219] | 122 | //---------------------------------------------------------------- |
---|
[540] | 123 | |
---|
[347] | 124 | void CDataOutput::writeFieldData(CField* field) |
---|
[1622] | 125 | TRY |
---|
[219] | 126 | { |
---|
[540] | 127 | // CGrid* grid = CGrid::get(field->grid_ref.getValue()); |
---|
| 128 | // CDomain* domain = CDomain::get(grid->domain_ref.getValue()); |
---|
[219] | 129 | this->writeFieldData_(field); |
---|
| 130 | } |
---|
[1622] | 131 | CATCH |
---|
[540] | 132 | |
---|
[219] | 133 | ///---------------------------------------------------------------- |
---|
| 134 | |
---|
[335] | 135 | } // namespace xios |
---|