Changeset 528 for XIOS/trunk


Ignore:
Timestamp:
12/03/14 17:54:33 (7 years ago)
Author:
rlacroix
Message:

Add the ability to append data to existing output file(s).

By default existing file(s) will still be overwritten. Set the new file attribute "append" to true if you wish to append data to existing NetCDF file(s).

Note that the append mode is currently not supported when file splitting is used and that the structure of the output file cannot be changed.

Location:
XIOS/trunk/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/config/file_attribute.conf

    r526 r528  
    1414DECLARE_ENUM2(format, netcdf4, netcdf4_classic) 
    1515DECLARE_ENUM2(par_access, collective, independent) 
     16DECLARE_ATTRIBUTE(bool,      append) 
    1617 
    1718// DECLARE_ATTRIBUTE_DEF(bool, enabled, true) 
  • XIOS/trunk/src/data_output.hpp

    r501 r528  
    3232            virtual void definition_end(void)   = 0; 
    3333 
     34            //!< Test if the file was opened in append mode 
     35            virtual bool IsInAppendMode() const { return appendMode; }; 
     36 
    3437            virtual ~CDataOutput(void); 
    3538 
     
    5659            /// Propriétés protégées /// 
    5760            EDataOutputType type; 
     61            bool appendMode; //!< If true, we are appending data to an existing file 
    5862 
    5963      }; // class CDataOutput 
  • XIOS/trunk/src/interface/c_attr/icfile_attr.cpp

    r526 r528  
    1717  typedef xios::CFile*  file_Ptr; 
    1818   
     19  void cxios_set_file_append(file_Ptr file_hdl, bool append) 
     20  { 
     21     CTimer::get("XIOS").resume(); 
     22    file_hdl->append.setValue(append); 
     23     CTimer::get("XIOS").suspend(); 
     24  } 
     25   
     26  void cxios_get_file_append(file_Ptr file_hdl, bool* append) 
     27  { 
     28    *append = file_hdl->append.getInheritedValue(); 
     29  } 
     30   
     31  bool cxios_is_defined_file_append(file_Ptr file_hdl ) 
     32  { 
     33     CTimer::get("XIOS").resume(); 
     34    return file_hdl->append.hasInheritedValue(); 
     35     CTimer::get("XIOS").suspend(); 
     36  } 
     37   
     38   
     39   
    1940  void cxios_set_file_description(file_Ptr file_hdl, const char * description, int description_size) 
    2041  { 
  • XIOS/trunk/src/interface/c_attr/icfilegroup_attr.cpp

    r526 r528  
    1717  typedef xios::CFileGroup*  filegroup_Ptr; 
    1818   
     19  void cxios_set_filegroup_append(filegroup_Ptr filegroup_hdl, bool append) 
     20  { 
     21     CTimer::get("XIOS").resume(); 
     22    filegroup_hdl->append.setValue(append); 
     23     CTimer::get("XIOS").suspend(); 
     24  } 
     25   
     26  void cxios_get_filegroup_append(filegroup_Ptr filegroup_hdl, bool* append) 
     27  { 
     28    *append = filegroup_hdl->append.getInheritedValue(); 
     29  } 
     30   
     31  bool cxios_is_defined_filegroup_append(filegroup_Ptr filegroup_hdl ) 
     32  { 
     33     CTimer::get("XIOS").resume(); 
     34    return filegroup_hdl->append.hasInheritedValue(); 
     35     CTimer::get("XIOS").suspend(); 
     36  } 
     37   
     38   
     39   
    1940  void cxios_set_filegroup_description(filegroup_Ptr filegroup_hdl, const char * description, int description_size) 
    2041  { 
  • XIOS/trunk/src/interface/fortran_attr/file_interface_attr.f90

    r517 r528  
    99     
    1010     
     11    SUBROUTINE cxios_set_file_append(file_hdl, append) BIND(C) 
     12      USE ISO_C_BINDING 
     13      INTEGER (kind = C_INTPTR_T), VALUE :: file_hdl 
     14      LOGICAL (KIND=C_BOOL)      , VALUE :: append 
     15    END SUBROUTINE cxios_set_file_append 
     16     
     17    SUBROUTINE cxios_get_file_append(file_hdl, append) BIND(C) 
     18      USE ISO_C_BINDING 
     19      INTEGER (kind = C_INTPTR_T), VALUE :: file_hdl 
     20      LOGICAL (KIND=C_BOOL)             :: append 
     21    END SUBROUTINE cxios_get_file_append 
     22     
     23    FUNCTION cxios_is_defined_file_append(file_hdl ) BIND(C) 
     24      USE ISO_C_BINDING 
     25      LOGICAL(kind=C_BOOL) :: cxios_is_defined_file_append 
     26      INTEGER (kind = C_INTPTR_T), VALUE :: file_hdl 
     27    END FUNCTION cxios_is_defined_file_append 
     28     
     29     
    1130    SUBROUTINE cxios_set_file_description(file_hdl, description, description_size) BIND(C) 
    1231      USE ISO_C_BINDING 
  • XIOS/trunk/src/interface/fortran_attr/filegroup_interface_attr.f90

    r517 r528  
    99     
    1010     
     11    SUBROUTINE cxios_set_filegroup_append(filegroup_hdl, append) BIND(C) 
     12      USE ISO_C_BINDING 
     13      INTEGER (kind = C_INTPTR_T), VALUE :: filegroup_hdl 
     14      LOGICAL (KIND=C_BOOL)      , VALUE :: append 
     15    END SUBROUTINE cxios_set_filegroup_append 
     16     
     17    SUBROUTINE cxios_get_filegroup_append(filegroup_hdl, append) BIND(C) 
     18      USE ISO_C_BINDING 
     19      INTEGER (kind = C_INTPTR_T), VALUE :: filegroup_hdl 
     20      LOGICAL (KIND=C_BOOL)             :: append 
     21    END SUBROUTINE cxios_get_filegroup_append 
     22     
     23    FUNCTION cxios_is_defined_filegroup_append(filegroup_hdl ) BIND(C) 
     24      USE ISO_C_BINDING 
     25      LOGICAL(kind=C_BOOL) :: cxios_is_defined_filegroup_append 
     26      INTEGER (kind = C_INTPTR_T), VALUE :: filegroup_hdl 
     27    END FUNCTION cxios_is_defined_filegroup_append 
     28     
     29     
    1130    SUBROUTINE cxios_set_filegroup_description(filegroup_hdl, description, description_size) BIND(C) 
    1231      USE ISO_C_BINDING 
  • XIOS/trunk/src/interface/fortran_attr/ifile_attr.F90

    r517 r528  
    1212   
    1313  SUBROUTINE xios(set_file_attr)  & 
    14     ( file_id, description, enabled, format, min_digits, name, name_suffix, output_freq, output_level  & 
    15     , par_access, split_freq, split_freq_format, sync_freq, type ) 
     14    ( file_id, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     15    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    1616     
    1717    IMPLICIT NONE 
    1818      TYPE(txios(file))  :: file_hdl 
    1919      CHARACTER(LEN=*), INTENT(IN) ::file_id 
     20      LOGICAL  , OPTIONAL, INTENT(IN) :: append 
     21      LOGICAL (KIND=C_BOOL) :: append_tmp 
    2022      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: description 
    2123      LOGICAL  , OPTIONAL, INTENT(IN) :: enabled 
     
    3537      CALL xios(get_file_handle)(file_id,file_hdl) 
    3638      CALL xios(set_file_attr_hdl_)   & 
    37       ( file_hdl, description, enabled, format, min_digits, name, name_suffix, output_freq, output_level  & 
    38       , par_access, split_freq, split_freq_format, sync_freq, type ) 
     39      ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     40      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    3941     
    4042  END SUBROUTINE xios(set_file_attr) 
    4143   
    4244  SUBROUTINE xios(set_file_attr_hdl)  & 
    43     ( file_hdl, description, enabled, format, min_digits, name, name_suffix, output_freq, output_level  & 
    44     , par_access, split_freq, split_freq_format, sync_freq, type ) 
    45      
    46     IMPLICIT NONE 
    47       TYPE(txios(file)) , INTENT(IN) :: file_hdl 
     45    ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     46    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
     47     
     48    IMPLICIT NONE 
     49      TYPE(txios(file)) , INTENT(IN) :: file_hdl 
     50      LOGICAL  , OPTIONAL, INTENT(IN) :: append 
     51      LOGICAL (KIND=C_BOOL) :: append_tmp 
    4852      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: description 
    4953      LOGICAL  , OPTIONAL, INTENT(IN) :: enabled 
     
    6266       
    6367      CALL xios(set_file_attr_hdl_)  & 
    64       ( file_hdl, description, enabled, format, min_digits, name, name_suffix, output_freq, output_level  & 
    65       , par_access, split_freq, split_freq_format, sync_freq, type ) 
     68      ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     69      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    6670     
    6771  END SUBROUTINE xios(set_file_attr_hdl) 
    6872   
    6973  SUBROUTINE xios(set_file_attr_hdl_)   & 
    70     ( file_hdl, description_, enabled_, format_, min_digits_, name_, name_suffix_, output_freq_  & 
     74    ( file_hdl, append_, description_, enabled_, format_, min_digits_, name_, name_suffix_, output_freq_  & 
    7175    , output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_ ) 
    7276     
    7377    IMPLICIT NONE 
    7478      TYPE(txios(file)) , INTENT(IN) :: file_hdl 
     79      LOGICAL  , OPTIONAL, INTENT(IN) :: append_ 
     80      LOGICAL (KIND=C_BOOL) :: append__tmp 
    7581      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: description_ 
    7682      LOGICAL  , OPTIONAL, INTENT(IN) :: enabled_ 
     
    8894      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: type_ 
    8995       
     96      IF (PRESENT(append_)) THEN 
     97        append__tmp=append_ 
     98        CALL cxios_set_file_append(file_hdl%daddr, append__tmp) 
     99      ENDIF 
     100       
    90101      IF (PRESENT(description_)) THEN 
    91102        CALL cxios_set_file_description(file_hdl%daddr, description_, len(description_)) 
     
    146157   
    147158  SUBROUTINE xios(get_file_attr)  & 
    148     ( file_id, description, enabled, format, min_digits, name, name_suffix, output_freq, output_level  & 
    149     , par_access, split_freq, split_freq_format, sync_freq, type ) 
     159    ( file_id, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     160    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    150161     
    151162    IMPLICIT NONE 
    152163      TYPE(txios(file))  :: file_hdl 
    153164      CHARACTER(LEN=*), INTENT(IN) ::file_id 
     165      LOGICAL  , OPTIONAL, INTENT(OUT) :: append 
     166      LOGICAL (KIND=C_BOOL) :: append_tmp 
    154167      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: description 
    155168      LOGICAL  , OPTIONAL, INTENT(OUT) :: enabled 
     
    169182      CALL xios(get_file_handle)(file_id,file_hdl) 
    170183      CALL xios(get_file_attr_hdl_)   & 
    171       ( file_hdl, description, enabled, format, min_digits, name, name_suffix, output_freq, output_level  & 
    172       , par_access, split_freq, split_freq_format, sync_freq, type ) 
     184      ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     185      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    173186     
    174187  END SUBROUTINE xios(get_file_attr) 
    175188   
    176189  SUBROUTINE xios(get_file_attr_hdl)  & 
    177     ( file_hdl, description, enabled, format, min_digits, name, name_suffix, output_freq, output_level  & 
    178     , par_access, split_freq, split_freq_format, sync_freq, type ) 
    179      
    180     IMPLICIT NONE 
    181       TYPE(txios(file)) , INTENT(IN) :: file_hdl 
     190    ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     191    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
     192     
     193    IMPLICIT NONE 
     194      TYPE(txios(file)) , INTENT(IN) :: file_hdl 
     195      LOGICAL  , OPTIONAL, INTENT(OUT) :: append 
     196      LOGICAL (KIND=C_BOOL) :: append_tmp 
    182197      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: description 
    183198      LOGICAL  , OPTIONAL, INTENT(OUT) :: enabled 
     
    196211       
    197212      CALL xios(get_file_attr_hdl_)  & 
    198       ( file_hdl, description, enabled, format, min_digits, name, name_suffix, output_freq, output_level  & 
    199       , par_access, split_freq, split_freq_format, sync_freq, type ) 
     213      ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     214      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    200215     
    201216  END SUBROUTINE xios(get_file_attr_hdl) 
    202217   
    203218  SUBROUTINE xios(get_file_attr_hdl_)   & 
    204     ( file_hdl, description_, enabled_, format_, min_digits_, name_, name_suffix_, output_freq_  & 
     219    ( file_hdl, append_, description_, enabled_, format_, min_digits_, name_, name_suffix_, output_freq_  & 
    205220    , output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_ ) 
    206221     
    207222    IMPLICIT NONE 
    208223      TYPE(txios(file)) , INTENT(IN) :: file_hdl 
     224      LOGICAL  , OPTIONAL, INTENT(OUT) :: append_ 
     225      LOGICAL (KIND=C_BOOL) :: append__tmp 
    209226      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: description_ 
    210227      LOGICAL  , OPTIONAL, INTENT(OUT) :: enabled_ 
     
    222239      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: type_ 
    223240       
     241      IF (PRESENT(append_)) THEN 
     242        CALL cxios_get_file_append(file_hdl%daddr, append__tmp) 
     243        append_=append__tmp 
     244      ENDIF 
     245       
    224246      IF (PRESENT(description_)) THEN 
    225247        CALL cxios_get_file_description(file_hdl%daddr, description_, len(description_)) 
     
    280302   
    281303  SUBROUTINE xios(is_defined_file_attr)  & 
    282     ( file_id, description, enabled, format, min_digits, name, name_suffix, output_freq, output_level  & 
    283     , par_access, split_freq, split_freq_format, sync_freq, type ) 
     304    ( file_id, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     305    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    284306     
    285307    IMPLICIT NONE 
    286308      TYPE(txios(file))  :: file_hdl 
    287309      CHARACTER(LEN=*), INTENT(IN) ::file_id 
     310      LOGICAL, OPTIONAL, INTENT(OUT) :: append 
     311      LOGICAL(KIND=C_BOOL) :: append_tmp 
    288312      LOGICAL, OPTIONAL, INTENT(OUT) :: description 
    289313      LOGICAL(KIND=C_BOOL) :: description_tmp 
     
    315339      CALL xios(get_file_handle)(file_id,file_hdl) 
    316340      CALL xios(is_defined_file_attr_hdl_)   & 
    317       ( file_hdl, description, enabled, format, min_digits, name, name_suffix, output_freq, output_level  & 
    318       , par_access, split_freq, split_freq_format, sync_freq, type ) 
     341      ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     342      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    319343     
    320344  END SUBROUTINE xios(is_defined_file_attr) 
    321345   
    322346  SUBROUTINE xios(is_defined_file_attr_hdl)  & 
    323     ( file_hdl, description, enabled, format, min_digits, name, name_suffix, output_freq, output_level  & 
    324     , par_access, split_freq, split_freq_format, sync_freq, type ) 
    325      
    326     IMPLICIT NONE 
    327       TYPE(txios(file)) , INTENT(IN) :: file_hdl 
     347    ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     348    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
     349     
     350    IMPLICIT NONE 
     351      TYPE(txios(file)) , INTENT(IN) :: file_hdl 
     352      LOGICAL, OPTIONAL, INTENT(OUT) :: append 
     353      LOGICAL(KIND=C_BOOL) :: append_tmp 
    328354      LOGICAL, OPTIONAL, INTENT(OUT) :: description 
    329355      LOGICAL(KIND=C_BOOL) :: description_tmp 
     
    354380       
    355381      CALL xios(is_defined_file_attr_hdl_)  & 
    356       ( file_hdl, description, enabled, format, min_digits, name, name_suffix, output_freq, output_level  & 
    357       , par_access, split_freq, split_freq_format, sync_freq, type ) 
     382      ( file_hdl, append, description, enabled, format, min_digits, name, name_suffix, output_freq  & 
     383      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    358384     
    359385  END SUBROUTINE xios(is_defined_file_attr_hdl) 
    360386   
    361387  SUBROUTINE xios(is_defined_file_attr_hdl_)   & 
    362     ( file_hdl, description_, enabled_, format_, min_digits_, name_, name_suffix_, output_freq_  & 
     388    ( file_hdl, append_, description_, enabled_, format_, min_digits_, name_, name_suffix_, output_freq_  & 
    363389    , output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_ ) 
    364390     
    365391    IMPLICIT NONE 
    366392      TYPE(txios(file)) , INTENT(IN) :: file_hdl 
     393      LOGICAL, OPTIONAL, INTENT(OUT) :: append_ 
     394      LOGICAL(KIND=C_BOOL) :: append__tmp 
    367395      LOGICAL, OPTIONAL, INTENT(OUT) :: description_ 
    368396      LOGICAL(KIND=C_BOOL) :: description__tmp 
     
    392420      LOGICAL(KIND=C_BOOL) :: type__tmp 
    393421       
     422      IF (PRESENT(append_)) THEN 
     423        append__tmp=cxios_is_defined_file_append(file_hdl%daddr) 
     424        append_=append__tmp 
     425      ENDIF 
     426       
    394427      IF (PRESENT(description_)) THEN 
    395428        description__tmp=cxios_is_defined_file_description(file_hdl%daddr) 
  • XIOS/trunk/src/interface/fortran_attr/ifilegroup_attr.F90

    r517 r528  
    1212   
    1313  SUBROUTINE xios(set_filegroup_attr)  & 
    14     ( filegroup_id, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    15     , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
     14    ( filegroup_id, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     15    , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    1616     
    1717    IMPLICIT NONE 
    1818      TYPE(txios(filegroup))  :: filegroup_hdl 
    1919      CHARACTER(LEN=*), INTENT(IN) ::filegroup_id 
     20      LOGICAL  , OPTIONAL, INTENT(IN) :: append 
     21      LOGICAL (KIND=C_BOOL) :: append_tmp 
    2022      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: description 
    2123      LOGICAL  , OPTIONAL, INTENT(IN) :: enabled 
     
    3638      CALL xios(get_filegroup_handle)(filegroup_id,filegroup_hdl) 
    3739      CALL xios(set_filegroup_attr_hdl_)   & 
    38       ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    39       , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
     40      ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     41      , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    4042     
    4143  END SUBROUTINE xios(set_filegroup_attr) 
    4244   
    4345  SUBROUTINE xios(set_filegroup_attr_hdl)  & 
    44     ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    45     , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
     46    ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     47    , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    4648     
    4749    IMPLICIT NONE 
    4850      TYPE(txios(filegroup)) , INTENT(IN) :: filegroup_hdl 
     51      LOGICAL  , OPTIONAL, INTENT(IN) :: append 
     52      LOGICAL (KIND=C_BOOL) :: append_tmp 
    4953      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: description 
    5054      LOGICAL  , OPTIONAL, INTENT(IN) :: enabled 
     
    6468       
    6569      CALL xios(set_filegroup_attr_hdl_)  & 
    66       ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    67       , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
     70      ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     71      , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    6872     
    6973  END SUBROUTINE xios(set_filegroup_attr_hdl) 
    7074   
    7175  SUBROUTINE xios(set_filegroup_attr_hdl_)   & 
    72     ( filegroup_hdl, description_, enabled_, format_, group_ref_, min_digits_, name_, name_suffix_  & 
     76    ( filegroup_hdl, append_, description_, enabled_, format_, group_ref_, min_digits_, name_, name_suffix_  & 
    7377    , output_freq_, output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_  & 
    7478     ) 
     
    7680    IMPLICIT NONE 
    7781      TYPE(txios(filegroup)) , INTENT(IN) :: filegroup_hdl 
     82      LOGICAL  , OPTIONAL, INTENT(IN) :: append_ 
     83      LOGICAL (KIND=C_BOOL) :: append__tmp 
    7884      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: description_ 
    7985      LOGICAL  , OPTIONAL, INTENT(IN) :: enabled_ 
     
    9298      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: type_ 
    9399       
     100      IF (PRESENT(append_)) THEN 
     101        append__tmp=append_ 
     102        CALL cxios_set_filegroup_append(filegroup_hdl%daddr, append__tmp) 
     103      ENDIF 
     104       
    94105      IF (PRESENT(description_)) THEN 
    95106        CALL cxios_set_filegroup_description(filegroup_hdl%daddr, description_, len(description_)) 
     
    154165   
    155166  SUBROUTINE xios(get_filegroup_attr)  & 
    156     ( filegroup_id, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    157     , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
     167    ( filegroup_id, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     168    , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    158169     
    159170    IMPLICIT NONE 
    160171      TYPE(txios(filegroup))  :: filegroup_hdl 
    161172      CHARACTER(LEN=*), INTENT(IN) ::filegroup_id 
     173      LOGICAL  , OPTIONAL, INTENT(OUT) :: append 
     174      LOGICAL (KIND=C_BOOL) :: append_tmp 
    162175      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: description 
    163176      LOGICAL  , OPTIONAL, INTENT(OUT) :: enabled 
     
    178191      CALL xios(get_filegroup_handle)(filegroup_id,filegroup_hdl) 
    179192      CALL xios(get_filegroup_attr_hdl_)   & 
    180       ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    181       , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
     193      ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     194      , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    182195     
    183196  END SUBROUTINE xios(get_filegroup_attr) 
    184197   
    185198  SUBROUTINE xios(get_filegroup_attr_hdl)  & 
    186     ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    187     , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
     199    ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     200    , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    188201     
    189202    IMPLICIT NONE 
    190203      TYPE(txios(filegroup)) , INTENT(IN) :: filegroup_hdl 
     204      LOGICAL  , OPTIONAL, INTENT(OUT) :: append 
     205      LOGICAL (KIND=C_BOOL) :: append_tmp 
    191206      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: description 
    192207      LOGICAL  , OPTIONAL, INTENT(OUT) :: enabled 
     
    206221       
    207222      CALL xios(get_filegroup_attr_hdl_)  & 
    208       ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    209       , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
     223      ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     224      , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    210225     
    211226  END SUBROUTINE xios(get_filegroup_attr_hdl) 
    212227   
    213228  SUBROUTINE xios(get_filegroup_attr_hdl_)   & 
    214     ( filegroup_hdl, description_, enabled_, format_, group_ref_, min_digits_, name_, name_suffix_  & 
     229    ( filegroup_hdl, append_, description_, enabled_, format_, group_ref_, min_digits_, name_, name_suffix_  & 
    215230    , output_freq_, output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_  & 
    216231     ) 
     
    218233    IMPLICIT NONE 
    219234      TYPE(txios(filegroup)) , INTENT(IN) :: filegroup_hdl 
     235      LOGICAL  , OPTIONAL, INTENT(OUT) :: append_ 
     236      LOGICAL (KIND=C_BOOL) :: append__tmp 
    220237      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: description_ 
    221238      LOGICAL  , OPTIONAL, INTENT(OUT) :: enabled_ 
     
    234251      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: type_ 
    235252       
     253      IF (PRESENT(append_)) THEN 
     254        CALL cxios_get_filegroup_append(filegroup_hdl%daddr, append__tmp) 
     255        append_=append__tmp 
     256      ENDIF 
     257       
    236258      IF (PRESENT(description_)) THEN 
    237259        CALL cxios_get_filegroup_description(filegroup_hdl%daddr, description_, len(description_)) 
     
    296318   
    297319  SUBROUTINE xios(is_defined_filegroup_attr)  & 
    298     ( filegroup_id, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    299     , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
     320    ( filegroup_id, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     321    , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    300322     
    301323    IMPLICIT NONE 
    302324      TYPE(txios(filegroup))  :: filegroup_hdl 
    303325      CHARACTER(LEN=*), INTENT(IN) ::filegroup_id 
     326      LOGICAL, OPTIONAL, INTENT(OUT) :: append 
     327      LOGICAL(KIND=C_BOOL) :: append_tmp 
    304328      LOGICAL, OPTIONAL, INTENT(OUT) :: description 
    305329      LOGICAL(KIND=C_BOOL) :: description_tmp 
     
    333357      CALL xios(get_filegroup_handle)(filegroup_id,filegroup_hdl) 
    334358      CALL xios(is_defined_filegroup_attr_hdl_)   & 
    335       ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    336       , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
     359      ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     360      , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    337361     
    338362  END SUBROUTINE xios(is_defined_filegroup_attr) 
    339363   
    340364  SUBROUTINE xios(is_defined_filegroup_attr_hdl)  & 
    341     ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    342     , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
     365    ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     366    , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    343367     
    344368    IMPLICIT NONE 
    345369      TYPE(txios(filegroup)) , INTENT(IN) :: filegroup_hdl 
     370      LOGICAL, OPTIONAL, INTENT(OUT) :: append 
     371      LOGICAL(KIND=C_BOOL) :: append_tmp 
    346372      LOGICAL, OPTIONAL, INTENT(OUT) :: description 
    347373      LOGICAL(KIND=C_BOOL) :: description_tmp 
     
    374400       
    375401      CALL xios(is_defined_filegroup_attr_hdl_)  & 
    376       ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    377       , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
     402      ( filegroup_hdl, append, description, enabled, format, group_ref, min_digits, name, name_suffix  & 
     403      , output_freq, output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    378404     
    379405  END SUBROUTINE xios(is_defined_filegroup_attr_hdl) 
    380406   
    381407  SUBROUTINE xios(is_defined_filegroup_attr_hdl_)   & 
    382     ( filegroup_hdl, description_, enabled_, format_, group_ref_, min_digits_, name_, name_suffix_  & 
     408    ( filegroup_hdl, append_, description_, enabled_, format_, group_ref_, min_digits_, name_, name_suffix_  & 
    383409    , output_freq_, output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_  & 
    384410     ) 
     
    386412    IMPLICIT NONE 
    387413      TYPE(txios(filegroup)) , INTENT(IN) :: filegroup_hdl 
     414      LOGICAL, OPTIONAL, INTENT(OUT) :: append_ 
     415      LOGICAL(KIND=C_BOOL) :: append__tmp 
    388416      LOGICAL, OPTIONAL, INTENT(OUT) :: description_ 
    389417      LOGICAL(KIND=C_BOOL) :: description__tmp 
     
    415443      LOGICAL(KIND=C_BOOL) :: type__tmp 
    416444       
     445      IF (PRESENT(append_)) THEN 
     446        append__tmp=cxios_is_defined_filegroup_append(filegroup_hdl%daddr) 
     447        append_=append__tmp 
     448      ENDIF 
     449       
    417450      IF (PRESENT(description_)) THEN 
    418451        description__tmp=cxios_is_defined_filegroup_description(filegroup_hdl%daddr) 
  • XIOS/trunk/src/node/file.cpp

    r526 r528  
    322322         } 
    323323 
     324        bool append = !this->append.isEmpty() && this->append.getValue(); 
     325         
    324326         bool useClassicFormat = !format.isEmpty() && format == format_attr::netcdf4_classic; 
    325327 
     
    362364         if (isOpen) data_out->closeFile(); 
    363365 
    364          data_out=shared_ptr<CDataOutput>(new CNc4DataOutput(oss.str(), false, useClassicFormat, 
    365                                                              fileComm, multifile, isCollective)); 
    366          isOpen=true ; 
    367  
    368          data_out->writeFile(CFile::get(this)); 
    369          std::vector<CField*>::iterator it, end = this->enabledFields.end(); 
    370          for (it = this->enabledFields.begin() ;it != end; it++) 
    371          { 
     366        data_out = shared_ptr<CDataOutput>(new CNc4DataOutput(oss.str(), append, useClassicFormat, 
     367                                                              fileComm, multifile, isCollective)); 
     368        isOpen = true; 
     369 
     370        data_out->writeFile(CFile::get(this)); 
     371 
     372        // Do not recreate the file structure if opening an existing file 
     373        if (!data_out->IsInAppendMode()) 
     374        { 
     375          std::vector<CField*>::iterator it, end = this->enabledFields.end(); 
     376          for (it = this->enabledFields.begin(); it != end; it++) 
     377          { 
    372378            CField* field = *it; 
    373379            this->data_out->writeFieldGrid(field); 
    374          } 
    375          this->data_out->writeTimeDimension(); 
    376  
    377          for (it = this->enabledFields.begin() ;it != end; it++) 
    378          { 
     380          } 
     381          this->data_out->writeTimeDimension(); 
     382 
     383          for (it = this->enabledFields.begin(); it != end; it++) 
     384          { 
    379385            CField* field = *it; 
    380386            this->data_out->writeField(field); 
    381          } 
    382  
    383          vector<CVariable*> listVars = getAllVariables() ; 
    384          for (vector<CVariable*>::iterator it = listVars.begin() ;it != listVars.end(); it++) this-> data_out-> writeAttribute(*it) ; 
    385  
    386          this->data_out->definition_end(); 
     387          } 
     388 
     389          vector<CVariable*> listVars = getAllVariables() ; 
     390          for (vector<CVariable*>::iterator it = listVars.begin(); it != listVars.end(); it++) 
     391            this->data_out->writeAttribute(*it); 
     392 
     393          this->data_out->definition_end(); 
     394        } 
    387395      } 
    388396   } 
  • XIOS/trunk/src/output/onetcdf4.cpp

    r517 r528  
     1#include <fstream> 
     2 
    13#include "onetcdf4.hpp" 
    24#include "group_template.hpp" 
     
    1113 
    1214      CONetCDF4::CONetCDF4 
    13          (const StdString & filename, bool exist, bool useClassicFormat, const MPI_Comm * comm, bool multifile) 
     15         (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm * comm, bool multifile) 
    1416            : path() 
    1517            , useClassicFormat(useClassicFormat) 
     18            , recordOffset(0) 
    1619      { 
    1720         this->wmpi = (comm != NULL) && !multifile; 
    18          this->initialize(filename, exist, useClassicFormat, comm,multifile); 
     21         this->initialize(filename, append, useClassicFormat, comm,multifile); 
    1922      } 
    2023 
     
    3033 
    3134      void CONetCDF4::initialize 
    32          (const StdString & filename, bool exist, bool useClassicFormat, const MPI_Comm * comm, bool multifile) 
     35         (const StdString & filename, bool append, bool useClassicFormat, const MPI_Comm * comm, bool multifile) 
    3336      { 
    3437         this->useClassicFormat = useClassicFormat; 
     
    3841            mode |= useClassicFormat ? NC_PNETCDF : NC_MPIIO; 
    3942 
    40          if (!exist) 
     43         // If the file does not exist, we always create it 
     44         if (!append || !std::ifstream(filename.c_str())) 
    4145         { 
    4246            if (comm != NULL) 
     
    4650            } 
    4751            else CNetCdfInterface::create(filename, mode, this->ncidp); 
     52 
     53            this->appendMode = false; 
     54            this->recordOffset = 0; 
    4855         } 
    4956         else 
    5057         { 
     58            mode |= NC_WRITE; 
    5159            if (comm != NULL) 
    5260            { 
     
    5563            } 
    5664            else CNetCdfInterface::open(filename, mode, this->ncidp); 
     65 
     66            this->appendMode = true; 
     67            // Find out how many temporal records have been written already to the file we are opening 
     68            int ncUnlimitedDimId; 
     69            CNetCdfInterface::inqUnLimDim(this->ncidp, ncUnlimitedDimId); 
     70            if (ncUnlimitedDimId != -1) 
     71               CNetCdfInterface::inqDimLen(this->ncidp, ncUnlimitedDimId, this->recordOffset); 
     72            else 
     73               this->recordOffset = 0; 
    5774         } 
    5875 
     
    424441         if (iddims.begin()->compare(this->getUnlimitedDimensionName()) == 0) 
    425442         { 
    426             sstart.push_back(record); 
     443            sstart.push_back(record + recordOffset); 
    427444            scount.push_back(1);  
    428445            if ((start == NULL) && 
  • XIOS/trunk/src/output/onetcdf4.hpp

    r517 r528  
    2626 
    2727            /// Constructeurs /// 
    28             CONetCDF4(const StdString & filename, bool exist, bool useClassicFormat = false, 
     28            CONetCDF4(const StdString & filename, bool append, bool useClassicFormat = false, 
    2929                      const MPI_Comm * comm = NULL, bool multifile = true); 
    3030 
     
    3434 
    3535            /// Initialisation /// 
    36             void initialize(const StdString & filename, bool exist, bool useClassicFormat, 
     36            void initialize(const StdString & filename, bool append, bool useClassicFormat, 
    3737                            const MPI_Comm * comm, bool multifile); 
    3838            void close(void) ; 
     
    118118            int ncidp; 
    119119            bool wmpi; 
     120            /*! Number of records already written when opening an existing file. 
     121             *  always 0 when creating a new file */ 
     122            size_t recordOffset; 
    120123            map<int,size_t> timeAxis ; 
    121124      }; // class CONetCDF4 
Note: See TracChangeset for help on using the changeset viewer.