1
// The AdiosJava.java file
4
import java.nio.ByteBuffer;
5
import java.nio.ByteOrder;
7
public class AdiosVarinfo
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();
14
//private native double[] adios_read_var_byid(long gp, int varid, long[] start, long[] count);
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);
35
// The runtime system executes a class's static
36
// initializer when it loads the class.
37
System.loadLibrary("AdiosJava");
40
public AdiosVarinfo(AdiosGroup group)
45
public int inq(String varname)
47
return adios_inq_var(group.gp, varname);
52
return adios_free_varinfo();
55
public int read(long[] start, long[] count, byte[] out)
57
return adios_read(group.gp, varid, start, count, out);
60
public int read(long[] start, long[] count, int[] out)
62
return adios_read(group.gp, varid, start, count, out);
65
public int read(long[] start, long[] count, long[] out)
67
return adios_read(group.gp, varid, start, count, out);
70
public int read(long[] start, long[] count, float[] out)
72
return adios_read(group.gp, varid, start, count, out);
75
public int read(long[] start, long[] count, double[] out)
77
return adios_read(group.gp, varid, start, count, out);
85
public int readIntValue()
87
ByteBuffer bb = ByteBuffer.wrap(value);
88
if (group.file.endianness == 0)
89
bb.order(ByteOrder.LITTLE_ENDIAN);
91
bb.order(ByteOrder.BIG_ENDIAN);
96
public long readLongValue()
98
ByteBuffer bb = ByteBuffer.wrap(value);
99
if (group.file.endianness == 0)
100
bb.order(ByteOrder.LITTLE_ENDIAN);
102
bb.order(ByteOrder.BIG_ENDIAN);
107
public float readFloatValue()
109
ByteBuffer bb = ByteBuffer.wrap(value);
110
if (group.file.endianness == 0)
111
bb.order(ByteOrder.LITTLE_ENDIAN);
113
bb.order(ByteOrder.BIG_ENDIAN);
115
return bb.getFloat();
118
public double readDoubleValue()
120
ByteBuffer bb = ByteBuffer.wrap(value);
121
if (group.file.endianness == 0)
122
bb.order(ByteOrder.LITTLE_ENDIAN);
124
bb.order(ByteOrder.BIG_ENDIAN);
126
return bb.getDouble();
129
public String toString()
131
StringBuilder result = new StringBuilder();
132
String NEW_LINE = System.getProperty("line.separator");
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);
146
result.append(" timedim: " + timedim + NEW_LINE);
149
return result.toString();