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

« back to all changes in this revision

Viewing changes to tests/suite/programs/steps_write.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
/*  Write a lot of text
 
3
*/
 
4
 
 
5
#include <stdio.h>
 
6
#include <string.h>
 
7
#include "mpi.h"
 
8
#include "adios.h"
 
9
#include "adios_types.h"
 
10
 
 
11
#ifdef DMALLOC
 
12
#include "dmalloc.h"
 
13
#endif
 
14
 
 
15
int main (int argc, char ** argv) 
 
16
{
 
17
        char        filename [256];
 
18
        int         rank, size, i, j, step, block;
 
19
        int         Offset; 
 
20
 
 
21
        int         NX = 2; // number of records written per step per process
 
22
        int         Width=20;
 
23
        int         sub_blocks = 2; // number of record-blocks written per process in one step
 
24
        int         steps = 3;
 
25
 
 
26
        char        t[NX][Width];
 
27
        MPI_Comm    comm = MPI_COMM_WORLD;
 
28
 
 
29
        /* ADIOS variables declarations for matching gwrite_temperature.ch */
 
30
        int         adios_err;
 
31
        uint64_t    adios_groupsize, adios_totalsize;
 
32
        int64_t     adios_handle;
 
33
 
 
34
        MPI_Init (&argc, &argv);
 
35
        MPI_Comm_rank (comm, &rank);
 
36
        MPI_Comm_size (comm, &size);
 
37
 
 
38
        //Global_bounds = sub_blocks * NX * size;
 
39
 
 
40
        strcpy (filename, "steps.bp");
 
41
 
 
42
        adios_init_noxml (comm);
 
43
        adios_allocate_buffer (ADIOS_BUFFER_ALLOC_NOW, 1);
 
44
 
 
45
        int64_t       m_adios_group;
 
46
        int64_t       m_adios_file;
 
47
 
 
48
        adios_declare_group (&m_adios_group, "steps", "", adios_flag_yes);
 
49
        adios_select_method (m_adios_group, "MPI", "", "");
 
50
 
 
51
 
 
52
        adios_define_var (m_adios_group, "NX" ,"", adios_integer ,0, 0, 0);
 
53
        adios_define_var (m_adios_group, "Width" ,"", adios_integer ,0, 0, 0);
 
54
        adios_define_var (m_adios_group, "nproc" ,"", adios_integer ,0, 0, 0);
 
55
   
 
56
        for (i=0;i<sub_blocks;i++) {
 
57
   
 
58
           adios_define_var (m_adios_group, "record" ,"", adios_byte ,"NX,Width", "", "");
 
59
        }
 
60
 
 
61
 
 
62
        for (step=0; step<steps; step++) {
 
63
 
 
64
            adios_open (&m_adios_file, "steps", filename, "a", comm);
 
65
 
 
66
            adios_groupsize = sub_blocks * (4 + 4 + 4 + (uint64_t) NX * (uint64_t)Width);
 
67
 
 
68
            adios_group_size (m_adios_file, adios_groupsize, &adios_totalsize);
 
69
            adios_write(m_adios_file, "nproc", (void *) &size);
 
70
            adios_write(m_adios_file, "NX", (void *) &NX);
 
71
            adios_write(m_adios_file, "Width", (void *) &Width);
 
72
            /* now we will write the data for each sub block */
 
73
            for (block=0;block<sub_blocks;block++) {
 
74
 
 
75
                for (i = 0; i < NX; i++)
 
76
                    //print 19 chars here + '\0'
 
77
                    sprintf (t[i], "r%2d  b%2d  s%2d  i%2d ", rank, block, step, i); 
 
78
 
 
79
                adios_write(m_adios_file, "record", t);
 
80
            }
 
81
 
 
82
            adios_close (m_adios_file);
 
83
        }
 
84
 
 
85
        MPI_Barrier (comm);
 
86
 
 
87
        adios_finalize (rank);
 
88
 
 
89
        MPI_Finalize ();
 
90
        return 0;
 
91
}