Changeset 1875
- Timestamp:
- 05/12/20 11:52:13 (4 years ago)
- Location:
- XIOS/dev/dev_ym/XIOS_COUPLING
- Files:
-
- 1 added
- 42 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/arch/arch-X64_IRENE.env
r1649 r1875 7 7 module load blitz 8 8 module load feature/bridge/heterogenous_mpmd 9 10 module load totalview -
XIOS/dev/dev_ym/XIOS_COUPLING/bld.cfg
r1510 r1875 38 38 src::xios::transformation::Functions $PWD/src/transformation/Functions 39 39 src::xios::type $PWD/src/type 40 src::xios::manager $PWD/src/manager 41 40 42 41 43 src::netcdf $PWD/extern/netcdf4 … … 46 48 #bld::target test_remap.exe 47 49 bld::target xios_server.exe 50 bld::target generic_testcase.exe 48 51 #bld::target test_regular.exe 49 52 #bld::target test_xios2_cmip6.exe -
XIOS/dev/dev_ym/XIOS_COUPLING/make_xios
r1510 r1875 11 11 use_extern_blitz="false" 12 12 use_memtrack="false" 13 use_tv="false" 13 14 job="1" 14 15 netcdf_lib="netcdf4_par" … … 34 35 echo " [--full] : to generate dependencies and recompile from scratch" 35 36 echo " [--use_oasis 'oasis3' 'oasis3_mct' : default oasis3_mct] : to use Oasis coupler" 36 echo " [--build_path : absolute path to the build directory" 37 echo " [--build_dir : name of the build directory" 38 echo " [--build_suffixed : generate automatically suffixed name of the build directory (e.g. config_X64_CURIE_prod)" 39 echo " [--use_extern_boost : to use external boost library" 40 echo " [--use_extern_blitz : to use external blitz library" 37 echo " [--build_path] : absolute path to the build directory" 38 echo " [--build_dir ]: name of the build directory" 39 echo " [--build_suffixed ]: generate automatically suffixed name of the build directory (e.g. config_X64_CURIE_prod)" 40 echo " [--use_extern_boost] : to use external boost library" 41 echo " [--use_extern_blitz] : to use external blitz library" 42 echo " [--use_tv] : to use totalview data type display" 41 43 echo " [--doc] : to generate Doxygen documentation (not available yet)" 42 44 echo " [--job ntasks] : to use parallel compilation with ntasks" … … 59 61 "--use_extern_boost") use_extern_boost="true" ; shift ;; 60 62 "--use_extern_blitz") use_extern_blitz="true" ; shift ;; 63 "--use_tv") use_tv="true" ; shift ;; 61 64 "--doc") doc="true" ; shift ;; 62 65 "--job") job=$2 ; shift ; shift ;; … … 233 236 fi 234 237 238 if [[ "$use_tv" == "true" ]] 239 then 240 echo "src::tv_data_display $PWD/extern/tv_data_display" >> ${PWD}/bld_dir.cfg 241 fi 242 235 243 236 244 if [[ "$use_memtrack" == "true" ]] -
XIOS/dev/dev_ym/XIOS_COUPLING/src/array_new.hpp
r1622 r1875 7 7 #include "buffer_out.hpp" 8 8 #include "message.hpp" 9 #include "tv_data_display.h" 10 #ifdef __GNUC__ 11 #include <typeinfo> 12 #include <cxxabi.h> 13 #endif 9 14 #include <cmath> 10 15 11 16 using namespace blitz; 12 17 BZ_DECLARE_FUNCTION(round) 18 19 namespace xios 20 { 21 template <typename T_numtype,int N_rank> 22 class CArray ; 23 24 template <typename T_numtype,int N_rank> 25 int TV_ttf_display_type ( const CArray<T_numtype, N_rank>* array ) ; 26 } 27 28 template <typename T_numtype,int N_rank> 29 int TV_ttf_display_type ( const xios::CArray<T_numtype, N_rank>* array ) ; 13 30 14 31 namespace xios … … 19 36 private: 20 37 bool initialized; 21 38 void inc_symbol(void) 39 { 40 TV_ttf_display_type(this); 41 } 22 42 public: 23 43 typedef typename Array<T_numtype,N_rank>::T_default_storage T_default_storage; … … 27 47 : Array<T_numtype,N_rank>(expr) 28 48 , initialized(true) 29 { }49 { bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol(); } 30 50 31 51 CArray(GeneralArrayStorage<N_rank> storage = T_default_storage()) 32 52 : Array<T_numtype,N_rank>(storage) 33 53 , initialized(false) 34 { }54 { bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 35 55 36 56 explicit CArray(int length0, GeneralArrayStorage<N_rank> storage = T_default_storage()) 37 57 : Array<T_numtype,N_rank>(length0, storage) 38 58 , initialized(true) 39 { }59 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 40 60 41 61 CArray(int length0, int length1, GeneralArrayStorage<N_rank> storage = T_default_storage()) 42 62 : Array<T_numtype,N_rank>(length0, length1, storage) 43 63 , initialized(true) 44 { }64 { bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 45 65 46 66 CArray(int length0, int length1, int length2, GeneralArrayStorage<N_rank> storage = T_default_storage()) 47 67 : Array<T_numtype,N_rank>(length0, length1, length2, storage) 48 68 , initialized(true) 49 { }69 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 50 70 51 71 CArray(int length0, int length1, int length2, int length3, GeneralArrayStorage<N_rank> storage = T_default_storage()) 52 72 : Array<T_numtype,N_rank>(length0, length1, length2, length3, storage) 53 73 , initialized(true) 54 { }74 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 55 75 56 76 CArray(int length0, int length1, int length2, int length3, int length4, GeneralArrayStorage<N_rank> storage = T_default_storage()) 57 77 : Array<T_numtype,N_rank>(length0,length1, length2, length3, length4, storage) 58 78 , initialized(true) 59 { }79 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 60 80 61 81 CArray(int length0, int length1, int length2, int length3, int length4, int length5, GeneralArrayStorage<N_rank> storage = T_default_storage()) 62 82 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, storage) 63 83 , initialized(true) 64 { }84 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 65 85 66 86 CArray(int length0, int length1, int length2, int length3, int length4, int length5, int length6, GeneralArrayStorage<N_rank> storage = T_default_storage()) 67 87 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, length6, storage) 68 88 , initialized(true) 69 { }89 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 70 90 71 91 CArray(int length0, int length1, int length2, int length3, int length4, int length5, int length6, int length7, … … 73 93 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, length6, length7, storage) 74 94 , initialized(true) 75 { }95 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 76 96 77 97 CArray(int length0, int length1, int length2, int length3, int length4, int length5, int length6, … … 79 99 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, length6, length7, length8, storage) 80 100 , initialized(true) 81 { }101 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 82 102 83 103 CArray(int length0, int length1, int length2, int length3, int length4, … … 85 105 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, length6, length7, length8, length9, storage) 86 106 , initialized(true) 87 { }107 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 88 108 89 109 CArray(int length0, int length1, int length2, int length3, int length4, int length5, int length6, … … 91 111 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, length6, length7, length8, length9, length10, storage) 92 112 , initialized(true) 93 { }113 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 94 114 95 115 CArray(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, GeneralArrayStorage<N_rank> storage = T_default_storage()) 96 116 : Array<T_numtype,N_rank>(dataFirst, shape, storage) 97 117 , initialized(true) 98 { }118 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 99 119 100 120 CArray(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, TinyVector<diffType, N_rank> stride, … … 102 122 : Array<T_numtype,N_rank>(dataFirst, shape, stride, storage) 103 123 , initialized(true) 104 { }124 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 105 125 106 126 CArray(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, preexistingMemoryPolicy deletionPolicy, … … 108 128 : Array<T_numtype,N_rank>(dataFirst, shape, deletionPolicy, storage) 109 129 , initialized(true) 110 { }130 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 111 131 112 132 CArray(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, TinyVector<diffType, N_rank> stride, … … 114 134 : Array<T_numtype,N_rank>(dataFirst, shape, stride, deletionPolicy, storage) 115 135 , initialized(true) 116 { }136 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 117 137 118 138 CArray(const TinyVector<int, N_rank>& extent, GeneralArrayStorage<N_rank> storage = T_default_storage()) 119 139 : Array<T_numtype,N_rank>(extent, storage) 120 140 , initialized(true) 121 { }141 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 122 142 123 143 CArray(const TinyVector<int, N_rank>& lbounds, const TinyVector<int, N_rank>& extent, … … 125 145 : Array<T_numtype,N_rank>(lbounds, extent, storage) 126 146 , initialized(true) 127 { }147 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 128 148 129 149 CArray(Range r0, GeneralArrayStorage<N_rank> storage = T_default_storage()) 130 150 : Array<T_numtype,N_rank>(r0, storage) 131 151 , initialized(true) 132 { }152 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 133 153 134 154 CArray(Range r0, Range r1, GeneralArrayStorage<N_rank> storage = T_default_storage()) 135 155 : Array<T_numtype,N_rank>(r0, r1, storage) 136 156 , initialized(true) 137 { }157 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 138 158 139 159 CArray(Range r0, Range r1, Range r2, GeneralArrayStorage<N_rank> storage = T_default_storage()) 140 160 : Array<T_numtype,N_rank>(r0, r1, r2, storage) 141 161 , initialized(true) 142 { }162 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 143 163 144 164 CArray(Range r0, Range r1, Range r2, Range r3, GeneralArrayStorage<N_rank> storage = T_default_storage()) 145 165 : Array<T_numtype,N_rank>(r0, r1, r2, r3, storage) 146 166 , initialized(true) 147 { }167 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 148 168 149 169 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, GeneralArrayStorage<N_rank> storage = T_default_storage()) 150 170 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, storage) 151 171 , initialized(true) 152 { }172 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 153 173 154 174 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, GeneralArrayStorage<N_rank> storage = T_default_storage()) 155 175 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, storage) 156 176 , initialized(true) 157 { }177 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 158 178 159 179 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Range r6, … … 161 181 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, r6, storage) 162 182 , initialized(true) 163 { }183 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 164 184 165 185 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Range r6, Range r7, … … 167 187 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, r6, r7, storage) 168 188 , initialized(true) 169 { }189 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 170 190 171 191 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, … … 173 193 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, r6, r7, r8, storage) 174 194 , initialized(true) 175 { }195 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 176 196 177 197 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, … … 179 199 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, storage) 180 200 , initialized(true) 181 { }201 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 182 202 183 203 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Range r6, Range r7, … … 185 205 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, storage) 186 206 , initialized(true) 187 { }207 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 188 208 189 209 CArray(const CArray<T_numtype, N_rank>& array) 190 210 : Array<T_numtype,N_rank>(array) 191 211 , initialized(array.initialized) 192 { }212 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 193 213 194 214 CArray(const Array<T_numtype, N_rank>& array) 195 215 : Array<T_numtype,N_rank>(array) 196 216 , initialized(true) 197 { }217 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 198 218 199 219 CArray(const TinyVector<int,N_rank-1>& shape, int lastExtent, const GeneralArrayStorage<N_rank>& storage) 200 220 : Array<T_numtype,N_rank>(shape, lastExtent, storage) 201 221 , initialized(true) 202 { }222 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 203 223 204 224 CArray(Array<T_numtype, N_rank>& array, Range r0) 205 225 : Array<T_numtype,N_rank>(array, r0) 206 226 , initialized(true) 207 { }227 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 208 228 209 229 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1) 210 230 : Array<T_numtype,N_rank>(array, r0, r1) 211 231 , initialized(true) 212 { }232 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 213 233 214 234 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2) 215 235 : Array<T_numtype,N_rank>( array, r0, r1, r2) 216 236 , initialized(true) 217 { }237 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 218 238 219 239 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3) 220 240 : Array<T_numtype,N_rank>(array, r0, r1, r2, r3) 221 241 , initialized(true) 222 { }242 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 223 243 224 244 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, … … 226 246 : Array<T_numtype,N_rank>(array, r0, r1, r2, r3, r4) 227 247 , initialized(true) 228 { }248 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 229 249 230 250 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, … … 232 252 : Array<T_numtype,N_rank>( array, r0, r1, r2, r3, r4, r5) 233 253 , initialized(true) 234 { }254 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 235 255 236 256 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3, … … 238 258 : Array<T_numtype,N_rank>( array, r0, r1, r2, r3, r4, r5, r6) 239 259 , initialized(true) 240 { }260 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 241 261 242 262 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3, Range r4, … … 244 264 : Array<T_numtype,N_rank>(array, r0, r1, r2, r3, r4, r5, r6, r7) 245 265 , initialized(true) 246 { }266 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 247 267 248 268 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, … … 250 270 : Array<T_numtype,N_rank>(array, r0, r1, r2, r3, r4, r5, r6, r7, r8) 251 271 , initialized(true) 252 { }272 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 253 273 254 274 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, … … 256 276 : Array<T_numtype,N_rank>(array, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9) 257 277 , initialized(true) 258 { }278 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 259 279 260 280 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Range r6, … … 262 282 : Array<T_numtype,N_rank>(array, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10) 263 283 , initialized(true) 264 { }284 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 265 285 266 286 CArray(Array<T_numtype, N_rank>& array, const RectDomain<N_rank>& subdomain) 267 287 : Array<T_numtype,N_rank>(array, subdomain) 268 288 , initialized(true) 269 { }289 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 270 290 271 291 CArray(Array<T_numtype, N_rank>& array, const StridedDomain<N_rank>& subdomain) 272 292 : Array<T_numtype,N_rank>(array, subdomain) 273 293 , initialized(true) 274 { }294 {bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol();} 275 295 276 296 template<int N_rank2, typename R0, typename R1, typename R2, typename R3, typename R4, typename R5, … … 279 299 : Array<T_numtype,N_rank>(array, r0,r1, r2, r3, r4, r5, r6, r7, r8, r9, r10) 280 300 , initialized(true) 281 { }301 { bool neverTrue ; neverTrue=false ; bool neverTrue ; neverTrue=false ; if(neverTrue) inc_symbol(); } 282 302 283 303 virtual ~CArray() {} … … 548 568 virtual size_t size(void) const { return size(this->numElements()); } 549 569 static size_t size(sizeType numElements) { return (N_rank + 1) * sizeof(int) + sizeof(size_t) + numElements * sizeof(T_numtype); } 550 570 571 static int show_TV_ttf_display_type ( const CArray<T_numtype,N_rank>* array ) 572 { 573 int status ; 574 if (array->isEmpty()) 575 { 576 status = TV_ttf_add_row("State", TV_ttf_type_ascii_string,"(empty)") ; 577 if (status != TV_ttf_ec_ok) return TV_ttf_format_raw ; 578 else return TV_ttf_format_ok_elide ; 579 } 580 else 581 { 582 char tname[128] ; 583 char bname[128] = "value_type" ; 584 #ifdef __GNUC__ 585 size_t size = sizeof(bname) ; 586 abi::__cxa_demangle(typeid(T_numtype).name(), bname, &size, &status) ; 587 if (status !=0) return TV_ttf_format_raw ; 588 #endif 589 int dim = array->dimensions() ; 590 if (dim==1) snprintf (tname, sizeof(tname), "%s[%d]", bname, array->extent(0)); 591 if (dim==2) snprintf (tname, sizeof(tname), "%s[%d][%d]", bname, array->extent(1), array->extent(0)); 592 if (dim==3) snprintf (tname, sizeof(tname), "%s[%d][%d][%d]", bname, array->extent(2), array->extent(1), array->extent(3)); 593 if (dim==4) snprintf (tname, sizeof(tname), "%s[%d][%d][%d][%d]", bname, array->extent(0), array->extent(1), array->extent(2), array->extent(3)); 594 if (dim==5) snprintf (tname, sizeof(tname), "%s[%d][%d][%d][%d][%d]", bname, array->extent(4), array->extent(3), array->extent(2), array->extent(1) 595 ,array->extent(0)); 596 if (dim==6) snprintf (tname, sizeof(tname), "%s[%d][%d][%d][%d][%d][%d]", bname, array->extent(5), array->extent(4), array->extent(3), array->extent(2) 597 ,array->extent(1),array->extent(0)); 598 if (dim==7) snprintf (tname, sizeof(tname), "%s[%d][%d][%d][%d][%d][%d][%d]", bname, array->extent(6), array->extent(5), array->extent(4), array->extent(3) 599 ,array->extent(2),array->extent(1),array->extent(0)); 600 status = TV_ttf_add_row("array_values", tname, array->dataFirst()) ; 601 if (status != TV_ttf_ec_ok) return TV_ttf_format_raw ; 602 else return TV_ttf_format_ok ; 603 } 604 } 605 606 607 static int TV_ttf_display_type ( const CArray<T_numtype,N_rank>* array ) 608 { 609 return show_TV_ttf_display_type (array) ; 610 } 611 551 612 virtual CBaseType* clone(void) const { return new CArray(*this); } 552 613 … … 578 639 return ret; 579 640 } 641 580 642 }; 643 644 645 #define macrotyperank(_TYPE_,_RANK_)\ 646 template<> int CArray<_TYPE_,_RANK_>::TV_ttf_display_type( const CArray<_TYPE_,_RANK_>* array ) \ 647 {\ 648 return show_TV_ttf_display_type (array) ;\ 649 } 650 651 #define macrotype(_TYPE_)\ 652 macrotyperank(_TYPE_,1)\ 653 macrotyperank(_TYPE_,2)\ 654 macrotyperank(_TYPE_,3)\ 655 macrotyperank(_TYPE_,4)\ 656 macrotyperank(_TYPE_,5)\ 657 macrotyperank(_TYPE_,6)\ 658 macrotyperank(_TYPE_,7) 659 660 macrotype(double) 661 macrotype(int) 662 macrotype(bool) 663 macrotype(size_t) 664 macrotype(float) 665 macrotype(string) 666 667 #undef macrotyperank 668 #undef macrotype 669 581 670 582 671 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/attribute_array.hpp
r1622 r1875 21 21 { 22 22 public : 23 24 using CArray<T_numtype,N_rank>::operator = ; 23 using CArray<T_numtype,N_rank>::operator = ; 25 24 26 25 /// Constructeurs /// … … 65 64 virtual void generateFortranInterfaceGetBody_(ostream& oss,const string& className) ; 66 65 virtual void generateFortranInterfaceGetDeclaration(ostream& oss,const string& className) ; 66 67 static int show_TV_ttf_display_type ( const CAttributeArray<T_numtype,N_rank>* array ) 68 { 69 int status ; 70 if (array->isEmpty()) 71 { 72 status = TV_ttf_add_row("State", TV_ttf_type_ascii_string,"(empty)") ; 73 if (status != TV_ttf_ec_ok) return TV_ttf_format_raw ; 74 else return TV_ttf_format_ok_elide ; 75 } 76 else 77 { 78 char tname[128] ; 79 char bname[128] = "value_type" ; 80 #ifdef __GNUC__ 81 size_t size = sizeof(bname) ; 82 abi::__cxa_demangle(typeid(T_numtype).name(), bname, &size, &status) ; 83 if (status !=0) return TV_ttf_format_raw ; 84 #endif 85 int dim = array->dimensions() ; 86 if (dim==1) snprintf (tname, sizeof(tname), "%s[%d]", bname, array->extent(0)); 87 if (dim==2) snprintf (tname, sizeof(tname), "%s[%d][%d]", bname, array->extent(1), array->extent(0)); 88 if (dim==3) snprintf (tname, sizeof(tname), "%s[%d][%d][%d]", bname, array->extent(2), array->extent(1), array->extent(3)); 89 if (dim==4) snprintf (tname, sizeof(tname), "%s[%d][%d][%d][%d]", bname, array->extent(0), array->extent(1), array->extent(2), array->extent(3)); 90 if (dim==5) snprintf (tname, sizeof(tname), "%s[%d][%d][%d][%d][%d]", bname, array->extent(4), array->extent(3), array->extent(2), array->extent(1) 91 ,array->extent(0)); 92 if (dim==6) snprintf (tname, sizeof(tname), "%s[%d][%d][%d][%d][%d][%d]", bname, array->extent(5), array->extent(4), array->extent(3), array->extent(2) 93 ,array->extent(1),array->extent(0)); 94 if (dim==7) snprintf (tname, sizeof(tname), "%s[%d][%d][%d][%d][%d][%d][%d]", bname, array->extent(6), array->extent(5), array->extent(4), array->extent(3) 95 ,array->extent(2),array->extent(1),array->extent(0)); 96 status = TV_ttf_add_row("array_values", tname, array->dataFirst()) ; 97 if (status != TV_ttf_ec_ok) return TV_ttf_format_raw ; 98 else return TV_ttf_format_ok ; 99 } 100 } 101 102 103 static int TV_ttf_display_type ( const CAttributeArray<T_numtype,N_rank>* array ) 104 { 105 return CAttributeArray<T_numtype,N_rank>::show_TV_ttf_display_type (array) ; 106 } 67 107 68 108 private : … … 75 115 bool _fromBuffer(CBufferIn& buffer) ; 76 116 }; // class CAttributeEnum 117 118 119 #define macrotyperank(_TYPE_,_RANK_)\ 120 template<> int CAttributeArray<_TYPE_,_RANK_>::TV_ttf_display_type(const CAttributeArray<_TYPE_,_RANK_>* array ) \ 121 {\ 122 return CAttributeArray<_TYPE_,_RANK_>::show_TV_ttf_display_type (array) ;\ 123 } 124 125 #define macrotype(_TYPE_)\ 126 macrotyperank(_TYPE_,1)\ 127 macrotyperank(_TYPE_,2)\ 128 macrotyperank(_TYPE_,3)\ 129 macrotyperank(_TYPE_,4)\ 130 macrotyperank(_TYPE_,5)\ 131 macrotyperank(_TYPE_,6)\ 132 macrotyperank(_TYPE_,7) 133 134 macrotype(double) 135 macrotype(int) 136 macrotype(bool) 137 macrotype(size_t) 138 macrotype(float) 139 macrotype(string) 140 141 #undef macrotyperank 142 #undef macrotype 77 143 } // namespace xios 78 144 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/attribute_array_impl.hpp
r1622 r1875 14 14 CAttributeArray<T_numtype, N_rank>::CAttributeArray(const StdString & id) 15 15 : CAttribute(id) 16 { /* Ne rien faire de plus */}16 { bool alwaysFalse ; alwaysFalse=false ; if (alwaysFalse) TV_ttf_display_type(this); } 17 17 18 18 template <typename T_numtype, int N_rank> … … 20 20 : CAttribute(id) 21 21 { 22 bool alwaysFalse ; alwaysFalse=false ; if (alwaysFalse) TV_ttf_display_type(this); 22 23 this->setValue(value); 23 24 } … … 27 28 : CAttribute(id) 28 29 { 30 bool alwaysFalse ; alwaysFalse=false ; if (alwaysFalse) TV_ttf_display_type(this); 29 31 umap.insert(umap.end(), std::make_pair(id, this)); 30 32 } … … 35 37 : CAttribute(id) 36 38 { 39 bool alwaysFalse ; alwaysFalse=false ; if (alwaysFalse) TV_ttf_display_type(this); 37 40 this->setValue(value); 38 41 umap.insert(umap.end(), std::make_pair(id, this)); -
XIOS/dev/dev_ym/XIOS_COUPLING/src/attribute_template.hpp
r1622 r1875 12 12 #include "buffer_out.hpp" 13 13 #include "type.hpp" 14 #include "tv_data_display.h" 15 16 #ifdef __GNUC__ 17 #include <typeinfo> 18 #include <cxxabi.h> 19 #endif 14 20 15 21 namespace xios … … 20 26 The class implements attribute of some basic types 21 27 */ 22 template <class T>28 template <class T> 23 29 class CAttributeTemplate : public CAttribute, public CType<T> 24 30 { … … 91 97 // virtual void generateFortranInterfaceIsDefinedDeclaration(ostream& oss,const string& className) ; 92 98 99 static int show_TV_ttf_display_type ( const CAttributeTemplate<T>* attr) 100 { 101 int status ; 102 if (attr->isEmpty()) 103 { 104 status = TV_ttf_add_row("State", TV_ttf_type_ascii_string,"(empty)") ; 105 if (status != TV_ttf_ec_ok) return TV_ttf_format_raw ; 106 else return TV_ttf_format_ok_elide ; 107 } 108 else 109 { 110 char tname[128] ; 111 char bname[128] = "ValueType" ; 112 #ifdef __GNUC__ 113 size_t size = sizeof(bname) ; 114 abi::__cxa_demangle(typeid(T).name(), bname, &size, &status) ; 115 if (status !=0) return TV_ttf_format_raw ; 116 #endif 117 snprintf (tname, sizeof(tname), "%s", bname); 118 if (typeid(T)==typeid(string)) 119 status = TV_ttf_add_row("values", TV_ttf_type_ascii_string, ((string*)(attr->ptrValue))->c_str() ); 120 else status = TV_ttf_add_row("values", tname, attr->ptrValue) ; 121 if (status != TV_ttf_ec_ok) return TV_ttf_format_raw ; 122 else return TV_ttf_format_ok_elide ; 123 } 124 } 125 126 static int TV_ttf_display_type ( const CAttributeTemplate<T>* attr ) 127 { 128 return show_TV_ttf_display_type (attr) ; 129 } 130 93 131 94 132 protected : … … 107 145 }; // class CAttribute 108 146 147 #define macrotype(_TYPE_)\ 148 template<> int CAttributeTemplate<_TYPE_>::TV_ttf_display_type( const CAttributeTemplate<_TYPE_>* attr ) \ 149 {\ 150 return show_TV_ttf_display_type (attr) ;\ 151 } 152 153 macrotype(double) 154 macrotype(int) 155 macrotype(bool) 156 macrotype(string) 157 //macrotype(CDate) 158 //macrotype(CDuration) 159 #undef macrotype 109 160 110 161 template <class T> void FromBinary(StdIStream & is, T & obj); 162 111 163 112 164 } // namespace xios -
XIOS/dev/dev_ym/XIOS_COUPLING/src/buffer_decl.cpp
r501 r1875 17 17 macro(short) 18 18 macro(long) 19 macro(longlong) 19 20 macro(uint) 20 21 macro(ushort) 21 22 macro(ulong) 23 macro(ulonglong) 22 24 macro(float) 23 25 macro(double) -
XIOS/dev/dev_ym/XIOS_COUPLING/src/buffer_impl.hpp
r501 r1875 10 10 template <> bool CBuffer::put<short>(const short& data) { return put_template(data) ; } 11 11 template <> bool CBuffer::put<long>(const long& data) { return put_template(data) ; } 12 template <> bool CBuffer::put<longlong>(const longlong& data) { return put_template(data) ; } 12 13 template <> bool CBuffer::put<uint>(const uint& data) { return put_template(data) ; } 13 14 template <> bool CBuffer::put<ushort>(const ushort& data) { return put_template(data) ; } 14 15 template <> bool CBuffer::put<ulong>(const ulong& data) { return put_template(data) ; } 16 template <> bool CBuffer::put<ulonglong>(const ulonglong& data) { return put_template(data) ; } 15 17 template <> bool CBuffer::put<float>(const float& data) { return put_template(data) ; } 16 18 template <> bool CBuffer::put<double>(const double& data) { return put_template(data) ; } … … 21 23 template <> bool CBuffer::put<short>(const short* data, size_t n) { return put_template(data,n) ; } 22 24 template <> bool CBuffer::put<long>(const long* data, size_t n) { return put_template(data,n) ; } 25 template <> bool CBuffer::put<longlong>(const longlong* data, size_t n) { return put_template(data,n) ; } 23 26 template <> bool CBuffer::put<uint>(const uint* data, size_t n) { return put_template(data,n) ; } 24 27 template <> bool CBuffer::put<ushort>(const ushort* data, size_t n) { return put_template(data,n) ; } 25 28 template <> bool CBuffer::put<ulong>(const ulong* data, size_t n) { return put_template(data,n) ; } 29 template <> bool CBuffer::put<ulonglong>(const ulonglong* data, size_t n) { return put_template(data,n) ; } 26 30 template <> bool CBuffer::put<float>(const float* data, size_t n) { return put_template(data,n) ; } 27 31 template <> bool CBuffer::put<double>(const double* data, size_t n) { return put_template(data,n) ; } … … 33 37 template <> bool CBuffer::put_ptr<short>(const short*& data, size_t n) { return put_ptr_template(data,n) ; } 34 38 template <> bool CBuffer::put_ptr<long>(const long*& data, size_t n) { return put_ptr_template(data,n) ; } 39 template <> bool CBuffer::put_ptr<longlong>(const longlong*& data, size_t n) { return put_ptr_template(data,n) ; } 35 40 template <> bool CBuffer::put_ptr<uint>(const uint*& data, size_t n) { return put_ptr_template(data,n) ; } 36 41 template <> bool CBuffer::put_ptr<ushort>(const ushort*& data, size_t n) { return put_ptr_template(data,n) ; } 37 42 template <> bool CBuffer::put_ptr<ulong>(const ulong*& data, size_t n) { return put_ptr_template(data,n) ; } 43 template <> bool CBuffer::put_ptr<ulonglong>(const ulonglong*& data, size_t n) { return put_ptr_template(data,n) ; } 38 44 template <> bool CBuffer::put_ptr<float>(const float*& data, size_t n) { return put_ptr_template(data,n) ; } 39 45 template <> bool CBuffer::put_ptr<double>(const double*& data, size_t n) { return put_ptr_template(data,n) ; } … … 46 52 template <> bool CBuffer::get<short>(short& data) { return get_template(data) ; } 47 53 template <> bool CBuffer::get<long>(long& data) { return get_template(data) ; } 54 template <> bool CBuffer::get<longlong>(longlong& data) { return get_template(data) ; } 48 55 template <> bool CBuffer::get<uint>(uint& data) { return get_template(data) ; } 49 56 template <> bool CBuffer::get<ushort>(ushort& data) { return get_template(data) ; } 50 57 template <> bool CBuffer::get<ulong>(ulong& data) { return get_template(data) ; } 58 template <> bool CBuffer::get<ulonglong>(ulonglong& data) { return get_template(data) ; } 51 59 template <> bool CBuffer::get<float>(float& data) { return get_template(data) ; } 52 60 template <> bool CBuffer::get<double>(double& data) { return get_template(data) ; } … … 57 65 template <> bool CBuffer::get<short>(short* data, size_t n) { return get_template(data,n) ; } 58 66 template <> bool CBuffer::get<long>(long* data, size_t n) { return get_template(data,n) ; } 67 template <> bool CBuffer::get<longlong>(longlong* data, size_t n) { return get_template(data,n) ; } 59 68 template <> bool CBuffer::get<uint>(uint* data, size_t n) { return get_template(data,n) ; } 60 69 template <> bool CBuffer::get<ushort>(ushort* data, size_t n) { return get_template(data,n) ; } 61 70 template <> bool CBuffer::get<ulong>(ulong* data, size_t n) { return get_template(data,n) ; } 71 template <> bool CBuffer::get<ulonglong>(ulonglong* data, size_t n) { return get_template(data,n) ; } 62 72 template <> bool CBuffer::get<float>(float* data, size_t n) { return get_template(data,n) ; } 63 73 template <> bool CBuffer::get<double>(double* data, size_t n) { return get_template(data,n) ; } … … 68 78 template <> bool CBuffer::get_ptr<short>(short*& data, size_t n) { return get_ptr_template(data,n) ; } 69 79 template <> bool CBuffer::get_ptr<long>(long*& data, size_t n) { return get_ptr_template(data,n) ; } 80 template <> bool CBuffer::get_ptr<longlong>(longlong*& data, size_t n) { return get_ptr_template(data,n) ; } 70 81 template <> bool CBuffer::get_ptr<uint>(uint*& data, size_t n) { return get_ptr_template(data,n) ; } 71 82 template <> bool CBuffer::get_ptr<ushort>(ushort*& data, size_t n) { return get_ptr_template(data,n) ; } 72 83 template <> bool CBuffer::get_ptr<ulong>(ulong*& data, size_t n) { return get_ptr_template(data,n) ; } 84 template <> bool CBuffer::get_ptr<ulonglong>(ulonglong*& data, size_t n) { return get_ptr_template(data,n) ; } 73 85 template <> bool CBuffer::get_ptr<float>(float*& data, size_t n) { return get_ptr_template(data,n) ; } 74 86 template <> bool CBuffer::get_ptr<double>(double*& data, size_t n) { return get_ptr_template(data,n) ; } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/buffer_in_decl.cpp
r501 r1875 14 14 macro(short) 15 15 macro(long) 16 macro(longlong) 16 17 macro(uint) 17 18 macro(ushort) 18 19 macro(ulong) 20 macro(ulonglong) 19 21 macro(float) 20 22 macro(double) -
XIOS/dev/dev_ym/XIOS_COUPLING/src/buffer_in_impl.hpp
r501 r1875 12 12 template <> bool CBufferIn::get<short>(short& data) { return get_template(data) ; } 13 13 template <> bool CBufferIn::get<long>(long& data) { return get_template(data) ; } 14 template <> bool CBufferIn::get<longlong>(longlong& data) { return get_template(data) ; } 14 15 template <> bool CBufferIn::get<uint>(uint& data) { return get_template(data) ; } 15 16 template <> bool CBufferIn::get<ushort>(ushort& data) { return get_template(data) ; } 16 17 template <> bool CBufferIn::get<ulong>(ulong& data) { return get_template(data) ; } 18 template <> bool CBufferIn::get<ulonglong>(ulonglong& data) { return get_template(data) ; } 17 19 template <> bool CBufferIn::get<float>(float& data) { return get_template(data) ; } 18 20 template <> bool CBufferIn::get<double>(double& data) { return get_template(data) ; } … … 24 26 template <> bool CBufferIn::get<short>(short* data, size_t n) { return get_template(data,n) ; } 25 27 template <> bool CBufferIn::get<long>(long* data, size_t n) { return get_template(data,n) ; } 28 template <> bool CBufferIn::get<longlong>(longlong* data, size_t n) { return get_template(data,n) ; } 26 29 template <> bool CBufferIn::get<uint>(uint* data, size_t n) { return get_template(data,n) ; } 27 30 template <> bool CBufferIn::get<ushort>(ushort* data, size_t n) { return get_template(data,n) ; } 28 31 template <> bool CBufferIn::get<ulong>(ulong* data, size_t n) { return get_template(data,n) ; } 32 template <> bool CBufferIn::get<ulonglong>(ulonglong* data, size_t n) { return get_template(data,n) ; } 29 33 template <> bool CBufferIn::get<float>(float* data, size_t n) { return get_template(data,n) ; } 30 34 template <> bool CBufferIn::get<double>(double* data, size_t n) { return get_template(data,n) ; } … … 36 40 template <> bool CBufferIn::advance<short>(size_t n) { return advance_template<short>(n) ; } 37 41 template <> bool CBufferIn::advance<long>(size_t n) { return advance_template<long>(n) ; } 42 template <> bool CBufferIn::advance<longlong>(size_t n) { return advance_template<longlong>(n) ; } 38 43 template <> bool CBufferIn::advance<uint>(size_t n) { return advance_template<uint>(n) ; } 39 44 template <> bool CBufferIn::advance<ushort>(size_t n) { return advance_template<ushort>(n) ; } 40 45 template <> bool CBufferIn::advance<ulong>(size_t n) { return advance_template<ulong>(n) ; } 46 template <> bool CBufferIn::advance<ulonglong>(size_t n) { return advance_template<ulonglong>(n) ; } 41 47 template <> bool CBufferIn::advance<float>(size_t n) { return advance_template<float>(n) ; } 42 48 template <> bool CBufferIn::advance<double>(size_t n) { return advance_template<double>(n) ; } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/buffer_out_decl.cpp
r501 r1875 15 15 macro(short) 16 16 macro(long) 17 macro(longlong) 17 18 macro(uint) 18 19 macro(ushort) 19 20 macro(ulong) 21 macro(ulonglong) 20 22 macro(float) 21 23 macro(double) -
XIOS/dev/dev_ym/XIOS_COUPLING/src/buffer_out_impl.hpp
r501 r1875 11 11 template <> bool CBufferOut::put<short>(const short& data) { return put_template(data) ; } 12 12 template <> bool CBufferOut::put<long>(const long& data) { return put_template(data) ; } 13 template <> bool CBufferOut::put<longlong>(const longlong& data) { return put_template(data) ; } 13 14 template <> bool CBufferOut::put<uint>(const uint& data) { return put_template(data) ; } 14 15 template <> bool CBufferOut::put<ushort>(const ushort& data) { return put_template(data) ; } 15 16 template <> bool CBufferOut::put<ulong>(const ulong& data) { return put_template(data) ; } 17 template <> bool CBufferOut::put<ulonglong>(const ulonglong& data) { return put_template(data) ; } 16 18 template <> bool CBufferOut::put<float>(const float& data) { return put_template(data) ; } 17 19 template <> bool CBufferOut::put<double>(const double& data) { return put_template(data) ; } … … 23 25 template <> bool CBufferOut::put<short>(const short* data, size_t n) { return put_template(data,n) ; } 24 26 template <> bool CBufferOut::put<long>(const long* data, size_t n) { return put_template(data,n) ; } 27 template <> bool CBufferOut::put<longlong>(const longlong* data, size_t n) { return put_template(data,n) ; } 25 28 template <> bool CBufferOut::put<uint>(const uint* data, size_t n) { return put_template(data,n) ; } 26 29 template <> bool CBufferOut::put<ushort>(const ushort* data, size_t n) { return put_template(data,n) ; } 27 30 template <> bool CBufferOut::put<ulong>(const ulong* data, size_t n) { return put_template(data,n) ; } 31 template <> bool CBufferOut::put<ulonglong>(const ulonglong* data, size_t n) { return put_template(data,n) ; } 28 32 template <> bool CBufferOut::put<float>(const float* data, size_t n) { return put_template(data,n) ; } 29 33 template <> bool CBufferOut::put<double>(const double* data, size_t n) { return put_template(data,n) ; } … … 36 40 template <> bool CBufferOut::advance<short>(size_t n) { return advance_template<short>(n) ; } 37 41 template <> bool CBufferOut::advance<long>(size_t n) { return advance_template<long>(n) ; } 42 template <> bool CBufferOut::advance<longlong>(size_t n) { return advance_template<longlong>(n) ; } 38 43 template <> bool CBufferOut::advance<uint>(size_t n) { return advance_template<uint>(n) ; } 39 44 template <> bool CBufferOut::advance<ushort>(size_t n) { return advance_template<ushort>(n) ; } 40 45 template <> bool CBufferOut::advance<ulong>(size_t n) { return advance_template<ulong>(n) ; } 46 template <> bool CBufferOut::advance<ulonglong>(size_t n) { return advance_template<ulonglong>(n) ; } 41 47 template <> bool CBufferOut::advance<float>(size_t n) { return advance_template<float>(n) ; } 42 48 template <> bool CBufferOut::advance<double>(size_t n) { return advance_template<double>(n) ; } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/context_server.cpp
r1853 r1875 326 326 // The best way to properly solve this problem will be to use the event scheduler also in attached mode 327 327 // for now just set up a MPI barrier 328 if (!eventScheduler_ && CXios::isServer) MPI_Barrier(intraComm) ; 328 //ym to be check later 329 // if (!eventScheduler_ && CXios::isServer) MPI_Barrier(intraComm) ; 329 330 330 331 // context->setProcessingEvent() ; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/declare_attribute.hpp
r1229 r1875 42 42 public : \ 43 43 using CAttributeArray<T_num, T_rank>::operator = ; \ 44 name##_attr(void) : CAttributeArray<T_num, T_rank> (#name, *CAttributeMap::Current) {} \ 44 bool alwaysFalse=false;\ 45 name##_attr(void) : CAttributeArray<T_num, T_rank> (#name, *CAttributeMap::Current) {if (alwaysFalse) TV_ttf_display_type(this);} \ 45 46 virtual bool doSend() const { return helper(__VA_ARGS__); } \ 46 47 bool helper(bool returnTrue=true) const { return returnTrue; } \ 48 static int TV_ttf_display_type ( const name##_attr* array )\ 49 {\ 50 cout<<"TV_ttf_display_type"<<endl ;\ 51 return CArray<T_num,T_rank>::TV_ttf_display_type((const CArray<T_num,T_rank>*)array) ;\ 52 }\ 47 53 virtual ~name##_attr(void) {} \ 48 54 } name; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/filter/file_writer_filter.cpp
r1853 r1875 35 35 } 36 36 37 field->sendUpdateData(data Array, client_);37 field->sendUpdateData(data[0]->timestamp, dataArray, client_); 38 38 } 39 39 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/filter/spatial_transform_filter.cpp
r1869 r1875 174 174 gridTransformation->computeAll(dataAuxInputs, packet->timestamp); 175 175 } 176 packet->data.resize(gridTransformation->getGridDestination()->get DataSize());176 packet->data.resize(gridTransformation->getGridDestination()->getLocalDataSize()); 177 177 if (0 != packet->data.numElements()) 178 178 (packet->data)(0) = defaultValue; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/group_template.hpp
r1784 r1875 72 72 void addChildGroup(V* childGroup) ; 73 73 static bool dispatchEvent(CEventServer& event) ; 74 void sendCreateChild(const string& id, CContextClient* client ) ;75 void sendCreateChildGroup(const string& id, CContextClient* client ) ;74 void sendCreateChild(const string& id, CContextClient* client, const string& objectId="") ; 75 void sendCreateChildGroup(const string& id, CContextClient* client, const string& objectId="") ; 76 76 static void recvCreateChild(CEventServer& event) ; 77 77 void recvCreateChild(CBufferIn& buffer) ; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/group_template_impl.hpp
r1784 r1875 370 370 371 371 template <class U, class V, class W> 372 void CGroupTemplate<U, V, W>::sendCreateChild(const string& id, CContextClient* client )372 void CGroupTemplate<U, V, W>::sendCreateChild(const string& id, CContextClient* client, const string& objectId) 373 373 { 374 374 … … 377 377 { 378 378 CMessage msg ; 379 msg<<this->getId() ; 379 if (objectId.empty()) msg << this->getId(); 380 else msg << objectId; 380 381 msg<<id ; 381 382 const std::list<int>& ranks = client->getRanksServerLeader(); … … 388 389 389 390 template <class U, class V, class W> 390 void CGroupTemplate<U, V, W>::sendCreateChildGroup(const string& id, CContextClient* client )391 void CGroupTemplate<U, V, W>::sendCreateChildGroup(const string& id, CContextClient* client, const string& objectId) 391 392 { 392 393 CEventClient event(this->getType(),EVENT_ID_CREATE_CHILD_GROUP) ; … … 394 395 { 395 396 CMessage msg ; 396 msg<<this->getId() ; 397 if (objectId.empty()) msg << this->getId(); 398 else msg << objectId; 397 399 msg<<id ; 398 400 const std::list<int>& ranks = client->getRanksServerLeader(); -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.cpp
r1872 r1875 575 575 } 576 576 577 void CAxis::sendAxisToCouplerOut(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, const string& fieldId, int posInGrid) 578 { 579 if (sendAxisToFileServer_done_.count(client)!=0) return ; 580 else sendAxisToFileServer_done_.insert(client) ; 581 582 string axisId="_axis["+std::to_string(posInGrid)+"]_of_"+fieldId ; 583 584 if (!axis_ref.isEmpty()) 585 { 586 auto axis_ref_tmp=axis_ref.getValue() ; 587 axis_ref.reset() ; // remove the reference, find an other way to do that more cleanly 588 this->sendAllAttributesToServer(client, axisId) ; 589 axis_ref = axis_ref_tmp ; 590 } 591 else this->sendAllAttributesToServer(client, axisId) ; 592 593 this->sendAttributes(client, globalDim, orderPositionInGrid, CServerDistributionDescription::BAND_DISTRIBUTION, axisId) ; 594 } 595 596 void CAxis::makeAliasForCoupling(const string& fieldId, int posInGrid) 597 { 598 const string axisId = "_axis["+std::to_string(posInGrid)+"]_of_"+fieldId ; 599 this->createAlias(axisId) ; 600 } 601 577 602 /*! 578 603 Send attributes from one client to other clients … … 581 606 */ 582 607 void CAxis::sendAttributes(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, 583 CServerDistributionDescription::ServerDistributionType distType )584 TRY 585 { 586 sendDistributionAttribute(client, globalDim, orderPositionInGrid, distType );608 CServerDistributionDescription::ServerDistributionType distType, const string& axisId) 609 TRY 610 { 611 sendDistributionAttribute(client, globalDim, orderPositionInGrid, distType, axisId); 587 612 588 613 // if (index.numElements() == n_glo.getValue()) … … 590 615 || (index.numElements() != n_glo)) 591 616 { 592 sendDistributedAttributes(client );617 sendDistributedAttributes(client, axisId); 593 618 } 594 619 else 595 620 { 596 sendNonDistributedAttributes(client );621 sendNonDistributedAttributes(client, axisId); 597 622 } 598 623 } … … 889 914 */ 890 915 void CAxis::sendDistributionAttribute(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, 891 CServerDistributionDescription::ServerDistributionType distType) 892 TRY 893 { 916 CServerDistributionDescription::ServerDistributionType distType, const string& axisId) 917 TRY 918 { 919 string serverAxisId = axisId.empty() ? this->getId() : axisId ; 894 920 int nbServer = client->serverSize; 895 921 … … 914 940 msgs.push_back(CMessage()); 915 941 CMessage& msg = msgs.back(); 916 msg << this->getId();942 msg << serverAxisId; 917 943 msg << ni << begin; 918 944 msg << isCompressible_; … … 962 988 In the future, if new attributes are added, they should also be processed in this function 963 989 */ 964 void CAxis::sendNonDistributedAttributes(CContextClient* client) 965 TRY 966 { 990 void CAxis::sendNonDistributedAttributes(CContextClient* client, const string& axisId) 991 TRY 992 { 993 string serverAxisId = axisId.empty() ? this->getId() : axisId ; 994 967 995 CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES); 968 996 size_t nbIndex = index.numElements(); … … 996 1024 msgs.push_back(CMessage()); 997 1025 CMessage& msg = msgs.back(); 998 msg << this->getId();1026 msg << serverAxisId; 999 1027 msg << index.getValue() << dataIndex << mask.getValue(); 1000 1028 msg << hasValue; … … 1087 1115 In future, if new attributes are added, they should also be processed in this function 1088 1116 */ 1089 void CAxis::sendDistributedAttributes(CContextClient* client) 1090 TRY 1091 { 1117 void CAxis::sendDistributedAttributes(CContextClient* client, const string& axisId) 1118 TRY 1119 { 1120 string serverAxisId = axisId.empty() ? this->getId() : axisId ; 1121 1092 1122 int ind, idx; 1093 1123 int nbServer = client->serverSize; … … 1166 1196 1167 1197 listData.push_back(CMessage()); 1168 listData.back() << this->getId()1198 listData.back() << serverAxisId 1169 1199 << list_indi.back() << list_dataInd.back(); 1170 1200 … … 1431 1461 CATCH_DUMP_ATTR 1432 1462 1433 /*!1434 \brief Check if a axis is completed1435 Before make any axis processing, we must be sure that all axis informations have1436 been sent, for exemple when reading a grid in a file or when grid elements are sent by an1437 other context (coupling). So all direct reference of the axis (axis_ref) must be also completed1438 \return true if axis and axis reference are completed1439 */1440 bool CAxis::checkIfCompleted(void)1441 {1442 if (hasDirectAxisReference()) if (!getDirectAxisReference()->checkIfCompleted()) return false;1443 return isCompleted_ ;1444 }1445 1446 /*!1447 \brief Set a axis as completed1448 When all information about a axis have been received, the axis is tagged as completed and is1449 suitable for processing1450 */1451 void CAxis::setCompleted(void)1452 {1453 if (hasDirectAxisReference()) getDirectAxisReference()->setCompleted() ;1454 isCompleted_=true ;1455 }1456 1457 /*!1458 \brief Set a axis as uncompleted1459 When informations about a axis are expected from a grid reading from file or coupling, the axis is1460 tagged as uncompleted and is not suitable for processing1461 */1462 void CAxis::setUncompleted(void)1463 {1464 if (hasDirectAxisReference()) getDirectAxisReference()->setUncompleted() ;1465 isCompleted_=false ;1466 }1467 1468 1469 1470 1463 /*! 1471 1464 * Go through the hierarchy to find the axis from which the transformations must be inherited -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp
r1870 r1875 124 124 bool isEqual(CAxis* axis); 125 125 126 bool checkIfCompleted(void) ;127 void setCompleted(void) ;128 void setUncompleted(void) ;129 130 126 public: 131 127 bool hasValue; … … 150 146 std::set<CContextClient*> sendAxisToFileServer_done_ ; 151 147 148 public: 149 void sendAxisToCouplerOut(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, const string& fieldId, int posInGrid) ; 150 private: 151 std::set<CContextClient*> sendAxisToCouplerOut_done_ ; 152 153 public: 154 void makeAliasForCoupling(const string& fieldId, int posInGrid) ; 155 152 156 private: 153 157 void sendAttributes(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, 154 CServerDistributionDescription::ServerDistributionType distType );158 CServerDistributionDescription::ServerDistributionType distType, const string& axisId=""); 155 159 void sendDistributionAttribute(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, 156 CServerDistributionDescription::ServerDistributionType distType );157 158 159 void sendNonDistributedAttributes(CContextClient* client );160 void sendDistributedAttributes(CContextClient* client );160 CServerDistributionDescription::ServerDistributionType distType, const string& axisId=""); 161 162 163 void sendNonDistributedAttributes(CContextClient* client, const string& axisId=""); 164 void sendDistributedAttributes(CContextClient* client, const string& axisId=""); 161 165 162 166 static void recvNonDistributedAttributes(CEventServer& event); … … 171 175 private: 172 176 173 /** Clients that have to send a domain. There can be multiple clients in case of secondary server, otherwise only one client. */177 /** Clients that have to send a axis. There can be multiple clients in case of secondary server, otherwise only one client. */ 174 178 std::list<CContextClient*> clients; 175 179 std::set<CContextClient*> clientsSet; 176 180 181 private: 177 182 /** define if the axis is completed or not ie all attributes have been received before in case 178 183 of grid reading from file or coupling */ 179 184 bool isCompleted_=true ; 180 185 public: 186 /*! 187 \brief Check if a axis is completed 188 Before make any axis processing, we must be sure that all axis informations have 189 been sent, for exemple when reading a grid in a file or when grid elements are sent by an 190 other context (coupling). So all direct reference of the axis (axis_ref) must be also completed 191 \return true if axis and axis reference are completed 192 */ 193 bool isCompleted(void) 194 { 195 if (hasDirectAxisReference()) if (!getDirectAxisReference()->isCompleted()) return false; 196 else return isCompleted_ ; 197 } 198 void setCompleted(void) { isCompleted_=true ; } 199 void unsetCompleted(void) { isCompleted_=false ; } 200 201 private: 181 202 bool isChecked; 182 203 bool areClientAttributesChecked_; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.cpp
r1872 r1875 708 708 } 709 709 710 for (auto it=couplerClient_.begin(); it!=couplerClient_.end(); ++it) 711 { 712 if (!finalized) it->second->checkBuffers(); 713 } 714 715 for (auto it=couplerServer_.begin(); it!=couplerServer_.end(); ++it) 716 { 717 if (!finalized) it->second->eventLoop(enableEventsProcessing); 718 } 719 710 for (auto couplerOut : couplerOutClient_) 711 if (!finalized) couplerOut.second->checkBuffers(); 712 713 for (auto couplerIn : couplerInClient_) 714 if (!finalized) couplerIn.second->checkBuffers(); 715 716 for (auto couplerOut : couplerOutServer_) 717 if (!finalized) couplerOut.second->eventLoop(enableEventsProcessing); 718 719 for (auto couplerIn : couplerInServer_) 720 if (!finalized) couplerIn.second->eventLoop(enableEventsProcessing); 721 720 722 if (server!=nullptr) if (!finalized) finished &= server->eventLoop(enableEventsProcessing); 721 723 … … 723 725 } 724 726 725 void CContext::addCouplingChanel(const std::string& context, bool out)727 void CContext::addCouplingChanel(const std::string& fullContextId, bool out) 726 728 { 727 vector<string> vectStr=splitRegex(context,"::") ;728 string poolId=vectStr[0] ;729 string serviceId=poolId ;730 string contextId=vectStr[1] ;731 732 729 int contextLeader ; 733 int type = CServicesManager::CLIENT ;734 string contextName=CXios::getContextsManager()->getServerContextName(poolId, serviceId, 0, type, contextId) ;735 730 736 if (couplerClient_.find(contextName)==couplerClient_.end()) 737 { 738 bool ok=CXios::getContextsManager()->getContextLeader(contextName, contextLeader, getIntraComm()) ; 731 if (out) 732 { 733 if (couplerOutClient_.find(fullContextId)==couplerOutClient_.end()) 734 { 735 bool ok=CXios::getContextsManager()->getContextLeader(fullContextId, contextLeader, getIntraComm()) ; 739 736 740 MPI_Comm interComm, interCommClient, interCommServer ; 741 MPI_Comm intraCommClient, intraCommServer ; 742 743 if (ok) MPI_Intercomm_create(getIntraComm(), 0, CXios::getXiosComm(), contextLeader, 0, &interComm) ; 744 745 MPI_Comm_dup(intraComm_, &intraCommClient) ; 746 MPI_Comm_dup(intraComm_, &intraCommServer) ; 747 if (out) 748 { 749 MPI_Comm_dup(interComm, &interCommClient) ; 750 MPI_Comm_dup(interComm, &interCommServer) ; 751 CContextClient* client = new CContextClient(this, intraCommClient, interCommClient); 752 CContextServer* server = new CContextServer(this, intraCommServer, interCommServer); 753 client->setAssociatedServer(server) ; 754 server->setAssociatedClient(client) ; 755 } 756 else 757 { 758 MPI_Comm_dup(interComm, &interCommServer) ; 759 MPI_Comm_dup(interComm, &interCommClient) ; 760 CContextServer* server = new CContextServer(this, intraCommServer, interCommServer); 761 CContextClient* client = new CContextClient(this, intraCommClient, interCommClient); 762 client->setAssociatedServer(server) ; 763 server->setAssociatedClient(client) ; 764 } 765 MPI_Comm_free(&interComm) ; 766 767 737 MPI_Comm interComm, interCommClient, interCommServer ; 738 MPI_Comm intraCommClient, intraCommServer ; 739 740 if (ok) MPI_Intercomm_create(getIntraComm(), 0, CXios::getXiosComm(), contextLeader, 0, &interComm) ; 741 742 MPI_Comm_dup(intraComm_, &intraCommClient) ; 743 MPI_Comm_dup(intraComm_, &intraCommServer) ; 744 MPI_Comm_dup(interComm, &interCommClient) ; 745 MPI_Comm_dup(interComm, &interCommServer) ; 746 CContextClient* client = new CContextClient(this, intraCommClient, interCommClient); 747 CContextServer* server = new CContextServer(this, intraCommServer, interCommServer); 748 client->setAssociatedServer(server) ; 749 server->setAssociatedClient(client) ; 750 MPI_Comm_free(&interComm) ; 751 couplerOutClient_[fullContextId] = client ; 752 couplerOutServer_[fullContextId] = server ; 753 754 /* 768 755 // for now, we don't now which beffer size must be used for client coupler 769 756 // It will be evaluated later. Fix a constant size for now... … … 777 764 778 765 client->setBufferSize(bufferSize, maxEventSize); 779 780 couplerClient_[contextName] = client ; 781 couplerServer_[contextName] = server ; 782 } 766 */ 767 } 768 } 769 else if (couplerInClient_.find(fullContextId)==couplerInClient_.end()) 770 { 771 bool ok=CXios::getContextsManager()->getContextLeader(fullContextId, contextLeader, getIntraComm()) ; 772 773 MPI_Comm interComm, interCommClient, interCommServer ; 774 MPI_Comm intraCommClient, intraCommServer ; 775 776 if (ok) MPI_Intercomm_create(getIntraComm(), 0, CXios::getXiosComm(), contextLeader, 0, &interComm) ; 777 778 MPI_Comm_dup(intraComm_, &intraCommClient) ; 779 MPI_Comm_dup(intraComm_, &intraCommServer) ; 780 MPI_Comm_dup(interComm, &interCommServer) ; 781 MPI_Comm_dup(interComm, &interCommClient) ; 782 CContextServer* server = new CContextServer(this, intraCommServer, interCommServer); 783 CContextClient* client = new CContextClient(this, intraCommClient, interCommClient); 784 client->setAssociatedServer(server) ; 785 server->setAssociatedClient(client) ; 786 MPI_Comm_free(&interComm) ; 787 788 map<int,size_t> bufferSize, maxEventSize ; 789 for(int i=0;i<client->getRemoteSize();i++) 790 { 791 bufferSize[i]=10000000 ; 792 maxEventSize[i]=10000000 ; 793 } 794 795 client->setBufferSize(bufferSize, maxEventSize); 796 couplerInClient_[fullContextId] = client ; 797 couplerInServer_[fullContextId] = server ; 798 } 783 799 } 784 800 … … 798 814 if (serviceType_==CServicesManager::CLIENT) 799 815 { 800 doPreTimestepOperationsForEnabledReadModeFiles(); // For now we only use server level 1 to read data 816 //ym doPreTimestepOperationsForEnabledReadModeFiles(); // For now we only use server level 1 to read data 817 818 triggerLateFields() ; 819 820 // inform couplerIn that I am finished 821 for(auto& couplerInClient : couplerInClient_) sendCouplerInContextFinalized(couplerInClient.second) ; 822 823 // wait until received message from couplerOut that they have finished 824 bool couplersInFinalized ; 825 do 826 { 827 couplersInFinalized=true ; 828 for(auto& couplerOutClient : couplerOutClient_) couplersInFinalized &= isCouplerInContextFinalized(couplerOutClient.second) ; 829 globalEventLoop() ; 830 } while (!couplersInFinalized) ; 801 831 802 832 info(100)<<"DEBUG: context "<<getId()<<" Send client finalize"<<endl ; … … 1055 1085 vector<CField*>&& fileOutField = findAllEnabledFieldsInFileOut(this->enabledWriteModeFiles); 1056 1086 vector<CField*>&& fileInField = findAllEnabledFieldsInFileIn(this->enabledReadModeFiles); 1057 vector<CField*>&& CouplerOutField = findAllEnabledFieldsCouplerOut(this->enabledCouplerOut);1058 vector<CField*>&& CouplerInField = findAllEnabledFieldsCouplerIn(this->enabledCouplerIn);1087 vector<CField*>&& couplerOutField = findAllEnabledFieldsCouplerOut(this->enabledCouplerOut); 1088 vector<CField*>&& couplerInField = findAllEnabledFieldsCouplerIn(this->enabledCouplerIn); 1059 1089 findFieldsWithReadAccess(); 1060 1090 vector<CField*>& fieldWithReadAccess = fieldsWithReadAccess_ ; … … 1073 1103 } 1074 1104 1075 1076 1105 1106 for (auto& field : couplerInField) 1107 { 1108 field->unsetGridCompleted() ; 1109 } 1077 1110 // find all field potentially at workflow end 1078 1111 vector<CField*> endWorkflowFields ; 1079 endWorkflowFields.reserve(fileOutField.size()+ CouplerOutField.size()+fieldWithReadAccess.size()) ;1112 endWorkflowFields.reserve(fileOutField.size()+couplerOutField.size()+fieldWithReadAccess.size()) ; 1080 1113 endWorkflowFields.insert(endWorkflowFields.end(),fileOutField.begin(), fileOutField.end()) ; 1081 endWorkflowFields.insert(endWorkflowFields.end(), CouplerOutField.begin(), CouplerOutField.end()) ;1114 endWorkflowFields.insert(endWorkflowFields.end(),couplerOutField.begin(), couplerOutField.end()) ; 1082 1115 endWorkflowFields.insert(endWorkflowFields.end(),fieldWithReadAccess.begin(), fieldWithReadAccess.end()) ; 1083 1116 1084 for(auto endWorkflowField : endWorkflowFields) endWorkflowField->buildWorkflowGraph(garbageCollector) ; 1117 bool workflowGraphIsCompleted ; 1118 1119 bool first=true ; 1120 do 1121 { 1122 workflowGraphIsCompleted=true; 1123 for(auto endWorkflowField : endWorkflowFields) 1124 { 1125 workflowGraphIsCompleted &= endWorkflowField->buildWorkflowGraph(garbageCollector) ; 1126 } 1127 1128 for(auto couplerIn : enabledCouplerIn) couplerIn->assignContext() ; 1129 for(auto field : couplerInField) field->makeGridAliasForCoupling(); 1130 for(auto field : couplerInField) this->sendCouplerInReady(field->getContextClient()) ; 1085 1131 1132 1133 // assign context to coupler out and related fields 1134 for(auto couplerOut : enabledCouplerOut) couplerOut->assignContext() ; 1135 // for now supose that all coupling out endpoint are succesfull. The difficultie is client/server buffer evaluation 1136 for(auto field : couplerOutField) 1137 { 1138 field->computeGridIndexToFileServer() ; // same kind of index than for file server -> in future distribution may change 1139 } 1140 if (first) setClientServerBuffer(couplerOutField, true) ; // set buffer context 1141 1142 bool couplersReady ; 1143 do 1144 { 1145 couplersReady=true ; 1146 for(auto field : couplerOutField) 1147 { 1148 bool ready = isCouplerInReady(field->getContextClient()) ; 1149 if (ready) field->sendFieldToCouplerOut() ; 1150 couplersReady &= ready ; 1151 } 1152 if (!couplersReady) this->eventLoop() ; 1153 } while (!couplersReady) ; 1154 1155 first=false ; 1156 this->eventLoop() ; 1157 } while (!workflowGraphIsCompleted) ; 1158 1159 for( auto field : couplerInField) couplerInFields_.push_back(field) ; 1160 1086 1161 // get all field coming potentially from model 1087 1162 for (auto field : CField::getAll() ) if (field->getModelIn()) fieldModelIn.push_back(field) ; … … 1101 1176 field->computeGridIndexToFileServer() ; // compute grid index for transfer to the server context 1102 1177 } 1103 setClientServerBuffer(fileOutField, true) ; // set context1178 setClientServerBuffer(fileOutField, true) ; // set buffer context 1104 1179 for(auto field : fileOutField) field->sendFieldToFileServer() ; 1105 1180 } … … 1146 1221 } 1147 1222 1223 1224 for(auto field : couplerInField) 1225 { 1226 field->connectToCouplerIn(garbageCollector) ; // connect the field to server filter 1227 } 1228 1229 1230 for(auto field : couplerOutField) 1231 { 1232 field->connectToCouplerOut(garbageCollector) ; // for now the same kind of filter that for file server 1233 } 1234 1148 1235 // workflow startpoint => data from server on client side 1149 1236 if (serviceType_==CServicesManager::CLIENT) … … 1151 1238 for(auto field : fileInField) 1152 1239 { 1153 field->connectToServerInput(garbageCollector) ; // connect t he field to server filter1240 field->connectToServerInput(garbageCollector) ; // connect tFhe field to server filter 1154 1241 field->computeGridIndexToFileServer() ; // compute grid index for transfer to the server context 1155 1242 field->sendFieldToInputFileServer() ; … … 1162 1249 // no filter for reading data from file => to be implemented 1163 1250 } 1164 1165 1166 if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER) this->sendCloseDefinition(); 1251 1252 // construct slave server list 1253 if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER) 1254 { 1255 for(auto field : fileOutField) slaveServers_.insert(field->getContextClient()) ; 1256 for(auto field : fileInField) slaveServers_.insert(field->getContextClient()) ; 1257 } 1258 1259 for(auto& slaveServer : slaveServers_) sendCloseDefinition(slaveServer) ; 1260 1167 1261 if (serviceType_==CServicesManager::IO_SERVER || serviceType_==CServicesManager::OUT_SERVER) 1168 1262 { … … 1172 1266 if (serviceType_==CServicesManager::CLIENT) startPrefetchingOfEnabledReadModeFiles(); 1173 1267 1174 1175 1268 // send signal to couplerIn context that definition phasis is done 1269 1270 for(auto& couplerInClient : couplerInClient_) sendCouplerInCloseDefinition(couplerInClient.second) ; 1271 1272 // wait until all couplerIn signal that closeDefition is done. 1273 bool ok; 1274 do 1275 { 1276 ok = true ; 1277 for(auto& couplerOutClient : couplerOutClient_) ok &= isCouplerInCloseDefinition(couplerOutClient.second) ; 1278 this->eventLoop() ; 1279 } while (!ok) ; 1176 1280 1177 1281 return ; 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1178 1292 // For now, only read files with client and only one level server 1179 1293 // if (hasClient && !hasServer) findEnabledReadModeFiles(); … … 1987 2101 recvPostProcessing(event); 1988 2102 return true; 1989 2103 case EVENT_ID_SEND_REGISTRY: 1990 2104 recvRegistry(event); 1991 2105 return true; 1992 2106 break; 1993 2107 case EVENT_ID_POST_PROCESS_GLOBAL_ATTRIBUTES: 1994 2108 recvPostProcessingGlobalAttributes(event); 1995 2109 return true; 1996 2110 break; 1997 2111 case EVENT_ID_PROCESS_GRID_ENABLED_FIELDS: 1998 2112 recvProcessingGridOfEnabledFields(event); 1999 2113 return true; 2000 2114 break; 2115 case EVENT_ID_COUPLER_IN_READY: 2116 recvCouplerInReady(event); 2117 return true; 2118 break; 2119 case EVENT_ID_COUPLER_IN_CLOSE_DEFINITION: 2120 recvCouplerInCloseDefinition(event); 2121 return true; 2122 break; 2123 case EVENT_ID_COUPLER_IN_CONTEXT_FINALIZED: 2124 recvCouplerInContextFinalized(event); 2125 return true; 2126 break; 2001 2127 default : 2002 2128 ERROR("bool CContext::dispatchEvent(CEventServer& event)", … … 2009 2135 2010 2136 //! Client side: Send a message to server to make it close 2137 // ym obsolete 2011 2138 void CContext::sendCloseDefinition(void) 2012 2139 TRY … … 2035 2162 } 2036 2163 CATCH_DUMP_ATTR 2164 2165 // ! Client side: Send a message to server to make it close 2166 void CContext::sendCloseDefinition(CContextClient* client) 2167 TRY 2168 { 2169 if (sendCloseDefinition_done_.count(client)!=0) return ; 2170 else sendCloseDefinition_done_.insert(client) ; 2171 2172 CEventClient event(getType(),EVENT_ID_CLOSE_DEFINITION); 2173 if (client->isServerLeader()) 2174 { 2175 CMessage msg; 2176 for(auto rank : client->getRanksServerLeader()) event.push(rank,1,msg); 2177 client->sendEvent(event); 2178 } 2179 else client->sendEvent(event); 2180 } 2181 CATCH_DUMP_ATTR 2037 2182 2038 2183 //! Server side: Receive a message of client announcing a context close … … 2049 2194 TRY 2050 2195 { 2051 int nbSrvPools ; 2052 if (serviceType_==CServicesManager::CLIENT) nbSrvPools = 1 ; 2053 else if (serviceType_==CServicesManager::GATHERER) nbSrvPools = this->clientPrimServer.size() ; 2054 else nbSrvPools = 0 ; 2055 CContextClient* contextClientTmp ; 2056 2057 for (int i = 0; i < nbSrvPools; ++i) 2058 { 2059 if (serviceType_==CServicesManager::CLIENT) contextClientTmp = client ; 2060 else if (serviceType_==CServicesManager::GATHERER ) contextClientTmp = clientPrimServer[i] ; 2061 CEventClient event(getType(),EVENT_ID_UPDATE_CALENDAR); 2062 2063 if (contextClientTmp->isServerLeader()) 2064 { 2065 CMessage msg; 2066 msg<<step; 2067 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 2068 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 2069 event.push(*itRank,1,msg); 2070 contextClientTmp->sendEvent(event); 2071 } 2072 else contextClientTmp->sendEvent(event); 2196 CEventClient event(getType(),EVENT_ID_UPDATE_CALENDAR); 2197 for(auto client : slaveServers_) 2198 { 2199 if (client->isServerLeader()) 2200 { 2201 CMessage msg; 2202 msg<<step; 2203 for (auto& rank : client->getRanksServerLeader() ) event.push(rank,1,msg); 2204 client->sendEvent(event); 2205 } 2206 else client->sendEvent(event); 2073 2207 } 2074 2208 } … … 2580 2714 CATCH_DUMP_ATTR 2581 2715 2716 void CContext::triggerLateFields(void) 2717 TRY 2718 { 2719 for(auto& field : fileInFields_) field->triggerLateField() ; 2720 for(auto& field : couplerInFields_) field->triggerLateField() ; 2721 } 2722 CATCH_DUMP_ATTR 2723 2582 2724 //! Update calendar in each time step 2583 2725 void CContext::updateCalendar(int step) … … 2590 2732 if (serviceType_==CServicesManager::CLIENT) // For now we only use server level 1 to read data 2591 2733 { 2592 doPreTimestepOperationsForEnabledReadModeFiles();2734 triggerLateFields(); 2593 2735 } 2594 2736 … … 2771 2913 } 2772 2914 CATCH_DUMP_ATTR 2915 2916 2917 2918 2919 //! Client side: Send a message announcing that context can receive grid definition from coupling 2920 void CContext::sendCouplerInReady(CContextClient* client) 2921 TRY 2922 { 2923 if (sendCouplerInReady_done_.count(client)!=0) return ; 2924 else sendCouplerInReady_done_.insert(client) ; 2925 2926 CEventClient event(getType(),EVENT_ID_COUPLER_IN_READY); 2927 2928 if (client->isServerLeader()) 2929 { 2930 CMessage msg; 2931 msg<<this->getId(); 2932 for (auto& rank : client->getRanksServerLeader()) event.push(rank,1,msg); 2933 client->sendEvent(event); 2934 } 2935 else client->sendEvent(event); 2936 } 2937 CATCH_DUMP_ATTR 2938 2939 //! Server side: Receive a message announcing that context can send grid definition for context coupling 2940 void CContext::recvCouplerInReady(CEventServer& event) 2941 TRY 2942 { 2943 CBufferIn* buffer=event.subEvents.begin()->buffer; 2944 getCurrent()->recvCouplerInReady(*buffer); 2945 } 2946 CATCH 2947 2948 //! Server side: Receive a message announcing that context can send grid definition for context coupling 2949 void CContext::recvCouplerInReady(CBufferIn& buffer) 2950 TRY 2951 { 2952 string contextId ; 2953 buffer>>contextId; 2954 couplerInReady_.insert(getCouplerOutClient(contextId)) ; 2955 } 2956 CATCH_DUMP_ATTR 2957 2958 2959 2960 2961 2962 //! Client side: Send a message announcing that a coupling context have done it closeDefinition, so data can be sent now. 2963 void CContext::sendCouplerInCloseDefinition(CContextClient* client) 2964 TRY 2965 { 2966 if (sendCouplerInCloseDefinition_done_.count(client)!=0) return ; 2967 else sendCouplerInCloseDefinition_done_.insert(client) ; 2968 2969 CEventClient event(getType(),EVENT_ID_COUPLER_IN_CLOSE_DEFINITION); 2970 2971 if (client->isServerLeader()) 2972 { 2973 CMessage msg; 2974 msg<<this->getId(); 2975 for (auto& rank : client->getRanksServerLeader()) event.push(rank,1,msg); 2976 client->sendEvent(event); 2977 } 2978 else client->sendEvent(event); 2979 } 2980 CATCH_DUMP_ATTR 2981 2982 //! Server side: Receive a message announcing that a coupling context have done it closeDefinition, so data can be sent now. 2983 void CContext::recvCouplerInCloseDefinition(CEventServer& event) 2984 TRY 2985 { 2986 CBufferIn* buffer=event.subEvents.begin()->buffer; 2987 getCurrent()->recvCouplerInCloseDefinition(*buffer); 2988 } 2989 CATCH 2990 2991 //! Server side: Receive a message announcing that a coupling context have done it closeDefinition, so data can be sent now. 2992 void CContext::recvCouplerInCloseDefinition(CBufferIn& buffer) 2993 TRY 2994 { 2995 string contextId ; 2996 buffer>>contextId; 2997 couplerInCloseDefinition_.insert(getCouplerOutClient(contextId)) ; 2998 } 2999 CATCH_DUMP_ATTR 3000 3001 3002 3003 3004 //! Client side: Send a message announcing that a coupling context have done it contextFinalize, so it can also close it own context. 3005 void CContext::sendCouplerInContextFinalized(CContextClient* client) 3006 TRY 3007 { 3008 if (sendCouplerInContextFinalized_done_.count(client)!=0) return ; 3009 else sendCouplerInContextFinalized_done_.insert(client) ; 3010 3011 CEventClient event(getType(),EVENT_ID_COUPLER_IN_CONTEXT_FINALIZED); 3012 3013 if (client->isServerLeader()) 3014 { 3015 CMessage msg; 3016 msg<<this->getId(); 3017 for (auto& rank : client->getRanksServerLeader()) event.push(rank,1,msg); 3018 client->sendEvent(event); 3019 } 3020 else client->sendEvent(event); 3021 } 3022 CATCH_DUMP_ATTR 3023 3024 //! Server side: Receive a message announcing that a coupling context have done it contextFinalize, so it can also close it own context. 3025 void CContext::recvCouplerInContextFinalized(CEventServer& event) 3026 TRY 3027 { 3028 CBufferIn* buffer=event.subEvents.begin()->buffer; 3029 getCurrent()->recvCouplerInContextFinalized(*buffer); 3030 } 3031 CATCH 3032 3033 //! Server side: Receive a message announcing that a coupling context have done it contextFinalize, so it can also close it own context. 3034 void CContext::recvCouplerInContextFinalized(CBufferIn& buffer) 3035 TRY 3036 { 3037 string contextId ; 3038 buffer>>contextId; 3039 couplerInContextFinalized_.insert(getCouplerOutClient(contextId)) ; 3040 } 3041 CATCH_DUMP_ATTR 2773 3042 2774 3043 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.hpp
r1870 r1875 57 57 EVENT_ID_PROCESS_GRID_ENABLED_FIELDS, 58 58 EVENT_ID_CONTEXT_FINALIZE_CLIENT, 59 EVENT_ID_COUPLER_IN_READY, 60 EVENT_ID_COUPLER_IN_CLOSE_DEFINITION, 61 EVENT_ID_COUPLER_IN_CONTEXT_FINALIZED, 59 62 }; 60 63 … … 150 153 void postProcessing(); 151 154 void postProcessingGlobalAttributes(); 152 155 void triggerLateFields(void) ; 153 156 void solveAllRefOfEnabledFieldsAndTransform(void); 154 157 void checkGridEnabledFields(); … … 169 172 // Send context close definition 170 173 void sendCloseDefinition(void); 174 public: 175 void sendCloseDefinition(CContextClient* client) ; 176 private: 177 set<CContextClient*> sendCloseDefinition_done_ ; 178 public: 171 179 // There are something to send on closing context defintion 172 180 void sendUpdateCalendar(int step); … … 208 216 static void recvFinalizeClient(CEventServer& event) ; 209 217 void recvFinalizeClient(CBufferIn& buffer); 210 211 void freeComms(void); //!< Free internally allcoated communicators 212 void releaseClientBuffers(void); //! Deallocate buffers allocated by clientContexts 218 219 public: 220 void sendCouplerInReady(CContextClient* client); 221 private: 222 set<CContextClient*> sendCouplerInReady_done_; 223 public: 224 static void recvCouplerInReady(CEventServer& event) ; 225 void recvCouplerInReady(CBufferIn& buffer) ; //!< coupler is ready to receive grid definition. 226 set<CContextClient*> couplerInReady_; 227 bool isCouplerInReady(CContextClient* client) { return couplerInReady_.count(client)!=0 ;} 228 229 public: 230 void sendCouplerInCloseDefinition(CContextClient* client) ; 231 set<CContextClient*> sendCouplerInCloseDefinition_done_; 232 static void recvCouplerInCloseDefinition(CEventServer& event) ; 233 void recvCouplerInCloseDefinition(CBufferIn& buffer) ; //!< coupler has finished it defintion, data can be sent 234 set<CContextClient*> couplerInCloseDefinition_ ; 235 bool isCouplerInCloseDefinition(CContextClient* client) { return couplerInCloseDefinition_.count(client)!=0 ;} 236 237 public: 238 void sendCouplerInContextFinalized(CContextClient* client) ; 239 set<CContextClient*> sendCouplerInContextFinalized_done_; 240 static void recvCouplerInContextFinalized(CEventServer& event) ; 241 void recvCouplerInContextFinalized(CBufferIn& buffer) ; //!< coupler has finished it defintion, data can be sent 242 set<CContextClient*> couplerInContextFinalized_ ; 243 bool isCouplerInContextFinalized(CContextClient* client) { return couplerInContextFinalized_.count(client)!=0 ;} 244 245 public: 246 void freeComms(void); //!< Free internally allcoated communicators 247 void releaseClientBuffers(void); //! Deallocate buffers allocated by clientContexts 213 248 214 249 // dispatch event … … 281 316 // but which are not part of a file 282 317 std::vector<CField*> fieldsWithReadAccess_; 318 std::vector<CField*> couplerInFields_; 319 std::vector<CField*> fileInFields_; 320 283 321 284 322 // Context root … … 295 333 std::vector<CContextServer*> serverPrimServer; 296 334 std::vector<CContextClient*> clientPrimServer; 297 std::map<std::string, CContextClient*> couplerClient_ ; 298 std::map<std::string, CContextServer*> couplerServer_ ; 299 300 335 336 // list of slave servers (IO server or others) 337 set<CContextClient*> slaveServers_ ; 338 private: 339 // the map containing context client associated to it string id for coupling out ; 340 std::map<std::string, CContextClient*> couplerOutClient_ ; 341 // the map containing context server associated to it string id for coupling out ; 342 std::map<std::string, CContextServer*> couplerOutServer_ ; 343 // the map containing context client associated to it string id for coupling in ; 344 std::map<std::string, CContextClient*> couplerInClient_ ; 345 // the map containing context server associated to it string id for coupling in ; 346 std::map<std::string, CContextServer*> couplerInServer_ ; 347 public: 348 CContextClient* getCouplerInClient(const string& contextId) { return couplerInClient_[contextId] ;} 349 CContextServer* getCouplerInServer(const string& contextId) { return couplerInServer_[contextId] ;} 350 CContextClient* getCouplerOutClient(const string& contextId) { return couplerOutClient_[contextId] ;} 351 CContextServer* getCouplerOutServer(const string& contextId) { return couplerOutServer_[contextId] ;} 352 353 301 354 std::vector<std::string> primServerId_; 302 355 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/coupler_in.cpp
r1784 r1875 51 51 CATCH_DUMP_ATTR 52 52 53 const string& CCouplerIn::getCouplingContextId(void) 54 { 55 if (couplingContextId_.empty()) 56 { 57 vector<string> vectStr=splitRegex(context,"::") ; 58 string poolId=vectStr[0] ; 59 string serviceId=poolId ; 60 string contextId=vectStr[1] ; 61 int contextLeader ; 62 int type = CServicesManager::CLIENT ; 63 couplingContextId_=CXios::getContextsManager()->getServerContextName(poolId, serviceId, 0, type, contextId) ; 64 } 65 return couplingContextId_ ; 66 } 67 53 68 void CCouplerIn::createInterCommunicator(void) 54 69 TRY … … 60 75 } 61 76 CContext* contextPtr = CContext::getCurrent(); 62 contextPtr->addCouplingChanel( context, false) ;77 contextPtr->addCouplingChanel(getCouplingContextId(), false) ; 63 78 } 64 79 CATCH_DUMP_ATTR … … 132 147 CATCH 133 148 134 149 /*! 150 * assign the context associated to the coupler to the enabled fields 151 */ 152 void CCouplerIn::assignContext(void) 153 { 154 client_ = CContext::getCurrent()->getCouplerInClient(getCouplingContextId()); 155 for (auto& field : getEnabledFields()) field->setContextClient(client_) ; 156 } 135 157 136 158 //---------------------------------------------------------------- -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/coupler_in.hpp
r1784 r1875 96 96 void solveFieldRefInheritance(bool apply); 97 97 void createInterCommunicator(void) ; 98 void assignContext(void) ; 99 100 private: 101 CContextClient* client_=nullptr ; 102 public: 103 CContextClient* getContextClient(void) {return client_; } 104 105 private: 106 string couplingContextId_ ; 107 public: 108 const string& getCouplingContextId(void) ; 98 109 99 110 private : 111 100 112 CFieldGroup* virtualFieldGroup; 101 113 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/coupler_out.cpp
r1784 r1875 54 54 } 55 55 CATCH_DUMP_ATTR 56 57 const string& CCouplerOut::getCouplingContextId(void) 58 { 59 if (couplingContextId_.empty()) 60 { 61 vector<string> vectStr=splitRegex(context,"::") ; 62 string poolId=vectStr[0] ; 63 string serviceId=poolId ; 64 string contextId=vectStr[1] ; 65 int contextLeader ; 66 int type = CServicesManager::CLIENT ; 67 couplingContextId_=CXios::getContextsManager()->getServerContextName(poolId, serviceId, 0, type, contextId) ; 68 } 69 return couplingContextId_ ; 70 } 56 71 57 72 std::vector<CField*> CCouplerOut::getEnabledFields(void) … … 75 90 CATCH_DUMP_ATTR 76 91 92 /*! 93 * assign the context associated to the coupler to the enabled fields 94 */ 95 void CCouplerOut::assignContext(void) 96 { 97 client_ = CContext::getCurrent()->getCouplerOutClient(getCouplingContextId()); 98 for (auto& field : getEnabledFields()) field->setContextClient(client_) ; 99 } 100 77 101 /*! 78 102 \brief Get virtual field group … … 133 157 } 134 158 CContext* contextPtr = CContext::getCurrent(); 135 contextPtr->addCouplingChanel( context, true) ;159 contextPtr->addCouplingChanel(getCouplingContextId(), true) ; 136 160 } 137 161 CATCH_DUMP_ATTR -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/coupler_out.hpp
r1784 r1875 96 96 void buildFilterGraphOfEnabledFields(CGarbageCollector& gc); 97 97 void checkGridOfEnabledFields(void) ; 98 99 private : 98 void assignContext(void) ; 99 private: 100 // the contextClient associated to the context Id attribute 101 CContextClient* client_=nullptr ; 102 public: 103 CContextClient* getContextClient(void) {return client_; } 104 105 private: 106 string couplingContextId_ ; 107 public: 108 const string& getCouplingContextId(void) ; 109 private: 100 110 CFieldGroup* virtualFieldGroup; 101 111 … … 118 128 } // namespace xios 119 129 120 #endif // __XIOS_CCouplingIn__ 130 #endif // __XIOS_CCouplingIn__2 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.cpp
r1871 r1875 2101 2101 } 2102 2102 2103 void CDomain::sendDomainToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid) 2104 { 2105 if (sendDomainToFileServer_done_.count(client)!=0) return ; 2106 else sendDomainToFileServer_done_.insert(client) ; 2107 2108 const string domainId = "_domain["+std::to_string(posInGrid)+"]_of_"+fieldId ; 2109 2110 if (!domain_ref.isEmpty()) 2111 { 2112 auto domain_ref_tmp=domain_ref.getValue() ; 2113 domain_ref.reset() ; // remove the reference, find an other way to do that more cleanly 2114 this->sendAllAttributesToServer(client, domainId) ; 2115 domain_ref = domain_ref_tmp ; 2116 } 2117 else this->sendAllAttributesToServer(client, domainId) ; 2118 2119 this->sendDistributionAttributes(client, domainId); 2120 this->sendIndex(client, domainId); 2121 this->sendLonLat(client, domainId); 2122 this->sendArea(client, domainId); 2123 this->sendDataIndex(client, domainId); 2124 } 2125 2126 void CDomain::makeAliasForCoupling(const string& fieldId, int posInGrid) 2127 { 2128 const string domainId = "_domain["+std::to_string(posInGrid)+"]_of_"+fieldId ; 2129 this->createAlias(domainId) ; 2130 } 2131 2103 2132 /*! 2104 2133 Send all attributes from client to connected clients … … 2119 2148 Send global index from client to connected client(s) 2120 2149 */ 2121 void CDomain::sendIndex(CContextClient* client )2150 void CDomain::sendIndex(CContextClient* client, const string& domainId) 2122 2151 TRY 2123 2152 { 2153 string serverDomainId = domainId.empty() ? this->getId() : domainId ; 2154 2124 2155 int ns, n, i, j, ind, nv, idx; 2125 2126 2156 int serverSize = client->serverSize; 2127 2157 CEventClient eventIndex(getType(), EVENT_ID_INDEX); … … 2146 2176 2147 2177 list_msgsIndex.push_back(CMessage()); 2148 list_msgsIndex.back() << this->getId()<< (int)type; // enum ne fonctionne pour les message => ToFix2178 list_msgsIndex.back() << serverDomainId << (int)type; // enum ne fonctionne pour les message => ToFix 2149 2179 list_msgsIndex.back() << isCurvilinear; 2150 2180 list_msgsIndex.back() << list_indGlob.back(); //list_indi.back() << list_indj.back(); … … 2161 2191 it calculates this distribution then sends it to the corresponding clients on the next level 2162 2192 */ 2163 void CDomain::sendDistributionAttributes(CContextClient* client )2193 void CDomain::sendDistributionAttributes(CContextClient* client, const string& domainId) 2164 2194 TRY 2165 2195 { 2196 string serverDomainId = domainId.empty() ? this->getId() : domainId ; 2197 2166 2198 int nbServer = client->serverSize; 2167 2199 std::vector<int> nGlobDomain(2); … … 2192 2224 msgs.push_back(CMessage()); 2193 2225 CMessage& msg = msgs.back(); 2194 msg << this->getId();2226 msg << serverDomainId ; 2195 2227 msg << isUnstructed_; 2196 2228 msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv; … … 2209 2241 Send area from client to connected client(s) 2210 2242 */ 2211 void CDomain::sendArea(CContextClient* client )2243 void CDomain::sendArea(CContextClient* client, const string& domainId) 2212 2244 TRY 2213 2245 { 2214 2246 if (!hasArea) return; 2215 2247 string serverDomainId = domainId.empty() ? this->getId() : domainId ; 2248 2216 2249 int ns, n, i, j, ind, nv, idx; 2217 2250 int serverSize = client->serverSize; … … 2242 2275 2243 2276 list_msgsArea.push_back(CMessage()); 2244 list_msgsArea.back() << this->getId()<< hasArea;2277 list_msgsArea.back() <<serverDomainId << hasArea; 2245 2278 list_msgsArea.back() << list_area.back(); 2246 2279 eventArea.push(rank, nbSenders[serverSize][rank], list_msgsArea.back()); … … 2255 2288 Because longitude and latitude are optional, this function only called if latitude and longitude exist 2256 2289 */ 2257 void CDomain::sendLonLat(CContextClient* client )2290 void CDomain::sendLonLat(CContextClient* client, const string& domainId) 2258 2291 TRY 2259 2292 { 2260 2293 if (!hasLonLat) return; 2261 2294 string serverDomainId = domainId.empty() ? this->getId() : domainId ; 2295 2262 2296 int ns, n, i, j, ind, nv, idx; 2263 2297 int serverSize = client->serverSize; … … 2316 2350 list_msgsLat.push_back(CMessage()); 2317 2351 2318 list_msgsLon.back() << this->getId()<< hasLonLat;2352 list_msgsLon.back() << serverDomainId << hasLonLat; 2319 2353 if (hasLonLat) 2320 2354 list_msgsLon.back() << list_lon.back(); … … 2325 2359 } 2326 2360 2327 list_msgsLat.back() << this->getId()<< hasLonLat;2361 list_msgsLat.back() << serverDomainId << hasLonLat; 2328 2362 if (hasLonLat) 2329 2363 list_msgsLat.back() << list_lat.back(); … … 2348 2382 The compressed index are represented with 1 and others are represented with -1 2349 2383 */ 2350 void CDomain::sendDataIndex(CContextClient* client )2384 void CDomain::sendDataIndex(CContextClient* client, const string& domainId) 2351 2385 TRY 2352 2386 { 2387 string serverDomainId = domainId.empty() ? this->getId() : domainId ; 2388 2353 2389 int ns, n, i, j, ind, nv, idx; 2354 2390 int serverSize = client->serverSize; … … 2406 2442 2407 2443 list_msgsDataIndex.push_back(CMessage()); 2408 list_msgsDataIndex.back() << this->getId();2444 list_msgsDataIndex.back() << serverDomainId ; 2409 2445 list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back(); 2410 2446 eventDataIndex.push(rank, nbSenders[serverSize][rank], list_msgsDataIndex.back()); … … 2614 2650 << "The number of sending clients is not correct." 2615 2651 << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 2616 2652 2653 int nbLonInd = 0; 2617 2654 vector<CArray<double,1> > recvLonValue(nbReceived); 2618 2655 vector<CArray<double,2> > recvBoundsLonValue(nbReceived); … … 2631 2668 if (hasLonLat) 2632 2669 { 2633 int nbLonInd = 0;2634 2670 for (i = 0; i < nbReceived; ++i) 2635 2671 { … … 2665 2701 } 2666 2702 } 2703 } 2704 2705 // setup attribute depending the type of domain 2706 if (hasLonLat) 2707 { 2708 nbLonInd = globalLocalIndexMap_.size(); 2709 if (ni*nj != nbLonInd) 2710 ERROR("void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers)", 2711 << "The number of index received is not coherent with the given resolution" 2712 << "nbLonInd=" << nbLonInd << ", ni=" << ni <<", nj"<<ni<<" ni*nj="<<ni*nj); 2713 2714 if (type == type_attr::rectilinear || type == type_attr::curvilinear) 2715 { 2716 lonvalue_2d.resize(ni,nj); 2717 for(int ij=0, j=0 ; j<nj ; j++) 2718 for(int i=0 ; i<ni; i++, ij++) lonvalue_2d(i,j) = lonvalue(ij) ; 2719 2720 if (hasBounds) 2721 { 2722 bounds_lon_2d.resize(nvertex, ni, nj) ; 2723 for(int ij=0, j=0 ; j<nj ; j++) 2724 for(int i=0 ; i<ni; i++, ij++) 2725 for(int nv=0; nv<nvertex; nv++) bounds_lon_2d(nv,i,j) = bounds_lonvalue(nv,ij) ; 2726 } 2727 } 2728 } 2729 else if (type == type_attr::unstructured || type == type_attr::gaussian) 2730 { 2731 lonvalue_1d.resize(nbLonInd); 2732 lonvalue_1d = lonvalue ; 2733 if (hasBounds) 2734 { 2735 bounds_lon_1d.resize(nvertex, nbLonInd) ; 2736 bounds_lon_1d = bounds_lonvalue ; 2737 } 2667 2738 } 2668 2739 } … … 2717 2788 } 2718 2789 2790 int nbLatInd = 0; 2719 2791 if (hasLonLat) 2720 2792 { 2721 int nbLatInd = 0;2722 2793 for (i = 0; i < nbReceived; ++i) 2723 2794 { … … 2756 2827 } 2757 2828 } 2829 // setup attribute depending the type of domain 2830 if (hasLonLat) 2831 { 2832 nbLatInd = globalLocalIndexMap_.size(); 2833 2834 if (ni*nj != nbLatInd) 2835 ERROR("void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers)", 2836 << "The number of index received is not coherent with the given resolution" 2837 << "nbLonInd=" << nbLatInd << ", ni=" << ni <<", nj"<<ni<<" ni*nj="<<ni*nj); 2838 2839 if (type == type_attr::rectilinear || type == type_attr::curvilinear) 2840 { 2841 { 2842 latvalue_2d.resize(ni,nj); 2843 for(int ij=0, j=0 ; j<nj ; j++) 2844 for(int i=0 ; i<ni; i++, ij++) latvalue_2d(i,j) = latvalue(ij) ; 2845 2846 if (hasBounds) 2847 { 2848 bounds_lat_2d.resize(nvertex, ni, nj) ; 2849 for(int ij=0, j=0 ; j<nj ; j++) 2850 for(int i=0 ; i<ni; i++, ij++) 2851 for(int nv=0; nv<nvertex; nv++) bounds_lat_2d(nv,i,j) = bounds_latvalue(nv,ij) ; 2852 } 2853 } 2854 } 2855 else if (type == type_attr::unstructured || type == type_attr::gaussian) 2856 { 2857 if (hasLonLat) 2858 { 2859 latvalue_1d.resize(nbLatInd); 2860 latvalue_1d = latvalue ; 2861 if (hasBounds) 2862 { 2863 bounds_lat_1d.resize(nvertex, nbLatInd) ; 2864 bounds_lon_1d = bounds_lonvalue ; 2865 } 2866 } 2867 } 2868 } 2758 2869 } 2759 2870 CATCH_DUMP_ATTR … … 3016 3127 } 3017 3128 CATCH_DUMP_ATTR 3018 3019 /*! 3020 \brief Check if a domain is completed 3021 Before make any domain processing, we must be sure that all domain informations have 3022 been sent, for exemple when reading a grid in a file or when grid elements are sent by an 3023 other context (coupling). So all direct reference of the domain (domain_ref) must be also completed 3024 \return true if domain and domain reference are completed 3025 */ 3026 bool CDomain::checkIfCompleted(void) 3027 { 3028 if (hasDirectDomainReference()) if (!getDirectDomainReference()->checkIfCompleted()) return false; 3029 return isCompleted_ ; 3030 } 3031 3032 /*! 3033 \brief Set a domain as completed 3034 When all information about a domain have been received, the domain is tagged as completed and is 3035 suitable for processing 3036 */ 3037 void CDomain::setCompleted(void) 3038 { 3039 if (hasDirectDomainReference()) getDirectDomainReference()->setCompleted() ; 3040 isCompleted_=true ; 3041 } 3042 3043 /*! 3044 \brief Set a domain as uncompleted 3045 When informations about a domain are expected from a grid reading from file or coupling, the domain is 3046 tagged as uncompleted and is not suitable for processing 3047 */ 3048 void CDomain::setUncompleted(void) 3049 { 3050 if (hasDirectDomainReference()) getDirectDomainReference()->setUncompleted() ; 3051 isCompleted_=false ; 3052 } 3053 3129 3054 3130 /*! 3055 3131 * Go through the hierarchy to find the domain from which the transformations must be inherited -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.hpp
r1870 r1875 111 111 112 112 static bool dispatchEvent(CEventServer& event); 113 114 bool checkIfCompleted(void) ; 115 void setCompleted(void) ; 116 void setUncompleted(void) ; 113 114 private: 115 /** define if the domain is completed or not ie all attributes have been received before in case 116 of grid reading from file or coupling */ 117 bool isCompleted_=true ; 118 public: 119 /*! 120 \brief Check if a domain is completed 121 Before make any domain processing, we must be sure that all domain informations have 122 been sent, for exemple when reading a grid in a file or when grid elements are sent by an 123 other context (coupling). So all direct reference of the domain (domain_ref) must be also completed 124 \return true if domain and domain reference are completed 125 */ 126 bool isCompleted(void) 127 { 128 if (hasDirectDomainReference()) if (!getDirectDomainReference()->isCompleted()) return false; 129 else return isCompleted_ ; 130 } 131 void setCompleted(void) { isCompleted_=true ; } 132 void unsetCompleted(void) { isCompleted_=false ; } 117 133 118 134 public: … … 190 206 std::set<CContextClient*> sendDomainToFileServer_done_ ; 191 207 private: 192 208 public: 209 void sendDomainToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid) ; 210 private: 211 std::set<CContextClient*> sendDomainToCouplerOut_done_ ; 212 213 public: 214 void makeAliasForCoupling(const string& fieldId, int posInGrid) ; 215 216 private: 217 193 218 void sendAttributes(); // ym obsolete -> to be removed 194 void sendIndex(CContextClient* client );195 void sendDistributionAttributes(CContextClient* client );196 void sendArea(CContextClient* client );197 void sendLonLat(CContextClient* client );198 void sendDataIndex(CContextClient* client );219 void sendIndex(CContextClient* client, const string& domainId=""); 220 void sendDistributionAttributes(CContextClient* client, const string& domainId=""); 221 void sendArea(CContextClient* client, const string& domainId=""); 222 void sendLonLat(CContextClient* client, const string& domainId=""); 223 void sendDataIndex(CContextClient* client, const string& domainId=""); 199 224 void convertLonLatValue(); 200 225 void fillInRectilinearLonLat(); … … 228 253 bool isClientChecked; // Verify whether all attributes of domain on the client side are good 229 254 bool isClientAfterTransformationChecked; 230 231 /** define if the domain is completed or not ie all attributes have been received before in case232 of grid reading from file or coupling */233 bool isCompleted_=true ;234 255 235 256 /** global index of the domain on server side, sent by the clients. This is global index for lon, lat, mask elements (ie non masked elements) -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp
r1872 r1875 133 133 return true; 134 134 break; 135 135 136 case EVENT_ID_GRID_COMPLETED : 137 recvGridCompleted(event); 138 return true; 139 break; 136 140 default : 137 141 ERROR("bool CField::dispatchEvent(CEventServer& event)", << "Unknown Event"); … … 142 146 CATCH 143 147 144 void CField::sendUpdateData( const CArray<double,1>& data, CContextClient* client)148 void CField::sendUpdateData(Time timeStamp, const CArray<double,1>& data, CContextClient* client) 145 149 TRY 146 150 { … … 169 173 for (int n = 0; n < data_tmp.numElements(); n++) data_tmp(n) = data(index(n)); 170 174 171 list_msg.back() << getId() << data_tmp;175 list_msg.back() << getId() << timeStamp << data_tmp; 172 176 event.push(rank, 1, list_msg.back()); 173 177 } … … 189 193 for (int n = 0; n < data_tmp.numElements(); n++) data_tmp(n) = data(index(n)); 190 194 191 list_msg.back() << getId() << data_tmp;195 list_msg.back() << getId() << timeStamp << data_tmp; 192 196 event.push(rank, grid_->nbSenders_[receiverSize][rank], list_msg.back()); 193 197 } … … 219 223 CATCH 220 224 225 221 226 void CField::recvUpdateData(std::map<int,CBufferIn*>& rankBuffers) 222 227 TRY 223 228 { 229 if (hasCouplerIn()) recvUpdateDataFromCoupler(rankBuffers) ; 230 else recvUpdateDataFromClient(rankBuffers) ; 231 } 232 CATCH 233 234 void CField::recvUpdateDataFromClient(std::map<int,CBufferIn*>& rankBuffers) 235 TRY 236 { 224 237 CContext* context = CContext::getCurrent(); 225 238 Time timeStamp ; 226 239 size_t sizeData = 0; 227 240 if (0 == recvDataSrv.numElements()) … … 249 262 CArray<double,1> tmp; 250 263 CArray<size_t,1>& indexTmp = it->second; 251 *(rankBuffers[it->first]) >> t mp;264 *(rankBuffers[it->first]) >> timeStamp >> tmp; 252 265 for (int idx = 0; idx < indexTmp.numElements(); ++idx) recv_data_tmp(indexTmp(idx)) = tmp(idx); 253 266 } … … 552 565 CATCH 553 566 567 568 void CField::recvUpdateDataFromCoupler(std::map<int,CBufferIn*>& rankBuffers) 569 TRY 570 { 571 CContext* context = CContext::getCurrent(); 572 Time timeStamp ; 573 if (wasDataAlreadyReceivedFromServer) 574 { 575 lastDataReceivedFromServer = lastDataReceivedFromServer + freq_op; 576 } 577 else 578 { 579 // unlikely to input from file server where data are received at ts=0 580 // for coupling, it would be after the first freq_op, because for now we don't have 581 // restart mecanism to send the value at ts=0. It mus be changed in future 582 lastDataReceivedFromServer = context->getCalendar()->getInitDate()+freq_op; 583 wasDataAlreadyReceivedFromServer = true; 584 } 585 586 CArray<int,1>& storeClient = grid_->getStoreIndex_client(); 587 CArray<double,1> recv_data_tmp(storeClient.numElements()); 588 589 auto& outLocalIndexStoreOnClient = grid_-> getOutLocalIndexStoreOnClient() ; 590 for (auto it = outLocalIndexStoreOnClient.begin(); it != outLocalIndexStoreOnClient.end(); ++it) 591 { 592 CArray<double,1> tmp; 593 CArray<size_t,1>& indexTmp = it->second; 594 *(rankBuffers[it->first]) >> timeStamp >> tmp; 595 for (int idx = 0; idx < indexTmp.numElements(); ++idx) recv_data_tmp(indexTmp(idx)) = tmp(idx); 596 } 597 598 clientSourceFilter->streamData(lastDataReceivedFromServer, recv_data_tmp); 599 600 } 601 CATCH_DUMP_ATTR 554 602 /*! 555 603 Receive read data from server … … 596 644 } 597 645 CATCH_DUMP_ATTR 646 647 void CField::checkForLateDataFromCoupler(void) 648 TRY 649 { 650 CContext* context = CContext::getCurrent(); 651 const CDate& currentDate = context->getCalendar()->getCurrentDate(); 652 653 CTimer timer("CField::checkForLateDataFromCoupler"); 654 timer.resume(); 655 traceOff() ; 656 timer.suspend(); 657 658 bool isDataLate; 659 do 660 { 661 const CDate nextDataDue = wasDataAlreadyReceivedFromServer ? (lastDataReceivedFromServer + freq_op) : context->getCalendar()->getInitDate(); 662 isDataLate = (nextDataDue <= currentDate); 663 664 if (isDataLate) 665 { 666 timer.resume(); 667 //ym context->checkBuffersAndListen(); 668 //ym context->eventLoop(); 669 context->globalEventLoop(); 670 671 timer.suspend(); 672 } 673 } while (isDataLate && timer.getCumulatedTime() < CXios::recvFieldTimeout); 674 675 timer.resume(); 676 traceOn() ; 677 timer.suspend() ; 678 679 if (isDataLate) ERROR("void CField::checkForLateDataFromCoupler(void)", 680 << "Late data at timestep = " << currentDate); 681 } 682 CATCH_DUMP_ATTR 683 598 684 599 685 void CField::checkForLateDataFromServer(void) … … 640 726 } 641 727 CATCH_DUMP_ATTR 728 729 void CField::triggerLateField(void) 730 TRY 731 { 732 if (hasFileIn()) 733 { 734 checkForLateDataFromServer() ; 735 serverSourceFilter->trigger(CContext::getCurrent()->getCalendar()->getCurrentDate()) ; 736 } 737 else if (hasCouplerIn()) 738 { 739 checkForLateDataFromCoupler() ; 740 clientSourceFilter->trigger(CContext::getCurrent()->getCalendar()->getCurrentDate()) ; 741 } 742 } 743 CATCH_DUMP_ATTR 744 642 745 643 746 void CField::checkIfMustAutoTrigger(void) … … 1140 1243 { 1141 1244 if (buildWorkflowGraphDone_) return true ; 1245 1142 1246 const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true); 1143 1247 const double defaultValue = detectMissingValues ? default_value : (!default_value.isEmpty() ? default_value : 0.0); … … 1152 1256 } 1153 1257 1258 // now construct grid and check if element are enabled 1259 solveGridReference() ; // grid_ is now defined 1260 if (!isGridCompleted()) return false; 1261 1154 1262 // Check if we have an expression to parse 1155 1263 std::shared_ptr<COutputPin> filterExpr ; … … 1161 1269 } 1162 1270 1163 // now construct grid and check if element are enabled1164 solveGridReference() ; // grid_ is now defined1165 1166 1271 // prepare transformation. Need to know before if workflow of auxillary field can be built 1167 1272 if (hasDirectFieldReference()) … … 1173 1278 for(auto grid : gridPath) 1174 1279 { 1175 if (!grid->checkIfCompleted()) return false ;1176 1280 grid->solveElementsRefInheritance() ; 1177 grid_->completeGrid(gridSrc); // grid generation, to be checked 1281 grid->completeGrid(gridSrc); // grid generation, to be checked 1282 grid->checkElementsAttributes() ; 1178 1283 grid->prepareTransformGrid(gridSrc) ; // prepare the grid tranformation 1179 1284 for(auto fieldId : grid->getAuxInputTransformGrid()) // try to build workflow graph for auxillary field tranformation … … 1205 1310 else 1206 1311 { 1207 if (!grid_->checkIfCompleted()) return false ;1208 1209 1312 if (hasFileIn()) // input file, attemp to read the grid from file 1210 1313 { … … 1221 1324 instantDataFilter=inputFilter ; 1222 1325 } 1223 else 1326 else if (hasCouplerIn()) 1327 { 1328 grid_->checkElementsAttributes() ; 1329 instantDataFilter=inputFilter ; 1330 } 1331 else 1224 1332 { 1225 1333 setModelIn() ; // no reference, the field is potentially a source field from model … … 1256 1364 // insert temporal filter before sending to files 1257 1365 getTemporalDataFilter(gc, fileOut_->output_freq)->connectOutput(fileWriterFilter, 0); 1366 } 1367 1368 void CField::connectToCouplerOut(CGarbageCollector& gc) 1369 { 1370 // insert temporal filter before sending to files 1371 fileWriterFilter = std::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this, client)); 1372 instantDataFilter->connectOutput(fileWriterFilter, 0); 1258 1373 } 1259 1374 … … 1303 1418 serverSourceFilter -> connectOutput(inputFilter,0) ; 1304 1419 } 1420 1421 /*! 1422 * Connect field to a source filter to receive data from coupler (on client side). 1423 */ 1424 void CField::connectToCouplerIn(CGarbageCollector& gc) 1425 { 1426 CContext* context = CContext::getCurrent(); 1427 1428 if (freq_op.isEmpty()) freq_op.setValue(TimeStep); 1429 if (freq_offset.isEmpty()) freq_offset.setValue(freq_op.getValue() - TimeStep); 1430 1431 freq_operation_srv = freq_op ; 1432 last_operation_srv = context->getCalendar()->getInitDate(); 1433 const CDuration toffset = freq_operation_srv - freq_offset.getValue() - context->getCalendar()->getTimeStep(); 1434 last_operation_srv = last_operation_srv - toffset; 1435 1436 clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid_, false, false, freq_offset, true)) ; 1437 clientSourceFilter -> connectOutput(inputFilter,0) ; 1438 } 1439 1305 1440 1306 1441 /*! … … 2021 2156 CATCH_DUMP_ATTR 2022 2157 2023 CContextClient* CField::getContextClient() 2024 TRY 2025 { 2026 return client; 2027 } 2028 CATCH 2029 2030 2158 void CField::sendCloseDefinition(void) 2159 { 2160 CContext::getCurrent()->sendCloseDefinition(client) ; 2161 } 2162 2031 2163 void CField::sendFieldToFileServer(void) 2032 2164 { … … 2037 2169 this->sendAddAllVariables(client); 2038 2170 } 2171 2172 void CField::sendFieldToCouplerOut(void) 2173 { 2174 if (sendFieldToCouplerOut_done_) return ; 2175 else sendFieldToCouplerOut_done_=true ; 2176 grid_->sendGridToCouplerOut(client, this->getId()); 2177 this->sendGridCompleted(); 2178 2179 } 2039 2180 2181 void CField::makeGridAliasForCoupling(void) 2182 { 2183 grid_->makeAliasForCoupling(this->getId()); 2184 } 2185 2186 //! Client side: Send a message announcing that the grid definition has been received from a coupling context 2187 void CField::sendGridCompleted(void) 2188 TRY 2189 { 2190 CEventClient event(getType(),EVENT_ID_GRID_COMPLETED); 2191 2192 if (client->isServerLeader()) 2193 { 2194 CMessage msg; 2195 msg<<this->getId(); 2196 for (auto& rank : client->getRanksServerLeader()) event.push(rank,1,msg); 2197 client->sendEvent(event); 2198 } 2199 else client->sendEvent(event); 2200 } 2201 CATCH_DUMP_ATTR 2202 2203 //! Server side: Receive a message announcing that the grid definition has been received from a coupling context 2204 void CField::recvGridCompleted(CEventServer& event) 2205 TRY 2206 { 2207 CBufferIn* buffer=event.subEvents.begin()->buffer; 2208 string id; 2209 *buffer>>id ; 2210 get(id)->recvGridCompleted(*buffer); 2211 } 2212 CATCH 2213 2214 //! Server side: Receive a message message announcing that the grid definition has been received from a coupling context 2215 void CField::recvGridCompleted(CBufferIn& buffer) 2216 TRY 2217 { 2218 setGridCompleted() ; 2219 } 2220 CATCH_DUMP_ATTR 2221 2222 2223 2224 2225 2040 2226 void CField::sendFieldToInputFileServer(void) 2041 2227 { … … 2145 2331 TRY 2146 2332 { 2147 bool isFieldRead = getRelFile() && !getRelFile()->mode.isEmpty() && getRelFile()->mode == CFile::mode_attr::read; 2148 bool isFieldWrite = getRelFile() && ( getRelFile()->mode.isEmpty() || getRelFile()->mode == CFile::mode_attr::write); 2149 if (isFieldRead && !(operation.getValue() == "instant" || operation.getValue() == "once") ) 2333 if (hasFileIn() && !(operation.getValue() == "instant" || operation.getValue() == "once") ) 2150 2334 ERROR("void CField::checkTimeAttributes(void)", 2151 2335 << "Unsupported operation for field '" << getFieldOutputName() << "'." << std::endl … … 2156 2340 if (operation.getValue() == "instant") 2157 2341 { 2158 if ( isFieldRead || isFieldWrite) freq_op.setValue(getRelFile()->output_freq.getValue());2342 if (hasFileIn() || hasFileOut()) freq_op.setValue(getRelFile()->output_freq.getValue()); 2159 2343 else freq_op=*freqOp ; 2160 2344 } 2161 2345 else freq_op.setValue(TimeStep); 2162 2346 } 2163 if (freq_offset.isEmpty()) freq_offset.setValue( isFieldRead? NoneDu : (freq_op.getValue() - TimeStep));2347 if (freq_offset.isEmpty()) freq_offset.setValue(hasFileIn() ? NoneDu : (freq_op.getValue() - TimeStep)); 2164 2348 } 2165 2349 CATCH_DUMP_ATTR -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp
r1872 r1875 78 78 { 79 79 EVENT_ID_UPDATE_DATA, EVENT_ID_READ_DATA, EVENT_ID_READ_DATA_READY, 80 EVENT_ID_ADD_VARIABLE, EVENT_ID_ADD_VARIABLE_GROUP 80 EVENT_ID_ADD_VARIABLE, EVENT_ID_ADD_VARIABLE_GROUP, EVENT_ID_GRID_COMPLETED 81 81 }; 82 82 … … 111 111 std::map<int, StdSize> getGridDataBufferSize(CContextClient* client, bool bufferForWriting = false); 112 112 113 void setContextClient(CContextClient* newContextClient); 114 CContextClient* getContextClient(); 115 113 public: 114 void makeGridAliasForCoupling(void) ; 116 115 public: 117 116 bool isActive(bool atCurrentTimestep = false) const; … … 144 143 145 144 void sendFieldToFileServer(void) ; 145 void sendCloseDefinition(void) ; 146 147 public: 148 void sendFieldToCouplerOut(void) ; 149 private: 150 bool sendFieldToCouplerOut_done_=false; 151 public: 152 146 153 void sendFieldToInputFileServer(void) ; 147 154 … … 177 184 void sendAllAttributesToServer(CContextClient* client) ; 178 185 void sendUpdateData(const CArray<double,1>& data); 179 void sendUpdateData( const CArray<double,1>& data, CContextClient* client);186 void sendUpdateData(Time timestamp, const CArray<double,1>& data, CContextClient* client); 180 187 static void recvUpdateData(CEventServer& event); 181 188 void recvUpdateData(std::map<int,CBufferIn*>& rankBuffers); 189 void recvUpdateDataFromClient(std::map<int,CBufferIn*>& rankBuffers); 190 void recvUpdateDataFromCoupler(std::map<int,CBufferIn*>& rankBuffers); 191 182 192 void writeField(void); 183 193 bool sendReadDataRequest(const CDate& tsDataRequested, CContextClient* client); … … 188 198 static void recvReadDataReady(CEventServer& event); 189 199 void recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers); 200 void recvDataFromCoupler(vector<int> ranks, vector<CBufferIn*> buffers) ; 190 201 void checkForLateDataFromServer(void); 191 void checkIfMustAutoTrigger(void); 192 void autoTriggerIfNeeded(void); 202 void checkForLateDataFromCoupler(void) ; 203 204 void checkIfMustAutoTrigger(void); // ym obsolete 205 void autoTriggerIfNeeded(void); //ym obsolete 206 void triggerLateField(void) ; 207 193 208 void outputField(CArray<double,3>& fieldOut); 194 209 void outputField(CArray<double,2>& fieldOut); … … 227 242 228 243 void connectToFileServer(CGarbageCollector& gc) ; 244 void connectToCouplerOut(CGarbageCollector& gc) ; 245 void connectToCouplerIn(CGarbageCollector& gc) ; 229 246 void connectToModelInput(CGarbageCollector& gc) ; 230 247 void connectToFileWriter(CGarbageCollector& gc) ; … … 241 258 map<CContextClient*,map<int,size_t>>& maxEventSize, 242 259 bool bufferForWriting) ; 260 private: 261 bool isGridCompleted_ = true ; 262 public: 263 bool isGridCompleted() { return isGridCompleted_ ;} 264 void setGridCompleted(void) { isGridCompleted_= true; } 265 void unsetGridCompleted(void) { isGridCompleted_ = false ;} 266 267 public: 268 void sendGridCompleted(void) ; 269 private: 270 static void recvGridCompleted(CEventServer& event); 271 void recvGridCompleted(CBufferIn& buffer); 272 273 243 274 private: 244 275 std::vector<CGrid*> getGridPath(void) ; … … 315 346 private: 316 347 CContextClient* client; 348 public: 349 void setContextClient(CContextClient* newContextClient); 350 CContextClient* getContextClient(void) {return client;} 351 352 private: 317 353 318 354 bool areAllReferenceSolved; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp
r1871 r1875 102 102 } 103 103 CATCH 104 105 /*! 106 * Get the local data grid size, ie the size of the compressed grid (inside the workflow) 107 * \return The size od the compressed grid 108 */ 109 StdSize CGrid::getLocalDataSize(void) { return getClientDistribution()->getLocalDataSize();} 110 104 111 105 112 /*! … … 326 333 CATCH_DUMP_ATTR 327 334 335 //ym obsolete -> to be removed later 328 336 void CGrid::checkMaskIndex(bool doSendingIndex) 329 337 TRY … … 334 342 if (this->isChecked && doSendingIndex && !isIndexSent) 335 343 { 336 if (isScalarGrid()) sendIndexScalarGrid();337 else sendIndex();344 if (isScalarGrid()) /*sendIndexScalarGrid()*/; 345 else /*sendIndex()*/; 338 346 this->isIndexSent = true; 339 347 } … … 1453 1461 CATCH_DUMP_ATTR 1454 1462 1455 void CGrid::sendIndexScalarGrid() 1456 TRY 1457 { 1463 void CGrid::sendIndexScalarGrid(CContextClient* client, const string& gridId) 1464 TRY 1465 { 1466 if (sendIndexScalarGrid_done_.count(client)!=0) return ; 1467 else sendIndexScalarGrid_done_.insert(client) ; 1468 1458 1469 CContext* context = CContext::getCurrent(); 1459 storeIndex_toSrv_.clear(); 1460 std::list<CContextClient*>::iterator it; 1461 1462 for (it=clients.begin(); it!=clients.end(); ++it) 1463 { 1464 CContextClient* client = *it; 1465 int receiverSize = client->serverSize; 1466 1467 CEventClient event(getType(), EVENT_ID_INDEX); 1468 list<CMessage> listMsg; 1469 list<CArray<size_t,1> > listOutIndex; 1470 1470 1471 string serverGridId = gridId.empty() ? serverGridId=this->getId() : serverGridId=gridId ; 1472 1473 int receiverSize = client->serverSize; 1474 1475 CEventClient event(getType(), EVENT_ID_INDEX); 1476 list<CMessage> listMsg; 1477 list<CArray<size_t,1> > listOutIndex; 1478 1479 if (client->isServerLeader()) 1480 { 1481 const std::list<int>& ranks = client->getRanksServerLeader(); 1482 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 1483 { 1484 int rank = *itRank; 1485 int nb = 1; 1486 storeIndex_toSrv_[client].insert(std::make_pair(rank, CArray<int,1>(nb))); 1487 listOutIndex.push_back(CArray<size_t,1>(nb)); 1488 1489 CArray<int, 1>& outLocalIndexToServer = storeIndex_toSrv_[client][rank]; 1490 CArray<size_t, 1>& outGlobalIndexOnServer = listOutIndex.back(); 1491 1492 for (int k = 0; k < nb; ++k) 1493 { 1494 outGlobalIndexOnServer(k) = 0; 1495 outLocalIndexToServer(k) = 0; 1496 } 1497 1498 if (context->getServiceType()==CServicesManager::CLIENT) // -> what about for coupling probably unusefull to be check 1499 storeIndex_fromSrv_.insert(std::make_pair(rank, CArray<int,1>(outLocalIndexToServer))); 1500 1501 listMsg.push_back(CMessage()); 1502 listMsg.back() << serverGridId << isCompressible_ << listOutIndex.back(); 1503 1504 event.push(rank, 1, listMsg.back()); 1505 } 1506 client->sendEvent(event); 1507 } 1508 else 1509 { 1510 const std::list<int>& ranks = client->getRanksServerNotLeader(); 1511 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 1512 { 1513 int rank = *itRank; 1514 int nb = 1; 1515 CArray<int, 1> outLocalIndexToServer(nb); 1516 for (int k = 0; k < nb; ++k) 1517 { 1518 outLocalIndexToServer(k) = 0; 1519 } 1520 1521 if (context->getServiceType()==CServicesManager::CLIENT) 1522 storeIndex_fromSrv_.insert(std::make_pair(rank, CArray<int,1>(outLocalIndexToServer))); 1523 } 1524 client->sendEvent(event); 1525 } 1526 } 1527 CATCH_DUMP_ATTR 1528 1529 void CGrid::sendIndex(CContextClient* client, const string& gridId) 1530 TRY 1531 { 1532 if (sendIndex_done_.count(client)!=0) return ; 1533 else sendIndex_done_.insert(client) ; 1534 CContext* context = CContext::getCurrent(); 1535 string serverGridId = gridId.empty() ? this->getId() : gridId ; 1536 1537 1538 1539 int receiverSize = client->serverSize; 1540 1541 CEventClient event(getType(), EVENT_ID_INDEX); 1542 int rank; 1543 list<CMessage> listMsg; 1544 list<CArray<size_t,1> > listOutIndex; 1545 const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = getClientDistribution()->getGlobalLocalDataSendToServer(); 1546 CDistributionClient::GlobalLocalDataMap::const_iterator itbIndex = globalLocalIndexSendToServer.begin(), itIndex, 1547 iteIndex = globalLocalIndexSendToServer.end(); 1548 itIndex = itbIndex; 1549 1550 if (!doGridHaveDataDistributed(client)) 1551 { 1471 1552 if (client->isServerLeader()) 1472 1553 { 1554 int indexSize = globalLocalIndexSendToServer.size(); 1555 CArray<size_t,1> outGlobalIndexOnServer(indexSize); 1556 CArray<int,1> outLocalIndexToServer(indexSize); 1557 for (int idx = 0; itIndex != iteIndex; ++itIndex, ++idx) 1558 { 1559 outGlobalIndexOnServer(idx) = itIndex->first; 1560 outLocalIndexToServer(idx) = itIndex->second; 1561 } 1562 1473 1563 const std::list<int>& ranks = client->getRanksServerLeader(); 1474 1564 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 1475 1565 { 1476 int rank = *itRank; 1477 int nb = 1; 1478 storeIndex_toSrv_[client].insert(std::make_pair(rank, CArray<int,1>(nb))); 1479 listOutIndex.push_back(CArray<size_t,1>(nb)); 1480 1481 CArray<int, 1>& outLocalIndexToServer = storeIndex_toSrv_[client][rank]; 1482 CArray<size_t, 1>& outGlobalIndexOnServer = listOutIndex.back(); 1483 1484 for (int k = 0; k < nb; ++k) 1485 { 1486 outGlobalIndexOnServer(k) = 0; 1487 outLocalIndexToServer(k) = 0; 1488 } 1489 1490 if (context->getServiceType()==CServicesManager::CLIENT) 1491 storeIndex_fromSrv_.insert(std::make_pair(rank, CArray<int,1>(outLocalIndexToServer))); 1566 storeIndex_toSrv_[client].insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer))); 1567 if (context->getServiceType()==CServicesManager::CLIENT) // -> what about for coupling probably unusefull to be check 1568 storeIndex_fromSrv_.insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer))); 1569 1570 listOutIndex.push_back(CArray<size_t,1>(outGlobalIndexOnServer)); 1492 1571 1493 1572 listMsg.push_back(CMessage()); 1494 listMsg.back() << getId( )<< isCompressible_ << listOutIndex.back();1495 1496 event.push( rank, 1, listMsg.back());1573 listMsg.back() << serverGridId << isCompressible_ << listOutIndex.back(); 1574 1575 event.push(*itRank, 1, listMsg.back()); 1497 1576 } 1498 1577 client->sendEvent(event); … … 1500 1579 else 1501 1580 { 1502 const std::list<int>& ranks = client->getRanksServerNotLeader(); 1503 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 1581 int indexSize = globalLocalIndexSendToServer.size(); 1582 CArray<int,1> outLocalIndexToServer(indexSize); 1583 for (int idx = 0; itIndex != iteIndex; ++itIndex, ++idx) 1584 { 1585 outLocalIndexToServer(idx) = itIndex->second; 1586 } 1587 1588 const std::list<int>& ranks = client->getRanksServerNotLeader(); 1589 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 1590 { 1591 storeIndex_fromSrv_.insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer))); 1592 } 1593 client->sendEvent(event); 1594 } 1595 } 1596 else 1597 { 1598 CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itGlobalMap; 1599 itGlobalMap = globalIndexOnServer_[receiverSize].begin(); 1600 iteGlobalMap = globalIndexOnServer_[receiverSize].end(); 1601 1602 std::map<int,std::vector<int> >localIndexTmp; 1603 std::map<int,std::vector<size_t> > globalIndexTmp; 1604 for (; itGlobalMap != iteGlobalMap; ++itGlobalMap) 1605 { 1606 int serverRank = itGlobalMap->first; 1607 int indexSize = itGlobalMap->second.size(); 1608 const std::vector<size_t>& indexVec = itGlobalMap->second; 1609 for (int idx = 0; idx < indexSize; ++idx) 1504 1610 { 1505 int rank = *itRank; 1506 int nb = 1; 1507 CArray<int, 1> outLocalIndexToServer(nb); 1508 for (int k = 0; k < nb; ++k) 1611 itIndex = globalLocalIndexSendToServer.find(indexVec[idx]); 1612 if (iteIndex != itIndex) 1509 1613 { 1510 outLocalIndexToServer(k) = 0; 1511 } 1512 1513 if (context->getServiceType()==CServicesManager::CLIENT) 1514 storeIndex_fromSrv_.insert(std::make_pair(rank, CArray<int,1>(outLocalIndexToServer))); 1515 } 1516 client->sendEvent(event); 1517 } 1518 } 1519 } 1520 CATCH_DUMP_ATTR 1521 1522 void CGrid::sendIndex(void) 1523 TRY 1524 { 1525 CContext* context = CContext::getCurrent(); 1526 storeIndex_toSrv_.clear(); 1527 std::list<CContextClient*>::iterator it; 1528 1529 for (it=clients.begin(); it!=clients.end(); ++it) 1530 { 1531 CContextClient* client = *it; 1532 int receiverSize = client->serverSize; 1533 1534 CEventClient event(getType(), EVENT_ID_INDEX); 1535 int rank; 1536 list<CMessage> listMsg; 1537 list<CArray<size_t,1> > listOutIndex; 1538 const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = getClientDistribution()->getGlobalLocalDataSendToServer(); 1539 CDistributionClient::GlobalLocalDataMap::const_iterator itbIndex = globalLocalIndexSendToServer.begin(), itIndex, 1540 iteIndex = globalLocalIndexSendToServer.end(); 1541 itIndex = itbIndex; 1542 1543 if (!doGridHaveDataDistributed(client)) 1544 { 1545 if (client->isServerLeader()) 1546 { 1547 int indexSize = globalLocalIndexSendToServer.size(); 1548 CArray<size_t,1> outGlobalIndexOnServer(indexSize); 1549 CArray<int,1> outLocalIndexToServer(indexSize); 1550 for (int idx = 0; itIndex != iteIndex; ++itIndex, ++idx) 1551 { 1552 outGlobalIndexOnServer(idx) = itIndex->first; 1553 outLocalIndexToServer(idx) = itIndex->second; 1554 } 1555 1556 const std::list<int>& ranks = client->getRanksServerLeader(); 1557 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 1558 { 1559 storeIndex_toSrv_[client].insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer))); 1560 if (context->getServiceType()==CServicesManager::CLIENT) 1561 storeIndex_fromSrv_.insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer))); 1562 1563 listOutIndex.push_back(CArray<size_t,1>(outGlobalIndexOnServer)); 1564 1565 listMsg.push_back(CMessage()); 1566 listMsg.back() << getId() << isCompressible_ << listOutIndex.back(); 1567 1568 event.push(*itRank, 1, listMsg.back()); 1569 } 1570 client->sendEvent(event); 1571 } 1572 else 1573 { 1574 int indexSize = globalLocalIndexSendToServer.size(); 1575 CArray<int,1> outLocalIndexToServer(indexSize); 1576 for (int idx = 0; itIndex != iteIndex; ++itIndex, ++idx) 1577 { 1578 outLocalIndexToServer(idx) = itIndex->second; 1579 } 1580 1581 const std::list<int>& ranks = client->getRanksServerNotLeader(); 1582 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 1583 { 1584 storeIndex_fromSrv_.insert(std::make_pair(*itRank, CArray<int,1>(outLocalIndexToServer))); 1585 } 1586 client->sendEvent(event); 1587 } 1588 } 1589 else 1590 { 1591 CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itGlobalMap; 1592 itGlobalMap = globalIndexOnServer_[receiverSize].begin(); 1593 iteGlobalMap = globalIndexOnServer_[receiverSize].end(); 1594 1595 std::map<int,std::vector<int> >localIndexTmp; 1596 std::map<int,std::vector<size_t> > globalIndexTmp; 1597 for (; itGlobalMap != iteGlobalMap; ++itGlobalMap) 1598 { 1599 int serverRank = itGlobalMap->first; 1600 int indexSize = itGlobalMap->second.size(); 1601 const std::vector<size_t>& indexVec = itGlobalMap->second; 1602 for (int idx = 0; idx < indexSize; ++idx) 1603 { 1604 itIndex = globalLocalIndexSendToServer.find(indexVec[idx]); 1605 if (iteIndex != itIndex) 1606 { 1607 globalIndexTmp[serverRank].push_back(itIndex->first); 1608 localIndexTmp[serverRank].push_back(itIndex->second); 1609 } 1614 globalIndexTmp[serverRank].push_back(itIndex->first); 1615 localIndexTmp[serverRank].push_back(itIndex->second); 1610 1616 } 1611 1617 } 1612 1613 for (int ns = 0; ns < connectedServerRank_[receiverSize].size(); ++ns) 1618 } 1619 1620 for (int ns = 0; ns < connectedServerRank_[receiverSize].size(); ++ns) 1621 { 1622 rank = connectedServerRank_[receiverSize][ns]; 1623 int nb = 0; 1624 if (globalIndexTmp.end() != globalIndexTmp.find(rank)) 1625 nb = globalIndexTmp[rank].size(); 1626 1627 storeIndex_toSrv_[client].insert(make_pair(rank, CArray<int,1>(nb))); 1628 listOutIndex.push_back(CArray<size_t,1>(nb)); 1629 1630 CArray<int, 1>& outLocalIndexToServer = storeIndex_toSrv_[client][rank]; 1631 CArray<size_t, 1>& outGlobalIndexOnServer = listOutIndex.back(); 1632 1633 for (int k = 0; k < nb; ++k) 1614 1634 { 1615 rank = connectedServerRank_[receiverSize][ns]; 1616 int nb = 0; 1617 if (globalIndexTmp.end() != globalIndexTmp.find(rank)) 1618 nb = globalIndexTmp[rank].size(); 1619 1620 storeIndex_toSrv_[client].insert(make_pair(rank, CArray<int,1>(nb))); 1621 listOutIndex.push_back(CArray<size_t,1>(nb)); 1622 1623 CArray<int, 1>& outLocalIndexToServer = storeIndex_toSrv_[client][rank]; 1624 CArray<size_t, 1>& outGlobalIndexOnServer = listOutIndex.back(); 1625 1626 for (int k = 0; k < nb; ++k) 1627 { 1628 outGlobalIndexOnServer(k) = globalIndexTmp[rank].at(k); 1629 outLocalIndexToServer(k) = localIndexTmp[rank].at(k); 1630 } 1631 1632 storeIndex_fromSrv_.insert(make_pair(rank, CArray<int,1>(outLocalIndexToServer))); 1633 listMsg.push_back(CMessage()); 1634 listMsg.back() << getId() << isCompressible_ << listOutIndex.back(); 1635 1636 event.push(rank, nbSenders_[receiverSize][rank], listMsg.back()); 1635 outGlobalIndexOnServer(k) = globalIndexTmp[rank].at(k); 1636 outLocalIndexToServer(k) = localIndexTmp[rank].at(k); 1637 1637 } 1638 1638 1639 client->sendEvent(event); 1640 } 1639 storeIndex_fromSrv_.insert(make_pair(rank, CArray<int,1>(outLocalIndexToServer))); 1640 listMsg.push_back(CMessage()); 1641 listMsg.back() << serverGridId << isCompressible_ << listOutIndex.back(); 1642 1643 event.push(rank, nbSenders_[receiverSize][rank], listMsg.back()); 1644 } 1645 client->sendEvent(event); 1641 1646 } 1642 1647 } … … 2235 2240 gridPtr->sendCreateChild(this->getId(),client); 2236 2241 this->sendAllAttributesToServer(client); 2237 if (isScalarGrid()) sendIndexScalarGrid( );2238 else sendIndex( );2242 if (isScalarGrid()) sendIndexScalarGrid(client); 2243 else sendIndex(client); 2239 2244 this->sendAllDomains(client); 2240 2245 this->sendAllAxis(client); 2241 2246 this->sendAllScalars(client); 2247 } 2248 2249 void CGrid::sendGridToCouplerOut(CContextClient* client, const string& fieldId) 2250 { 2251 if (sendGridToCouplerOut_done_.count(client)!=0) return ; 2252 else sendGridToCouplerOut_done_.insert(client) ; 2253 string gridId="_grid_of_"+fieldId ; 2254 this->sendAllAttributesToServer(client, gridId); 2255 2256 if (isScalarGrid()) sendIndexScalarGrid(client, gridId); 2257 else sendIndex(client, gridId); 2258 2259 const auto& domVect = getDomains() ; 2260 for (int pos=0; pos<domVect.size();pos++) domVect[pos]->sendDomainToCouplerOut(client, fieldId, pos); 2261 2262 const auto& axisVect=getAxis() ; 2263 for (int pos=0; pos<axisVect.size();pos++) axisVect[pos]->sendAxisToCouplerOut(client, getGlobalDimension(), getAxisPositionInGrid()[pos], fieldId, pos); 2264 2265 const auto& scalVect=getScalars() ; 2266 for (int pos=0; pos<scalVect.size();pos++) scalVect[pos]->sendScalarToCouplerOut(client, fieldId, pos); 2267 } 2268 2269 void CGrid::makeAliasForCoupling(const string& fieldId) 2270 { 2271 string gridId="_grid_of_"+fieldId ; 2272 createAlias(gridId) ; 2273 2274 const auto& domVect = getDomains() ; 2275 for (int pos=0; pos<domVect.size();pos++) domVect[pos]->makeAliasForCoupling(fieldId, pos); 2276 2277 const auto& axisVect=getAxis() ; 2278 for (int pos=0; pos<axisVect.size();pos++) axisVect[pos]->makeAliasForCoupling(fieldId, pos); 2279 2280 const auto& scalVect=getScalars() ; 2281 for (int pos=0; pos<scalVect.size();pos++) scalVect[pos]->makeAliasForCoupling(fieldId, pos); 2242 2282 } 2243 2283 … … 2365 2405 other context (coupling) 2366 2406 */ 2367 bool CGrid:: checkIfCompleted(void)2407 bool CGrid::isCompleted(void) 2368 2408 { 2369 2409 setDomainList(); 2370 for (auto domainId : domList_) if (!CDomain::get(domainId)-> checkIfCompleted()) return false ;2410 for (auto domainId : domList_) if (!CDomain::get(domainId)->isCompleted()) return false ; 2371 2411 setAxisList() ; 2372 for (auto axisId : axisList_) if (!CAxis::get(axisId)-> checkIfCompleted()) return false ;2412 for (auto axisId : axisList_) if (!CAxis::get(axisId)->isCompleted()) return false ; 2373 2413 setScalarList() ; 2374 for (auto scalarId : scalarList_) if (!CScalar::get(scalarId)-> checkIfCompleted()) return false ;2414 for (auto scalarId : scalarList_) if (!CScalar::get(scalarId)->isCompleted()) return false ; 2375 2415 return true ; 2416 } 2417 2418 /*! 2419 \brief impose that all elements of the grid are complete 2420 Before make any grid processing, we must be sure that all grid information elements have 2421 been sent, for exemple when reading a grid in a file or when grid elements are sent by an 2422 other context (coupling) 2423 */ 2424 void CGrid::setCompleted(void) 2425 { 2426 setDomainList(); 2427 for (auto domainId : domList_) CDomain::get(domainId)->setCompleted() ; 2428 setAxisList() ; 2429 for (auto axisId : axisList_) CAxis::get(axisId)->setCompleted() ; 2430 setScalarList() ; 2431 for (auto scalarId : scalarList_) CScalar::get(scalarId)->setCompleted() ; 2432 } 2433 2434 /*! 2435 \brief impose that all elements of the grid are incomplete 2436 Before make any grid processing, we must be sure that all grid information elements have 2437 been sent, for exemple when reading a grid in a file or when grid elements are sent by an 2438 other context (coupling) 2439 */ 2440 void CGrid::unsetCompleted(void) 2441 { 2442 setDomainList(); 2443 for (auto domainId : domList_) CDomain::get(domainId)->unsetCompleted() ; 2444 setAxisList() ; 2445 for (auto axisId : axisList_) CAxis::get(axisId)->unsetCompleted() ; 2446 setScalarList() ; 2447 for (auto scalarId : scalarList_) CScalar::get(scalarId)->unsetCompleted() ; 2376 2448 } 2377 2449 … … 2904 2976 clientsSet.insert(contextClient); 2905 2977 } 2906 for ( int i=0; i<this->getDomains().size(); i++)2907 this->getDomains()[i]->setContextClient(contextClient);2908 for ( int i=0; i<this->getAxis().size(); i++)2909 this->getAxis()[i]->setContextClient(contextClient);2978 for (auto domain : getDomains()) domain->setContextClient(contextClient); 2979 for (auto axis : getAxis()) axis->setContextClient(contextClient); 2980 for (auto scalar : getScalars()) scalar->setContextClient(contextClient); 2981 2910 2982 } 2911 2983 CATCH_DUMP_ATTR -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp
r1872 r1875 90 90 91 91 StdSize getDataSize(void) ; 92 93 /** 94 * Get the local data grid size, ie the size of the compressed grid (inside the workflow) 95 * \return The size od the compressed grid 96 */ 97 StdSize getLocalDataSize(void) ; 92 98 93 99 /// Entrees-sorties de champs … … 151 157 private: 152 158 std::set<CContextClient*> sendGridToFileServer_done_ ; 153 159 160 public: 161 void sendGridToCouplerOut(CContextClient* client, const string& fieldId) ; 162 private: 163 std::set<CContextClient*> sendGridToCouplerOut_done_ ; 164 165 public: 166 void makeAliasForCoupling(const string& fieldId) ; 167 154 168 public: 155 169 void sendAddDomain(const std::string& id,CContextClient* contextClient); … … 170 184 static void recvIndex(CEventServer& event); 171 185 void recvIndex(vector<int> ranks, vector<CBufferIn*> buffers, CContextServer* server); 172 void sendIndex(void); 173 void sendIndexScalarGrid(); 174 186 187 public: 188 void sendIndex(CContextClient* client, const string& gridId=""); 189 private: 190 set<CContextClient*> sendIndex_done_ ; 191 192 public: 193 void sendIndexScalarGrid(CContextClient* client, const string& gridId=""); 194 private: 195 set<CContextClient*> sendIndexScalarGrid_done_ ; 196 197 public: 175 198 void setContextClient(CContextClient* contextClient); 176 199 … … 221 244 bool hasTransform(); 222 245 size_t getGlobalWrittenSize(void) ; 223 bool checkIfCompleted(void) ; 246 247 bool isCompleted(void) ; 248 void setCompleted(void) ; 249 void unsetCompleted(void) ; 224 250 225 251 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.cpp
r1870 r1875 68 68 69 69 } 70 71 /*!72 \brief Check if a scalar is completed73 Before make any scalar processing, we must be sure that all scalar informations have74 been sent, for exemple when reading a grid in a file or when grid elements are sent by an75 other context (coupling). So all direct reference of the scalar (scalar_ref) must be also completed76 \return true if scalar and scalar reference are completed77 */78 bool CScalar::checkIfCompleted(void)79 {80 if (hasDirectScalarReference()) if (!getDirectScalarReference()->checkIfCompleted()) return false;81 return isCompleted_ ;82 }83 84 /*!85 \brief Set a scalar as completed86 When all information about a scalar have been received, the scalar is tagged as completed and is87 suitable for processing88 */89 void CScalar::setCompleted(void)90 {91 if (hasDirectScalarReference()) getDirectScalarReference()->setCompleted() ;92 isCompleted_=true ;93 }94 95 /*!96 \brief Set a scalar as uncompleted97 When informations about a scalar are expected from a grid reading from file or coupling, the scalar is98 tagged as uncompleted and is not suitable for processing99 */100 void CScalar::setUncompleted(void)101 {102 if (hasDirectScalarReference()) getDirectScalarReference()->setUncompleted() ;103 isCompleted_=false ;104 }105 106 107 108 70 109 71 /*! … … 187 149 refScalar[i]->setTransformations(scalar->getAllTransformations()); 188 150 } 189 151 190 152 void CScalar::sendScalarToFileServer(CContextClient* client) 191 153 { 192 154 if (sendScalarToFileServer_done_.count(client)!=0) return ; 193 155 else sendScalarToFileServer_done_.insert(client) ; 194 195 156 StdString scalarDefRoot("scalar_definition"); 196 157 CScalarGroup* scalarPtr = CScalarGroup::get(scalarDefRoot); 197 158 this->sendAllAttributesToServer(client); 198 159 } 160 161 void CScalar::sendScalarToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid) 162 { 163 if (sendScalarToCouplerOut_done_.count(client)!=0) return ; 164 else sendScalarToCouplerOut_done_.insert(client) ; 165 166 string scalarId="_scalar["+std::to_string(posInGrid)+"]_of_"+fieldId ; 167 168 if (!scalar_ref.isEmpty()) 169 { 170 auto scalar_ref_tmp=scalar_ref.getValue() ; 171 scalar_ref.reset() ; // remove the reference, find an other way to do that more cleanly 172 this->sendAllAttributesToServer(client, scalarId) ; 173 scalar_ref = scalar_ref_tmp ; 174 } 175 else this->sendAllAttributesToServer(client, scalarId) ; 176 177 178 this->sendAllAttributesToServer(client, scalarId); 179 } 180 181 void CScalar::makeAliasForCoupling(const string& fieldId, int posInGrid) 182 { 183 const string scalarId = "_scalar["+std::to_string(posInGrid)+"]_of_"+fieldId ; 184 this->createAlias(scalarId) ; 185 } 186 187 void CScalar::setContextClient(CContextClient* contextClient) 188 TRY 189 { 190 if (clientsSet.find(contextClient)==clientsSet.end()) 191 { 192 clients.push_back(contextClient) ; 193 clientsSet.insert(contextClient); 194 } 195 } 196 CATCH_DUMP_ATTR 199 197 /*! 200 198 Parse children nodes of a scalar in xml file. -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.hpp
r1870 r1875 72 72 void checkAttributesOnClient(); 73 73 virtual void parse(xml::CXMLNode & node); 74 75 bool checkIfCompleted(void) ; 76 void setCompleted(void) ; 77 void setUncompleted(void) ; 78 74 79 75 public: 80 76 void sendScalarToFileServer(CContextClient* client) ; 81 77 private: 82 78 std::set<CContextClient*> sendScalarToFileServer_done_ ; 79 80 public: 81 void sendScalarToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid) ; 82 private: 83 std::set<CContextClient*> sendScalarToCouplerOut_done_ ; 84 85 public: 86 void makeAliasForCoupling(const string& fieldId, int posInGrid) ; 83 87 84 88 public: … … 89 93 CTransformation<CScalar>* addTransformation(ETranformationType transType, const StdString& id=""); 90 94 bool isEqual(CScalar* scalar); 91 95 private: 96 /** Clients that have to send a scalar. There can be multiple clients in case of secondary server, otherwise only one client. */ 97 std::list<CContextClient*> clients; 98 std::set<CContextClient*> clientsSet; 99 public: 100 void setContextClient(CContextClient* contextClient) ; 101 92 102 private: 93 103 std::set<StdString> relFiles; … … 103 113 /** define if the scalar is completed or not ie all attributes have been received before in case 104 114 of grid reading from file or coupling */ 105 bool isCompleted_=true ; 115 private: 116 /** define if the scalar is completed or not ie all attributes have been received before in case 117 of grid reading from file or coupling */ 118 bool isCompleted_=true ; 119 public: 120 /*! 121 \brief Check if a scalar is completed 122 Before make any scalar processing, we must be sure that all scalar informations have 123 been sent, for exemple when reading a grid in a file or when grid elements are sent by an 124 other context (coupling). So all direct reference of the scalar (scalar_ref) must be also completed 125 \return true if scalar and scalar reference are completed 126 */ 127 bool isCompleted(void) 128 { 129 if (hasDirectScalarReference()) if (!getDirectScalarReference()->isCompleted()) return false; 130 else return isCompleted_ ; 131 } 132 void setCompleted(void) { isCompleted_=true ; } 133 void unsetCompleted(void) { isCompleted_=false ; } 106 134 135 private: 107 136 DECLARE_REF_FUNC(Scalar,scalar) 108 137 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/object_template.hpp
r1869 r1875 56 56 static void ClearAllAttributes(void); 57 57 std::map<int, size_t> getMinimumBufferSizeForAttributes(CContextClient* client); 58 void sendAttributToServer(const string& id, CContextClient* client );59 void sendAttributToServer(CAttribute& attr, CContextClient* client ) ;60 void sendAllAttributesToServer(CContextClient* client );61 void sendAddItem(const string& id, int itemType, CContextClient* client );58 void sendAttributToServer(const string& id, CContextClient* client, const string& objectId=""); 59 void sendAttributToServer(CAttribute& attr, CContextClient* client, const string& objectId="") ; 60 void sendAllAttributesToServer(CContextClient* client, const string& objectId=""); 61 void sendAddItem(const string& id, int itemType, CContextClient* client, const string& objectId=""); 62 62 static void recvAttributFromClient(CEventServer& event) ; 63 63 static bool dispatchEvent(CEventServer& event) ; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/object_template_impl.hpp
r1869 r1875 216 216 217 217 template<typename T> 218 void CObjectTemplate<T>::sendAllAttributesToServer(CContextClient* client )218 void CObjectTemplate<T>::sendAllAttributesToServer(CContextClient* client, const string& objectId) 219 219 { 220 220 CAttributeMap& attrMap = *this; … … 222 222 for (; it != itE; ++it) 223 223 { 224 if (it->second->doSend() && !(it->second)->isEmpty()) sendAttributToServer(*(it->second), client );224 if (it->second->doSend() && !(it->second)->isEmpty()) sendAttributToServer(*(it->second), client, objectId); 225 225 } 226 226 } 227 227 228 228 template <class T> 229 void CObjectTemplate<T>::sendAttributToServer(const string& id, CContextClient* client )229 void CObjectTemplate<T>::sendAttributToServer(const string& id, CContextClient* client, const string& objectId ) 230 230 { 231 231 CAttributeMap & attrMap = *this; … … 235 235 236 236 template <class T> 237 void CObjectTemplate<T>::sendAttributToServer(CAttribute& attr, CContextClient* client )237 void CObjectTemplate<T>::sendAttributToServer(CAttribute& attr, CContextClient* client, const string& objectId) 238 238 { 239 239 CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE); … … 241 241 { 242 242 CMessage msg; 243 msg<<this->getId(); 243 if (objectId.empty()) msg << this->getId(); 244 else msg << objectId; 244 245 msg << attr.getName(); 245 246 msg << attr; … … 254 255 /* specialisation for context, because context Id on client is not the same on server, and no need to transfer context Id */ 255 256 template <> 256 void CObjectTemplate<CContext>::sendAttributToServer(CAttribute& attr, CContextClient* client )257 void CObjectTemplate<CContext>::sendAttributToServer(CAttribute& attr, CContextClient* client, const string& objectId) 257 258 { 258 259 CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE); … … 278 279 279 280 template<class T> 280 void CObjectTemplate<T>::sendAddItem(const StdString& id, int itemType, CContextClient* client )281 void CObjectTemplate<T>::sendAddItem(const StdString& id, int itemType, CContextClient* client, const string& objectId) 281 282 { 282 283 typedef typename T::EEventId ItemType; … … 285 286 { 286 287 CMessage msg; 287 msg << this->getId(); 288 if (objectId.empty()) msg << this->getId(); 289 else msg << objectId; 288 290 msg << id; 289 291 const std::list<int>& ranks = client->getRanksServerLeader(); -
XIOS/dev/dev_ym/XIOS_COUPLING/src/test/generic_testcase.f90
r1869 r1875 1860 1860 bounds_lon(3,i,j)=bounds_lon_glo(1,ibegin+i) 1861 1861 bounds_lon(4,i,j)=bounds_lon_glo(2,ibegin+i) 1862 bounds_lat(1,i,j)=bounds_lat_glo(1, ibegin+i)1863 bounds_lat(2,i,j)=bounds_lat_glo(1, ibegin+i)1864 bounds_lat(3,i,j)=bounds_lat_glo(2, ibegin+i)1865 bounds_lat(4,i,j)=bounds_lat_glo(2, ibegin+i)1862 bounds_lat(1,i,j)=bounds_lat_glo(1,jbegin+j) 1863 bounds_lat(2,i,j)=bounds_lat_glo(1,jbegin+j) 1864 bounds_lat(3,i,j)=bounds_lat_glo(2,jbegin+j) 1865 bounds_lat(4,i,j)=bounds_lat_glo(2,jbegin+j) 1866 1866 1867 1867 ij=(j+offset_j)*(ni+2*offset_i)+i+offset_i … … 1908 1908 CALL xios_set_domain_attr(TRIM(domain_id), nj_glo=nj_glo, jbegin=jbegin, nj=nj, data_jbegin=-offset_j, data_nj=nj+2*offset_j) 1909 1909 CALL xios_set_domain_attr(TRIM(domain_id), data_dim=2, lonvalue_2d=lon, latvalue_2d=lat, mask_1d=return_mask) 1910 CALL xios_set_domain_attr(TRIM(domain_id), bounds_lon_2d=bounds_lon, bounds_lat_2d=bounds_lat, nvertex=4) 1910 1911 ENDIF 1911 1912 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/domain_algorithm_interpolate.cpp
r1787 r1875 171 171 step=(domainSrc_->lat_end-domainSrc_->lat_start)/domainSrc_->nj_glo ; 172 172 for (int i=0; i<domainSrc_->ni_glo; ++i) lat_g(i)=domainSrc_->lat_start+i*step ; 173 } 174 else if (!domainSrc_->lonvalue.isEmpty() && !domainSrc_->latvalue.isEmpty()) // data can come possibly from coupler so only lonvalue and latvalue are defined ? 175 { 176 CArray<double,1> lon(niSrc), lat(njSrc) ; 177 for(int i=0; i< niSrc;++i) lon(i) = domainSrc_->lonvalue(i) ; 178 for(int j=0, n=0; j<njSrc; ++j, n+=niSrc) lat(j) = domainSrc_->latvalue(n) ; 179 domainSrc_->AllgatherRectilinearLonLat(lon, lat, lon_g, lat_g) ; 173 180 } 174 181 else ERROR("void CDomainAlgorithmInterpolate::computeRemap()",<<"Cannot compute bounds for rectilinear domain") ; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/type/type_decl.cpp
r1509 r1875 33 33 34 34 macro(string) 35 macro(char) 36 macro(short) 35 37 macro(int) 38 macro(unsigned int) 39 macro(long) 40 macro(unsigned long) 41 macro(long long) 42 macro(unsigned long long) 36 43 macro(double) 37 44 macro(bool) 38 macro(StdSize)39 45 macro(CDate) 40 46 macro(CDuration) -
XIOS/dev/dev_ym/XIOS_COUPLING/src/type/type_util.hpp
r1782 r1875 76 76 macro(unsigned int) 77 77 macro(long) 78 macro(long long) 78 79 macro(unsigned long) 80 macro(unsigned long long) 79 81 macro(float) 80 82 macro(double) -
XIOS/dev/dev_ym/XIOS_COUPLING/src/xios_spl.hpp
r1622 r1875 49 49 typedef std::size_t StdSize; 50 50 51 typedef unsigned short int ushort; 52 typedef unsigned int uint; 53 typedef unsigned long int ulong; 51 typedef unsigned short int ushort; 52 typedef unsigned int uint; 53 typedef unsigned long int ulong; 54 typedef long long int longlong; 55 typedef unsigned long long int ulonglong; 54 56 55 57 const size_t stringArrayLen=255 ;
Note: See TracChangeset
for help on using the changeset viewer.