Changeset 517


Ignore:
Timestamp:
11/26/14 12:06:21 (7 years ago)
Author:
rlacroix
Message:

Add a new attribute to the file definition so that the output format can be controlled.

Currently the supported formats are "netcdf4" and "netcdf4_classic". The "format" attribute is optional. The "netcdf4" format will be used when no format is explicitly defined. Since "netcdf4" is the format which was previously used by XIOS, existing configuration files will not be affected by this change.

If "netcdf4_classic" is used, the output file(s) will be created using the classic NetCDF format. This format can be used with the attribute "type" set to "one_file" if the NetCDF4 library was compiled with Parallel NetCDF support (--enable-pnetcdf).

Location:
XIOS/trunk/src
Files:
15 edited

Legend:

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

    r501 r517  
    1212DECLARE_ATTRIBUTE(bool,      enabled) 
    1313DECLARE_ENUM2(type,one_file,multiple_file) 
     14DECLARE_ENUM2(format, netcdf4, netcdf4_classic) 
    1415DECLARE_ATTRIBUTE(StdString,      par_access) 
    1516 
  • XIOS/trunk/src/interface/c_attr/icfile_attr.cpp

    r509 r517  
    6464   
    6565   
     66  void cxios_set_file_format(file_Ptr file_hdl, const char * format, int format_size) 
     67  { 
     68    std::string format_str; 
     69    if(!cstr2string(format, format_size, format_str)) return; 
     70     CTimer::get("XIOS").resume(); 
     71    file_hdl->format.fromString(format_str); 
     72     CTimer::get("XIOS").suspend(); 
     73  } 
     74   
     75  void cxios_get_file_format(file_Ptr file_hdl, char * format, int format_size) 
     76  { 
     77     CTimer::get("XIOS").resume(); 
     78    if(!string_copy(file_hdl->format.getInheritedStringValue(),format , format_size)) 
     79      ERROR("void cxios_get_file_format(file_Ptr file_hdl, char * format, int format_size)", <<"Input string is to short"); 
     80     CTimer::get("XIOS").suspend(); 
     81  } 
     82   
     83  bool cxios_is_defined_file_format(file_Ptr file_hdl ) 
     84  { 
     85     CTimer::get("XIOS").resume(); 
     86    return file_hdl->format.hasInheritedValue(); 
     87     CTimer::get("XIOS").suspend(); 
     88  } 
     89   
     90   
     91   
    6692  void cxios_set_file_min_digits(file_Ptr file_hdl, int min_digits) 
    6793  { 
  • XIOS/trunk/src/interface/c_attr/icfilegroup_attr.cpp

    r509 r517  
    6464   
    6565   
     66  void cxios_set_filegroup_format(filegroup_Ptr filegroup_hdl, const char * format, int format_size) 
     67  { 
     68    std::string format_str; 
     69    if(!cstr2string(format, format_size, format_str)) return; 
     70     CTimer::get("XIOS").resume(); 
     71    filegroup_hdl->format.fromString(format_str); 
     72     CTimer::get("XIOS").suspend(); 
     73  } 
     74   
     75  void cxios_get_filegroup_format(filegroup_Ptr filegroup_hdl, char * format, int format_size) 
     76  { 
     77     CTimer::get("XIOS").resume(); 
     78    if(!string_copy(filegroup_hdl->format.getInheritedStringValue(),format , format_size)) 
     79      ERROR("void cxios_get_filegroup_format(filegroup_Ptr filegroup_hdl, char * format, int format_size)", <<"Input string is to short"); 
     80     CTimer::get("XIOS").suspend(); 
     81  } 
     82   
     83  bool cxios_is_defined_filegroup_format(filegroup_Ptr filegroup_hdl ) 
     84  { 
     85     CTimer::get("XIOS").resume(); 
     86    return filegroup_hdl->format.hasInheritedValue(); 
     87     CTimer::get("XIOS").suspend(); 
     88  } 
     89   
     90   
     91   
    6692  void cxios_set_filegroup_group_ref(filegroup_Ptr filegroup_hdl, const char * group_ref, int group_ref_size) 
    6793  { 
  • XIOS/trunk/src/interface/fortran_attr/file_interface_attr.f90

    r501 r517  
    4949     
    5050     
     51    SUBROUTINE cxios_set_file_format(file_hdl, format, format_size) BIND(C) 
     52      USE ISO_C_BINDING 
     53      INTEGER (kind = C_INTPTR_T), VALUE :: file_hdl 
     54      CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: format 
     55      INTEGER  (kind = C_INT)     , VALUE        :: format_size 
     56    END SUBROUTINE cxios_set_file_format 
     57     
     58    SUBROUTINE cxios_get_file_format(file_hdl, format, format_size) BIND(C) 
     59      USE ISO_C_BINDING 
     60      INTEGER (kind = C_INTPTR_T), VALUE :: file_hdl 
     61      CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: format 
     62      INTEGER  (kind = C_INT)     , VALUE        :: format_size 
     63    END SUBROUTINE cxios_get_file_format 
     64     
     65    FUNCTION cxios_is_defined_file_format(file_hdl ) BIND(C) 
     66      USE ISO_C_BINDING 
     67      LOGICAL(kind=C_BOOL) :: cxios_is_defined_file_format 
     68      INTEGER (kind = C_INTPTR_T), VALUE :: file_hdl 
     69    END FUNCTION cxios_is_defined_file_format 
     70     
     71     
    5172    SUBROUTINE cxios_set_file_min_digits(file_hdl, min_digits) BIND(C) 
    5273      USE ISO_C_BINDING 
  • XIOS/trunk/src/interface/fortran_attr/filegroup_interface_attr.f90

    r501 r517  
    4949     
    5050     
     51    SUBROUTINE cxios_set_filegroup_format(filegroup_hdl, format, format_size) BIND(C) 
     52      USE ISO_C_BINDING 
     53      INTEGER (kind = C_INTPTR_T), VALUE :: filegroup_hdl 
     54      CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: format 
     55      INTEGER  (kind = C_INT)     , VALUE        :: format_size 
     56    END SUBROUTINE cxios_set_filegroup_format 
     57     
     58    SUBROUTINE cxios_get_filegroup_format(filegroup_hdl, format, format_size) BIND(C) 
     59      USE ISO_C_BINDING 
     60      INTEGER (kind = C_INTPTR_T), VALUE :: filegroup_hdl 
     61      CHARACTER(kind = C_CHAR)    , DIMENSION(*) :: format 
     62      INTEGER  (kind = C_INT)     , VALUE        :: format_size 
     63    END SUBROUTINE cxios_get_filegroup_format 
     64     
     65    FUNCTION cxios_is_defined_filegroup_format(filegroup_hdl ) BIND(C) 
     66      USE ISO_C_BINDING 
     67      LOGICAL(kind=C_BOOL) :: cxios_is_defined_filegroup_format 
     68      INTEGER (kind = C_INTPTR_T), VALUE :: filegroup_hdl 
     69    END FUNCTION cxios_is_defined_filegroup_format 
     70     
     71     
    5172    SUBROUTINE cxios_set_filegroup_group_ref(filegroup_hdl, group_ref, group_ref_size) BIND(C) 
    5273      USE ISO_C_BINDING 
  • XIOS/trunk/src/interface/fortran_attr/ifile_attr.F90

    r501 r517  
    1212   
    1313  SUBROUTINE xios(set_file_attr)  & 
    14     ( file_id, description, enabled, min_digits, name, name_suffix, output_freq, output_level, par_access  & 
    15     , split_freq, split_freq_format, sync_freq, type ) 
     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 ) 
    1616     
    1717    IMPLICIT NONE 
     
    2121      LOGICAL  , OPTIONAL, INTENT(IN) :: enabled 
    2222      LOGICAL (KIND=C_BOOL) :: enabled_tmp 
     23      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: format 
    2324      INTEGER  , OPTIONAL, INTENT(IN) :: min_digits 
    2425      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name 
     
    3435      CALL xios(get_file_handle)(file_id,file_hdl) 
    3536      CALL xios(set_file_attr_hdl_)   & 
    36       ( file_hdl, description, enabled, min_digits, name, name_suffix, output_freq, output_level, par_access  & 
    37       , split_freq, split_freq_format, sync_freq, type ) 
     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 ) 
    3839     
    3940  END SUBROUTINE xios(set_file_attr) 
    4041   
    4142  SUBROUTINE xios(set_file_attr_hdl)  & 
    42     ( file_hdl, description, enabled, min_digits, name, name_suffix, output_freq, output_level, par_access  & 
    43     , split_freq, split_freq_format, sync_freq, type ) 
     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 ) 
    4445     
    4546    IMPLICIT NONE 
     
    4849      LOGICAL  , OPTIONAL, INTENT(IN) :: enabled 
    4950      LOGICAL (KIND=C_BOOL) :: enabled_tmp 
     51      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: format 
    5052      INTEGER  , OPTIONAL, INTENT(IN) :: min_digits 
    5153      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name 
     
    6062       
    6163      CALL xios(set_file_attr_hdl_)  & 
    62       ( file_hdl, description, enabled, min_digits, name, name_suffix, output_freq, output_level, par_access  & 
    63       , split_freq, split_freq_format, sync_freq, type ) 
     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 ) 
    6466     
    6567  END SUBROUTINE xios(set_file_attr_hdl) 
    6668   
    6769  SUBROUTINE xios(set_file_attr_hdl_)   & 
    68     ( file_hdl, description_, enabled_, min_digits_, name_, name_suffix_, output_freq_, output_level_  & 
    69     , par_access_, split_freq_, split_freq_format_, sync_freq_, type_ ) 
     70    ( file_hdl, description_, enabled_, format_, min_digits_, name_, name_suffix_, output_freq_  & 
     71    , output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_ ) 
    7072     
    7173    IMPLICIT NONE 
     
    7476      LOGICAL  , OPTIONAL, INTENT(IN) :: enabled_ 
    7577      LOGICAL (KIND=C_BOOL) :: enabled__tmp 
     78      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: format_ 
    7679      INTEGER  , OPTIONAL, INTENT(IN) :: min_digits_ 
    7780      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: name_ 
     
    9497      ENDIF 
    9598       
     99      IF (PRESENT(format_)) THEN 
     100        CALL cxios_set_file_format(file_hdl%daddr, format_, len(format_)) 
     101      ENDIF 
     102       
    96103      IF (PRESENT(min_digits_)) THEN 
    97104        CALL cxios_set_file_min_digits(file_hdl%daddr, min_digits_) 
     
    139146   
    140147  SUBROUTINE xios(get_file_attr)  & 
    141     ( file_id, description, enabled, min_digits, name, name_suffix, output_freq, output_level, par_access  & 
    142     , split_freq, split_freq_format, sync_freq, type ) 
     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 ) 
    143150     
    144151    IMPLICIT NONE 
     
    148155      LOGICAL  , OPTIONAL, INTENT(OUT) :: enabled 
    149156      LOGICAL (KIND=C_BOOL) :: enabled_tmp 
     157      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: format 
    150158      INTEGER  , OPTIONAL, INTENT(OUT) :: min_digits 
    151159      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name 
     
    161169      CALL xios(get_file_handle)(file_id,file_hdl) 
    162170      CALL xios(get_file_attr_hdl_)   & 
    163       ( file_hdl, description, enabled, min_digits, name, name_suffix, output_freq, output_level, par_access  & 
    164       , split_freq, split_freq_format, sync_freq, type ) 
     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 ) 
    165173     
    166174  END SUBROUTINE xios(get_file_attr) 
    167175   
    168176  SUBROUTINE xios(get_file_attr_hdl)  & 
    169     ( file_hdl, description, enabled, min_digits, name, name_suffix, output_freq, output_level, par_access  & 
    170     , split_freq, split_freq_format, sync_freq, type ) 
     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 ) 
    171179     
    172180    IMPLICIT NONE 
     
    175183      LOGICAL  , OPTIONAL, INTENT(OUT) :: enabled 
    176184      LOGICAL (KIND=C_BOOL) :: enabled_tmp 
     185      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: format 
    177186      INTEGER  , OPTIONAL, INTENT(OUT) :: min_digits 
    178187      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name 
     
    187196       
    188197      CALL xios(get_file_attr_hdl_)  & 
    189       ( file_hdl, description, enabled, min_digits, name, name_suffix, output_freq, output_level, par_access  & 
    190       , split_freq, split_freq_format, sync_freq, type ) 
     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 ) 
    191200     
    192201  END SUBROUTINE xios(get_file_attr_hdl) 
    193202   
    194203  SUBROUTINE xios(get_file_attr_hdl_)   & 
    195     ( file_hdl, description_, enabled_, min_digits_, name_, name_suffix_, output_freq_, output_level_  & 
    196     , par_access_, split_freq_, split_freq_format_, sync_freq_, type_ ) 
     204    ( file_hdl, description_, enabled_, format_, min_digits_, name_, name_suffix_, output_freq_  & 
     205    , output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_ ) 
    197206     
    198207    IMPLICIT NONE 
     
    201210      LOGICAL  , OPTIONAL, INTENT(OUT) :: enabled_ 
    202211      LOGICAL (KIND=C_BOOL) :: enabled__tmp 
     212      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: format_ 
    203213      INTEGER  , OPTIONAL, INTENT(OUT) :: min_digits_ 
    204214      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: name_ 
     
    221231      ENDIF 
    222232       
     233      IF (PRESENT(format_)) THEN 
     234        CALL cxios_get_file_format(file_hdl%daddr, format_, len(format_)) 
     235      ENDIF 
     236       
    223237      IF (PRESENT(min_digits_)) THEN 
    224238        CALL cxios_get_file_min_digits(file_hdl%daddr, min_digits_) 
     
    266280   
    267281  SUBROUTINE xios(is_defined_file_attr)  & 
    268     ( file_id, description, enabled, min_digits, name, name_suffix, output_freq, output_level, par_access  & 
    269     , split_freq, split_freq_format, sync_freq, type ) 
     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 ) 
    270284     
    271285    IMPLICIT NONE 
     
    276290      LOGICAL, OPTIONAL, INTENT(OUT) :: enabled 
    277291      LOGICAL(KIND=C_BOOL) :: enabled_tmp 
     292      LOGICAL, OPTIONAL, INTENT(OUT) :: format 
     293      LOGICAL(KIND=C_BOOL) :: format_tmp 
    278294      LOGICAL, OPTIONAL, INTENT(OUT) :: min_digits 
    279295      LOGICAL(KIND=C_BOOL) :: min_digits_tmp 
     
    299315      CALL xios(get_file_handle)(file_id,file_hdl) 
    300316      CALL xios(is_defined_file_attr_hdl_)   & 
    301       ( file_hdl, description, enabled, min_digits, name, name_suffix, output_freq, output_level, par_access  & 
    302       , split_freq, split_freq_format, sync_freq, type ) 
     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 ) 
    303319     
    304320  END SUBROUTINE xios(is_defined_file_attr) 
    305321   
    306322  SUBROUTINE xios(is_defined_file_attr_hdl)  & 
    307     ( file_hdl, description, enabled, min_digits, name, name_suffix, output_freq, output_level, par_access  & 
    308     , split_freq, split_freq_format, sync_freq, type ) 
     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 ) 
    309325     
    310326    IMPLICIT NONE 
     
    314330      LOGICAL, OPTIONAL, INTENT(OUT) :: enabled 
    315331      LOGICAL(KIND=C_BOOL) :: enabled_tmp 
     332      LOGICAL, OPTIONAL, INTENT(OUT) :: format 
     333      LOGICAL(KIND=C_BOOL) :: format_tmp 
    316334      LOGICAL, OPTIONAL, INTENT(OUT) :: min_digits 
    317335      LOGICAL(KIND=C_BOOL) :: min_digits_tmp 
     
    336354       
    337355      CALL xios(is_defined_file_attr_hdl_)  & 
    338       ( file_hdl, description, enabled, min_digits, name, name_suffix, output_freq, output_level, par_access  & 
    339       , split_freq, split_freq_format, sync_freq, type ) 
     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 ) 
    340358     
    341359  END SUBROUTINE xios(is_defined_file_attr_hdl) 
    342360   
    343361  SUBROUTINE xios(is_defined_file_attr_hdl_)   & 
    344     ( file_hdl, description_, enabled_, min_digits_, name_, name_suffix_, output_freq_, output_level_  & 
    345     , par_access_, split_freq_, split_freq_format_, sync_freq_, type_ ) 
     362    ( file_hdl, description_, enabled_, format_, min_digits_, name_, name_suffix_, output_freq_  & 
     363    , output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_ ) 
    346364     
    347365    IMPLICIT NONE 
     
    351369      LOGICAL, OPTIONAL, INTENT(OUT) :: enabled_ 
    352370      LOGICAL(KIND=C_BOOL) :: enabled__tmp 
     371      LOGICAL, OPTIONAL, INTENT(OUT) :: format_ 
     372      LOGICAL(KIND=C_BOOL) :: format__tmp 
    353373      LOGICAL, OPTIONAL, INTENT(OUT) :: min_digits_ 
    354374      LOGICAL(KIND=C_BOOL) :: min_digits__tmp 
     
    382402      ENDIF 
    383403       
     404      IF (PRESENT(format_)) THEN 
     405        format__tmp=cxios_is_defined_file_format(file_hdl%daddr) 
     406        format_=format__tmp 
     407      ENDIF 
     408       
    384409      IF (PRESENT(min_digits_)) THEN 
    385410        min_digits__tmp=cxios_is_defined_file_min_digits(file_hdl%daddr) 
  • XIOS/trunk/src/interface/fortran_attr/ifilegroup_attr.F90

    r501 r517  
    1212   
    1313  SUBROUTINE xios(set_filegroup_attr)  & 
    14     ( filegroup_id, description, enabled, group_ref, min_digits, name, name_suffix, output_freq  & 
     14    ( filegroup_id, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    1515    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    1616     
     
    2121      LOGICAL  , OPTIONAL, INTENT(IN) :: enabled 
    2222      LOGICAL (KIND=C_BOOL) :: enabled_tmp 
     23      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: format 
    2324      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: group_ref 
    2425      INTEGER  , OPTIONAL, INTENT(IN) :: min_digits 
     
    3536      CALL xios(get_filegroup_handle)(filegroup_id,filegroup_hdl) 
    3637      CALL xios(set_filegroup_attr_hdl_)   & 
    37       ( filegroup_hdl, description, enabled, group_ref, min_digits, name, name_suffix, output_freq  & 
     38      ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    3839      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    3940     
     
    4142   
    4243  SUBROUTINE xios(set_filegroup_attr_hdl)  & 
    43     ( filegroup_hdl, description, enabled, group_ref, min_digits, name, name_suffix, output_freq  & 
     44    ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    4445    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    4546     
     
    4950      LOGICAL  , OPTIONAL, INTENT(IN) :: enabled 
    5051      LOGICAL (KIND=C_BOOL) :: enabled_tmp 
     52      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: format 
    5153      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: group_ref 
    5254      INTEGER  , OPTIONAL, INTENT(IN) :: min_digits 
     
    6264       
    6365      CALL xios(set_filegroup_attr_hdl_)  & 
    64       ( filegroup_hdl, description, enabled, group_ref, min_digits, name, name_suffix, output_freq  & 
     66      ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    6567      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    6668     
     
    6870   
    6971  SUBROUTINE xios(set_filegroup_attr_hdl_)   & 
    70     ( filegroup_hdl, description_, enabled_, group_ref_, min_digits_, name_, name_suffix_, output_freq_  & 
    71     , output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_ ) 
     72    ( filegroup_hdl, description_, enabled_, format_, group_ref_, min_digits_, name_, name_suffix_  & 
     73    , output_freq_, output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_  & 
     74     ) 
    7275     
    7376    IMPLICIT NONE 
     
    7679      LOGICAL  , OPTIONAL, INTENT(IN) :: enabled_ 
    7780      LOGICAL (KIND=C_BOOL) :: enabled__tmp 
     81      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: format_ 
    7882      CHARACTER(len = *) , OPTIONAL, INTENT(IN) :: group_ref_ 
    7983      INTEGER  , OPTIONAL, INTENT(IN) :: min_digits_ 
     
    97101      ENDIF 
    98102       
     103      IF (PRESENT(format_)) THEN 
     104        CALL cxios_set_filegroup_format(filegroup_hdl%daddr, format_, len(format_)) 
     105      ENDIF 
     106       
    99107      IF (PRESENT(group_ref_)) THEN 
    100108        CALL cxios_set_filegroup_group_ref(filegroup_hdl%daddr, group_ref_, len(group_ref_)) 
     
    146154   
    147155  SUBROUTINE xios(get_filegroup_attr)  & 
    148     ( filegroup_id, description, enabled, group_ref, min_digits, name, name_suffix, output_freq  & 
     156    ( filegroup_id, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    149157    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    150158     
     
    155163      LOGICAL  , OPTIONAL, INTENT(OUT) :: enabled 
    156164      LOGICAL (KIND=C_BOOL) :: enabled_tmp 
     165      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: format 
    157166      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: group_ref 
    158167      INTEGER  , OPTIONAL, INTENT(OUT) :: min_digits 
     
    169178      CALL xios(get_filegroup_handle)(filegroup_id,filegroup_hdl) 
    170179      CALL xios(get_filegroup_attr_hdl_)   & 
    171       ( filegroup_hdl, description, enabled, group_ref, min_digits, name, name_suffix, output_freq  & 
     180      ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    172181      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    173182     
     
    175184   
    176185  SUBROUTINE xios(get_filegroup_attr_hdl)  & 
    177     ( filegroup_hdl, description, enabled, group_ref, min_digits, name, name_suffix, output_freq  & 
     186    ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    178187    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    179188     
     
    183192      LOGICAL  , OPTIONAL, INTENT(OUT) :: enabled 
    184193      LOGICAL (KIND=C_BOOL) :: enabled_tmp 
     194      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: format 
    185195      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: group_ref 
    186196      INTEGER  , OPTIONAL, INTENT(OUT) :: min_digits 
     
    196206       
    197207      CALL xios(get_filegroup_attr_hdl_)  & 
    198       ( filegroup_hdl, description, enabled, group_ref, min_digits, name, name_suffix, output_freq  & 
     208      ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    199209      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    200210     
     
    202212   
    203213  SUBROUTINE xios(get_filegroup_attr_hdl_)   & 
    204     ( filegroup_hdl, description_, enabled_, group_ref_, min_digits_, name_, name_suffix_, output_freq_  & 
    205     , output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_ ) 
     214    ( filegroup_hdl, description_, enabled_, format_, group_ref_, min_digits_, name_, name_suffix_  & 
     215    , output_freq_, output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_  & 
     216     ) 
    206217     
    207218    IMPLICIT NONE 
     
    210221      LOGICAL  , OPTIONAL, INTENT(OUT) :: enabled_ 
    211222      LOGICAL (KIND=C_BOOL) :: enabled__tmp 
     223      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: format_ 
    212224      CHARACTER(len = *) , OPTIONAL, INTENT(OUT) :: group_ref_ 
    213225      INTEGER  , OPTIONAL, INTENT(OUT) :: min_digits_ 
     
    231243      ENDIF 
    232244       
     245      IF (PRESENT(format_)) THEN 
     246        CALL cxios_get_filegroup_format(filegroup_hdl%daddr, format_, len(format_)) 
     247      ENDIF 
     248       
    233249      IF (PRESENT(group_ref_)) THEN 
    234250        CALL cxios_get_filegroup_group_ref(filegroup_hdl%daddr, group_ref_, len(group_ref_)) 
     
    280296   
    281297  SUBROUTINE xios(is_defined_filegroup_attr)  & 
    282     ( filegroup_id, description, enabled, group_ref, min_digits, name, name_suffix, output_freq  & 
     298    ( filegroup_id, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    283299    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    284300     
     
    290306      LOGICAL, OPTIONAL, INTENT(OUT) :: enabled 
    291307      LOGICAL(KIND=C_BOOL) :: enabled_tmp 
     308      LOGICAL, OPTIONAL, INTENT(OUT) :: format 
     309      LOGICAL(KIND=C_BOOL) :: format_tmp 
    292310      LOGICAL, OPTIONAL, INTENT(OUT) :: group_ref 
    293311      LOGICAL(KIND=C_BOOL) :: group_ref_tmp 
     
    315333      CALL xios(get_filegroup_handle)(filegroup_id,filegroup_hdl) 
    316334      CALL xios(is_defined_filegroup_attr_hdl_)   & 
    317       ( filegroup_hdl, description, enabled, group_ref, min_digits, name, name_suffix, output_freq  & 
     335      ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    318336      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    319337     
     
    321339   
    322340  SUBROUTINE xios(is_defined_filegroup_attr_hdl)  & 
    323     ( filegroup_hdl, description, enabled, group_ref, min_digits, name, name_suffix, output_freq  & 
     341    ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    324342    , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    325343     
     
    330348      LOGICAL, OPTIONAL, INTENT(OUT) :: enabled 
    331349      LOGICAL(KIND=C_BOOL) :: enabled_tmp 
     350      LOGICAL, OPTIONAL, INTENT(OUT) :: format 
     351      LOGICAL(KIND=C_BOOL) :: format_tmp 
    332352      LOGICAL, OPTIONAL, INTENT(OUT) :: group_ref 
    333353      LOGICAL(KIND=C_BOOL) :: group_ref_tmp 
     
    354374       
    355375      CALL xios(is_defined_filegroup_attr_hdl_)  & 
    356       ( filegroup_hdl, description, enabled, group_ref, min_digits, name, name_suffix, output_freq  & 
     376      ( filegroup_hdl, description, enabled, format, group_ref, min_digits, name, name_suffix, output_freq  & 
    357377      , output_level, par_access, split_freq, split_freq_format, sync_freq, type ) 
    358378     
     
    360380   
    361381  SUBROUTINE xios(is_defined_filegroup_attr_hdl_)   & 
    362     ( filegroup_hdl, description_, enabled_, group_ref_, min_digits_, name_, name_suffix_, output_freq_  & 
    363     , output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_ ) 
     382    ( filegroup_hdl, description_, enabled_, format_, group_ref_, min_digits_, name_, name_suffix_  & 
     383    , output_freq_, output_level_, par_access_, split_freq_, split_freq_format_, sync_freq_, type_  & 
     384     ) 
    364385     
    365386    IMPLICIT NONE 
     
    369390      LOGICAL, OPTIONAL, INTENT(OUT) :: enabled_ 
    370391      LOGICAL(KIND=C_BOOL) :: enabled__tmp 
     392      LOGICAL, OPTIONAL, INTENT(OUT) :: format_ 
     393      LOGICAL(KIND=C_BOOL) :: format__tmp 
    371394      LOGICAL, OPTIONAL, INTENT(OUT) :: group_ref_ 
    372395      LOGICAL(KIND=C_BOOL) :: group_ref__tmp 
     
    402425      ENDIF 
    403426       
     427      IF (PRESENT(format_)) THEN 
     428        format__tmp=cxios_is_defined_filegroup_format(filegroup_hdl%daddr) 
     429        format_=format__tmp 
     430      ENDIF 
     431       
    404432      IF (PRESENT(group_ref_)) THEN 
    405433        group_ref__tmp=cxios_is_defined_filegroup_group_ref(filegroup_hdl%daddr) 
  • XIOS/trunk/src/node/file.cpp

    r509 r517  
    322322         } 
    323323 
     324         bool useClassicFormat = !format.isEmpty() && format == format_attr::netcdf4_classic; 
     325 
    324326         bool multifile=true ; 
    325327         if (!type.isEmpty()) 
     
    369371           } 
    370372         } 
    371          data_out=shared_ptr<CDataOutput>(new CNc4DataOutput(oss.str(), false, fileComm, multifile, isCollective)); 
     373         data_out=shared_ptr<CDataOutput>(new CNc4DataOutput(oss.str(), false, useClassicFormat, 
     374                                                             fileComm, multifile, isCollective)); 
    372375         isOpen=true ; 
    373376 
  • XIOS/trunk/src/output/nc4_data_output.cpp

    r501 r517  
    2929 
    3030      CNc4DataOutput::CNc4DataOutput 
    31          (const StdString & filename, bool exist, MPI_Comm comm_file,bool multifile, bool isCollective) 
     31         (const StdString & filename, bool exist, bool useClassicFormat, 
     32          MPI_Comm comm_file,bool multifile, bool isCollective) 
    3233            : SuperClass() 
    33             , SuperClassWriter(filename, exist, &comm_file,multifile) 
     34            , SuperClassWriter(filename, exist, useClassicFormat, &comm_file, multifile) 
    3435            , comm_file(comm_file) 
    3536            , filename(filename) 
     
    732733           } 
    733734           else 
    734            { 
    735               double * default_value = NULL; 
    736               SuperClassWriter::setDefaultValue(fieldid, default_value); 
    737            } 
     735              SuperClassWriter::setDefaultValue(fieldid, (double*)NULL); 
    738736 
    739737           {  // Ecriture des coordonnées 
  • XIOS/trunk/src/output/nc4_data_output.hpp

    r501 r517  
    2525               (const StdString & filename, bool exist); 
    2626            CNc4DataOutput 
    27                (const StdString & filename, bool exist, MPI_Comm comm_file, bool multifile, bool isCollective=true); 
     27               (const StdString & filename, bool exist, bool useClassicFormat, 
     28                MPI_Comm comm_file, bool multifile, bool isCollective=true); 
    2829 
    2930            CNc4DataOutput(const CNc4DataOutput & dataoutput);       // Not implemented. 
  • XIOS/trunk/src/output/netCdfInterface.cpp

    r505 r517  
    524524   } 
    525525 
     526  /*! 
     527  Set or unset the fill mode for a NetCDF file specified by its file id. 
     528  \param [in] ncid File id 
     529  \param [in] fill Define whether the fill mode should be enabled or not 
     530  \return Status code 
     531  */ 
     532  int CNetCdfInterface::setFill(int ncid, bool fill) 
     533  { 
     534    int old_fill_mode; 
     535    int status = nc_set_fill(ncid, fill ? NC_FILL : NC_NOFILL, &old_fill_mode); 
     536    if (NC_NOERR != status) 
     537    { 
     538      StdString errormsg(nc_strerror(status)); 
     539      StdStringStream sstr; 
     540 
     541      sstr << "Error when calling function nc_set_fill(ncid, fill ? NC_FILL : NC_NOFILL, &old_fill_mode)" << std::endl; 
     542      sstr << errormsg << std::endl; 
     543      sstr << "Unable to set the fill mode to : " << (fill ? "NC_FILL" : "NC_NOFILL") << std::endl; 
     544      StdString e = sstr.str(); 
     545      throw CNetCdfException(e); 
     546    } 
     547 
     548    return status; 
     549  } 
     550 
    526551   /*! 
    527552   This function makes a request to netcdf with a ncid, to set the fill parameters for a variable, 
  • XIOS/trunk/src/output/netCdfInterface.hpp

    r515 r517  
    8585    static int defVarChunking(int ncid, int varId, int storage, StdSize chunkSize[]); 
    8686 
     87    //! Set or unset the fill mode 
     88    static int setFill(int ncid, bool fill); 
     89 
    8790    //! Define variable fill parameters 
    8891    static int defVarFill(int ncid, int varId, int noFill, void* fillValue); 
  • XIOS/trunk/src/output/onetcdf4.cpp

    r501 r517  
    1111 
    1212      CONetCDF4::CONetCDF4 
    13          (const StdString & filename, bool exist, const MPI_Comm * comm, bool multifile) 
     13         (const StdString & filename, bool exist, bool useClassicFormat, const MPI_Comm * comm, bool multifile) 
    1414            : path() 
     15            , useClassicFormat(useClassicFormat) 
    1516      { 
    1617         this->wmpi = (comm != NULL) && !multifile; 
    17          this->initialize(filename, exist, comm,multifile); 
     18         this->initialize(filename, exist, useClassicFormat, comm,multifile); 
    1819      } 
    1920 
     
    2930 
    3031      void CONetCDF4::initialize 
    31          (const StdString & filename, bool exist, const MPI_Comm * comm, bool multifile) 
    32       { 
     32         (const StdString & filename, bool exist, bool useClassicFormat, const MPI_Comm * comm, bool multifile) 
     33      { 
     34         this->useClassicFormat = useClassicFormat; 
     35 
     36         int mode = useClassicFormat ? 0 : NC_NETCDF4; 
     37         if (!multifile) 
     38            mode |= useClassicFormat ? NC_PNETCDF : NC_MPIIO; 
     39 
    3340         if (!exist) 
    3441         { 
    3542            if (comm != NULL) 
    3643            { 
    37                if (!multifile) (CNetCdfInterface::createPar(filename, NC_NETCDF4|NC_MPIIO, *comm, MPI_INFO_NULL, (this->ncidp))); 
    38                else (CNetCdfInterface::create(filename, NC_NETCDF4, this->ncidp)); 
     44               if (!multifile) CNetCdfInterface::createPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp); 
     45               else CNetCdfInterface::create(filename, mode, this->ncidp); 
    3946            } 
    40             else (CNetCdfInterface::create(filename, NC_NETCDF4, this->ncidp)); 
     47            else CNetCdfInterface::create(filename, mode, this->ncidp); 
    4148         } 
    4249         else 
     
    4451            if (comm != NULL) 
    4552            { 
    46                if (!multifile) (CNetCdfInterface::openPar(filename, NC_NETCDF4|NC_MPIIO, *comm, MPI_INFO_NULL, this->ncidp)); 
    47                else (CNetCdfInterface::open(filename, NC_NETCDF4, this->ncidp)); 
     53               if (!multifile) CNetCdfInterface::openPar(filename, mode, *comm, MPI_INFO_NULL, this->ncidp); 
     54               else CNetCdfInterface::open(filename, mode, this->ncidp); 
    4855            } 
    49             else  (CNetCdfInterface::open(filename, NC_NETCDF4, this->ncidp)); 
    50          } 
     56            else CNetCdfInterface::open(filename, mode, this->ncidp); 
     57         } 
     58 
     59         // If the classic NetCDF format is used, we enable the "no-fill mode" globally. 
     60         // This is done per variable for the NetCDF4 format. 
     61         if (useClassicFormat) 
     62            CNetCdfInterface::setFill(this->ncidp, false);     
    5163      } 
    5264 
     
    264276         } 
    265277 
    266          (CNetCdfInterface::defVar(grpid, name, type, dimids.size(), &(dimids[0]), varid)); 
    267  
    268 // set chunksize : size of one record 
    269 // but must not be > 2GB (netcdf or HDF5 problem) 
    270          totalSize=1 ; 
    271          for(vector<StdSize>::reverse_iterator it=dimsizes.rbegin(); it!=dimsizes.rend();++it) 
    272          { 
    273            totalSize*= *it ; 
    274            if (totalSize>=maxSize) *it=1 ; 
    275          } 
    276  
    277          (CNetCdfInterface::defVarChunking(grpid, varid, NC_CHUNKED, &(dimsizes[0]))); 
    278          (CNetCdfInterface::defVarFill(grpid, varid, true, NULL)); 
     278         CNetCdfInterface::defVar(grpid, name, type, dimids.size(), &(dimids[0]), varid); 
     279 
     280         // The classic NetCDF format does not support chunking nor fill parameters 
     281         if (!useClassicFormat) 
     282         { 
     283            // set chunksize : size of one record 
     284            // but must not be > 2GB (netcdf or HDF5 problem) 
     285            totalSize = 1; 
     286            for (vector<StdSize>::reverse_iterator it = dimsizes.rbegin(); it != dimsizes.rend(); ++it) 
     287            { 
     288              totalSize *= *it; 
     289              if (totalSize >= maxSize) *it = 1; 
     290            } 
     291 
     292            CNetCdfInterface::defVarChunking(grpid, varid, NC_CHUNKED, &dimsizes[0]); 
     293            CNetCdfInterface::defVarFill(grpid, varid, true, NULL); 
     294         } 
     295 
    279296         return (varid); 
    280297      } 
  • XIOS/trunk/src/output/onetcdf4.hpp

    r501 r517  
    2626 
    2727            /// Constructeurs /// 
    28             CONetCDF4(const StdString & filename, bool exist, const MPI_Comm * comm = NULL, bool multifile=true); 
     28            CONetCDF4(const StdString & filename, bool exist, bool useClassicFormat = false, 
     29                      const MPI_Comm * comm = NULL, bool multifile = true); 
    2930 
    3031            CONetCDF4(const CONetCDF4 & onetcdf4);       // Not implemented. 
     
    3334 
    3435            /// Initialisation /// 
    35             void initialize(const StdString & filename, bool exist, const MPI_Comm * comm, bool multifile); 
     36            void initialize(const StdString & filename, bool exist, bool useClassicFormat, 
     37                            const MPI_Comm * comm, bool multifile); 
    3638            void close(void) ; 
    3739            void sync(void) ; 
     
    9294            bool varExist(const StdString & varname); 
    9395 
     96            bool useClassicFormat; //!< If true, NetCDF4 will use the classic NetCDF3 format 
     97 
    9498      //---------------------------------------------------------------- 
    9599       
  • XIOS/trunk/src/output/onetcdf4_impl.hpp

    r501 r517  
    4646    if (value != NULL) 
    4747    { 
    48       CNetCdfInterface::defVarFill(grpid, varid, 0, (void*)value); 
     48      // nc_def_var_fill will automatically set the _FillValue attribute when 
     49      // using the NetCDF 4 format but we need to do it manually otherwise 
     50      if (useClassicFormat) 
     51        this->addAttribute(StdString("_FillValue"), *value, &varname); 
     52      else 
     53        CNetCdfInterface::defVarFill(grpid, varid, 0, (void*)value); 
    4954      this->addAttribute(StdString("missing_value"), *value, &varname); 
    5055    } 
    51     else CNetCdfInterface::defVarFill(grpid, varid, 1, NULL); 
     56    else if (!useClassicFormat) 
     57    { 
     58      // The "no-fill mode" is set globally for the classic NetCDF format 
     59      CNetCdfInterface::defVarFill(grpid, varid, 1, NULL); 
     60    } 
    5261  } 
    5362 
Note: See TracChangeset for help on using the changeset viewer.