@@ -2961,6 +2961,14 @@ int spio_createfile_int(int iosysid, int *ncidp, const int *iotype, const char *
29612961 file->num_adiostasks = ios->num_adiostasks ;
29622962 file->adios_io_process = ios->adios_io_process ;
29632963
2964+ file->adios_reader_num_decomp_blocks = 0 ;
2965+
2966+ #ifdef _SPIO_ADIOS_NO_DECOMPS
2967+ file->store_adios_decomp = false ;
2968+ #else
2969+ file->store_adios_decomp = true ;
2970+ #endif
2971+
29642972 /* Create a new ADIOS group */
29652973 char declare_name[PIO_MAX_NAME];
29662974 snprintf (declare_name, PIO_MAX_NAME, " %s%lu" , file->filename , get_adios2_io_cnt ());
@@ -3073,7 +3081,35 @@ int spio_createfile_int(int iosysid, int *ncidp, const int *iotype, const char *
30733081 " Putting (ADIOS) variable (name=/__pio__/info/nproc) failed (adios2_error=%s) for file (%s)" ,
30743082 convert_adios2_error_to_string (adiosErr), pio_get_fname_from_file (file));
30753083 }
3076- (file->num_written_blocks )++;
3084+
3085+ variableH = adios2_inquire_variable (file->ioH , " /__pio__/info/decomp_stored" );
3086+ if (variableH == NULL )
3087+ {
3088+ variableH = adios2_define_variable (file->ioH ,
3089+ " /__pio__/info/decomp_stored" , adios2_type_int32_t ,
3090+ 0 , NULL , NULL , NULL ,
3091+ adios2_constant_dims_true);
3092+ if (variableH == NULL )
3093+ {
3094+ spio_ltimer_stop (file->io_fstats ->wr_timer_name );
3095+ spio_ltimer_stop (file->io_fstats ->tot_timer_name );
3096+ return pio_err (ios, NULL , PIO_EADIOS2ERR, __FILE__, __LINE__,
3097+ " Defining (ADIOS) variable (name=/__pio__/info/decomp_stored) failed for file (%s)" ,
3098+ pio_get_fname_from_file (file));
3099+ }
3100+ }
3101+
3102+ int info_decomp_stored = (file->store_adios_decomp )? 1 : 0 ;
3103+ adiosErr = adios2_put (file->engineH , variableH, &info_decomp_stored, adios2_mode_sync);
3104+ if (adiosErr != adios2_error_none)
3105+ {
3106+ spio_ltimer_stop (file->io_fstats ->wr_timer_name );
3107+ spio_ltimer_stop (file->io_fstats ->tot_timer_name );
3108+ return pio_err (ios, NULL , PIO_EADIOS2ERR, __FILE__, __LINE__,
3109+ " Putting (ADIOS) variable (name=/__pio__/info/decomp_stored) failed (adios2_error=%s) for file (%s)" ,
3110+ convert_adios2_error_to_string (adiosErr), pio_get_fname_from_file (file));
3111+ }
3112+ file->num_written_blocks += 2 ;
30773113 }
30783114
30793115 /* Write the number and list of processes in block merges */
@@ -3537,6 +3573,8 @@ static int adios_get_step_info(file_desc_t *file, int, size_t, size_t);
35373573static int adios_get_dim_ids (file_desc_t *file, int );
35383574static int adios_get_nc_op_tag (file_desc_t *file, int );
35393575static int adios_get_attr (file_desc_t *file, int current_var_cnt, char *const *attr_names, size_t );
3576+ static int adios_get_num_decomp_blocks (file_desc_t *file);
3577+ static int adios_get_decomp_storage_info (file_desc_t *file);
35403578static size_t adios_read_vars_vars (file_desc_t *file, size_t var_size, char *const *var_names);
35413579static size_t adios_read_vars_attrs (file_desc_t *file, size_t attr_size, char *const *attr_names);
35423580
@@ -4113,6 +4151,62 @@ static int adios_get_step_info(file_desc_t *file, int varid, size_t adios_step,
41134151 return 0 ;
41144152}
41154153
4154+ static int adios_get_num_decomp_blocks (file_desc_t *file)
4155+ {
4156+ adios2_variable *variableH = adios2_inquire_variable (file->ioH , " /__pio__/info/block_list" );
4157+ if (variableH == NULL )
4158+ {
4159+ return pio_err (NULL , file, PIO_EADIOS2ERR, __FILE__, __LINE__,
4160+ " Getting number of decomposition blocks in file (%s, ncid=%d) using ADIOS iotype failed. "
4161+ " /__pio__/info/block_list is missing" ,
4162+ pio_get_fname_from_file (file), file->pio_ncid );
4163+ }
4164+
4165+ adios2_varinfo *info_block_list = adios2_inquire_blockinfo (file->engineH , variableH, 0 );
4166+ if (info_block_list == NULL )
4167+ {
4168+ return pio_err (NULL , file, PIO_EADIOS2ERR, __FILE__, __LINE__,
4169+ " Getting number of decomposition blocks (%s, ncid=%d) using ADIOS iotype failed. "
4170+ " The low level (ADIOS) I/O library call failed to get the list of blocks for a variable in a given step (NULL pointer returned)" ,
4171+ pio_get_fname_from_file (file), file->pio_ncid );
4172+ }
4173+
4174+ file->adios_reader_num_decomp_blocks = info_block_list->nblocks ;
4175+
4176+ /* Free adios2_varinfo structure (this ADIOS2 API returns void) */
4177+ adios2_free_blockinfo (info_block_list);
4178+
4179+ return PIO_NOERR;
4180+ }
4181+
4182+ static int adios_get_decomp_storage_info (file_desc_t *file)
4183+ {
4184+ adios2_variable *variableH = adios2_inquire_variable (file->ioH , " /__pio__/info/decomp_stored" );
4185+
4186+ /* Maintains backward compatibility with earlier generated BP files where decomposition storage
4187+ * information is absent. */
4188+ if (variableH == NULL )
4189+ {
4190+ file->store_adios_decomp = true ;
4191+ return PIO_NOERR;
4192+ }
4193+
4194+ int info_decomp_stored = -1 ;
4195+ adios2_error adiosErr = adios2_get (file->engineH , variableH, &info_decomp_stored, adios2_mode_sync);
4196+ if (adiosErr != adios2_error_none)
4197+ {
4198+ return pio_err (NULL , file, PIO_EADIOS2ERR, __FILE__, __LINE__,
4199+ " Getting decomposition storage info in file (%s, ncid=%d) using ADIOS iotype failed. "
4200+ " The low level (ADIOS) I/O library call failed to get data associated with a variable from an engine (adios2_error=%s)" ,
4201+ pio_get_fname_from_file (file), file->pio_ncid , convert_adios2_error_to_string (adiosErr));
4202+ }
4203+ assert (info_decomp_stored == 0 || info_decomp_stored == 1 );
4204+
4205+ file->store_adios_decomp = (info_decomp_stored == 0 )? false : true ;
4206+
4207+ return PIO_NOERR;
4208+ }
4209+
41164210static size_t adios_read_vars_attrs (file_desc_t *file, size_t attr_size, char *const *attr_names)
41174211{
41184212 size_t current_var_cnt = 0 ;
@@ -4604,6 +4698,10 @@ int PIOc_openfile_retry_impl(int iosysid, int *ncidp, int *iotype, const char *f
46044698 file->cache_block_sizes = spio_hash (10000 );
46054699 file->cache_darray_info = spio_hash (10000 );
46064700
4701+ file->adios_reader_num_decomp_blocks = 0 ;
4702+
4703+ file->store_adios_decomp = true ;
4704+
46074705 while (step < nsteps && adios2_begin_step (file->engineH , adios2_step_mode_read, -1.0 , &status) == adios2_error_none)
46084706 {
46094707 file->begin_step_called = 1 ;
@@ -4669,6 +4767,12 @@ int PIOc_openfile_retry_impl(int iosysid, int *ncidp, int *iotype, const char *f
46694767 adios_get_step_info (file, var_id, step, nsteps);
46704768 }
46714769
4770+ if (step == 0 )
4771+ {
4772+ adios_get_num_decomp_blocks (file);
4773+ adios_get_decomp_storage_info (file);
4774+ }
4775+
46724776 adiosErr = adios2_end_step (file->engineH );
46734777 if (adiosErr != adios2_error_none)
46744778 {
0 commit comments