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

« back to all changes in this revision

Viewing changes to examples/C/schema/rectilinear.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
/* ADIOS C Example: write a variable along with a rectilinear mesh. 
 
9
 * Note that the mesh dimensions depend on the rank. 
 
10
*/
 
11
#include <stdio.h>
 
12
#include <string.h>
 
13
#include "mpi.h"
 
14
#include "adios.h"
 
15
int main (int argc, char * argv[] ) 
 
16
{
 
17
    char        filename []="rectilinear.bp";
 
18
    int         rank, size, i;
 
19
    int         NX = 10;  
 
20
    double      t[NX], mean = 0;
 
21
    MPI_Comm    comm = MPI_COMM_WORLD;
 
22
    char * str = "Jul, 2012";
 
23
 
 
24
    int         adios_err;
 
25
    uint64_t    adios_groupsize, adios_totalsize;
 
26
    int64_t     adios_handle;
 
27
 
 
28
    MPI_Init (&argc, &argv);
 
29
    MPI_Comm_rank (comm, &rank);
 
30
    MPI_Comm_size (comm, &size);
 
31
 
 
32
    int xydim = size+NX;
 
33
    float       X[size];
 
34
    float       Y[NX];
 
35
 
 
36
    X[0] = 0;
 
37
    for (i = 1; i< size; i++)
 
38
    {
 
39
        X[i] = i + X[i-1];
 
40
    }
 
41
 
 
42
    Y[0] = 0;
 
43
    for (i = 1; i< NX; i++)
 
44
    {
 
45
        Y[i] = i + Y[i-1];
 
46
    }
 
47
 
 
48
    for (i = 0; i < NX; i++)
 
49
    {
 
50
        t[i] = rank * NX + i;
 
51
        mean += t[i];
 
52
    }
 
53
 
 
54
    mean /= NX;
 
55
 
 
56
    adios_init ("rectilinear.xml", comm);
 
57
 
 
58
    adios_open (&adios_handle, "schema", filename, "w", comm);
 
59
 
 
60
    adios_groupsize = 4 \
 
61
                      + 4 \
 
62
                + 4 \
 
63
                + 4 \
 
64
                + 8 \
 
65
                + strlen(str) \
 
66
                + 4 * (1) * (size) \
 
67
                + 4 * (1) * (NX) \
 
68
                + 8 * (1) * (NX);
 
69
    adios_group_size (adios_handle, adios_groupsize, &adios_totalsize);
 
70
    adios_write (adios_handle, "NX", &NX);
 
71
    adios_write (adios_handle, "size", &size);
 
72
    adios_write (adios_handle, "rank", &rank);
 
73
    adios_write (adios_handle, "mean", &mean);
 
74
    adios_write (adios_handle, "xydim", &xydim);
 
75
    adios_write (adios_handle, "X", X);
 
76
    adios_write (adios_handle, "Y", Y);
 
77
    adios_write (adios_handle, "date", str);
 
78
    adios_write (adios_handle, "temperature", t);
 
79
 
 
80
    adios_close (adios_handle);
 
81
 
 
82
    MPI_Barrier (comm);
 
83
 
 
84
    adios_finalize (rank);
 
85
 
 
86
    MPI_Finalize ();
 
87
 
 
88
    return 0;
 
89
}