Changeset 998
- Timestamp:
- 11/19/16 15:19:36 (8 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/config/field_attribute.conf
r990 r998 11 11 DECLARE_ATTRIBUTE(int, level) 12 12 DECLARE_ATTRIBUTE(int, prec) 13 DECLARE_ATTRIBUTE(StdString, expr) 13 14 14 15 DECLARE_ATTRIBUTE(bool, enabled) -
XIOS/trunk/src/context_server.cpp
r887 r998 184 184 // The best way to properly solve this problem will be to use the event scheduler also in attached mode 185 185 // for now just set up a MPI barrier 186 if (!CServer::eventScheduler ) MPI_Barrier(intraComm) ;186 if (!CServer::eventScheduler && CXios::isServer) MPI_Barrier(intraComm) ; 187 187 188 188 CTimer::get("Process events").resume(); -
XIOS/trunk/src/node/field.cpp
r989 r998 768 768 { 769 769 if (!areAllReferenceSolved) solveAllReferenceEnabledField(false); 770 771 770 // Start by building a filter which can provide the field's instant data 772 771 if (!instantDataFilter) 773 772 { 773 boost::shared_ptr<COutputPin> arithmDataFilter; 774 774 775 // Check if we have an expression to parse 775 if (!content.empty()) 776 { 777 boost::scoped_ptr<IFilterExprNode> expr(parseExpr(content + '\0')); 778 instantDataFilter = expr->reduce(gc, *this); 779 } 780 // Check if we have a reference on another field 781 else if (!field_ref.isEmpty()) 782 instantDataFilter = getFieldReference(gc); 776 if (hasExpression() || !field_ref.isEmpty()) 777 { 778 if (hasExpression()) 779 { 780 boost::scoped_ptr<IFilterExprNode> expr(parseExpr(getExpression() + '\0')); 781 arithmDataFilter = expr->reduce(gc, *this); 782 } 783 // Check if we have a reference on another field 784 if (!field_ref.isEmpty()) instantDataFilter = getFieldReference(gc,arithmDataFilter); 785 } 783 786 // Check if the data is to be read from a file 784 787 else if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read) … … 813 816 * \return the output pin corresponding to the field reference 814 817 */ 815 boost::shared_ptr<COutputPin> CField::getFieldReference(CGarbageCollector& gc )818 boost::shared_ptr<COutputPin> CField::getFieldReference(CGarbageCollector& gc, boost::shared_ptr<COutputPin> OutputPin) 816 819 { 817 820 if (instantDataFilter || field_ref.isEmpty()) … … 820 823 821 824 CField* fieldRef = CField::get(field_ref); 822 fieldRef->buildFilterGraph(gc, false);825 if (!OutputPin) fieldRef->buildFilterGraph(gc, false); 823 826 824 827 std::pair<boost::shared_ptr<CFilter>, boost::shared_ptr<CFilter> > filters; … … 834 837 filters.first = filters.second = boost::shared_ptr<CFilter>(new CPassThroughFilter(gc)); 835 838 836 fieldRef->getInstantDataFilter()->connectOutput(filters.first, 0); 839 if (!OutputPin) fieldRef->getInstantDataFilter()->connectOutput(filters.first, 0); 840 else OutputPin->connectOutput(filters.first, 0); 837 841 838 842 return filters.second; … … 850 854 boost::shared_ptr<COutputPin> CField::getSelfReference(CGarbageCollector& gc) 851 855 { 852 if (instantDataFilter || content.empty())856 if (instantDataFilter || ! hasExpression()) 853 857 ERROR("COutputPin* CField::getSelfReference(CGarbageCollector& gc)", 854 858 "Impossible to add a self reference to a field which has already been parsed or which does not have an expression."); … … 865 869 } 866 870 else if (!field_ref.isEmpty()) 867 selfReferenceFilter = getFieldReference(gc); 871 { 872 CField* fieldRef = CField::get(field_ref); 873 fieldRef->buildFilterGraph(gc, false); 874 selfReferenceFilter = fieldRef->getInstantDataFilter(); 875 } 868 876 else 869 877 { … … 915 923 return it->second; 916 924 } 925 926 /*! 927 * Returns the temporal filter corresponding to the field's temporal operation 928 * for the specified operation frequency. The filter is created if it does not 929 * exist, otherwise it is reused. 930 * 931 * \param gc the garbage collector to use 932 * \param outFreq the operation frequency, i.e. the frequency at which the output data will be computed 933 * \return the output pin corresponding to the requested temporal filter 934 */ 935 936 boost::shared_ptr<COutputPin> CField::getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq) 937 { 938 939 if (instantDataFilter || !hasExpression()) 940 ERROR("COutputPin* CField::getSelfTemporalDataFilter(CGarbageCollector& gc)", 941 "Impossible to add a self reference to a field which has already been parsed or which does not have an expression."); 942 943 if (!selfReferenceFilter) getSelfReference(gc) ; 944 945 if (serverSourceFilter || clientSourceFilter) 946 { 947 if (operation.isEmpty()) 948 ERROR("void CField::getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq)", 949 << "An operation must be defined for field \"" << getId() << "\"."); 950 951 if (freq_op.isEmpty()) freq_op.setValue(TimeStep); 952 if (freq_offset.isEmpty()) freq_offset.setValue(NoneDu); 953 954 const bool ignoreMissingValue = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true); 955 956 boost::shared_ptr<CTemporalFilter> temporalFilter(new CTemporalFilter(gc, operation, 957 CContext::getCurrent()->getCalendar()->getInitDate(), 958 freq_op, freq_offset, outFreq, 959 ignoreMissingValue, ignoreMissingValue ? default_value : 0.0)); 960 selfReferenceFilter->connectOutput(temporalFilter, 0); 961 return temporalFilter ; 962 } 963 else if (!field_ref.isEmpty()) 964 { 965 CField* fieldRef = CField::get(field_ref); 966 fieldRef->buildFilterGraph(gc, false); 967 return fieldRef->getTemporalDataFilter(gc, outFreq) ; 968 } 969 } 970 971 972 /* 973 boost::shared_ptr<COutputPin> CField::getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq) 974 { 975 976 if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read) 977 { 978 if (!serverSourceFilter) 979 serverSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid, 980 freq_offset.isEmpty() ? NoneDu : freq_offset)); 981 982 selfReferenceFilter = serverSourceFilter; 983 } 984 else if (!field_ref.isEmpty()) 985 { 986 CField* fieldRef = CField::get(field_ref); 987 fieldRef->buildFilterGraph(gc, false); 988 return fieldRef->getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq) ; 989 } 990 991 } 992 993 */ 917 994 918 995 //---------------------------------------------------------------- … … 1344 1421 } 1345 1422 1423 /*! 1424 * Returns string arithmetic expression associated to the field. 1425 * \return if content is defined return content string, otherwise, if "expr" attribute is defined, return expr string. 1426 */ 1427 string CField::getExpression(void) 1428 { 1429 if (! expr.isEmpty() && content.empty()) 1430 { 1431 content=expr ; 1432 expr.reset() ; 1433 } 1434 return content; 1435 } 1436 1437 bool CField::hasExpression(void) 1438 { 1439 if (! expr.isEmpty()) return true ; 1440 if (!content.empty()) return true ; 1441 return false; 1442 } 1346 1443 DEFINE_REF_FUNC(Field,field) 1347 1444 } // namespace xios -
XIOS/trunk/src/node/field.hpp
r989 r998 121 121 122 122 void buildFilterGraph(CGarbageCollector& gc, bool enableOutput); 123 boost::shared_ptr<COutputPin> getFieldReference(CGarbageCollector& gc );123 boost::shared_ptr<COutputPin> getFieldReference(CGarbageCollector& gc, boost::shared_ptr<COutputPin> OutputPin = boost::shared_ptr<COutputPin>()); 124 124 boost::shared_ptr<COutputPin> getSelfReference(CGarbageCollector& gc); 125 125 boost::shared_ptr<COutputPin> getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq); 126 boost::shared_ptr<COutputPin> getSelfTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq); 126 127 127 128 // virtual void fromBinary(StdIStream& is); … … 177 178 178 179 const std::vector<StdString>& getRefDomainAxisIds(); 180 string getExpression(void) ; 181 bool hasExpression(void) ; 179 182 180 183 public: -
XIOS/trunk/src/node/field_impl.hpp
r645 r998 20 20 if (clientSourceFilter) 21 21 clientSourceFilter->streamData(CContext::getCurrent()->getCalendar()->getCurrentDate(), _data); 22 else if (!field_ref.isEmpty() || !content.empty())22 else if (!field_ref.isEmpty() || hasExpression()) 23 23 ERROR("void CField::setData(const CArray<double, N>& _data)", 24 24 << "Impossible to receive data from the model for a field [ id = " << getId() << " ] with a reference or an arithmetic operation."); -
XIOS/trunk/src/parse_expr/filter_expr_node.cpp
r643 r998 40 40 boost::shared_ptr<COutputPin> CFilterTemporalFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const 41 41 { 42 if (!CField::has(fieldId)) 42 if (fieldId == "this") return thisField.getSelfTemporalDataFilter(gc, thisField.freq_op.isEmpty() ? TimeStep : thisField.freq_op); 43 44 if (!CField::has(fieldId)) 43 45 ERROR("boost::shared_ptr<COutputPin> CFilterTemporalFieldExprNode::reduce(CGarbageCollector& gc, CField& thisField) const", 44 46 << "The field " << fieldId << " does not exist."); 45 47 48 46 49 CField* field = CField::get(fieldId); 47 50 if (field == &thisField)
Note: See TracChangeset
for help on using the changeset viewer.