2
* ADIOS is freely available under the terms of the BSD license described
3
* in the COPYING file in the top level directory of this source distribution.
5
* Copyright (c) 2008 - 2009. UT-BATTELLE, LLC. All rights reserved.
8
/*************************************************************/
9
/* Example of reading arrays in ADIOS */
10
/* which were written from the same number of processors */
12
/* Similar example is manual/2_adios_read.c */
13
/*************************************************************/
20
#include "public/adios_read.h"
22
int main (int argc, char ** argv)
28
MPI_Comm comm = MPI_COMM_WORLD;
31
int64_t adios_handle, adios_buf_size;
33
MPI_Init (&argc, &argv);
34
MPI_Comm_rank (comm, &rank);
36
adios_read_init_method(ADIOS_READ_METHOD_FLEXPATH, comm, "");
38
ADIOS_SELECTION global_range_select;
40
global_range_select.type=ADIOS_SELECTION_BOUNDINGBOX;
41
global_range_select.u.bb.start = malloc(sizeof(uint64_t)*2);
42
global_range_select.u.bb.count = malloc(sizeof(uint64_t)*2);
43
(global_range_select.u.bb.start)[0] = rank;
44
(global_range_select.u.bb.count)[0] = 1;
45
(global_range_select.u.bb.start)[1] = 0;
46
(global_range_select.u.bb.count)[1] = 40;
47
global_range_select.u.bb.ndim = 2;
49
ADIOS_SELECTION scalar_block_select;
50
scalar_block_select.type = ADIOS_SELECTION_WRITEBLOCK;
51
scalar_block_select.u.block.index = rank;
52
//fprintf(stderr, "app got here\n");
53
/* schedule_read of a scalar. */
55
ADIOS_FILE* afile = adios_read_open("arrays",
56
ADIOS_READ_METHOD_FLEXPATH,
58
ADIOS_LOCKMODE_NONE, 0.0);
61
while(adios_errno != err_end_of_stream){
63
/* get a bounding box - rank 0 for now*/
64
ADIOS_VARINFO* nx_info = adios_inq_var( afile, "NX");
65
ADIOS_VARINFO* ny_info = adios_inq_var( afile, "NY");
68
NX = *((int *)nx_info->value);
71
NY= *((int*)ny_info->value);
74
//printf("\trank=%d: NX=%d\n", rank, NX);
75
//printf("\trank=%d: NY=%d\n", rank, NY);
77
/* Allocate space for the arrays */
79
int arr_size = sizeof(double) * nelem;
80
t = (double *) malloc (arr_size);
81
memset(t, 0, arr_size);
82
//fprintf(stderr, "t %p\n", t);
85
adios_schedule_read (afile,
89
adios_schedule_read (afile,
94
adios_perform_reads (afile, 1);
98
printf("Rank=%d: test_scalar: %d step: %d, t[0,5+x] = [%6.2f", rank, test_scalar, ii, t[0]);
99
for(j=0; j<nelem; j++) {
100
printf(", %6.2f", t[j]);
103
adios_release_step(afile);
104
adios_advance_step(afile, 0, 30);
106
//MPI_Barrier (comm);
110
adios_read_close(afile);
112
adios_read_finalize_method(ADIOS_READ_METHOD_FLEXPATH);