Skip to content

Commit c9b8c3d

Browse files
authored
Merge pull request #204 from JohnLCaron/kmp2
reenable native KMP.
2 parents 5d67bde + f87a5b7 commit c9b8c3d

File tree

31 files changed

+371
-149
lines changed

31 files changed

+371
-149
lines changed

.idea/artifacts/netchdf_0_6_0.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/netchdf_0_7_0.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ Also see:
5959
We use the latest LTS (long term support) Java version, and will not be explicitly supporting older versions.
6060
Currently that is Java 21.
6161

62-
We also use the latest stable version of Kotlin that is compatible with the Java version. Currently that is Kotlin 2.1.
62+
We also use the latest stable version of Kotlin that is compatible with the Java version. Currently that is Kotlin 2.1.21.
6363

6464
Gradle is our build system. We will use the latest stable version of Gradle compatible with our Java and Kotlin versions.
65-
Currently that is Gradle 8.14.
65+
Currently that is Gradle 8.14.3.
6666

6767
For now, you must download and build the library yourself. Eventually we will publish it to Maven Central.
6868
The IntelliJ IDE is highly recommended for all JVM development.
@@ -265,7 +265,7 @@ For example, a Variable of datatype Float will return an ArrayFloat, which is Ar
265265
return data as ArrayUByte.
266266
* Netcdf-4 encodes CHAR values as HDF5 string type with elemSize = 1, so we use that convention to detect
267267
legacy CHAR variables in HDF5 format. (NC_CHAR should not be used in new Netcdf-4 files, use NC_UBYTE or NC_STRING.)
268-
Variables of type CHAR return data as STRING, since users can use UBYTE if thats what they intend.
268+
Variables of type CHAR return data as STRING, since users can use UBYTE if that's what they intend.
269269
* Netcdf-4/HDF5 String variables may be fixed or variable length. For fixed Strings, we set the size of Datatype.STRING to
270270
the fixed size. For both fixed and variable length Strings, the string will be truncated at the first zero byte, if any.
271271
* HDF4 does not have a STRING type, but does have signed and unsigned CHAR, and signed and unsigned BYTE.
@@ -318,7 +318,7 @@ isNetcdf4 = true.
318318
1. If a group or variable has an attribute with name "_NCProperties", "_Netcdf4Coordinates", "_Netcdf4Dimid" or "_nc3_strict".
319319
2. If a variable name starts with "_nc4_non_coord_".
320320
3. If a variable has an attrinute named "DIMENSION_LIST with type vlen of reference.
321-
4. If a dimenson name starts with "This is a netCDF dimension but not a netCDF variable"
321+
4. If a dimension name starts with "This is a netCDF dimension but not a netCDF variable"
322322

323323
Other than trying to identify which library wrote the file, Netchdf does not do any special processing for Netcdf4 files,
324324
except:

core/build.gradle.kts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ version = libs.versions.netchdf.get()
99
kotlin {
1010
jvm()
1111

12-
/*
1312
val hostOs = System.getProperty("os.name")
1413
val arch = System.getProperty("os.arch")
1514
when {
@@ -29,8 +28,6 @@ kotlin {
2928
else -> throw GradleException("Host OS is not supported.")
3029
}
3130

32-
*/
33-
3431
sourceSets {
3532
val commonMain by getting {
3633
dependencies {

core/src/commonMain/kotlin/com/sunya/cdm/api/Dimension.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ data class Dimension(val orgName : String, val length : Long, val isShared : Boo
1212
constructor(len : Int) : this("", len.toLong(), false)
1313
constructor(len : Long) : this("", len, false)
1414

15-
// orgName may be different
1615
override fun equals(other: Any?): Boolean {
1716
if (this === other) return true
18-
if (javaClass != other?.javaClass) return false
17+
if (other == null || this::class != other::class) return false
1918

2019
other as Dimension
2120

@@ -33,5 +32,4 @@ data class Dimension(val orgName : String, val length : Long, val isShared : Boo
3332
return result
3433
}
3534

36-
3735
}

core/src/commonMain/kotlin/com/sunya/netchdf/hdf5/BTree2.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ fun getSizeOfNumberOfRecords(
210210

211211
// jhdf
212212
internal fun bytesNeededToHoldNumber(number: Int): Int {
213-
return (Integer.numberOfTrailingZeros(Integer.highestOneBit(number)) + 8) / 8
213+
// return (Integer.numberOfTrailingZeros(Integer.highestOneBit(number)) + 8) / 8
214+
val p1 = number.takeHighestOneBit()
215+
return (p1.countTrailingZeroBits() + 8) / 8
214216
}
215217

216218
/* private fun getSizeOfTotalNumberOfChildRecords(nodeSize: Int, depth: Int, recordSize: Int): Int {

core/src/commonMain/kotlin/com/sunya/netchdf/hdf5/BTree2data.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ internal class BTree2data(
6363
}
6464
}
6565

66+
fun countChunks() = asSequence().count()
67+
6668
fun chunkIterator(): Iterator<DataChunk> = asSequence().iterator()
6769

6870
internal fun findDataChunk(order: Int): DataChunk? {

core/src/commonMain/kotlin/com/sunya/netchdf/hdf5/ExtensibleArrayIndex.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package com.sunya.netchdf.hdf5
55
import com.sunya.cdm.api.computeSize
66
import com.sunya.cdm.iosp.OpenFileState
77
import com.sunya.cdm.util.InternalLibraryApi
8-
import java.util.*
98

109
// DataLayoutExtensibleArray4
1110
class ExtensibleArrayIndex(val h5: H5builder, address: Long, datasetDimensions: IntArray, chunkDimensions: IntArray) {

core/src/commonMain/kotlin/com/sunya/netchdf/hdf5/FractalHeap.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import com.sunya.cdm.iosp.OpenFileIF
77
import com.sunya.cdm.iosp.OpenFileState
88
import com.sunya.cdm.util.*
99

10+
val UNDEFINED_ADDRESS = -1L
11+
1012
/** Level 1G - Fractal Heap */
1113
// TODO rewrite
1214
internal class FractalHeap(private val h5: H5builder, forWho: String, address: Long) {

0 commit comments

Comments
 (0)