~ubuntu-branches/ubuntu/vivid/adios/vivid-proposed

« back to all changes in this revision

Viewing changes to tests/suite/programs/group_free_test.c

  • Committer: Package Import Robot
  • Author(s): Alastair McKinstry
  • Date: 2014-06-16 23:06:38 UTC
  • mfrom: (15.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20140616230638-cxryhot6b8ge32l6
Tags: 1.7.0-1
* New upstream release.
* Add adios.pc pkgconfig file. adios_config now uses this.

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 test: declare multiple groups and free them. 
 
9
 * Test issue that was fixed in 084d601de8fca676361b0ac4b96735e04295fa0f
 
10
 *
 
11
 * How to run: group_free_test
 
12
 * Output: None
 
13
 * ADIOS config file: None
 
14
 *
 
15
 * This is a sequential test.
 
16
*/
 
17
 
 
18
/* This example will create 3 adios groups for writing, then frees them.
 
19
*/
 
20
 
 
21
#define _NOMPI
 
22
 
 
23
#include <stdio.h>
 
24
#include <string.h>
 
25
#include "public/adios.h"
 
26
#include "public/adios_types.h"
 
27
 
 
28
const int  NBLOCKS = 3;
 
29
const int  NGROUPS = 3;
 
30
 
 
31
int main (int argc, char ** argv) 
 
32
{
 
33
        int         rank, size, i, j;
 
34
        int         NX = 100, gb, offset;  //local/global/offset
 
35
        MPI_Comm    comm = MPI_COMM_WORLD;
 
36
        char g_str[100], o_str[100], l_str[100];
 
37
        char groupname[256];
 
38
 
 
39
        MPI_Init (&argc, &argv);
 
40
        MPI_Comm_rank (comm, &rank);
 
41
        MPI_Comm_size (comm, &size);
 
42
 
 
43
        gb = NBLOCKS * NX * size;
 
44
        sprintf (g_str, "%d", gb);
 
45
        sprintf (l_str, "%d", NX);
 
46
 
 
47
 
 
48
        adios_init_noxml (comm);
 
49
        adios_allocate_buffer (ADIOS_BUFFER_ALLOC_NOW, 10);
 
50
 
 
51
        int64_t   groupid[NGROUPS];
 
52
        int64_t   var_ids[NGROUPS][NBLOCKS];
 
53
 
 
54
        for (j = 0; j < NGROUPS; j++) 
 
55
        {
 
56
            sprintf (groupname, "group%1.1d", j);
 
57
            adios_declare_group (&groupid[j], groupname, "", adios_flag_yes);
 
58
            adios_select_method (groupid[j], "MPI", "", "");
 
59
 
 
60
            for (i = 0; i < NBLOCKS; i++) 
 
61
            {
 
62
                offset = rank * NBLOCKS * NX + i * NX;
 
63
                sprintf (o_str, "%d", offset);
 
64
                var_ids[j][i] = adios_define_var (groupid[j], "temperature"
 
65
                        ,"", adios_double
 
66
                        ,l_str, g_str, o_str
 
67
                        );
 
68
                adios_set_transform (var_ids[j][i], "identity");
 
69
            }
 
70
        }
 
71
 
 
72
        MPI_Barrier (comm);
 
73
 
 
74
        // free groups in an illogical order 1, 0, 2 [3 4 ...]
 
75
        if (NGROUPS > 1) adios_free_group (groupid[1]);
 
76
        adios_free_group (groupid[0]);
 
77
        for (j = 2; j < NGROUPS; j++) 
 
78
        {
 
79
            adios_free_group (groupid[j]);
 
80
        }
 
81
 
 
82
        adios_finalize (rank);
 
83
        MPI_Finalize ();
 
84
        return 0;
 
85
}