Changeset 598


Ignore:
Timestamp:
05/26/15 16:13:47 (9 years ago)
Author:
rlacroix
Message:

Add the infrastructure to request fields from the server.

This will be used to read input files so add a new file attribute mode to define whether data is written or read from a file.

Currently the data is not actually read and random data is transfered for those fields in read mode.

Location:
XIOS/trunk/src
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/client_server_mapping.hpp

    r591 r598  
    4141                                           const std::vector<CArray<size_t,1>* >& globalIndexOnServer); 
    4242 
    43     std::map<int,int> computeConnectedClients(int nbServer, int nbClient, 
    44                                               MPI_Comm& clientIntraComm, 
    45                                               const std::vector<int>& connectedServerRank); 
     43    static std::map<int,int> computeConnectedClients(int nbServer, int nbClient, 
     44                                                     MPI_Comm& clientIntraComm, 
     45                                                     const std::vector<int>& connectedServerRank); 
    4646 
    4747    const std::map<int, std::vector<size_t> >& getGlobalIndexOnServer() const; 
  • XIOS/trunk/src/config/file_attribute.conf

    r538 r598  
    1515DECLARE_ENUM2(par_access, collective, independent) 
    1616DECLARE_ATTRIBUTE(bool,      append) 
     17DECLARE_ENUM2(mode, read, write) 
    1718 
    1819// DECLARE_ATTRIBUTE_DEF(bool, enabled, true) 
  • XIOS/trunk/src/interface/c/iccalendar.cpp

    r597 r598  
    1616    context->updateCalendar(step); 
    1717    context->sendUpdateCalendar(step); 
     18    context->checkPrefetchingOfEnabledReadModeFiles(); 
    1819    CTimer::get("XIOS").suspend(); 
    1920  } 
  • XIOS/trunk/src/interface/c_attr/icfile_attr.cpp

    r591 r598  
    139139 
    140140 
     141  void cxios_set_file_mode(file_Ptr file_hdl, const char * mode, int mode_size) 
     142  { 
     143    std::string mode_str; 
     144    if (!cstr2string(mode, mode_size, mode_str)) return; 
     145    CTimer::get("XIOS").resume(); 
     146    file_hdl->mode.fromString(mode_str); 
     147    CTimer::get("XIOS").suspend(); 
     148  } 
     149 
     150  void cxios_get_file_mode(file_Ptr file_hdl, char * mode, int mode_size) 
     151  { 
     152    CTimer::get("XIOS").resume(); 
     153    if (!string_copy(file_hdl->mode.getInheritedStringValue(), mode, mode_size)) 
     154      ERROR("void cxios_get_file_mode(file_Ptr file_hdl, char * mode, int mode_size)", << "Input string is too short"); 
     155    CTimer::get("XIOS").suspend(); 
     156  } 
     157 
     158  bool cxios_is_defined_file_mode(file_Ptr file_hdl) 
     159  { 
     160     CTimer::get("XIOS").resume(); 
     161     bool isDefined = file_hdl->mode.hasInheritedValue(); 
     162     CTimer::get("XIOS").suspend(); 
     163     return isDefined; 
     164  } 
     165 
     166 
    141167  void cxios_set_file_name(file_Ptr file_hdl, const char * name, int name_size) 
    142168  { 
  • XIOS/trunk/src/interface/c_attr/icfilegroup_attr.cpp

    r591 r598  
    165165 
    166166 
     167  void cxios_set_filegroup_mode(filegroup_Ptr filegroup_hdl, const char * mode, int mode_size) 
     168  { 
     169    std::string mode_str; 
     170    if (!cstr2string(mode, mode_size, mode_str)) return; 
     171    CTimer::get("XIOS").resume(); 
     172    filegroup_hdl->mode.fromString(mode_str); 
     173    CTimer::get("XIOS").suspend(); 
     174  } 
     175 
     176  void cxios_get_filegroup_mode(filegroup_Ptr filegroup_hdl, char * mode, int mode_size) 
     177  { 
     178    CTimer::get("XIOS").resume(); 
     179    if (!string_copy(filegroup_hdl->mode.getInheritedStringValue(), mode, mode_size)) 
     180      ERROR("void cxios_get_filegroup_mode(filegroup_Ptr filegroup_hdl, char * mode, int mode_size)", << "Input string is too short"); 
     181    CTimer::get("XIOS").suspend(); 
     182  } 
     183 
     184  bool cxios_is_defined_filegroup_mode(filegroup_Ptr filegroup_hdl) 
     185  { 
     186     CTimer::get("XIOS").resume(); 
     187     bool isDefined = filegroup_hdl->mode.hasInheritedValue(); 
     188     CTimer::get("XIOS").suspend(); 
     189     return isDefined; 
     190  } 
     191 
     192 
    167193  void cxios_set_filegroup_name(filegroup_Ptr filegroup_hdl, const char * name, int name_size) 
    168194  { 
  • XIOS/trunk/src/interface/fortran_attr/file_interface_attr.F90

    r581 r598  
    109109 
    110110 
     111    SUBROUTINE cxios_set_file_mode(file_hdl, mode, mode_size) BIND(C) 
     112      USE ISO_C_BINDING 
     113      INTEGER (kind = C_INTPTR_T), VALUE :: file_hdl 
     114      CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: mode 
     115      INTEGER  (kind = C_INT)     , VALUE        :: mode_size 
     116    END SUBROUTINE cxios_set_file_mode 
     117 
     118    SUBROUTINE cxios_get_file_mode(file_hdl, mode, mode_size) BIND(C) 
     119      USE ISO_C_BINDING 
     120      INTEGER (kind = C_INTPTR_T), VALUE :: file_hdl 
     121      CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: mode 
     122      INTEGER  (kind = C_INT)     , VALUE        :: mode_size 
     123    END SUBROUTINE cxios_get_file_mode 
     124 
     125    FUNCTION cxios_is_defined_file_mode(file_hdl) BIND(C) 
     126      USE ISO_C_BINDING 
     127      LOGICAL(kind=C_BOOL) :: cxios_is_defined_file_mode 
     128      INTEGER (kind = C_INTPTR_T), VALUE :: file_hdl 
     129    END FUNCTION cxios_is_defined_file_mode 
     130 
     131 
    111132    SUBROUTINE cxios_set_file_name(file_hdl, name, name_size) BIND(C) 
    112133      USE ISO_C_BINDING 
  • XIOS/trunk/src/interface/fortran_attr/filegroup_interface_attr.F90

    r581 r598  
    130130 
    131131 
     132    SUBROUTINE cxios_set_filegroup_mode(filegroup_hdl, mode, mode_size) BIND(C) 
     133      USE ISO_C_BINDING 
     134      INTEGER (kind = C_INTPTR_T), VALUE :: filegroup_hdl 
     135      CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: mode 
     136      INTEGER  (kind = C_INT)     , VALUE        :: mode_size 
     137    END SUBROUTINE cxios_set_filegroup_mode 
     138 
     139    SUBROUTINE cxios_get_filegroup_mode(filegroup_hdl, mode, mode_size) BIND(C) 
     140      USE ISO_C_BINDING 
     141      INTEGER (kind = C_INTPTR_T), VALUE :: filegroup_hdl 
     142      CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: mode 
     143      INTEGER  (kind = C_INT)     , VALUE        :: mode_size 
     144    END SUBROUTINE cxios_get_filegroup_mode 
     145 
     146    FUNCTION cxios_is_defined_filegroup_mode(filegroup_hdl) BIND(C) 
     147      USE ISO_C_BINDING 
     148      LOGICAL(kind=C_BOOL) :: cxios_is_defined_filegroup_mode 
     149      INTEGER (kind = C_INTPTR_T), VALUE :: filegroup_hdl 
     150    END FUNCTION cxios_is_defined_filegroup_mode 
     151 
     152 
    132153    SUBROUTINE cxios_set_filegroup_name(filegroup_hdl, name, name_size) BIND(C) 
    133154      USE ISO_C_BINDING 
  • XIOS/trunk/src/interface/fortran_attr/ifile_attr.F90

    r581 r598  
    1212 
    1313  SUBROUTINE xios(set_file_attr)  & 
    14     ( file_id, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     14    ( file_id, append, description, enabled, format, min_digits, mode, name, name_suffix, output_freq  & 
    1515    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    1616 
     
    2525      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: format 
    2626      INTEGER  , OPTIONAL, INTENT(IN) :: min_digits 
     27      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: mode 
    2728      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name 
    2829      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name_suffix 
     
    3738      CALL xios(get_file_handle)(file_id,file_hdl) 
    3839      CALL xios(set_file_attr_hdl_)   & 
    39       ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     40      ( file_hdl, append, description, enabled, format, min_digits, mode, name, name_suffix, output_freq  & 
    4041      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    4142 
     
    4344 
    4445  SUBROUTINE xios(set_file_attr_hdl)  & 
    45     ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     46    ( file_hdl, append, description, enabled, format, min_digits, mode, name, name_suffix, output_freq  & 
    4647    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    4748 
     
    5556      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: format 
    5657      INTEGER  , OPTIONAL, INTENT(IN) :: min_digits 
     58      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: mode 
    5759      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name 
    5860      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name_suffix 
     
    6668 
    6769      CALL xios(set_file_attr_hdl_)  & 
    68       ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     70      ( file_hdl, append, description, enabled, format, min_digits, mode, name, name_suffix, output_freq  & 
    6971      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    7072 
     
    7274 
    7375  SUBROUTINE xios(set_file_attr_hdl_)   & 
    74     ( file_hdl, append_, description_, enabled_, format_, min_digits_, name_, name_suffix_, output_freq_  & 
    75     , output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_ ) 
     76    ( file_hdl, append_, description_, enabled_, format_, min_digits_, mode_, name_, name_suffix_  & 
     77    , output_freq_, output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_  & 
     78     ) 
    7679 
    7780    IMPLICIT NONE 
     
    8487      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: format_ 
    8588      INTEGER  , OPTIONAL, INTENT(IN) :: min_digits_ 
     89      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: mode_ 
    8690      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name_ 
    8791      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name_suffix_ 
     
    116120      ENDIF 
    117121 
     122      IF (PRESENT(mode_)) THEN 
     123        CALL cxios_set_file_mode(file_hdl%daddr, mode_, len(mode_)) 
     124      ENDIF 
     125 
    118126      IF (PRESENT(name_)) THEN 
    119127        CALL cxios_set_file_name(file_hdl%daddr, name_, len(name_)) 
     
    155163 
    156164  SUBROUTINE xios(get_file_attr)  & 
    157     ( file_id, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     165    ( file_id, append, description, enabled, format, min_digits, mode, name, name_suffix, output_freq  & 
    158166    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    159167 
     
    168176      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: format 
    169177      INTEGER  , OPTIONAL, INTENT(OUT) :: min_digits 
     178      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: mode 
    170179      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name 
    171180      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name_suffix 
     
    180189      CALL xios(get_file_handle)(file_id,file_hdl) 
    181190      CALL xios(get_file_attr_hdl_)   & 
    182       ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     191      ( file_hdl, append, description, enabled, format, min_digits, mode, name, name_suffix, output_freq  & 
    183192      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    184193 
     
    186195 
    187196  SUBROUTINE xios(get_file_attr_hdl)  & 
    188     ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     197    ( file_hdl, append, description, enabled, format, min_digits, mode, name, name_suffix, output_freq  & 
    189198    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    190199 
     
    198207      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: format 
    199208      INTEGER  , OPTIONAL, INTENT(OUT) :: min_digits 
     209      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: mode 
    200210      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name 
    201211      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name_suffix 
     
    209219 
    210220      CALL xios(get_file_attr_hdl_)  & 
    211       ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     221      ( file_hdl, append, description, enabled, format, min_digits, mode, name, name_suffix, output_freq  & 
    212222      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    213223 
     
    215225 
    216226  SUBROUTINE xios(get_file_attr_hdl_)   & 
    217     ( file_hdl, append_, description_, enabled_, format_, min_digits_, name_, name_suffix_, output_freq_  & 
    218     , output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_ ) 
     227    ( file_hdl, append_, description_, enabled_, format_, min_digits_, mode_, name_, name_suffix_  & 
     228    , output_freq_, output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_  & 
     229     ) 
    219230 
    220231    IMPLICIT NONE 
     
    227238      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: format_ 
    228239      INTEGER  , OPTIONAL, INTENT(OUT) :: min_digits_ 
     240      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: mode_ 
    229241      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name_ 
    230242      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name_suffix_ 
     
    259271      ENDIF 
    260272 
     273      IF (PRESENT(mode_)) THEN 
     274        CALL cxios_get_file_mode(file_hdl%daddr, mode_, len(mode_)) 
     275      ENDIF 
     276 
    261277      IF (PRESENT(name_)) THEN 
    262278        CALL cxios_get_file_name(file_hdl%daddr, name_, len(name_)) 
     
    298314 
    299315  SUBROUTINE xios(is_defined_file_attr)  & 
    300     ( file_id, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     316    ( file_id, append, description, enabled, format, min_digits, mode, name, name_suffix, output_freq  & 
    301317    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    302318 
     
    314330      LOGICAL, OPTIONAL, INTENT(OUT) :: min_digits 
    315331      LOGICAL(KIND=C_BOOL) :: min_digits_tmp 
     332      LOGICAL, OPTIONAL, INTENT(OUT) :: mode 
     333      LOGICAL(KIND=C_BOOL) :: mode_tmp 
    316334      LOGICAL, OPTIONAL, INTENT(OUT) :: name 
    317335      LOGICAL(KIND=C_BOOL) :: name_tmp 
     
    335353      CALL xios(get_file_handle)(file_id,file_hdl) 
    336354      CALL xios(is_defined_file_attr_hdl_)   & 
    337       ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     355      ( file_hdl, append, description, enabled, format, min_digits, mode, name, name_suffix, output_freq  & 
    338356      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    339357 
     
    341359 
    342360  SUBROUTINE xios(is_defined_file_attr_hdl)  & 
    343     ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     361    ( file_hdl, append, description, enabled, format, min_digits, mode, name, name_suffix, output_freq  & 
    344362    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    345363 
     
    356374      LOGICAL, OPTIONAL, INTENT(OUT) :: min_digits 
    357375      LOGICAL(KIND=C_BOOL) :: min_digits_tmp 
     376      LOGICAL, OPTIONAL, INTENT(OUT) :: mode 
     377      LOGICAL(KIND=C_BOOL) :: mode_tmp 
    358378      LOGICAL, OPTIONAL, INTENT(OUT) :: name 
    359379      LOGICAL(KIND=C_BOOL) :: name_tmp 
     
    376396 
    377397      CALL xios(is_defined_file_attr_hdl_)  & 
    378       ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     398      ( file_hdl, append, description, enabled, format, min_digits, mode, name, name_suffix, output_freq  & 
    379399      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    380400 
     
    382402 
    383403  SUBROUTINE xios(is_defined_file_attr_hdl_)   & 
    384     ( file_hdl, append_, description_, enabled_, format_, min_digits_, name_, name_suffix_, output_freq_  & 
    385     , output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_ ) 
     404    ( file_hdl, append_, description_, enabled_, format_, min_digits_, mode_, name_, name_suffix_  & 
     405    , output_freq_, output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_  & 
     406     ) 
    386407 
    387408    IMPLICIT NONE 
     
    397418      LOGICAL, OPTIONAL, INTENT(OUT) :: min_digits_ 
    398419      LOGICAL(KIND=C_BOOL) :: min_digits__tmp 
     420      LOGICAL, OPTIONAL, INTENT(OUT) :: mode_ 
     421      LOGICAL(KIND=C_BOOL) :: mode__tmp 
    399422      LOGICAL, OPTIONAL, INTENT(OUT) :: name_ 
    400423      LOGICAL(KIND=C_BOOL) :: name__tmp 
     
    441464      ENDIF 
    442465 
     466      IF (PRESENT(mode_)) THEN 
     467        mode__tmp = cxios_is_defined_file_mode(file_hdl%daddr) 
     468        mode_ = mode__tmp 
     469      ENDIF 
     470 
    443471      IF (PRESENT(name_)) THEN 
    444472        name__tmp = cxios_is_defined_file_name(file_hdl%daddr) 
  • XIOS/trunk/src/interface/fortran_attr/ifilegroup_attr.F90

    r581 r598  
    1212 
    1313  SUBROUTINE xios(set_filegroup_attr)  & 
    14     ( filegroup_id, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     14    ( filegroup_id, append, description, enabled, format, group_ref, min_digits, mode, name, name_suffix  & 
    1515    , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    1616 
     
    2626      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: group_ref 
    2727      INTEGER  , OPTIONAL, INTENT(IN) :: min_digits 
     28      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: mode 
    2829      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name 
    2930      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name_suffix 
     
    3839      CALL xios(get_filegroup_handle)(filegroup_id,filegroup_hdl) 
    3940      CALL xios(set_filegroup_attr_hdl_)   & 
    40       ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     41      ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, mode, name, name_suffix  & 
    4142      , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    4243 
     
    4445 
    4546  SUBROUTINE xios(set_filegroup_attr_hdl)  & 
    46     ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     47    ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, mode, name, name_suffix  & 
    4748    , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    4849 
     
    5758      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: group_ref 
    5859      INTEGER  , OPTIONAL, INTENT(IN) :: min_digits 
     60      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: mode 
    5961      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name 
    6062      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name_suffix 
     
    6870 
    6971      CALL xios(set_filegroup_attr_hdl_)  & 
    70       ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     72      ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, mode, name, name_suffix  & 
    7173      , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    7274 
     
    7476 
    7577  SUBROUTINE xios(set_filegroup_attr_hdl_)   & 
    76     ( filegroup_hdl, append_, description_, enabled_, format_, group_ref_, min_digits_, name_, name_suffix_  & 
    77     , output_freq_, output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_  & 
    78     ) 
     78    ( filegroup_hdl, append_, description_, enabled_, format_, group_ref_, min_digits_, mode_, name_  & 
     79    , name_suffix_, output_freq_, output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_  & 
     80    , type_ ) 
    7981 
    8082    IMPLICIT NONE 
     
    8890      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: group_ref_ 
    8991      INTEGER  , OPTIONAL, INTENT(IN) :: min_digits_ 
     92      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: mode_ 
    9093      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name_ 
    9194      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name_suffix_ 
     
    124127      ENDIF 
    125128 
     129      IF (PRESENT(mode_)) THEN 
     130        CALL cxios_set_filegroup_mode(filegroup_hdl%daddr, mode_, len(mode_)) 
     131      ENDIF 
     132 
    126133      IF (PRESENT(name_)) THEN 
    127134        CALL cxios_set_filegroup_name(filegroup_hdl%daddr, name_, len(name_)) 
     
    163170 
    164171  SUBROUTINE xios(get_filegroup_attr)  & 
    165     ( filegroup_id, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     172    ( filegroup_id, append, description, enabled, format, group_ref, min_digits, mode, name, name_suffix  & 
    166173    , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    167174 
     
    177184      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: group_ref 
    178185      INTEGER  , OPTIONAL, INTENT(OUT) :: min_digits 
     186      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: mode 
    179187      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name 
    180188      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name_suffix 
     
    189197      CALL xios(get_filegroup_handle)(filegroup_id,filegroup_hdl) 
    190198      CALL xios(get_filegroup_attr_hdl_)   & 
    191       ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     199      ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, mode, name, name_suffix  & 
    192200      , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    193201 
     
    195203 
    196204  SUBROUTINE xios(get_filegroup_attr_hdl)  & 
    197     ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     205    ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, mode, name, name_suffix  & 
    198206    , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    199207 
     
    208216      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: group_ref 
    209217      INTEGER  , OPTIONAL, INTENT(OUT) :: min_digits 
     218      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: mode 
    210219      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name 
    211220      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name_suffix 
     
    219228 
    220229      CALL xios(get_filegroup_attr_hdl_)  & 
    221       ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     230      ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, mode, name, name_suffix  & 
    222231      , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    223232 
     
    225234 
    226235  SUBROUTINE xios(get_filegroup_attr_hdl_)   & 
    227     ( filegroup_hdl, append_, description_, enabled_, format_, group_ref_, min_digits_, name_, name_suffix_  & 
    228     , output_freq_, output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_  & 
    229     ) 
     236    ( filegroup_hdl, append_, description_, enabled_, format_, group_ref_, min_digits_, mode_, name_  & 
     237    , name_suffix_, output_freq_, output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_  & 
     238    , type_ ) 
    230239 
    231240    IMPLICIT NONE 
     
    239248      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: group_ref_ 
    240249      INTEGER  , OPTIONAL, INTENT(OUT) :: min_digits_ 
     250      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: mode_ 
    241251      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name_ 
    242252      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name_suffix_ 
     
    275285      ENDIF 
    276286 
     287      IF (PRESENT(mode_)) THEN 
     288        CALL cxios_get_filegroup_mode(filegroup_hdl%daddr, mode_, len(mode_)) 
     289      ENDIF 
     290 
    277291      IF (PRESENT(name_)) THEN 
    278292        CALL cxios_get_filegroup_name(filegroup_hdl%daddr, name_, len(name_)) 
     
    314328 
    315329  SUBROUTINE xios(is_defined_filegroup_attr)  & 
    316     ( filegroup_id, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     330    ( filegroup_id, append, description, enabled, format, group_ref, min_digits, mode, name, name_suffix  & 
    317331    , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    318332 
     
    332346      LOGICAL, OPTIONAL, INTENT(OUT) :: min_digits 
    333347      LOGICAL(KIND=C_BOOL) :: min_digits_tmp 
     348      LOGICAL, OPTIONAL, INTENT(OUT) :: mode 
     349      LOGICAL(KIND=C_BOOL) :: mode_tmp 
    334350      LOGICAL, OPTIONAL, INTENT(OUT) :: name 
    335351      LOGICAL(KIND=C_BOOL) :: name_tmp 
     
    353369      CALL xios(get_filegroup_handle)(filegroup_id,filegroup_hdl) 
    354370      CALL xios(is_defined_filegroup_attr_hdl_)   & 
    355       ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     371      ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, mode, name, name_suffix  & 
    356372      , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    357373 
     
    359375 
    360376  SUBROUTINE xios(is_defined_filegroup_attr_hdl)  & 
    361     ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     377    ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, mode, name, name_suffix  & 
    362378    , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    363379 
     
    376392      LOGICAL, OPTIONAL, INTENT(OUT) :: min_digits 
    377393      LOGICAL(KIND=C_BOOL) :: min_digits_tmp 
     394      LOGICAL, OPTIONAL, INTENT(OUT) :: mode 
     395      LOGICAL(KIND=C_BOOL) :: mode_tmp 
    378396      LOGICAL, OPTIONAL, INTENT(OUT) :: name 
    379397      LOGICAL(KIND=C_BOOL) :: name_tmp 
     
    396414 
    397415      CALL xios(is_defined_filegroup_attr_hdl_)  & 
    398       ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     416      ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, mode, name, name_suffix  & 
    399417      , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    400418 
     
    402420 
    403421  SUBROUTINE xios(is_defined_filegroup_attr_hdl_)   & 
    404     ( filegroup_hdl, append_, description_, enabled_, format_, group_ref_, min_digits_, name_, name_suffix_  & 
    405     , output_freq_, output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_  & 
    406     ) 
     422    ( filegroup_hdl, append_, description_, enabled_, format_, group_ref_, min_digits_, mode_, name_  & 
     423    , name_suffix_, output_freq_, output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_  & 
     424    , type_ ) 
    407425 
    408426    IMPLICIT NONE 
     
    420438      LOGICAL, OPTIONAL, INTENT(OUT) :: min_digits_ 
    421439      LOGICAL(KIND=C_BOOL) :: min_digits__tmp 
     440      LOGICAL, OPTIONAL, INTENT(OUT) :: mode_ 
     441      LOGICAL(KIND=C_BOOL) :: mode__tmp 
    422442      LOGICAL, OPTIONAL, INTENT(OUT) :: name_ 
    423443      LOGICAL(KIND=C_BOOL) :: name__tmp 
     
    469489      ENDIF 
    470490 
     491      IF (PRESENT(mode_)) THEN 
     492        mode__tmp = cxios_is_defined_filegroup_mode(filegroup_hdl%daddr) 
     493        mode_ = mode__tmp 
     494      ENDIF 
     495 
    471496      IF (PRESENT(name_)) THEN 
    472497        name__tmp = cxios_is_defined_filegroup_name(filegroup_hdl%daddr) 
  • XIOS/trunk/src/node/context.cpp

    r597 r598  
    253253   void CContext::setClientServerBuffer() 
    254254   { 
    255      if (hasClient) 
    256      { 
    257        size_t bufferSizeMin = 10 * sizeof(size_t) * 1024; 
     255     size_t bufferSizeMin = 10 * sizeof(size_t) * 1024; 
    258256#define DECLARE_NODE(Name_, name_)    \ 
    259        bufferSizeMin = (bufferSizeMin < sizeof(C##Name_##Definition)) ?  sizeof(C##Name_##Definition) : bufferSizeMin; 
     257     bufferSizeMin = (bufferSizeMin < sizeof(C##Name_##Definition)) ?  sizeof(C##Name_##Definition) : bufferSizeMin; 
    260258#define DECLARE_NODE_PAR(Name_, name_) 
    261259#include "node_type.conf" 
    262        std::map<int, StdSize> bufferSize = getDataSize(); 
    263        if (bufferSize.empty()) 
     260     std::map<int, StdSize> bufferSize = getDataSize(); 
     261     if (bufferSize.empty()) 
     262     { 
     263       if (client->isServerLeader()) 
    264264       { 
    265          if (client->isServerLeader()) 
    266          { 
    267            const std::list<int>& ranks = client->getRanksServerLeader(); 
    268            for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    269              bufferSize[*itRank] = bufferSizeMin; 
    270          } 
    271          else 
    272           return; 
     265         const std::list<int>& ranks = client->getRanksServerLeader(); 
     266         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     267           bufferSize[*itRank] = bufferSizeMin; 
    273268       } 
    274269       else 
    275        { 
    276          std::map<int, StdSize>::iterator it  = bufferSize.begin(), 
    277                                           ite = bufferSize.end(); 
    278          for (; it != ite; ++it) 
    279            it->second = (it->second < bufferSizeMin) ? bufferSizeMin : it->second; 
    280        } 
    281  
    282        client->setBufferSize(bufferSize); 
    283      } 
     270        return; 
     271     } 
     272     else 
     273     { 
     274       std::map<int, StdSize>::iterator it  = bufferSize.begin(), 
     275                                        ite = bufferSize.end(); 
     276       for (; it != ite; ++it) 
     277         it->second = (it->second < bufferSizeMin) ? bufferSizeMin : it->second; 
     278     } 
     279 
     280     client->setBufferSize(bufferSize); 
    284281   } 
    285282 
     
    307304     } 
    308305     client = new CContextClient(this,intraCommClient,interCommClient, cxtClient); 
    309      // Do something clever instead 
    310      std::map<int, StdSize> bufferSize; 
    311      for (int r = 0; r < client->serverSize; r++) 
    312        bufferSize[r] = 10 * sizeof(size_t) * 1024; 
    313      client->setBufferSize(bufferSize); 
    314306   } 
    315307 
     
    363355       // After xml is parsed, there are some more works with post processing 
    364356       postProcessing(); 
    365  
    366        setClientServerBuffer(); 
    367      } 
     357     } 
     358     setClientServerBuffer(); 
    368359 
    369360     if (hasClient && !hasServer) 
     
    388379       sendRefGrid(); 
    389380    } 
    390  
    391     // Now tell server that it can process all messages from client 
    392     if (hasClient && !hasServer) this->sendCloseDefinition(); 
    393381 
    394382    // We have a xml tree on the server side and now, it should be also processed 
     
    403391    } 
    404392 
     393    // Now tell server that it can process all messages from client 
     394    if (hasClient && !hasServer) this->sendCloseDefinition(); 
    405395 
    406396    // Nettoyage de l'arborescence 
    407397    if (hasClient && !hasServer) CleanTree(); // Only on client side?? 
    408398 
    409     if (hasClient) sendCreateFileHeader(); 
     399    if (hasClient) 
     400    { 
     401      sendCreateFileHeader(); 
     402 
     403      startPrefetchingOfEnabledReadModeFiles(); 
     404    } 
    410405   } 
    411406 
     
    431426     { 
    432427       this->enabledFiles[i]->buildAllExpressionOfEnabledFields(); 
     428     } 
     429   } 
     430 
     431   void CContext::startPrefetchingOfEnabledReadModeFiles() 
     432   { 
     433     int size = enabledReadModeFiles.size(); 
     434     for (int i = 0; i < size; ++i) 
     435     { 
     436        enabledReadModeFiles[i]->prefetchEnabledReadModeFields(); 
     437     } 
     438   } 
     439 
     440   void CContext::checkPrefetchingOfEnabledReadModeFiles() 
     441   { 
     442     int size = enabledReadModeFiles.size(); 
     443     for (int i = 0; i < size; ++i) 
     444     { 
     445        enabledReadModeFiles[i]->prefetchEnabledReadModeFieldsIfNeeded(); 
    433446     } 
    434447   } 
     
    440453    for (size_t i = 0; i < allFields.size(); ++i) 
    441454    { 
     455      if (allFields[i]->file && !allFields[i]->file->mode.isEmpty() && allFields[i]->file->mode.getValue() == CFile::mode_attr::read) 
     456        allFields[i]->read_access = true; 
    442457      if (!allFields[i]->read_access.isEmpty() && allFields[i]->read_access.getValue()) 
    443458        fieldsWithReadAccess.push_back(allFields[i]); 
     
    501516         DEBUG(<<"Aucun fichier ne va être sorti dans le contexte nommé \"" 
    502517               << getId() << "\" !"); 
     518   } 
     519 
     520   void CContext::findEnabledReadModeFiles(void) 
     521   { 
     522     int size = this->enabledFiles.size(); 
     523     for (int i = 0; i < size; ++i) 
     524     { 
     525       if (!enabledFiles[i]->mode.isEmpty() && enabledFiles[i]->mode.getValue() == CFile::mode_attr::read) 
     526        enabledReadModeFiles.push_back(enabledFiles[i]); 
     527     } 
    503528   } 
    504529 
     
    717742      //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 
    718743      this->findEnabledFiles(); 
     744      this->findEnabledReadModeFiles(); 
    719745 
    720746      // Find all enabled fields of each file 
     
    734760   std::map<int, StdSize>& CContext::getDataSize() 
    735761   { 
     762     CFile::mode_attr::t_enum mode = hasClient ? CFile::mode_attr::write : CFile::mode_attr::read; 
     763 
    736764     // Set of grid used by enabled fields 
    737765     std::set<StdString> usedGrid; 
     
    741769     for (int i = 0; i < numEnabledFiles; ++i) 
    742770     { 
    743        std::vector<CField*> enabledFields = this->enabledFiles[i]->getEnabledFields(); 
    744        int numEnabledFields = enabledFields.size(); 
    745        for (int j = 0; j < numEnabledFields; ++j) 
     771       CFile* file = this->enabledFiles[i]; 
     772       CFile::mode_attr::t_enum fileMode = file->mode.isEmpty() ? CFile::mode_attr::write : file->mode.getValue(); 
     773 
     774       if (fileMode == mode) 
    746775       { 
    747 //         const std::pair<StdString, StdString>& prDomAxisId = enabledFields[j]->getDomainAxisIds(); 
    748          StdString currentGrid = enabledFields[j]->grid->getId(); 
    749          const std::map<int, StdSize> mapSize = enabledFields[j]->getGridDataSize(); 
    750          if (dataSize_.empty()) 
     776         std::vector<CField*> enabledFields = file->getEnabledFields(); 
     777         int numEnabledFields = enabledFields.size(); 
     778         for (int j = 0; j < numEnabledFields; ++j) 
    751779         { 
    752            dataSize_ = mapSize; 
    753            usedGrid.insert(currentGrid); 
    754 //           domainIds.insert(prDomAxisId.first); 
    755          } 
    756          else 
    757          { 
    758            std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 
    759            if (usedGrid.find(currentGrid) == usedGrid.end()) 
     780           StdString currentGrid = enabledFields[j]->grid->getId(); 
     781           const std::map<int, StdSize> mapSize = enabledFields[j]->getGridDataSize(); 
     782           if (dataSize_.empty()) 
    760783           { 
    761              for (; it != itE; ++it) 
     784             dataSize_ = mapSize; 
     785             usedGrid.insert(currentGrid); 
     786           } 
     787           else 
     788           { 
     789             std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 
     790             if (usedGrid.find(currentGrid) == usedGrid.end()) 
    762791             { 
    763                if (0 < dataSize_.count(it->first)) dataSize_[it->first] += it->second; 
    764                else dataSize_.insert(make_pair(it->first, it->second)); 
    765              } 
    766            } else 
    767            { 
    768              for (; it != itE; ++it) 
     792               for (; it != itE; ++it) 
     793               { 
     794                 if (0 < dataSize_.count(it->first)) dataSize_[it->first] += it->second; 
     795                 else dataSize_.insert(make_pair(it->first, it->second)); 
     796               } 
     797             } else 
    769798             { 
    770                if (0 < dataSize_.count(it->first)) 
    771                 if (CXios::isOptPerformance) dataSize_[it->first] += it->second; 
    772                 else 
    773                 { 
    774                   if (dataSize_[it->first] < it->second) dataSize_[it->first] = it->second; 
    775                 } 
    776                else dataSize_.insert(make_pair(it->first, it->second)); 
     799               for (; it != itE; ++it) 
     800               { 
     801                 if (0 < dataSize_.count(it->first)) 
     802                  if (CXios::isOptPerformance) dataSize_[it->first] += it->second; 
     803                  else 
     804                  { 
     805                    if (dataSize_[it->first] < it->second) dataSize_[it->first] = it->second; 
     806                  } 
     807                 else dataSize_.insert(make_pair(it->first, it->second)); 
     808               } 
    777809             } 
    778810           } 
  • XIOS/trunk/src/node/context.hpp

    r597 r598  
    105105         void solveAllInheritance(bool apply=true); 
    106106         void findEnabledFiles(void); 
     107         void findEnabledReadModeFiles(void); 
    107108         void closeAllFile(void); 
    108109         void updateCalendar(int step); 
     
    110111         void solveAllRefOfEnabledFields(bool sendToServer); 
    111112         void buildAllExpressionOfEnabledFields(); 
     113         void startPrefetchingOfEnabledReadModeFiles(); 
     114         void checkPrefetchingOfEnabledReadModeFiles(); 
    112115         void findFieldsWithReadAccess(void); 
    113116         void solveAllRefOfFieldsWithReadAccess(); 
     
    187190         boost::shared_ptr<CCalendar>   calendar; 
    188191 
    189          // List of all enabled files (files on which fields are written) 
     192         // List of all enabled files (files on which fields are written or read) 
    190193         std::vector<CFile*> enabledFiles; 
     194         // List of all enabled files in read mode (files on which fields are read) 
     195         std::vector<CFile*> enabledReadModeFiles; 
    191196 
    192197         // List of all fields whose instant data is accessible from the public API 
  • XIOS/trunk/src/node/field.cpp

    r595 r598  
    2828      , active(false) , hasOutputFile(false),hasFieldOut(false), slotUpdateDate(NULL) 
    2929      , processed(false), domAxisIds_("", ""), areAllReferenceSolved(false), areAllExpressionBuilt(false) 
     30      , isReadDataRequestPending(false) 
    3031      { setVirtualVariableGroup(); } 
    3132 
     
    4041      , active(false), hasOutputFile(false), hasFieldOut(false), slotUpdateDate(NULL) 
    4142      , processed(false), domAxisIds_("", ""), areAllReferenceSolved(false), areAllExpressionBuilt(false) 
     43      , isReadDataRequestPending(false) 
    4244   { setVirtualVariableGroup(); } 
    4345 
     
    112114   } 
    113115 
    114    bool CField::dispatchEvent(CEventServer& event) 
    115   { 
    116  
     116  bool CField::dispatchEvent(CEventServer& event) 
     117  { 
    117118    if (SuperClass::dispatchEvent(event)) return true; 
    118119    else 
     
    125126          break; 
    126127 
    127             case EVENT_ID_ADD_VARIABLE : 
    128              recvAddVariable(event); 
    129              return true; 
    130              break; 
    131  
    132            case EVENT_ID_ADD_VARIABLE_GROUP : 
    133              recvAddVariableGroup(event); 
    134              return true; 
    135              break; 
     128        case EVENT_ID_READ_DATA : 
     129          recvReadDataRequest(event); 
     130          return true; 
     131          break; 
     132 
     133        case EVENT_ID_READ_DATA_READY : 
     134          recvReadDataReady(event); 
     135          return true; 
     136          break; 
     137 
     138        case EVENT_ID_ADD_VARIABLE : 
     139          recvAddVariable(event); 
     140          return true; 
     141          break; 
     142 
     143        case EVENT_ID_ADD_VARIABLE_GROUP : 
     144          recvAddVariableGroup(event); 
     145          return true; 
     146          break; 
    136147 
    137148        default : 
     
    263274      } 
    264275    } 
     276  } 
     277 
     278  void CField::sendReadDataRequest(void) 
     279  { 
     280    CContext* context = CContext::getCurrent(); 
     281    CContextClient* client = context->client; 
     282 
     283    CEventClient event(getType(), EVENT_ID_READ_DATA); 
     284    if (client->isServerLeader()) 
     285    { 
     286      CMessage msg; 
     287      msg << getId(); 
     288      const std::list<int>& ranks = client->getRanksServerLeader(); 
     289      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     290        event.push(*itRank, 1, msg); 
     291      client->sendEvent(event); 
     292    } 
     293    else client->sendEvent(event); 
     294 
     295    lastDataRequestedFromServer = context->getCalendar()->getCurrentDate(); 
     296    isReadDataRequestPending = true; 
     297  } 
     298 
     299  /*! 
     300  Send request new data read from file if need be, that is the current data is out-of-date. 
     301  \return true if and only if some data was requested 
     302  */ 
     303  bool CField::sendReadDataRequestIfNeeded(void) 
     304  { 
     305    const CDate& currentDate = CContext::getCurrent()->getCalendar()->getCurrentDate(); 
     306 
     307    bool requestData = (currentDate >= lastDataRequestedFromServer + file->output_freq.getValue()); 
     308 
     309    if (requestData) 
     310      sendReadDataRequest(); 
     311 
     312    return requestData; 
     313  } 
     314 
     315  void CField::recvReadDataRequest(CEventServer& event) 
     316  { 
     317    CBufferIn* buffer = event.subEvents.begin()->buffer; 
     318    StdString fieldId; 
     319    *buffer >> fieldId; 
     320    get(fieldId)->recvReadDataRequest(); 
     321  } 
     322 
     323  void CField::recvReadDataRequest(void) 
     324  { 
     325    CContext* context = CContext::getCurrent(); 
     326    CContextClient* client = context->client; 
     327 
     328    CEventClient event(getType(), EVENT_ID_READ_DATA_READY); 
     329    std::list<CMessage> msgs; 
     330 
     331    // TODO: Read the data from the file 
     332    if (data_srv.empty()) 
     333    { 
     334      for (map<int, CArray<size_t, 1>* >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 
     335        data_srv.insert( pair<int, CArray<double,1>* >(it->first, new CArray<double,1>(it->second->numElements()))); 
     336    } 
     337 
     338    map<int, CArray<double,1>* >::iterator it; 
     339    for (it = data_srv.begin(); it != data_srv.end(); it++) 
     340    { 
     341      msgs.push_back(CMessage()); 
     342      CMessage& msg = msgs.back(); 
     343      msg << getId() << getNStep() << *it->second; 
     344      event.push(it->first, grid->nbSenders[it->first], msg); 
     345    } 
     346    client->sendEvent(event); 
     347 
     348    incrementNStep(); 
     349  } 
     350 
     351  void CField::recvReadDataReady(CEventServer& event) 
     352  { 
     353    string fieldId; 
     354    vector<int> ranks; 
     355    vector<CBufferIn*> buffers; 
     356 
     357    list<CEventServer::SSubEvent>::iterator it; 
     358    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 
     359    { 
     360      ranks.push_back(it->rank); 
     361      CBufferIn* buffer = it->buffer; 
     362      *buffer >> fieldId; 
     363      buffers.push_back(buffer); 
     364    } 
     365    get(fieldId)->recvReadDataReady(ranks, buffers); 
     366  } 
     367 
     368  void CField::recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers) 
     369  { 
     370    CContext* context = CContext::getCurrent(); 
     371    StdSize record; 
     372    for (int i = 0; i < ranks.size(); i++) 
     373    { 
     374      int rank = ranks[i]; 
     375      CArray<int,1>& index = *grid->storeIndex_toSrv[rank]; 
     376      CArray<double,1> data_tmp(index.numElements()); 
     377      *buffers[i] >> record >> data_tmp; 
     378 
     379      for (int n = 0; n < data_tmp.numElements(); n++) 
     380        instantData(index(n)) = data_tmp(n); 
     381    } 
     382 
     383    for (list< pair<CField*, int> >::iterator it = fieldDependency.begin(); it != fieldDependency.end(); ++it) 
     384      it->first->setSlot(it->second); 
     385 
     386    if (!hasExpression) // Should be always true ? 
     387    { 
     388      const std::vector<CField*>& refField = getAllReference(); 
     389      std::vector<CField*>::const_iterator it = refField.begin(), end = refField.end(); 
     390 
     391      for (; it != end; it++) (*it)->setDataFromExpression(instantData); 
     392      if (hasFieldOut) updateDataFromExpression(instantData); 
     393    } 
     394 
     395    isReadDataRequestPending = false; 
    265396  } 
    266397 
     
    477608         const CDuration toffset = this->freq_operation - freq_offset.getValue() - context->getCalendar()->getTimeStep(); 
    478609         *this->last_operation   = *this->last_operation - toffset; 
     610 
     611         lastDataRequestedFromServer.setRelCalendar(*context->getCalendar()); 
    479612 
    480613        if (operation.get() == "once") isOnceOperation = true; 
  • XIOS/trunk/src/node/field.hpp

    r593 r598  
    5454         enum EEventId 
    5555         { 
    56            EVENT_ID_UPDATE_DATA, EVENT_ID_ADD_VARIABLE, EVENT_ID_ADD_VARIABLE_GROUP 
     56           EVENT_ID_UPDATE_DATA, EVENT_ID_READ_DATA, EVENT_ID_READ_DATA_READY, 
     57           EVENT_ID_ADD_VARIABLE, EVENT_ID_ADD_VARIABLE_GROUP 
    5758         } ; 
    5859 
     
    133134        void recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) ; 
    134135        void writeField(void) ; 
     136        void sendReadDataRequest(void); 
     137        bool sendReadDataRequestIfNeeded(void); 
     138        static void recvReadDataRequest(CEventServer& event); 
     139        void recvReadDataRequest(void); 
     140        static void recvReadDataReady(CEventServer& event); 
     141        void recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers); 
    135142        void outputField(CArray<double,3>& fieldOut) ; 
    136143        void outputField(CArray<double,2>& fieldOut) ; 
     
    172179         boost::shared_ptr<CDate>    last_Write, last_operation; 
    173180         boost::shared_ptr<CDate>    lastlast_Write_srv,last_Write_srv, last_operation_srv; 
     181         CDate lastDataRequestedFromServer; 
    174182 
    175183         boost::shared_ptr<func::CFunctor> foperation; 
     
    198206         bool areAllExpressionBuilt; 
    199207         std::pair<StdString,StdString> domAxisIds_; 
     208         bool isReadDataRequestPending; 
    200209         DECLARE_REF_FUNC(Field,field) 
    201210//       public: 
  • XIOS/trunk/src/node/field_impl.hpp

    r593 r598  
    184184    if (!read_access.isEmpty() && read_access.getValue() && hasInstantData) 
    185185    { 
     186      CContext* context = CContext::getCurrent(); 
     187      const CDate& currentDate = context->getCalendar()->getCurrentDate(); 
     188 
     189      while (isReadDataRequestPending) 
     190        context->checkBuffersAndListen(); 
     191 
    186192      grid->outputField(instantData, _data); 
    187193    } 
  • XIOS/trunk/src/node/file.cpp

    r595 r598  
    517517   } 
    518518 
     519   /*! 
     520     Prefetching the data for enabled fields read from file. 
     521   */ 
     522   void CFile::prefetchEnabledReadModeFields(void) 
     523   { 
     524     if (mode.isEmpty() || mode.getValue() != mode_attr::read) 
     525       return; 
     526 
     527     int size = this->enabledFields.size(); 
     528     for (int i = 0; i < size; ++i) 
     529       this->enabledFields[i]->sendReadDataRequest(); 
     530   } 
     531 
     532   /*! 
     533     Prefetching the data for enabled fields read from file whose data is out-of-date. 
     534   */ 
     535   void CFile::prefetchEnabledReadModeFieldsIfNeeded(void) 
     536   { 
     537     if (mode.isEmpty() || mode.getValue() != mode_attr::read) 
     538       return; 
     539 
     540     int size = this->enabledFields.size(); 
     541     for (int i = 0; i < size; ++i) 
     542       this->enabledFields[i]->sendReadDataRequestIfNeeded(); 
     543   } 
     544 
    519545   void CFile::solveFieldRefInheritance(bool apply) 
    520546   { 
  • XIOS/trunk/src/node/file.hpp

    r591 r598  
    105105         void solveAllRefOfEnabledFields(bool sendToServer); 
    106106         void buildAllExpressionOfEnabledFields(); 
     107         void prefetchEnabledReadModeFields(); 
     108         void prefetchEnabledReadModeFieldsIfNeeded(); 
    107109 
    108110         // Add component into file 
  • XIOS/trunk/src/node/grid.cpp

    r595 r598  
    669669  void CGrid::recvIndex(CEventServer& event) 
    670670  { 
    671     list<CEventServer::SSubEvent>::iterator it ; 
     671    string gridId; 
     672    vector<int> ranks; 
     673    vector<CBufferIn*> buffers; 
     674 
     675    list<CEventServer::SSubEvent>::iterator it; 
    672676    for (it=event.subEvents.begin();it!=event.subEvents.end();++it) 
    673677    { 
    674       int rank=it->rank; 
    675       CBufferIn* buffer=it->buffer; 
    676       string gridId ; 
    677       *buffer>>gridId ; 
    678       get(gridId)->recvIndex(rank,*buffer) ; 
    679     } 
     678      ranks.push_back(it->rank); 
     679      CBufferIn* buffer = it->buffer; 
     680      *buffer >> gridId; 
     681      buffers.push_back(buffer); 
     682    } 
     683    get(gridId)->recvIndex(ranks, buffers) ; 
    680684  } 
    681685 
     
    748752  } 
    749753 
    750   void CGrid::recvIndex(int rank, CBufferIn& buffer) 
    751   { 
    752     CContext* context = CContext::getCurrent() ; 
    753     CContextServer* server=context->server ; 
    754     buffer>>isDataDistributed_; 
    755     size_t dataSize = 0; 
    756  
    757     if (true == scalar_grid) 
    758     { 
    759        writtenDataSize_ = 1; 
    760        CArray<size_t,1> outIndex; 
    761        buffer>>outIndex; 
    762        outIndexFromClient.insert(std::pair<int, CArray<size_t,1>* >(rank, new CArray<size_t,1>(outIndex))); 
    763        std::vector<int> nZoomBegin(1,0), nZoomSize(1,1), nGlob(1,1), nZoomBeginGlobal(1,0); 
    764        serverDistribution_ = new CDistributionServer(server->intraCommRank, nZoomBegin, nZoomSize, 
    765                                                      nZoomBeginGlobal, nGlob); 
    766        return; 
    767     } 
    768  
    769  
    770      if (0 == serverDistribution_) 
    771      { 
    772        int idx = 0, numElement = axis_domain_order.numElements(); 
    773        int ssize = numElement; 
    774        std::vector<int> indexMap(numElement); 
    775        for (int i = 0; i < numElement; ++i) 
    776        { 
    777          indexMap[i] = idx; 
    778          if (true == axis_domain_order(i)) 
    779          { 
     754  void CGrid::recvIndex(vector<int> ranks, vector<CBufferIn*> buffers) 
     755  { 
     756    CContext* context = CContext::getCurrent(); 
     757    CContextServer* server = context->server; 
     758 
     759    for (int n = 0; n < ranks.size(); n++) 
     760    { 
     761      int rank = ranks[n]; 
     762      CBufferIn& buffer = *buffers[n]; 
     763 
     764      buffer >> isDataDistributed_; 
     765      size_t dataSize = 0; 
     766 
     767      if (true == scalar_grid) 
     768      { 
     769        writtenDataSize_ = 1; 
     770        CArray<size_t,1> outIndex; 
     771        buffer >> outIndex; 
     772        outIndexFromClient.insert(std::pair<int, CArray<size_t,1>* >(rank, new CArray<size_t,1>(outIndex))); 
     773        std::vector<int> nZoomBegin(1,0), nZoomSize(1,1), nGlob(1,1), nZoomBeginGlobal(1,0); 
     774        serverDistribution_ = new CDistributionServer(server->intraCommRank, nZoomBegin, nZoomSize, 
     775                                                      nZoomBeginGlobal, nGlob); 
     776        return; 
     777      } 
     778 
     779      if (0 == serverDistribution_) 
     780      { 
     781        int idx = 0, numElement = axis_domain_order.numElements(); 
     782        int ssize = numElement; 
     783        std::vector<int> indexMap(numElement); 
     784        for (int i = 0; i < numElement; ++i) 
     785        { 
     786          indexMap[i] = idx; 
     787          if (true == axis_domain_order(i)) 
     788          { 
    780789            ++ssize; 
    781790            idx += 2; 
    782          } 
    783          else 
    784           ++idx; 
    785        } 
    786  
    787        int axisId = 0, domainId = 0; 
    788        std::vector<CDomain*> domainList = getDomains(); 
    789        std::vector<CAxis*> axisList = getAxis(); 
    790        std::vector<int> nZoomBegin(ssize), nZoomSize(ssize), nGlob(ssize), nZoomBeginGlobal(ssize); 
    791        for (int i = 0; i < numElement; ++i) 
    792        { 
    793          if (axis_domain_order(i)) 
    794          { 
    795             nZoomBegin[indexMap[i]]   = domainList[domainId]->zoom_ibegin_srv; 
    796             nZoomSize[indexMap[i]]    = domainList[domainId]->zoom_ni_srv; 
     791          } 
     792          else 
     793            ++idx; 
     794        } 
     795 
     796        int axisId = 0, domainId = 0; 
     797        std::vector<CDomain*> domainList = getDomains(); 
     798        std::vector<CAxis*> axisList = getAxis(); 
     799        std::vector<int> nZoomBegin(ssize), nZoomSize(ssize), nGlob(ssize), nZoomBeginGlobal(ssize); 
     800        for (int i = 0; i < numElement; ++i) 
     801        { 
     802          if (axis_domain_order(i)) 
     803          { 
     804            nZoomBegin[indexMap[i]] = domainList[domainId]->zoom_ibegin_srv; 
     805            nZoomSize[indexMap[i]]  = domainList[domainId]->zoom_ni_srv; 
    797806            nZoomBeginGlobal[indexMap[i]] = domainList[domainId]->zoom_ibegin; 
    798             nGlob[indexMap[i]]    = domainList[domainId]->ni_glo; 
    799  
    800             nZoomBegin[indexMap[i]+1] = domainList[domainId]->zoom_jbegin_srv; 
    801             nZoomSize[indexMap[i]+1] = domainList[domainId]->zoom_nj_srv; 
    802             nZoomBeginGlobal[indexMap[i]+1] = domainList[domainId]->zoom_jbegin; 
    803             nGlob[indexMap[i]+1]    = domainList[domainId]->nj_glo; 
     807            nGlob[indexMap[i]] = domainList[domainId]->ni_glo; 
     808 
     809            nZoomBegin[indexMap[i] + 1] = domainList[domainId]->zoom_jbegin_srv; 
     810            nZoomSize[indexMap[i] + 1] = domainList[domainId]->zoom_nj_srv; 
     811            nZoomBeginGlobal[indexMap[i] + 1] = domainList[domainId]->zoom_jbegin; 
     812            nGlob[indexMap[i] + 1] = domainList[domainId]->nj_glo; 
    804813            ++domainId; 
    805          } 
    806          else 
    807          { 
     814          } 
     815          else 
     816          { 
    808817            nZoomBegin[indexMap[i]] = axisList[axisId]->zoom_begin_srv; 
    809818            nZoomSize[indexMap[i]]  = axisList[axisId]->zoom_size_srv; 
    810819            nZoomBeginGlobal[indexMap[i]] = axisList[axisId]->zoom_begin; 
    811             nGlob[indexMap[i]]      = axisList[axisId]->size; 
     820            nGlob[indexMap[i]] = axisList[axisId]->size; 
    812821            ++axisId; 
    813          } 
    814        } 
    815        dataSize = 1; 
    816        for (int i = 0; i < nZoomSize.size(); ++i) 
    817         dataSize *= nZoomSize[i]; 
    818  
    819        serverDistribution_ = new CDistributionServer(server->intraCommRank, nZoomBegin, nZoomSize, 
    820                                                      nZoomBeginGlobal, nGlob); 
    821      } 
    822  
    823      CArray<size_t,1> outIndex; 
    824      buffer>>outIndex; 
    825      if (isDataDistributed_) 
    826       serverDistribution_->computeLocalIndex(outIndex); 
    827      else 
    828      { 
    829        dataSize = outIndex.numElements(); 
    830        for (int i = 0; i < outIndex.numElements(); ++i) outIndex(i) = i; 
    831      } 
    832      writtenDataSize_ += dataSize; 
    833  
    834      outIndexFromClient.insert(std::pair<int, CArray<size_t,1>* >(rank, new CArray<size_t,1>(outIndex))); 
     822          } 
     823        } 
     824        dataSize = 1; 
     825        for (int i = 0; i < nZoomSize.size(); ++i) 
     826          dataSize *= nZoomSize[i]; 
     827 
     828        serverDistribution_ = new CDistributionServer(server->intraCommRank, nZoomBegin, nZoomSize, 
     829                                                      nZoomBeginGlobal, nGlob); 
     830      } 
     831 
     832      CArray<size_t,1> outIndex; 
     833      buffer >> outIndex; 
     834      if (isDataDistributed_) 
     835        serverDistribution_->computeLocalIndex(outIndex); 
     836      else 
     837      { 
     838        dataSize = outIndex.numElements(); 
     839        for (int i = 0; i < outIndex.numElements(); ++i) outIndex(i) = i; 
     840      } 
     841      writtenDataSize_ += dataSize; 
     842 
     843      outIndexFromClient.insert(std::pair<int, CArray<size_t,1>* >(rank, new CArray<size_t,1>(outIndex))); 
     844      connectedDataSize_[rank] = outIndex.numElements(); 
     845    } 
     846 
     847    nbSenders = CClientServerMappingDistributed::computeConnectedClients(context->client->serverSize, context->client->clientSize, context->client->intraComm, ranks); 
    835848  } 
    836849 
  • XIOS/trunk/src/node/grid.hpp

    r593 r598  
    157157         void outputFieldToServer(CArray<double,1>& fieldIn, int rank, CArray<double,1>& fieldOut) ; 
    158158         static void recvIndex(CEventServer& event) ; 
    159          void recvIndex(int rank, CBufferIn& buffer) ; 
     159         void recvIndex(vector<int> ranks, vector<CBufferIn*> buffers) ; 
    160160         void sendIndex(void) ; 
    161161         void sendIndexScalarGrid(); 
Note: See TracChangeset for help on using the changeset viewer.