Skip to content

Commit

Permalink
update error message in adios_expected_var_size()
Browse files Browse the repository at this point in the history
  • Loading branch information
pnorbert committed Apr 27, 2016
1 parent 7ca88ef commit 99c1f83
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
25 changes: 21 additions & 4 deletions examples/C/global-array/adios_global_no_xml.c
Expand Up @@ -20,6 +20,7 @@
*/

#include <stdio.h>
#include <inttypes.h>
#include <string.h>
#include "mpi.h"
#include "public/adios.h"
Expand All @@ -35,7 +36,8 @@ int main (int argc, char ** argv)
int rank, size, i, block;
int NX = 100, Global_bounds, Offsets;
double t[NX];
int sub_blocks = 3;
int sub_blocks = 3;
int64_t var_ids[sub_blocks];
MPI_Comm comm = MPI_COMM_WORLD;

/* ADIOS variables declarations for matching gwrite_temperature.ch */
Expand Down Expand Up @@ -73,11 +75,20 @@ int main (int argc, char ** argv)
,"", adios_integer
,0, 0, 0);

int64_t varid;
varid = adios_define_var (m_adios_group, "temperature"
var_ids[i] = adios_define_var (m_adios_group, "temperature"
,"", adios_double
,"NX", "Global_bounds", "Offsets");
adios_set_transform (varid, "none");
adios_set_transform (var_ids[i], "identity");

/* This is here just for test and will cause errors.
* adios_expected_var_size() does not work here because the definition of the variable depends
* on the "NX" dimension variable and it's value known to adios only after adios_write("NX")
*/
/*
uint64_t varsize = adios_expected_var_size(var_ids[i]);
fprintf (stderr, "Temperature block %d is %" PRIu64 " bytes\n", i, varsize);
*/

}

adios_open (&m_adios_file, "restart", filename, "w", comm);
Expand All @@ -96,6 +107,12 @@ int main (int argc, char ** argv)
for (i = 0; i < NX; i++)
t[i] = Offsets + i;

/* This is here just for fun */
uint64_t varsize = adios_expected_var_size(var_ids[block]);
/* adios_expected_var_size() works here because NX's value is known by adios at this point */
fprintf (stderr, "Temperature block %d is %" PRIu64 " bytes\n", block, varsize);


adios_write(m_adios_file, "temperature", t);
}

Expand Down
9 changes: 6 additions & 3 deletions src/core/adios.c
Expand Up @@ -337,9 +337,12 @@ uint64_t adios_expected_var_size (int64_t var_id)
size = adios_get_var_size (var, var->data);
}
if (size == 0 || adios_errno != err_no_error) {
adios_error (err_dimension_required, "%s: a dimension of variable %s is not yet known. "
"The dimension will be known after adios_write() of that dimension variable\n",
__func__, var->name);
if (adios_errno == err_invalid_var_as_dimension)
{
log_error ("%s: An array size depends on the actual value of the dimension variable. "
"This will be known after adios_write() of that dimension variable.\n",
__func__);
}
}
/*
enum ADIOS_DATATYPES original_var_type = adios_transform_get_var_original_type_var (var);
Expand Down
2 changes: 1 addition & 1 deletion src/core/adios_internals.c
Expand Up @@ -5725,7 +5725,7 @@ int adios_multiply_dimensions (uint64_t * size
return 1;

default:
adios_error (err_invalid_var_as_dimension,
adios_error (err_invalid_type_as_dimension,
"Invalid datatype for array dimension on var %s: %s\n",
var->name,
adios_type_to_string_int (type));
Expand Down
1 change: 1 addition & 0 deletions src/public/adios_error.h
Expand Up @@ -72,6 +72,7 @@ enum ADIOS_ERRCODES {
err_invalid_type_attr = -70,
err_invalid_value_attr = -71,
err_histogram_error = -72,
err_invalid_type_as_dimension = -73,

// Write method errors
err_invalid_file_mode = -100,
Expand Down

0 comments on commit 99c1f83

Please sign in to comment.