Changeset 821 for XIOS/trunk


Ignore:
Timestamp:
02/10/16 14:35:03 (8 years ago)
Author:
mhnguyen
Message:

Making some improvements of transformation algorithm

+) Correct the way to enlisting transformations in an element (domain, axis)
+) Optimize generic transformation to make sure temporary grid to be created on demand
+) Update some mpi tag to prevent conflict
+) Correct some minor stuffs
+) Update documents

Test
+) On Curie
+) all test pass

Location:
XIOS/trunk
Files:
1 added
22 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/doc/XIOS_reference_guide.lyx

    r797 r821  
    14181418\end_layout 
    14191419 
     1420\begin_layout Subsection* 
     1421index:  
     1422\begin_inset Flex Emph 
     1423status collapsed 
     1424 
     1425\begin_layout Plain Layout 
     14261D-array of double 
     1427\end_layout 
     1428 
     1429\end_inset 
     1430 
     1431 
     1432\end_layout 
     1433 
     1434\begin_layout Standard 
     1435Fortran: 
     1436\end_layout 
     1437 
     1438\begin_layout LyX-Code 
     1439DOUBLE PRECISION :: index(:) 
     1440\end_layout 
     1441 
     1442\begin_layout Standard 
     1443Define the global index of axis which the local axis holds. 
     1444 This attribute is optional and the size of the array is equal to  
     1445\begin_inset Flex Strong 
     1446status collapsed 
     1447 
     1448\begin_layout Plain Layout 
     1449n 
     1450\end_layout 
     1451 
     1452\end_inset 
     1453 
     1454. 
     1455\end_layout 
     1456 
    14201457\begin_layout Section 
    14211458Domain attribute reference 
     
    15431580\begin_layout Standard 
    15441581Define the type of the grid. 
     1582 This attribute is mandatory. 
    15451583\end_layout 
    15461584 
     
    18771915 
    18781916. 
    1879  This attribute is mandatory. 
     1917 This attribute is optional. 
    18801918\end_layout 
    18811919 
     
    19471985 
    19481986. 
    1949  This attribute is mandatory. 
     1987 This attribute is optional. 
    19501988\end_layout 
    19511989 
     
    24232461 
    24242462\begin_layout Standard 
    2425 Define the size of the field data for the first dimension. 
    2426  This attribute is take account only if  
     2463Define the size of the field data for the second dimension. 
     2464 This attribute is taken account only if  
    24272465\begin_inset Flex Strong 
    24282466status collapsed 
     
    25612599 in the output file. 
    25622600 This value is useful in case a field is stored linearly in memory. 
    2563   
     2601 This attribute is optional. 
    25642602\end_layout 
    25652603 
     
    26102648\begin_layout Standard 
    26112649Define the reference of the domain. 
    2612  All attributes are inherited from the referenced domain with the classical 
     2650 All attributes are inherited from the referenced domain with the classic 
    26132651 inheritance mechanism. 
    26142652 The value assigned to the referenced domain is transmitted to to current 
     
    26172655\end_layout 
    26182656 
     2657\begin_layout Subsection* 
     2658i_index:  
     2659\begin_inset Flex Emph 
     2660status collapsed 
     2661 
     2662\begin_layout Plain Layout 
     26631D-array of double 
     2664\end_layout 
     2665 
     2666\end_inset 
     2667 
     2668 
     2669\end_layout 
     2670 
     2671\begin_layout Standard 
     2672Fortran: 
     2673\end_layout 
     2674 
     2675\begin_layout LyX-Code 
     2676DOUBLE PRECISION :: i_index(:) 
     2677\end_layout 
     2678 
     2679\begin_layout Standard 
     2680Define the global index of the first dimension of domain which the local 
     2681 domain holds. 
     2682 This attribute is optional and by default, the size of the array is equal 
     2683 to  
     2684\begin_inset Flex Strong 
     2685status collapsed 
     2686 
     2687\begin_layout Plain Layout 
     2688ni*nj 
     2689\end_layout 
     2690 
     2691\end_inset 
     2692 
     2693. 
     2694\end_layout 
     2695 
     2696\begin_layout Subsection* 
     2697j_index:  
     2698\begin_inset Flex Emph 
     2699status collapsed 
     2700 
     2701\begin_layout Plain Layout 
     27021D-array of double 
     2703\end_layout 
     2704 
     2705\end_inset 
     2706 
     2707 
     2708\end_layout 
     2709 
     2710\begin_layout Standard 
     2711Fortran: 
     2712\end_layout 
     2713 
     2714\begin_layout LyX-Code 
     2715DOUBLE PRECISION :: j_index(:) 
     2716\end_layout 
     2717 
     2718\begin_layout Standard 
     2719Define the global index of the second dimension of domain which the local 
     2720 domain holds. 
     2721 This attribute is optional and by default, the size of the array is equal 
     2722 to  
     2723\begin_inset Flex Strong 
     2724status collapsed 
     2725 
     2726\begin_layout Plain Layout 
     2727ni*nj 
     2728\end_layout 
     2729 
     2730\end_inset 
     2731 
     2732. 
     2733\end_layout 
     2734 
    26192735\begin_layout Section 
    26202736Grid attribute reference 
     
    26572773 
    26582774\begin_layout Subsection* 
    2659 mask:  
     2775mask_1d:  
    26602776\emph on 
    266127771D-array of bool 
     
    26672783 
    26682784\begin_layout LyX-Code 
    2669 LOGICAL :: mask(:) 
     2785LOGICAL :: mask_1d(:) 
    26702786\end_layout 
    26712787 
     
    26882804 
    26892805\begin_layout Subsection* 
    2690 mask:  
     2806mask_2d:  
    26912807\emph on 
    269228082D-array of bool 
     
    26982814 
    26992815\begin_layout LyX-Code 
    2700 LOGICAL :: mask(:,:) 
     2816LOGICAL :: mask_2d(:,:) 
    27012817\end_layout 
    27022818 
     
    27192835 
    27202836\begin_layout Subsection* 
    2721 mask:  
     2837mask_3d:  
    27222838\emph on 
    272328393D-array of bool 
     
    27292845 
    27302846\begin_layout LyX-Code 
    2731 LOGICAL :: mask(:,:,:) 
     2847LOGICAL :: mask_3d(:,:,:) 
    27322848\end_layout 
    27332849 
     
    32373353 
    32383354\begin_layout Subsection* 
     3355grid_path:  
     3356\emph on 
     3357string 
     3358\end_layout 
     3359 
     3360\begin_layout Standard 
     3361Fortran:  
     3362\end_layout 
     3363 
     3364\begin_layout LyX-Code 
     3365CHARACTER(LEN=*) :: grid_path 
     3366\end_layout 
     3367 
     3368\begin_layout Standard 
     3369Define the way operations passing from a grid to others. 
     3370 This attribute is optional. 
     3371\end_layout 
     3372 
     3373\begin_layout Subsection* 
    32393374default_value:  
    32403375\emph on 
     
    36243759 
    36253760\begin_layout Subsection* 
     3761description:  
     3762\emph on 
     3763string 
     3764\end_layout 
     3765 
     3766\begin_layout Standard 
     3767Fortran: 
     3768\end_layout 
     3769 
     3770\begin_layout LyX-Code 
     3771CHARACTER(LEN=*) :: description 
     3772\end_layout 
     3773 
     3774\begin_layout Standard 
     3775Define the description of the file. 
     3776 This attribute is optional. 
     3777\end_layout 
     3778 
     3779\begin_layout Subsection* 
    36263780name_suffix:  
    36273781\emph on 
     
    40314185\emph default 
    40324186. 
    4033 \begin_inset Newline newline 
    4034 \end_inset 
    4035  
    4036  
    4037 \begin_inset Newline newline 
    4038 \end_inset 
    4039  
    4040 Note that the  
     4187 Note that the  
    40414188\series bold 
    40424189\emph on 
     
    42374384 
    42384385\begin_layout Subsection* 
     4386time_counter_name:  
     4387\emph on 
     4388string 
     4389\end_layout 
     4390 
     4391\begin_layout Standard 
     4392Fortran: 
     4393\end_layout 
     4394 
     4395\begin_layout LyX-Code 
     4396CHARACTER(LEN=*) :: time_counter_name 
     4397\end_layout 
     4398 
     4399\begin_layout Standard 
     4400Define the name of the time counter. 
     4401 This attribute is optional. 
     4402\end_layout 
     4403 
     4404\begin_layout Subsection* 
    42394405timeseries:  
    42404406\emph on 
     
    42474413 
    42484414\begin_layout LyX-Code 
    4249 CHARACTER(LEN=*) :: time_counter 
     4415CHARACTER(LEN=*) :: time_series 
    42504416\end_layout 
    42514417 
     
    43264492\series default 
    43274493 will be used. 
     4494\end_layout 
     4495 
     4496\begin_layout Subsection* 
     4497record_offset:  
     4498\emph on 
     4499integer 
     4500\end_layout 
     4501 
     4502\begin_layout Standard 
     4503Fortran: 
     4504\end_layout 
     4505 
     4506\begin_layout LyX-Code 
     4507INTEGER :: record_offset 
     4508\end_layout 
     4509 
     4510\begin_layout Standard 
     4511Define offset of record from the beginning record. 
     4512 This attribute is optional, by default, its value is 0. 
    43284513\end_layout 
    43294514 
  • XIOS/trunk/doc/inputs/user/Domain.lyx

    r797 r821  
    317317interpolation_domain: Implement interpolation from a domain to one another, 
    318318 for now XIOS can only do interpolation by reading calculated weight values 
    319  from a file. 
    320  The calculation on the fly will be implemented soon. 
     319 from a file or calculate the weights on the fly. 
    321320\end_layout 
    322321 
     
    496495 per client process. 
    497496 In the next sections, local describes everything related to a client process, 
    498  whereas global means whole data. 
     497 whereas global means global data. 
    499498 The followings describe the essential parts of domain. 
    500499 Details of its attributes and operations can be found in XIOS reference 
     
    533532curvilinear: a 2-dimensional coordinates allows the generality of two axes 
    534533 not perpendicular to each other. 
    535  Latitude and longitude have the size equivalent to size of whole domain. 
     534 Latitude and longitude have the size equivalent to size of local domain. 
    536535  
    537536\end_layout 
     
    692691\begin_layout Plain Layout 
    693692 
    694 CALL xios_set_domain_attr("domain_A",i_index=iIndex, j_index=jIndex) 
     693CALL xios_set_domain_attr("domain_A",ni_glo=9, nj_glo=9, i_index=iIndex, 
     694 j_index=jIndex) 
    695695\end_layout 
    696696 
     
    10301030 
    10311031\begin_layout Standard 
    1032 For curlinear mesh, bounds_lon_2d and bounds_lat_2d provide a convenient 
     1032For curvilinear mesh, bounds_lon_2d and bounds_lat_2d provide a convenient 
    10331033 way to define longitude and latitude value for the vertex of the cell. 
    10341034 However, it is possible to use bounds_lon_1d and bounds_lat_1d to describe 
  • XIOS/trunk/inputs/REMAP/iodef.xml

    r820 r821  
    6464       <generate_rectilinear_domain id="domain_regular_pole"/> 
    6565       <interpolate_domain/> 
    66 <!--       <zoom_domain id="zoom_0" ibegin="0" ni="180" jbegin="0" nj="90"/>--> 
     66       <zoom_domain id="zoom_0" ibegin="0" ni="90" jbegin="0" nj="90"/> 
    6767     </domain> 
    6868     <domain id="dst_domain_regular" ni_glo="90" nj_glo="45" type="rectilinear"> 
  • XIOS/trunk/inputs/Unstruct/iodef.xml

    r818 r821  
    55   <calendar type="Gregorian" start_date="2012-03-01 15:00:00" time_origin="2012-02-28 15:00:00 + 1d" /> 
    66 
    7    <field_definition level="1" enabled=".TRUE."> 
     7   <field_definition level="1" enabled=".TRUE." default_value="1000"> 
    88     <field id="field_A_srf"  operation="average" freq_op="3600s" grid_ref="grid_A"/> 
    99   </field_definition> 
    1010 
    11    <file_definition type="one_file" par_access="collective" output_freq="6h" output_level="10" enabled=".TRUE."> 
     11   <file_definition type="one_file" par_access="collective" output_freq="6h" output_level="10" enabled=".TRUE." > 
    1212     <file id="output" name="output"> 
    13         <field field_ref="field_A_srf" name="field_A_srf" /> 
     13        <field field_ref="field_A_srf" name="field_A_srf"/> 
    1414     </file> 
    1515   </file_definition> 
  • XIOS/trunk/inputs/Version2/iodef.xml

    r775 r821  
    2222     </file> 
    2323     <file id="output_Axis" name="output_Axis" type="one_file"> 
    24 <!--        <field field_ref="field_Axis" />--> 
     24        <field field_ref="field_Axis" /> 
     25     </file> 
     26     <file id="output_Two_Axis" name="output_Two_Axis" type="one_file"> 
     27        <field field_ref="field_Two_Axis" /> 
    2528     </file> 
    2629     <file id="output_All_Axis" name="output_All_Axis" type="one_file"> 
    27 <!--        <field field_ref="field_All_Axis" />--> 
     30        <field field_ref="field_All_Axis" /> 
    2831     </file> 
    2932     <file id="output_Axis_transformed" name="output_Axis_transformed" type="one_file"> 
    30 <!--        <field field_ref="field_Axis_transformed" />--> 
     33        <field field_ref="field_Axis_transformed" /> 
    3134     </file> 
    3235     <file id="output_Axis_transformed_interpolated" name="output_Axis_transformed_interpolated"> 
    33 <!--        <field field_ref="field_Axis_transformed_Interpolated" />--> 
     36        <field field_ref="field_Axis_transformed_Interpolated" /> 
    3437     </file> 
    3538     <file id="output_Domain_transformed_interpolated" name="output_Domain_transformed_interpolated" type="one_file"> 
     
    4649     <axis id="axis_C" /> 
    4750     <axis id="axis_D" /> 
    48      <axis id="axis_E" axis_ref="axis_A"> 
    49        <inverse_axis /> 
    50      </axis> 
    51      <axis id="axis_F" axis_ref="axis_B"> 
    52         <inverse_axis /> 
    53         <zoom_axis zoom_begin="0" zoom_size="4" /> 
    54         <inverse_axis /> 
    55      </axis> 
    56      <axis id="axis_G" axis_ref="axis_D"> 
     51     <axis id="axis_E"> 
    5752       <interpolate_axis type="polynomial" order="3"/> 
    5853     </axis> 
    59      <axis id="axis_H" axis_ref="axis_C"> 
    60 <!--       <inverse_axis />--> 
    61 <!--       <zoom_axis zoom_begin="0" zoom_size="1" />--> 
     54     <axis id="axis_F" axis_ref="axis_C"> 
     55        <inverse_axis /> 
     56        <zoom_axis begin="0" n="4" /> 
     57        <inverse_axis /> 
    6258     </axis> 
    6359   </axis_definition> 
     
    6561   <domain_definition> 
    6662     <domain id="domain_A" /> 
    67      <domain id="domain_A_zoom" domain_ref="domain_A"> 
    68 <!--       <zoom_domain zoom_ibegin="1" zoom_ni="3" zoom_jbegin="0" zoom_nj="2"/>--> 
    69        <zoom_domain zoom_ibegin="1" zoom_ni="9" zoom_jbegin="0" zoom_nj="2"/> 
    70 <!--       <zoom_domain zoom_ibegin="0" zoom_ni="2" zoom_jbegin="0" zoom_nj="2"/>--> 
    71      </domain> 
    72      <domain id="domain_A_transformed" domain_src="domain_A"> 
    73 <!--       <interpolate_from_file_domain file="" />--> 
     63     <domain id="domain_A_transformed"> 
    7464       <generate_rectilinear_domain /> 
    7565     </domain> 
     
    9585       </grid> 
    9686       <grid id="grid_Axis_tranformed"> 
    97 <!--         <domain domain_ref="domain_A" />--> 
    98          <domain domain_ref="domain_A_zoom" /> 
    99          <axis axis_ref="axis_H" /> 
    100 <!--         <axis axis_ref="axis_E" />--> 
    101 <!--         <axis axis_ref="axis_F" />--> 
     87         <domain domain_ref="domain_A" /> 
     88         <axis axis_ref="axis_F" /> 
    10289       </grid> 
    10390       <grid id="grid_Domain_tranformed_Interpolated"> 
    10491         <domain domain_ref="domain_A_transformed" /> 
    105          <axis axis_ref="axis_H" /> 
     92         <axis axis_ref="axis_C" /> 
    10693       </grid> 
    10794       <grid id="grid_Axis_tranformed_Interpolated"> 
    108          <axis axis_ref="axis_G" /> 
     95         <axis axis_ref="axis_E" /> 
    10996       </grid> 
    11097       <grid id="ScalarGrid"> 
  • XIOS/trunk/src/config/domain_attribute_private.conf

    r775 r821  
    1313DECLARE_ARRAY_PRIVATE(double, 1, lonvalue_rectilinear_read_from_file) 
    1414DECLARE_ARRAY_PRIVATE(double, 1, latvalue_rectilinear_read_from_file) 
     15 
     16DECLARE_ATTRIBUTE_PRIVATE(int,  global_zoom_ibegin) 
     17DECLARE_ATTRIBUTE_PRIVATE(int,  global_zoom_ni) 
     18DECLARE_ATTRIBUTE_PRIVATE(int,  global_zoom_jbegin) 
     19DECLARE_ATTRIBUTE_PRIVATE(int,  global_zoom_nj) 
  • XIOS/trunk/src/distribution_client.cpp

    r818 r821  
    235235      nBeginGlobal_.at(indexMap_[idx]) = axisList[axisIndex]->begin.getValue(); 
    236236      nZoomBegin_.at((indexMap_[idx])) = axisList[axisIndex]->global_zoom_begin; 
    237       nZoomEnd_.at((indexMap_[idx])) = axisList[axisIndex]->global_zoom_begin + axisList[axisIndex]->global_zoom_size-1; 
     237      nZoomEnd_.at((indexMap_[idx])) = axisList[axisIndex]->global_zoom_begin + axisList[axisIndex]->global_zoom_n-1; 
    238238 
    239239      dataBegin_.at(indexMap_[idx]) = axisList[axisIndex]->data_begin.getValue(); 
  • XIOS/trunk/src/io/nc4_data_output.cpp

    r819 r821  
    625625        int zoom_begin_srv = axis->zoom_begin_srv; 
    626626        int zoom_size  = (MULTI_FILE == SuperClass::type) ? zoom_size_srv 
    627                                                               : axis->global_zoom_size; 
     627                                                              : axis->global_zoom_n; 
    628628        int zoom_begin = (MULTI_FILE == SuperClass::type) ? zoom_begin_srv 
    629629                                                              : axis->global_zoom_begin; 
  • XIOS/trunk/src/mpi_tag.hpp

    r720 r821  
    1414#define MPI_DHT_INFO_0 22 
    1515 
     16/* Tag for mpi communication to send and receive info of current grid source in grid transformation*/ 
     17#define MPI_GRID_TRANSFORMATION_CURRENT_GRID_INDEX 31 
     18 
     19/* Tag for mpi communication to send and receive info of current grid source in grid transformation*/ 
     20#define MPI_GRID_TRANSFORMATION_ORIGINAL_GRID_INDEX 32 
     21 
     22/* Tag for mpi communication to send and receive info of current grid source in grid transformation*/ 
     23#define MPI_GRID_TRANSFORMATION_ORIGINAL_GRID_WEIGHT 33 
     24 
     25/* Tag for mpi communication to send and receive info of DOMAIN in domain interpolation*/ 
     26#define MPI_DOMAIN_INTERPOLATION_DEST_INDEX 7 
     27 
     28/* Tag for mpi communication to send and receive info of DOMAIN in domain interpolation*/ 
     29#define MPI_DOMAIN_INTERPOLATION_SRC_INDEX 8 
     30 
     31/* Tag for mpi communication to send and receive info of DOMAIN in domain interpolation*/ 
     32#define MPI_DOMAIN_INTERPOLATION_WEIGHT 9 
     33 
    1634#endif 
  • XIOS/trunk/src/node/axis.cpp

    r817 r821  
    2626      , isDistributed_(false), hasBounds_(false), isCompressible_(false) 
    2727      , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 
    28       , transformationMap_(), global_zoom_begin(0), global_zoom_size(0), hasValue(false) 
     28      , transformationMap_(), hasValue(false) 
    2929   { 
    3030   } 
     
    3535      , isDistributed_(false), hasBounds_(false), isCompressible_(false) 
    3636      , numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 
    37       , transformationMap_(), global_zoom_begin(0), global_zoom_size(0), hasValue(false) 
     37      , transformationMap_(), hasValue(false) 
    3838   { 
    3939   } 
     
    266266   void CAxis::checkZoom(void) 
    267267   { 
    268      if (0 == global_zoom_size) global_zoom_size = this->n_glo.getValue(); 
     268     if (global_zoom_begin.isEmpty()) global_zoom_begin.setValue(0); 
     269     if (global_zoom_n.isEmpty()) global_zoom_n.setValue(n_glo.getValue()); 
    269270   } 
    270271 
     
    391392    size_t ni = this->n.getValue(); 
    392393    size_t ibegin = this->begin.getValue(); 
    393     size_t zoom_end = global_zoom_begin+global_zoom_size-1; 
     394    size_t zoom_end = global_zoom_begin+global_zoom_n-1; 
    394395    size_t nZoomCount = 0; 
    395396    size_t nbIndex = index.numElements(); 
     
    517518    CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_VALUE); 
    518519 
    519     int zoom_end = global_zoom_begin + global_zoom_size - 1; 
     520    int zoom_end = global_zoom_begin + global_zoom_n - 1; 
    520521    int nb = 0; 
    521522    for (size_t idx = 0; idx < n; ++idx) 
     
    830831        msg << this->getId(); 
    831832        msg << ni << begin << end; 
    832         msg << global_zoom_begin << global_zoom_size; 
     833        msg << global_zoom_begin.getValue() << global_zoom_n.getValue(); 
    833834        msg << isCompressible_; 
    834835 
     
    850851  void CAxis::recvServerAttribut(CBufferIn& buffer) 
    851852  { 
    852     int ni_srv, begin_srv, end_srv, global_zoom_begin_tmp, global_zoom_size_tmp; 
     853    int ni_srv, begin_srv, end_srv, global_zoom_begin_tmp, global_zoom_n_tmp; 
    853854 
    854855    buffer >> ni_srv >> begin_srv >> end_srv; 
    855     buffer >> global_zoom_begin_tmp >> global_zoom_size_tmp; 
     856    buffer >> global_zoom_begin_tmp >> global_zoom_n_tmp; 
    856857    buffer >> isCompressible_; 
    857858    global_zoom_begin = global_zoom_begin_tmp; 
    858     global_zoom_size  = global_zoom_size_tmp; 
    859     int global_zoom_end = global_zoom_begin + global_zoom_size - 1; 
     859    global_zoom_n  = global_zoom_n_tmp; 
     860    int global_zoom_end = global_zoom_begin + global_zoom_n - 1; 
    860861 
    861862    zoom_begin_srv = global_zoom_begin > begin_srv ? global_zoom_begin : begin_srv ; 
  • XIOS/trunk/src/node/axis.hpp

    r816 r821  
    2929   BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis) 
    3030#  include "axis_attribute.conf" 
     31#  include "axis_attribute_private.conf" 
    3132   END_DECLARE_ATTRIBUTE_MAP(CAxis) 
    3233 
     
    116117        int zoom_begin_srv, zoom_end_srv, zoom_size_srv; 
    117118        int ni_srv, begin_srv, end_srv; 
    118         int global_zoom_begin, global_zoom_size;  // The real global zoom begin and zoom size after axis is transformed (zoomed) 
    119119        CArray<double,1> value_srv; 
    120120        CArray<double,2> bound_srv; 
  • XIOS/trunk/src/node/domain.cpp

    r815 r821  
    3232      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 
    3333      , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isCompressible_(false), isUnstructed_(false) 
    34       , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0) 
    3534      , isClientAfterTransformationChecked(false), hasLonLat(false) 
    3635      , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() 
     
    4241      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 
    4342      , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isCompressible_(false), isUnstructed_(false) 
    44       , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0) 
    4543      , isClientAfterTransformationChecked(false), hasLonLat(false) 
    4644      , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client() 
     
    663661     } 
    664662     computeNGlobDomain(); 
    665  
    666      if (0 == global_zoom_ni) global_zoom_ni = ni_glo; 
    667      if (0 == global_zoom_nj) global_zoom_nj = nj_glo; 
     663     checkZoom(); 
     664   } 
     665 
     666   void CDomain::checkZoom(void) 
     667   { 
     668     if (global_zoom_ibegin.isEmpty()) 
     669      global_zoom_ibegin.setValue(0); 
     670     if (global_zoom_ni.isEmpty()) 
     671      global_zoom_ni.setValue(ni_glo); 
     672     if (global_zoom_jbegin.isEmpty()) 
     673      global_zoom_jbegin.setValue(0); 
     674     if (global_zoom_nj.isEmpty()) 
     675      global_zoom_nj.setValue(nj_glo); 
    668676   } 
    669677 
     
    12531261        msg << this->getId() ; 
    12541262        msg << ni_srv << ibegin_srv << iend_srv << nj_srv << jbegin_srv << jend_srv; 
    1255         msg << global_zoom_ni << global_zoom_ibegin << global_zoom_nj << global_zoom_jbegin; 
     1263        msg << global_zoom_ni.getValue() << global_zoom_ibegin.getValue() << global_zoom_nj.getValue() << global_zoom_jbegin.getValue(); 
    12561264        msg << isCompressible_; 
    12571265 
     
    16801688  void CDomain::recvServerAttribut(CBufferIn& buffer) 
    16811689  { 
     1690    int global_zoom_ni_tmp, global_zoom_ibegin_tmp, global_zoom_nj_tmp, global_zoom_jbegin_tmp; 
    16821691    buffer >> ni_srv >> ibegin_srv >> iend_srv >> nj_srv >> jbegin_srv >> jend_srv 
    1683            >> global_zoom_ni >> global_zoom_ibegin >> global_zoom_nj >> global_zoom_jbegin 
     1692           >> global_zoom_ni_tmp >> global_zoom_ibegin_tmp >> global_zoom_nj_tmp >> global_zoom_jbegin_tmp 
    16841693           >> isCompressible_; 
     1694 
     1695    global_zoom_ni.setValue(global_zoom_ni_tmp); 
     1696    global_zoom_ibegin.setValue(global_zoom_ibegin_tmp); 
     1697    global_zoom_nj.setValue(global_zoom_nj_tmp); 
     1698    global_zoom_jbegin.setValue(global_zoom_jbegin_tmp); 
    16851699 
    16861700    int zoom_iend = global_zoom_ibegin + global_zoom_ni - 1; 
  • XIOS/trunk/src/node/domain.hpp

    r809 r821  
    9595         bool isCompressible(void) const; 
    9696 
    97          int global_zoom_ibegin, global_zoom_ni; 
    98          int global_zoom_jbegin, global_zoom_nj; 
    99  
    10097         int ni_srv,ibegin_srv,iend_srv ; 
    10198         int zoom_ni_srv,zoom_ibegin_srv,zoom_iend_srv ; 
     
    124121         void sendLonLatArea(void); 
    125122         void computeConnectedServer(void) ; 
    126           
    127          void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat,  
     123 
     124         void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 
    128125                                         CArray<double,1>& lon_g, CArray<double,1>& lat_g); 
    129           
    130          void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat,  
     126 
     127         void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, 
    131128                                           CArray<double,2>& boundsLon, CArray<double,2>& boundsLat); 
    132129         void fillInRectilinearLonLat(); 
     
    170167         void checkArea(void); 
    171168         void checkLonLat(); 
     169         void checkZoom(void); 
    172170 
    173171         void checkTransformations(); 
  • XIOS/trunk/src/node/grid.cpp

    r817 r821  
    262262     } 
    263263     this->isChecked = true; 
     264   } 
     265 
     266   void CGrid::createMask(void) 
     267   { 
     268      using namespace std; 
     269      std::vector<CDomain*> domainP = this->getDomains(); 
     270      std::vector<CAxis*> axisP = this->getAxis(); 
     271      int dim = domainP.size() * 2 + axisP.size(); 
     272 
     273      std::vector<CArray<bool,1>* > domainMasks(domainP.size()); 
     274      for (int i = 0; i < domainMasks.size(); ++i) domainMasks[i] = &(domainP[i]->mask_1d); 
     275      std::vector<CArray<bool,1>* > axisMasks(axisP.size()); 
     276      for (int i = 0; i < axisMasks.size(); ++i) axisMasks[i] = &(axisP[i]->mask); 
     277 
     278      switch (dim) { 
     279        case 1: 
     280          checkGridMask(mask_1d, domainMasks, axisMasks, axis_domain_order, true); 
     281          break; 
     282        case 2: 
     283          checkGridMask(mask_2d, domainMasks, axisMasks, axis_domain_order, true); 
     284          break; 
     285        case 3: 
     286          checkGridMask(mask_3d, domainMasks, axisMasks, axis_domain_order, true); 
     287          break; 
     288        default: 
     289          break; 
     290      } 
    264291   } 
    265292 
  • XIOS/trunk/src/node/grid.hpp

    r775 r821  
    206206         map<int, CArray<size_t, 1> > outIndexFromClient, compressedOutIndexFromClient; 
    207207         void checkMask(void); 
     208         void createMask(void); 
    208209         void modifyMask(const CArray<int,1>& indexToModify); 
    209210 
     
    217218                          const std::vector<CArray<bool,1>* >& domainMasks, 
    218219                          const std::vector<CArray<bool,1>* >& axisMasks, 
    219                           const CArray<bool,1>& axisDomainOrder); 
     220                          const CArray<bool,1>& axisDomainOrder, 
     221                          bool createMask = false); 
    220222        template<int N> 
    221223        void modifyGridMask(CArray<bool,N>& gridMask, const CArray<int,1>& indexToModify); 
     
    295297                             const std::vector<CArray<bool,1>* >& domainMasks, 
    296298                             const std::vector<CArray<bool,1>* >& axisMasks, 
    297                              const CArray<bool,1>& axisDomainOrder) 
     299                             const CArray<bool,1>& axisDomainOrder, 
     300                             bool createMask) 
    298301   { 
    299302     int idx = 0; 
     
    319322    } 
    320323 
    321     if (!gridMask.isEmpty()) 
     324    if (!gridMask.isEmpty() && !createMask) 
    322325    { 
    323326      for (int i = 0; i < dim; ++i) 
  • XIOS/trunk/src/test/test_new_features.f90

    r782 r821  
    1717  INTEGER,PARAMETER :: ni_glo=100 
    1818  INTEGER,PARAMETER :: nj_glo=100 
    19   INTEGER,PARAMETER :: llm=2 
    20   INTEGER,PARAMETER :: llmInterPolated=5 
     19  INTEGER,PARAMETER :: llm=5 
     20  INTEGER,PARAMETER :: llmInterPolated=4 
    2121  DOUBLE PRECISION  :: lval(llm)=1, tsTemp, lvalInterPolated(llmInterPolated)=1 
    2222  TYPE(xios_field) :: field_hdl 
     
    4545 
    4646!!! XIOS Initialization (get the local communicator) 
    47  
    4847  CALL xios_initialize(id,return_comm=comm) 
    4948 
     
    147146  CALL xios_set_axis_attr("axis_C", n_glo=llm, value=lval) 
    148147  CALL xios_set_axis_attr("axis_D", n_glo=llm, begin=axisBegin, n=nAxis, value=lvaln) 
    149   CALL xios_set_axis_attr("axis_G", n_glo=llmInterPolated, value=lvalnInterp, begin=axisterpBegin, n=nAxisinterp) 
     148  CALL xios_set_axis_attr("axis_E", n_glo=llmInterPolated, value=lvalnInterp, begin=axisterpBegin, n=nAxisinterp) 
    150149  CALL xios_set_domain_attr("domain_A",ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, ni=ni,jbegin=jbegin,nj=nj) 
    151150  CALL xios_set_domain_attr("domain_A",data_dim=2, data_ibegin=-1, data_ni=ni+2, data_jbegin=-2, data_nj=nj+4) 
     
    206205    CALL xios_send_field("field_A",field_A) 
    207206    CALL xios_send_field("field_Axis",field_Axis) 
    208  
    209207    CALL xios_send_field("field_Two_Axis",field_Two_Axis) 
    210208    CALL xios_send_field("field_All_Axis",field_All_Axis) 
  • XIOS/trunk/src/transformation/axis_algorithm_zoom.cpp

    r787 r821  
    6262{ 
    6363  axisDest_->global_zoom_begin = zoomBegin_; 
    64   axisDest_->global_zoom_size  = zoomSize_; 
     64  axisDest_->global_zoom_n  = zoomSize_; 
    6565} 
    6666 
  • XIOS/trunk/src/transformation/domain_algorithm_interpolate.cpp

    r809 r821  
    1515#include "netcdf.hpp" 
    1616#include "mapper.hpp" 
     17#include "mpi_tag.hpp" 
    1718 
    1819namespace xios { 
     
    9596          double step=(domainSrc_->lon_end-domainSrc_->lon_start)/domainSrc_->ni_glo ; 
    9697          for(int i=0; i<domainSrc_->ni_glo; ++i) lon_g(i)=domainSrc_->lon_start+i*step ; 
    97           step=(domainSrc_->lat_end-domainSrc_->lat_start)/domainSrc_->nj_glo ;  
     98          step=(domainSrc_->lat_end-domainSrc_->lat_start)/domainSrc_->nj_glo ; 
    9899          for(int i=0; i<domainSrc_->ni_glo; ++i) lat_g(i)=domainSrc_->lat_start+i*step ; 
    99100        } 
     
    160161          double step=(domainDest_->lon_end-domainDest_->lon_start)/domainDest_->ni_glo ; 
    161162          for(int i=0; i<domainDest_->ni_glo; ++i) lon_g(i)=domainDest_->lon_start+i*step ; 
    162           step=(domainDest_->lat_end-domainDest_->lat_start)/domainDest_->nj_glo ;  
     163          step=(domainDest_->lat_end-domainDest_->lat_start)/domainDest_->nj_glo ; 
    163164          for(int i=0; i<domainDest_->ni_glo; ++i) lat_g(i)=domainDest_->lat_start+i*step ; 
    164165        } 
     
    167168    if (std::abs(poleValue - std::abs(lat_g(domainDest_->nj_glo-1))) < NumTraits<double>::epsilon()) isSouthPole = true; 
    168169 
    169      
    170      
    171      
     170 
     171 
     172 
    172173    if (isNorthPole && (0 == domainDest_->jbegin.getValue())) 
    173174    { 
     
    469470             MPI_INT, 
    470471             itMap->first, 
    471              7, 
     472             MPI_DOMAIN_INTERPOLATION_DEST_INDEX, 
    472473             client->intraComm, 
    473474             &sendRequest.back()); 
     
    477478             MPI_INT, 
    478479             itMap->first, 
    479              8, 
     480             MPI_DOMAIN_INTERPOLATION_SRC_INDEX, 
    480481             client->intraComm, 
    481482             &sendRequest.back()); 
     
    485486             MPI_DOUBLE, 
    486487             itMap->first, 
    487              9, 
     488             MPI_DOMAIN_INTERPOLATION_WEIGHT, 
    488489             client->intraComm, 
    489490             &sendRequest.back()); 
     
    504505             MPI_INT, 
    505506             MPI_ANY_SOURCE, 
    506              7, 
     507             MPI_DOMAIN_INTERPOLATION_DEST_INDEX, 
    507508             client->intraComm, 
    508509             &recvStatus); 
     
    516517             MPI_INT, 
    517518             clientSrcRank, 
    518              8, 
     519             MPI_DOMAIN_INTERPOLATION_SRC_INDEX, 
    519520             client->intraComm, 
    520521             &recvStatus); 
     
    524525             MPI_DOUBLE, 
    525526             clientSrcRank, 
    526              9, 
     527             MPI_DOMAIN_INTERPOLATION_WEIGHT, 
    527528             client->intraComm, 
    528529             &recvStatus); 
  • XIOS/trunk/src/transformation/grid_transformation.cpp

    r795 r821  
    1818#include "axis_algorithm_transformation.hpp" 
    1919#include "distribution_client.hpp" 
     20#include "mpi_tag.hpp" 
    2021 
    2122namespace xios { 
    2223CGridTransformation::CGridTransformation(CGrid* destination, CGrid* source) 
    2324: gridSource_(source), gridDestination_(destination), originalGridSource_(source), 
    24   globalIndexOfCurrentGridSource_(), globalIndexOfOriginalGridSource_(), weightOfGlobalIndexOfOriginalGridSource_(0), algoTypes_() 
     25  algoTypes_(), nbAlgos_(0), currentGridIndexToOriginalGridIndex_() 
     26 
    2527{ 
    2628  //Verify the compatibity between two grids 
     
    4143  } 
    4244 
    43   std::vector<CAxis*> axisSrcTmp = gridSource_->getAxis(), axisSrc; 
    44   std::vector<CDomain*> domainSrcTmp = gridSource_->getDomains(), domainSrc; 
    45   for (int idx = 0; idx < axisSrcTmp.size(); ++idx) 
    46   { 
    47     CAxis* axis = CAxis::createAxis(); 
    48     axis->axis_ref.setValue(axisSrcTmp[idx]->getId()); 
    49     axis->solveRefInheritance(true); 
    50     axis->solveInheritanceTransformation(); 
    51     axis->checkAttributesOnClient(); 
    52     axisSrc.push_back(axis); 
    53   } 
    54  
    55   for (int idx = 0; idx < domainSrcTmp.size(); ++idx) 
    56   { 
    57     CDomain* domain = CDomain::createDomain(); 
    58     domain->domain_ref.setValue(domainSrcTmp[idx]->getId()); 
    59     domain->solveRefInheritance(true); 
    60     domain->solveInheritanceTransformation(); 
    61     domain->checkAttributesOnClient(); 
    62     domainSrc.push_back(domain); 
    63   } 
    64  
    65   gridSource_ = CGrid::createGrid(domainSrc, axisSrc, gridDestination_->axis_domain_order); 
    66   gridSource_->computeGridGlobalDimension(domainSrc, axisSrc, gridDestination_->axis_domain_order); 
     45//  std::vector<CAxis*> axisSrcTmp = gridSource_->getAxis(), axisSrc; 
     46//  std::vector<CDomain*> domainSrcTmp = gridSource_->getDomains(), domainSrc; 
     47//  for (int idx = 0; idx < axisSrcTmp.size(); ++idx) 
     48//  { 
     49//    CAxis* axis = CAxis::createAxis(); 
     50//    axis->axis_ref.setValue(axisSrcTmp[idx]->getId()); 
     51//    axis->solveRefInheritance(true); 
     52//    axis->solveInheritanceTransformation(); 
     53//    axis->checkAttributesOnClient(); 
     54//    axisSrc.push_back(axis); 
     55//  } 
     56// 
     57//  for (int idx = 0; idx < domainSrcTmp.size(); ++idx) 
     58//  { 
     59//    CDomain* domain = CDomain::createDomain(); 
     60//    domain->domain_ref.setValue(domainSrcTmp[idx]->getId()); 
     61//    domain->solveRefInheritance(true); 
     62//    domain->solveInheritanceTransformation(); 
     63//    domain->checkAttributesOnClient(); 
     64//    domainSrc.push_back(domain); 
     65//  } 
     66// 
     67//  gridSource_ = CGrid::createGrid(domainSrc, axisSrc, gridDestination_->axis_domain_order); 
     68//  gridSource_->computeGridGlobalDimension(domainSrc, axisSrc, gridDestination_->axis_domain_order); 
    6769 
    6870  initializeMappingOfOriginalGridSource(); 
    69   initializeAlgorithms(); 
     71//  initializeAlgorithms(); 
    7072} 
    7173 
     
    8183  CContextClient* client = context->client; 
    8284 
    83   CDistributionClient distribution(client->clientRank, originalGridSource_); 
    84   const std::vector<size_t>& globalIndexGridSrcSendToServer = distribution.getGlobalDataIndexSendToServer(); 
    85  
    86   weightOfGlobalIndexOfOriginalGridSource_.resize(globalIndexGridSrcSendToServer.size()); 
    87   globalIndexOfCurrentGridSource_  = globalIndexGridSrcSendToServer; 
    88   globalIndexOfOriginalGridSource_ = globalIndexGridSrcSendToServer; 
    89   weightOfGlobalIndexOfOriginalGridSource_ = 1.0; 
     85  // Initialize algorithms 
     86  initializeAlgorithms(); 
     87 
     88  ListAlgoType::const_iterator itb = listAlgos_.begin(), 
     89                               ite = listAlgos_.end(), it; 
     90 
     91  for (it = itb; it != ite; ++it) 
     92  { 
     93    ETranformationType transType = (it->second).first; 
     94    if (!isSpecialTransformation(transType)) ++nbAlgos_; 
     95  } 
     96 
     97  if (1<nbAlgos_)  // Only when there are more than 1 algorithm, will we create temporary grid source 
     98  { 
     99    std::vector<CAxis*> axisSrcTmp = gridSource_->getAxis(), axisSrc; 
     100    std::vector<CDomain*> domainSrcTmp = gridSource_->getDomains(), domainSrc; 
     101    for (int idx = 0; idx < axisSrcTmp.size(); ++idx) 
     102    { 
     103      CAxis* axis = CAxis::createAxis(); 
     104      axis->axis_ref.setValue(axisSrcTmp[idx]->getId()); 
     105      axis->solveRefInheritance(true); 
     106      axis->solveInheritanceTransformation(); 
     107      axis->checkAttributesOnClient(); 
     108      axisSrc.push_back(axis); 
     109    } 
     110 
     111    for (int idx = 0; idx < domainSrcTmp.size(); ++idx) 
     112    { 
     113      CDomain* domain = CDomain::createDomain(); 
     114      domain->domain_ref.setValue(domainSrcTmp[idx]->getId()); 
     115      domain->solveRefInheritance(true); 
     116      domain->solveInheritanceTransformation(); 
     117      domain->checkAttributesOnClient(); 
     118      domainSrc.push_back(domain); 
     119    } 
     120 
     121    gridSource_ = CGrid::createGrid(domainSrc, axisSrc, gridDestination_->axis_domain_order); 
     122    gridSource_->computeGridGlobalDimension(domainSrc, axisSrc, gridDestination_->axis_domain_order); 
     123  } 
    90124} 
    91125 
     
    149183  } 
    150184} 
    151  
    152  
    153185 
    154186/*! 
     
    335367      break; 
    336368  } 
     369  gridSource_->createMask(); 
     370  gridSource_->computeGridGlobalDimension(domListSrcP, axisListSrcP, gridSource_->axis_domain_order); 
    337371} 
    338372 
     
    352386  ListAlgoType::const_iterator itb = listAlgos_.begin(), 
    353387                               ite = listAlgos_.end(), it; 
     388 
    354389  CGenericAlgorithmTransformation* algo = 0; 
    355390  int nbAgloTransformation = 0; // Only count for executed transformation. Generate domain is a special one, not executed in the list 
     
    381416                                     globaIndexWeightFromDestToSource); 
    382417 
    383       // Compute transformation of global indexes among grids 
    384       computeTransformationFromOriginalGridSource(globaIndexWeightFromDestToSource); 
    385  
    386       // Now grid destination becomes grid source in a new transformation 
    387       setUpGrid(elementPositionInGrid, transType); 
     418      if (1 < nbAlgos_) 
     419      { 
     420        // Compute transformation of global indexes among grids 
     421        computeTransformationFromOriginalGridSource(globaIndexWeightFromDestToSource); 
     422 
     423        // Now grid destination becomes grid source in a new transformation 
     424        if (nbAgloTransformation != (nbAlgos_-1)) setUpGrid(elementPositionInGrid, transType); 
     425      } 
     426      else 
     427      { 
     428        currentGridIndexToOriginalGridIndex_.swap(globaIndexWeightFromDestToSource); 
     429      } 
     430 
    388431      ++nbAgloTransformation; 
    389432    } 
     
    416459  iteArr = globalIndexOnClientDest.end(); 
    417460 
    418   // Then find out which index became invalid (become masked after being applied the algorithms, or demande some masked points from grid source) 
    419   int num = globalIndexOfOriginalGridSource_.size(); 
     461  GlobalIndexMap::const_iterator iteGlobalMap = currentGridIndexToOriginalGridIndex_.end(); 
    420462  const size_t sfmax = NumTraits<unsigned long>::sfmax(); 
    421463  int maskIndexNum = 0; 
    422   for (int idx = 0; idx < num; ++idx) 
    423   { 
    424     if (sfmax == globalIndexOfOriginalGridSource_[idx]) 
    425     { 
    426       size_t maskedGlobalIndex = globalIndexOfCurrentGridSource_[idx]; 
    427       itArr = std::find(itbArr, iteArr, maskedGlobalIndex); 
    428       if (iteArr != itArr) ++maskIndexNum; 
     464  for (itArr = itbArr; itArr != iteArr; ++itArr) 
     465  { 
     466    if (iteGlobalMap != currentGridIndexToOriginalGridIndex_.find(*itArr)) 
     467    { 
     468      const std::vector<std::pair<size_t,double> >& vecIndex = currentGridIndexToOriginalGridIndex_[*itArr]; 
     469      for (int idx = 0; idx < vecIndex.size(); ++idx) 
     470      { 
     471        if (sfmax == vecIndex[idx].first) 
     472        { 
     473          ++maskIndexNum; 
     474          break; 
     475        } 
     476      } 
    429477    } 
    430478  } 
     
    432480  CArray<int,1> maskIndexToModify(maskIndexNum); 
    433481  maskIndexNum = 0; 
    434   for (int idx = 0; idx < num; ++idx) 
    435   { 
    436     if (sfmax == globalIndexOfOriginalGridSource_[idx]) 
    437     { 
    438       size_t maskedGlobalIndex = globalIndexOfCurrentGridSource_[idx]; 
    439       itArr = std::find(itbArr, iteArr, maskedGlobalIndex); 
    440       if (iteArr != itArr) 
     482  for (itArr = itbArr; itArr != iteArr; ++itArr) 
     483  { 
     484    if (iteGlobalMap != currentGridIndexToOriginalGridIndex_.find(*itArr)) 
     485    { 
     486      const std::vector<std::pair<size_t,double> >& vecIndex = currentGridIndexToOriginalGridIndex_[*itArr]; 
     487      for (int idx = 0; idx < vecIndex.size(); ++idx) 
    441488      { 
    442         int localIdx = std::distance(itbArr, itArr); 
    443         maskIndexToModify(maskIndexNum) = localMaskIndexOnClientDest[localIdx]; 
    444         ++maskIndexNum; 
     489        if (sfmax == vecIndex[idx].first) 
     490        { 
     491          int localIdx = std::distance(itbArr, itArr); 
     492          maskIndexToModify(maskIndexNum) = localMaskIndexOnClientDest[localIdx]; 
     493          ++maskIndexNum; 
     494          break; 
     495        } 
    445496      } 
    446497    } 
     
    460511  CContextClient* client = context->client; 
    461512 
     513  if (currentGridIndexToOriginalGridIndex_.empty()) 
     514  { 
     515    currentGridIndexToOriginalGridIndex_ = globaIndexMapFromDestToSource; 
     516    return; 
     517  } 
     518 
    462519  CTransformationMapping transformationMap(gridDestination_, gridSource_); 
    463520 
     
    471528  std::map<int,std::vector<size_t> >::const_iterator itbSend = globalIndexToSend.begin(), itSend, 
    472529                                                     iteSend = globalIndexToSend.end(); 
    473   std::vector<size_t>::const_iterator itbArr = globalIndexOfCurrentGridSource_.begin(), itArr, 
    474                                       iteArr = globalIndexOfCurrentGridSource_.end(); 
    475530 int sendBuffSize = 0; 
    476531 for (itSend = itbSend; itSend != iteSend; ++itSend) sendBuffSize += (itSend->second).size(); 
     532 // We use the first element of each block to send number of element in this block 
     533 sendBuffSize += globalIndexToSend.size(); 
     534 
    477535 
    478536 typedef unsigned long Scalar; 
    479  unsigned long* sendBuff, *currentSendBuff; 
    480  if (0 != sendBuffSize) sendBuff = new unsigned long [sendBuffSize]; 
     537 Scalar* sendBuff, *currentSendBuff; 
     538 if (0 != sendBuffSize) sendBuff = new Scalar [sendBuffSize]; 
    481539 for (StdSize idx = 0; idx < sendBuffSize; ++idx) sendBuff[idx] = NumTraits<Scalar>::sfmax(); 
    482540 
    483  std::map<int, MPI_Request> requests; 
    484  
    485  std::vector<int> permutIndex(globalIndexOfCurrentGridSource_.size()); 
    486  typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 
    487  XIOSAlgorithms::fillInIndex(globalIndexOfCurrentGridSource_.size(), permutIndex); 
    488  XIOSAlgorithms::sortWithIndex<size_t, CVectorStorage>(globalIndexOfCurrentGridSource_, permutIndex); 
    489  BinarySearch searchCurrentSrc(globalIndexOfCurrentGridSource_); 
    490  std::vector<int>::iterator itbIndex = permutIndex.begin(), itIndex, 
    491                             iteIndex = permutIndex.end(); 
    492  
    493   // Find out local index on grid destination (received) 
     541 std::map<int, MPI_Request> requestsCurrentGrid, requestsOriginalGrid, requestsWeightGrid; 
     542 GlobalIndexMap::const_iterator iteGlobalIndex = currentGridIndexToOriginalGridIndex_.end(); 
     543 
     544  // Only send global index of original source corresponding to non-masked index 
     545  // Use first position of each block to specify the number of elemnt in this block 
     546 int globalIndexOriginalSrcSendBuffSize = 0; 
    494547 int currentBuffPosition = 0; 
    495548 for (itSend = itbSend; itSend != iteSend; ++itSend) 
     
    497550   int destRank = itSend->first; 
    498551   const std::vector<size_t>& globalIndexOfCurrentGridSourceToSend = itSend->second; 
    499    int countSize = globalIndexOfCurrentGridSourceToSend.size(); 
    500    for (int idx = 0; idx < (countSize); ++idx) 
     552   int countSize  = globalIndexOfCurrentGridSourceToSend.size(); 
     553   size_t countBlock = 0; 
     554   for (int idx = 0; idx < countSize; ++idx) 
    501555   { 
    502      if (searchCurrentSrc.search(itbIndex, iteIndex, globalIndexOfCurrentGridSourceToSend[idx], itIndex)) 
     556     size_t index = globalIndexOfCurrentGridSourceToSend[idx]; 
     557     if (iteGlobalIndex != currentGridIndexToOriginalGridIndex_.find(index))// searchCurrentSrc.search(itbIndex, iteIndex, globalIndexOfCurrentGridSourceToSend[idx], itIndex)) 
    503558     { 
    504        sendBuff[idx+currentBuffPosition] = globalIndexOfOriginalGridSource_[*itIndex]; 
     559       globalIndexOriginalSrcSendBuffSize += currentGridIndexToOriginalGridIndex_[index].size() + 1; // 1 for number of elements in this block 
     560       sendBuff[idx+currentBuffPosition+1] = index; 
     561       countBlock += currentGridIndexToOriginalGridIndex_[index].size() + 1; 
    505562     } 
    506563   } 
     564   sendBuff[currentBuffPosition] = countBlock; 
    507565   currentSendBuff = sendBuff + currentBuffPosition; 
    508    MPI_Isend(currentSendBuff, countSize, MPI_UNSIGNED_LONG, destRank, 14, client->intraComm, &requests[destRank]); 
    509    currentBuffPosition += countSize; 
     566   MPI_Isend(currentSendBuff, countSize +1, MPI_UNSIGNED_LONG, destRank, MPI_GRID_TRANSFORMATION_CURRENT_GRID_INDEX, client->intraComm, &requestsCurrentGrid[destRank]); 
     567   currentBuffPosition += countSize + 1; 
    510568 } 
     569 
     570 Scalar* sendOriginalIndexBuff, *currentOriginalIndexSendBuff; 
     571 if (0 != globalIndexOriginalSrcSendBuffSize) sendOriginalIndexBuff = new Scalar [globalIndexOriginalSrcSendBuffSize]; 
     572 double* sendOriginalWeightBuff, *currentOriginalWeightSendBuff; 
     573 if (0 != globalIndexOriginalSrcSendBuffSize) sendOriginalWeightBuff = new double [globalIndexOriginalSrcSendBuffSize]; 
     574 
     575 currentBuffPosition = 0; 
     576 for (itSend = itbSend; itSend != iteSend; ++itSend) 
     577 { 
     578   int destRank = itSend->first; 
     579   const std::vector<size_t>& globalIndexOfCurrentGridSourceToSend = itSend->second; 
     580   int countSize = globalIndexOfCurrentGridSourceToSend.size(); 
     581   int increaseStep = 0; 
     582   for (int idx = 0; idx < countSize; ++idx) 
     583   { 
     584     size_t index = globalIndexOfCurrentGridSourceToSend[idx]; 
     585     if (iteGlobalIndex != currentGridIndexToOriginalGridIndex_.find(index)) 
     586     { 
     587       size_t vectorSize = currentGridIndexToOriginalGridIndex_[index].size(); 
     588       sendOriginalIndexBuff[currentBuffPosition+increaseStep]  = vectorSize; 
     589       sendOriginalWeightBuff[currentBuffPosition+increaseStep] = (double)vectorSize; 
     590       const std::vector<std::pair<size_t,double> >& indexWeightPair = currentGridIndexToOriginalGridIndex_[index]; 
     591       for (size_t i = 0; i < vectorSize; ++i) 
     592       { 
     593         ++increaseStep; 
     594         sendOriginalIndexBuff[currentBuffPosition+increaseStep]  = indexWeightPair[i].first; 
     595         sendOriginalWeightBuff[currentBuffPosition+increaseStep] = indexWeightPair[i].second; 
     596       } 
     597       ++increaseStep; 
     598     } 
     599   } 
     600 
     601   currentOriginalIndexSendBuff = sendOriginalIndexBuff + currentBuffPosition; 
     602   currentOriginalWeightSendBuff = sendOriginalWeightBuff + currentBuffPosition; 
     603   if (0 != increaseStep) 
     604   { 
     605     MPI_Isend(currentOriginalIndexSendBuff, increaseStep, MPI_UNSIGNED_LONG, destRank, MPI_GRID_TRANSFORMATION_ORIGINAL_GRID_INDEX, client->intraComm, &requestsOriginalGrid[destRank]); 
     606     MPI_Isend(currentOriginalWeightSendBuff, increaseStep, MPI_DOUBLE, destRank, MPI_GRID_TRANSFORMATION_ORIGINAL_GRID_WEIGHT, client->intraComm, &requestsWeightGrid[destRank]); 
     607   } 
     608   currentBuffPosition += increaseStep; 
     609 } 
     610 
    511611 
    512612 // Receiving global index of grid source sending from current grid source 
     
    515615 int recvBuffSize = 0; 
    516616 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) recvBuffSize += (itRecv->second).size(); 
    517  
    518  unsigned long* recvBuff, *currentRecvBuff; 
    519  if (0 != recvBuffSize) recvBuff = new unsigned long [recvBuffSize]; 
     617 recvBuffSize += globalIndexToReceive.size(); 
     618 
     619 Scalar* recvBuff, *currentRecvBuff; 
     620 if (0 != recvBuffSize) recvBuff = new Scalar [recvBuffSize]; 
    520621 for (StdSize idx = 0; idx < recvBuffSize; ++idx) recvBuff[idx] = NumTraits<Scalar>::sfmax(); 
    521622 
     623 std::map<int,int> countBlockMap; 
     624 int globalIndexOriginalSrcRecvBuffSize = 0; 
    522625 int currentRecvBuffPosition = 0; 
    523626 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) 
     
    527630   int countSize = (itRecv->second).size(); 
    528631   currentRecvBuff = recvBuff + currentRecvBuffPosition; 
    529    MPI_Recv(currentRecvBuff, countSize, MPI_UNSIGNED_LONG, srcRank, 14, client->intraComm, &status); 
    530    currentRecvBuffPosition += countSize; 
     632   MPI_Recv(currentRecvBuff, countSize +1, MPI_UNSIGNED_LONG, srcRank, MPI_GRID_TRANSFORMATION_CURRENT_GRID_INDEX, client->intraComm, &status); 
     633   globalIndexOriginalSrcRecvBuffSize += *currentRecvBuff; 
     634   countBlockMap[srcRank] = *currentRecvBuff; 
     635   currentRecvBuffPosition += countSize +1; 
    531636 } 
    532637 
    533  int nbCurrentGridSource = 0; 
     638 Scalar* recvOriginalIndexBuff, *currentOriginalIndexRecvBuff; 
     639 if (0 != globalIndexOriginalSrcRecvBuffSize) recvOriginalIndexBuff = new Scalar [globalIndexOriginalSrcRecvBuffSize]; 
     640 double* recvOriginalWeightBuff, *currentOriginalWeightRecvBuff; 
     641 if (0 != globalIndexOriginalSrcRecvBuffSize) recvOriginalWeightBuff = new double [globalIndexOriginalSrcRecvBuffSize]; 
     642 
     643 int countBlock = 0; 
     644 currentRecvBuffPosition = 0; 
     645 currentBuffPosition = 0; 
    534646 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) 
    535647 { 
    536    int ssize = (itRecv->second).size(); 
    537    for (int idx = 0; idx < ssize; ++idx) 
     648   MPI_Status statusIndex, statusWeight; 
     649   int srcRank = itRecv->first; 
     650   countBlock = countBlockMap[srcRank]; 
     651   currentOriginalIndexRecvBuff = recvOriginalIndexBuff + currentBuffPosition; 
     652   currentOriginalWeightRecvBuff = recvOriginalWeightBuff + currentBuffPosition; 
     653   if (0 != countBlock) 
    538654   { 
    539      nbCurrentGridSource += (itRecv->second)[idx].size(); 
     655     MPI_Recv(currentOriginalIndexRecvBuff, countBlock, MPI_UNSIGNED_LONG, srcRank, MPI_GRID_TRANSFORMATION_ORIGINAL_GRID_INDEX, client->intraComm, &statusIndex); 
     656     MPI_Recv(currentOriginalWeightRecvBuff, countBlock, MPI_DOUBLE, srcRank, MPI_GRID_TRANSFORMATION_ORIGINAL_GRID_WEIGHT, client->intraComm, &statusWeight); 
     657   } 
     658   currentBuffPosition += countBlock; 
     659 } 
     660 
     661 // We process everything in here, even case of masked index 
     662 // The way to process masked index needs discussing 
     663 const size_t sfmax = NumTraits<unsigned long>::sfmax(); 
     664 GlobalIndexMap currentToOriginalTmp; 
     665 
     666 currentRecvBuffPosition = 0; 
     667 currentRecvBuff = recvBuff; 
     668 currentOriginalIndexRecvBuff  = recvOriginalIndexBuff; 
     669 currentOriginalWeightRecvBuff = recvOriginalWeightBuff; 
     670 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) 
     671 { 
     672   int countBlockRank = countBlockMap[itRecv->first]; 
     673 
     674   ++currentRecvBuff;  // it's very subtle here, pay attention 
     675   int countSize = (itRecv->second).size(); 
     676   for (int idx = 0; idx < countSize; ++idx) 
     677   { 
     678      ++currentRecvBuff; 
     679     int ssize = (itRecv->second)[idx].size(); 
     680     if (sfmax != *currentRecvBuff) 
     681     { 
     682       if (0 != countBlockRank) 
     683       { 
     684         countBlock = *(currentOriginalIndexRecvBuff+currentRecvBuffPosition); 
     685         for (int i = 0; i < ssize; ++i) 
     686         { 
     687           for (int j = 0; j < countBlock; ++j) 
     688           { 
     689             size_t globalOriginalIndex = *(currentOriginalIndexRecvBuff+currentRecvBuffPosition+j+1); 
     690             double weightGlobal = *(currentOriginalWeightRecvBuff+currentRecvBuffPosition+j+1) * (itRecv->second)[idx][i].second; 
     691             currentToOriginalTmp[(itRecv->second)[idx][i].first].push_back(make_pair(globalOriginalIndex,weightGlobal)); 
     692           } 
     693         } 
     694         currentRecvBuffPosition += countBlock+1; 
     695       } 
     696     } 
     697//     else 
     698//     { 
     699//       for (int i = 0; i < ssize; ++i) 
     700//       { 
     701//         currentToOriginalTmp[(itRecv->second)[idx][i].first].push_back(make_pair(sfmax,1.0)); 
     702//       } 
     703//     } 
    540704   } 
    541705 } 
    542706 
    543  if (globalIndexOfCurrentGridSource_.size() != nbCurrentGridSource) 
    544  { 
    545    globalIndexOfCurrentGridSource_.resize(nbCurrentGridSource); 
    546    globalIndexOfOriginalGridSource_.resize(nbCurrentGridSource); 
    547    weightOfGlobalIndexOfOriginalGridSource_.resize(nbCurrentGridSource); 
    548  } 
    549  
    550  int k = 0; 
    551  currentRecvBuff = recvBuff; 
    552  for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) 
    553  { 
    554    int countSize = (itRecv->second).size(); 
    555    for (int idx = 0; idx < countSize; ++idx, ++currentRecvBuff) 
    556    { 
    557      int ssize = (itRecv->second)[idx].size(); 
    558      for (int i = 0; i < ssize; ++i) 
    559      { 
    560        globalIndexOfCurrentGridSource_[k] = ((itRecv->second)[idx][i]).first; 
    561        weightOfGlobalIndexOfOriginalGridSource_(k) = ((itRecv->second)[idx][i]).second; 
    562        globalIndexOfOriginalGridSource_[k] = *currentRecvBuff; 
    563        ++k; 
    564      } 
    565    } 
    566  } 
     707 currentGridIndexToOriginalGridIndex_.swap(currentToOriginalTmp); 
    567708 
    568709 std::map<int, MPI_Request>::iterator itRequest; 
    569  for (itRequest = requests.begin(); itRequest != requests.end(); ++itRequest) 
     710 for (itRequest = requestsCurrentGrid.begin(); itRequest != requestsCurrentGrid.end(); ++itRequest) 
     711   MPI_Wait(&itRequest->second, MPI_STATUS_IGNORE); 
     712 for (itRequest = requestsOriginalGrid.begin(); itRequest != requestsOriginalGrid.end(); ++itRequest) 
     713   MPI_Wait(&itRequest->second, MPI_STATUS_IGNORE); 
     714 for (itRequest = requestsWeightGrid.begin(); itRequest != requestsWeightGrid.end(); ++itRequest) 
    570715   MPI_Wait(&itRequest->second, MPI_STATUS_IGNORE); 
    571716 
    572717 if (0 != sendBuffSize) delete [] sendBuff; 
    573718 if (0 != recvBuffSize) delete [] recvBuff; 
     719 if (0 != globalIndexOriginalSrcSendBuffSize) delete [] sendOriginalIndexBuff; 
     720 if (0 != globalIndexOriginalSrcSendBuffSize) delete [] sendOriginalWeightBuff; 
     721 if (0 != globalIndexOriginalSrcRecvBuffSize) delete [] recvOriginalIndexBuff; 
     722 if (0 != globalIndexOriginalSrcRecvBuffSize) delete [] recvOriginalWeightBuff; 
    574723} 
    575724 
     
    586735  CTransformationMapping transformationMap(gridDestination_, originalGridSource_); 
    587736 
    588   std::map<size_t, std::vector<std::pair<size_t,double> > > globaIndexWeightFromDestToSource; 
    589   int nb = globalIndexOfCurrentGridSource_.size(); 
    590   const size_t sfmax = NumTraits<unsigned long>::sfmax(); 
    591   for (int idx = 0; idx < nb; ++idx) 
    592   { 
    593     if (sfmax != globalIndexOfOriginalGridSource_[idx]) 
    594       globaIndexWeightFromDestToSource[globalIndexOfCurrentGridSource_[idx]].push_back(make_pair(globalIndexOfOriginalGridSource_[idx], weightOfGlobalIndexOfOriginalGridSource_(idx))) ; 
    595   } 
    596  
    597   // Then compute transformation mapping among clients 
    598   transformationMap.computeTransformationMapping(globaIndexWeightFromDestToSource); 
     737  transformationMap.computeTransformationMapping(currentGridIndexToOriginalGridIndex_); 
    599738 
    600739  const std::map<int,std::vector<std::vector<std::pair<size_t,double> > > >& globalIndexToReceive = transformationMap.getGlobalIndexReceivedOnGridDestMapping(); 
     
    667806} 
    668807 
     808bool CGridTransformation::isSpecialTransformation(ETranformationType transType) 
     809{ 
     810  bool res; 
     811  switch (transType) 
     812  { 
     813    case TRANS_GENERATE_RECTILINEAR_DOMAIN: 
     814     res = true; 
     815     break; 
     816    default: 
     817     res = false; 
     818     break; 
     819  } 
     820 
     821  return res; 
     822} 
     823 
    669824/*! 
    670825  Local index of data which need sending from the grid source 
  • XIOS/trunk/src/transformation/grid_transformation.hpp

    r790 r821  
    6363  void computeTransformationFromOriginalGridSource(const std::map<size_t, std::vector<std::pair<size_t,double> > >& globaIndexMapFromDestToSource); 
    6464  void updateFinalGridDestination(); 
     65  bool isSpecialTransformation(ETranformationType transType); 
    6566 
    6667protected: 
     
    7778  //! List of algorithm types and their order 
    7879  ListAlgoType listAlgos_; 
     80 
     81  //! Number of algorithm 
     82  int nbAlgos_; 
     83 
     84  typedef std::map<size_t, std::vector<std::pair<size_t,double> > > GlobalIndexMap; 
     85 
    7986  // true if domain algorithm and false if axis algorithm (can be replaced by tuple with listAlgos_ 
    8087  std::vector<bool> algoTypes_; 
     
    96103 
    97104  //! (Grid) Global index of grid source 
    98   std::vector<size_t> globalIndexOfCurrentGridSource_; 
    99   std::vector<size_t> globalIndexOfOriginalGridSource_; 
    100   CArray<double,1> weightOfGlobalIndexOfOriginalGridSource_; 
     105  GlobalIndexMap currentGridIndexToOriginalGridIndex_; 
    101106}; 
    102107 
Note: See TracChangeset for help on using the changeset viewer.