~ubuntu-branches/ubuntu/utopic/adios/utopic

« back to all changes in this revision

Viewing changes to examples/C/flexpath_arrays/global_range_select/arrays_write.c

  • Committer: Package Import Robot
  • Author(s): Alastair McKinstry
  • Date: 2013-12-09 15:21:31 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20131209152131-jtd4fpmdv3xnunnm
Tags: 1.5.0-1
* New upstream.
* Standards-Version: 3.9.5
* Include latest config.{sub,guess} 
* New watch file.
* Create libadios-bin for binaries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
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.
 
4
 *
 
5
 * Copyright (c) 2008 - 2009.  UT-BATTELLE, LLC. All rights reserved.
 
6
 */
 
7
 
 
8
#include <stdio.h>
 
9
#include <string.h>
 
10
#include "mpi.h"
 
11
#include "adios.h"
 
12
 
 
13
/*************************************************************/
 
14
/*          Example of writing arrays in ADIOS               */
 
15
/*                                                           */
 
16
/*        Similar example is manual/2_adios_write.c          */
 
17
/*************************************************************/
 
18
int main (int argc, char ** argv) 
 
19
{
 
20
    char        filename [256];
 
21
    int         rank, size, i;
 
22
    int         NX = 10000; 
 
23
    int         NY = 1;
 
24
    double      t[NX];
 
25
    MPI_Comm    comm = MPI_COMM_WORLD;
 
26
 
 
27
    int64_t     adios_handle;
 
28
 
 
29
    MPI_Init (&argc, &argv);
 
30
    MPI_Comm_rank (comm, &rank);
 
31
    MPI_Comm_size (comm, &size);
 
32
    
 
33
    strcpy (filename, "arrays");
 
34
    adios_init ("arrays.xml", comm);
 
35
    
 
36
    int test_scalar = rank * 1000;
 
37
    int ii;
 
38
    for(ii = 0; ii<200; ii++){
 
39
      for (i = 0; i < NX; i++)
 
40
        t[i] = rank * NX + i*ii;
 
41
    
 
42
      adios_open (&adios_handle, "temperature", filename, "w", comm);
 
43
    
 
44
      adios_write (adios_handle, "NX", &NX);
 
45
      adios_write (adios_handle, "NY", &NY);
 
46
      adios_write (adios_handle, "test_scalar", &test_scalar);
 
47
      adios_write (adios_handle, "size", &size);
 
48
      adios_write (adios_handle, "rank", &rank);
 
49
      adios_write (adios_handle, "var_2d_array", t);
 
50
    
 
51
      adios_close (adios_handle);
 
52
      fprintf(stderr, "Rank=%d commited write %d\n", rank, ii);
 
53
    }
 
54
    adios_finalize (rank);
 
55
 
 
56
    //MPI_Finalize ();
 
57
    return 0;
 
58
}