Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
H5iosp/Tiling bug
Browse files Browse the repository at this point in the history
yuan's rewrite class
  • Loading branch information
JohnLCaron committed Mar 12, 2014
1 parent 317b40f commit 37b26e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
9 changes: 6 additions & 3 deletions cdm/src/main/java/ucar/nc2/iosp/hdf5/Tiling.java
Expand Up @@ -64,14 +64,17 @@ public Tiling(int[] shape, int[] tileSize) {
this.shape = new int[rank];
for (int i=0; i<rank; i++)
this.shape[i] = Math.max(shape[i], tileSize[i]);
int[] tile = tile(this.shape);

// LOOK this is wrong
int[] tiles = new int[rank];
for (int i = 0; i < rank; i++) {
tiles[i] = (this.shape[i] +tileSize[i] - 1) / tileSize[i];
}

this.stride = new int[rank];
int strider = 1;
for (int k = rank-1; k >= 0; k--) {
stride[k] = strider;
strider *= tile[k];
strider *= tiles[k];
}
}

Expand Down
12 changes: 8 additions & 4 deletions cdm/src/main/java/ucar/nc2/rewrite/Rewrite.java
Expand Up @@ -52,14 +52,18 @@ public class Rewrite {
NetcdfFile ncIn;
NetcdfFileWriter ncOut;
NetcdfFileWriter.Version version;
boolean isRadial = false;

Rewrite(NetcdfFile ncIn, NetcdfFileWriter ncOut) {
public Rewrite(NetcdfFile ncIn, NetcdfFileWriter ncOut) {
this.ncIn = ncIn;
this.ncOut = ncOut;
this.version = ncOut.getVersion();
}

void rewrite() throws IOException, InvalidRangeException {
public void rewrite() throws IOException, InvalidRangeException {
Attribute attr = ncIn.getRootGroup().findAttribute("featureType");
if(attr.getStringValue().contains("RADIAL"))
isRadial = true;
createGroup(null, ncIn.getRootGroup());

ncOut.create();
Expand Down Expand Up @@ -94,7 +98,7 @@ void createGroup(Group newParent, Group oldGroup) throws IOException, InvalidRan
}

Variable nv;
if (v.getRank() >= 3) { // make first dimension last
if (!isRadial && v.getRank() >= 3) { // make first dimension last
StringBuilder sb = new StringBuilder();
for (int i=1; i<dims.size(); i++)
sb.append(dims.get(i).getShortName()).append(" ");
Expand All @@ -117,7 +121,7 @@ void createGroup(Group newParent, Group oldGroup) throws IOException, InvalidRan
void transferData(Group oldGroup) throws IOException, InvalidRangeException {

for (Variable v : oldGroup.getVariables()) {
if (v.getRank() >= 3) {
if (!isRadial && v.getRank() >= 3) {
invertOneVar(v);

} else {
Expand Down

0 comments on commit 37b26e8

Please sign in to comment.