Java Cube Reader Tool Developer Guide  (jCubeR 4.9, revision v4.9)
Intoduction in Cube tool development guide for Java
Examples of using Cube Reader Java library

Present example shows in several short steps the main idea of using the jCubeR library and obtaining different values from this cube file.

Commented source

Import necessary modules

....
import scalasca.cubex.cube.*;
import scalasca.cubex.cube.errors.*;
import java.util.*;
import java.lang.*;
import java.lang.String;
import java.io.*;

Import own jCubeR modules.

import scalasca.cubex.cube.services.transformation.*;
import scalasca.cubex.cube.datalayout.data.value.*;

Start as usual with a public static main call

public class jcuber_example
{
public static void main(String[] args)
{

Create an instance of Cube object,.

Cube cube = new Cube();
try
{

Open an existing .cubex file. If file is not found an exception is thrown. Hence try-catch.

cube.openCubeReport(args[0]);

With various get_ calls obtain information about structure of the .cubex file.

ArrayList<Metric> metrics = cube.get_metv();
ArrayList<Metric> root_metrics = cube.get_root_metv();
ArrayList<Region> regions = cube.get_regionv();
ArrayList<Cnode> cnodes = cube.get_cnodev();
ArrayList<Cnode> root_cnodes = cube.get_root_cnodev();
ArrayList<SystemTreeNode> machines = cube.get_root_stnv();
ArrayList<SystemTreeNode> stns = cube.get_stnv();
ArrayList<Node> nodes = cube.get_nodev();
ArrayList<scalasca.cubex.cube.LocationGroup> lgs = cube.get_location_groupv();
ArrayList<scalasca.cubex.cube.Location> locs = cube.get_locationv();
ArrayList<scalasca.cubex.cube.Cartesian> topologies = cube.get_cartv();

For example you can print out data for every element.

System.out.println(
"Version:" + cube.get_version() + "\n" +
"Metrics:" + metrics.size() + "\n" +
"Root Metrics:" + root_metrics.size() + "\n" +
"Regions:" + regions.size() + "\n" +
"Cnodes:" + cnodes.size() + "\n" +
"SystemTreeNodes:" + stns.size() + "\n" +
"Machines:" + machines.size() + "\n" +
"LocationGroups:" + lgs.size() + "\n" +
"Locationa:" + locs.size() + "\n" +
"Topologies:" + topologies.size()
);
System.out.println("------- Metrics in " + args[0] + " ------------------");
for (Metric met : root_metrics)
{
printMetrics(met, 0);
}

To obtain the data for a specific metric, call path and location use the call get_sev_adv

for (scalasca.cubex.cube.Metric met: metrics)
{
System.out.println(" ================================ Metric "+met.getDisplayName() + " ============================");
for (scalasca.cubex.cube.Cnode cnode: cnodes)
{
System.out.println(" -------------------------------- Cnode "+cnode.getName() + " ----------------------------");
for (scalasca.cubex.cube.Location location: locs)
{
System.out.print( cube.get_sev_adv(met, cnode, location).toString() + " ");
}System.out.println();
}
}

Various exceptions can be thrown and should be cought and processed properly

}catch (BadSyntaxException e)
{
...
System.out.println("General error:" + e.getMessage());
}
}

Example of usage of the jCubeR library one can find in [prefix]/share/doc/jcuber/examples


Cube Writer Library    Copyright © 1998–2024 Forschungszentrum Jülich GmbH, Jülich Supercomputing Centre
Copyright © 2009–2015 German Research School for Simulation Sciences GmbH, Laboratory for Parallel Programming