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

« back to all changes in this revision

Viewing changes to wrappers/java/gov/ornl/ccs/AdiosVarinfo.java

  • 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
// The AdiosJava.java file
 
2
package gov.ornl.ccs;
 
3
 
 
4
import java.nio.ByteBuffer;
 
5
import java.nio.ByteOrder;
 
6
 
 
7
public class AdiosVarinfo
 
8
{
 
9
 
 
10
    // Declaration of the Native (C) function
 
11
    private native int adios_inq_var(long gp, String varname);
 
12
    private native int adios_free_varinfo();
 
13
 
 
14
    //private native double[] adios_read_var_byid(long gp, int varid, long[] start, long[] count);
 
15
 
 
16
    private native int adios_read(long gp, int varid, long[] start, long[] count, byte[] out);
 
17
    private native int adios_read(long gp, int varid, long[] start, long[] count, int[] out);
 
18
    private native int adios_read(long gp, int varid, long[] start, long[] count, long[] out);
 
19
    private native int adios_read(long gp, int varid, long[] start, long[] count, float[] out);
 
20
    private native int adios_read(long gp, int varid, long[] start, long[] count, double[] out);
 
21
 
 
22
    AdiosGroup group;
 
23
 
 
24
    public long vp;
 
25
    public int grpid;
 
26
    public int varid;
 
27
    public int type;
 
28
    public int ndim;
 
29
    public long[] dims;
 
30
    public int timedim;
 
31
    public byte[] value;
 
32
 
 
33
    static
 
34
    {
 
35
        // The runtime system executes a class's static
 
36
        // initializer when it loads the class.
 
37
        System.loadLibrary("AdiosJava");
 
38
    }
 
39
 
 
40
    public AdiosVarinfo(AdiosGroup group)
 
41
    {
 
42
        this.group = group;
 
43
    }
 
44
 
 
45
    public int inq(String varname)
 
46
    {
 
47
        return adios_inq_var(group.gp, varname);
 
48
    }
 
49
 
 
50
    public int close()
 
51
    {
 
52
        return adios_free_varinfo();
 
53
    }
 
54
 
 
55
    public int read(long[] start, long[] count, byte[] out)
 
56
    {
 
57
        return adios_read(group.gp, varid, start, count, out);
 
58
    }
 
59
 
 
60
    public int read(long[] start, long[] count, int[] out)
 
61
    {
 
62
        return adios_read(group.gp, varid, start, count, out);
 
63
    }
 
64
 
 
65
    public int read(long[] start, long[] count, long[] out)
 
66
    {
 
67
        return adios_read(group.gp, varid, start, count, out);
 
68
    }
 
69
 
 
70
    public int read(long[] start, long[] count, float[] out)
 
71
    {
 
72
        return adios_read(group.gp, varid, start, count, out);
 
73
    }
 
74
 
 
75
    public int read(long[] start, long[] count, double[] out)
 
76
    {
 
77
        return adios_read(group.gp, varid, start, count, out);
 
78
    }
 
79
 
 
80
    public byte[] read()
 
81
    {
 
82
        return value;
 
83
    }
 
84
 
 
85
    public int readIntValue()
 
86
    {
 
87
        ByteBuffer bb = ByteBuffer.wrap(value);
 
88
        if (group.file.endianness == 0)
 
89
            bb.order(ByteOrder.LITTLE_ENDIAN);
 
90
        else
 
91
            bb.order(ByteOrder.BIG_ENDIAN);
 
92
 
 
93
        return bb.getInt();
 
94
    }
 
95
 
 
96
    public long readLongValue()
 
97
    {
 
98
        ByteBuffer bb = ByteBuffer.wrap(value);
 
99
        if (group.file.endianness == 0)
 
100
            bb.order(ByteOrder.LITTLE_ENDIAN);
 
101
        else
 
102
            bb.order(ByteOrder.BIG_ENDIAN);
 
103
 
 
104
        return bb.getLong();
 
105
    }
 
106
 
 
107
    public float readFloatValue()
 
108
    {
 
109
        ByteBuffer bb = ByteBuffer.wrap(value);
 
110
        if (group.file.endianness == 0)
 
111
            bb.order(ByteOrder.LITTLE_ENDIAN);
 
112
        else
 
113
            bb.order(ByteOrder.BIG_ENDIAN);
 
114
 
 
115
        return bb.getFloat();
 
116
    }
 
117
 
 
118
    public double readDoubleValue()
 
119
    {
 
120
        ByteBuffer bb = ByteBuffer.wrap(value);
 
121
        if (group.file.endianness == 0)
 
122
            bb.order(ByteOrder.LITTLE_ENDIAN);
 
123
        else
 
124
            bb.order(ByteOrder.BIG_ENDIAN);
 
125
 
 
126
        return bb.getDouble();
 
127
    }
 
128
 
 
129
    public String toString()
 
130
    {
 
131
        StringBuilder result = new StringBuilder();
 
132
        String NEW_LINE = System.getProperty("line.separator");
 
133
 
 
134
        result.append(this.getClass().getName() + " Object {" + NEW_LINE);
 
135
        result.append(" vp: " + vp + NEW_LINE);
 
136
        result.append(" grpid: " + grpid + NEW_LINE);
 
137
        result.append(" varid: " + varid + NEW_LINE);
 
138
        result.append(" type: " + type + NEW_LINE);
 
139
        result.append(" ndim: " + ndim + NEW_LINE);
 
140
        result.append(" dims.length: " + dims.length + NEW_LINE);
 
141
        if (dims.length > 0) {
 
142
            for (int i = 0; i < dims.length; i++) {
 
143
                result.append(" dims[" + i + "]: " + dims[i] + NEW_LINE);
 
144
            }
 
145
        }
 
146
        result.append(" timedim: " + timedim + NEW_LINE);
 
147
        result.append("}");
 
148
 
 
149
        return result.toString();
 
150
    }
 
151
}