Thanks for the response. How do I read with more than one cores and distribute when I use nc_open? I realized that I don't really need parallel reading but simply each rank taking a chunk so that process 0 won't need to have a huge amount of available memory. The code that I put together below seems to still read chunks only with process 0 and svd is likely incorrectly computed. Do you spot any mistakes?
suppressMessages(library(pbdMPI, quietly = TRUE))
suppressMessages(library(pbdNCDF4, quietly = TRUE))
suppressMessages(library(pbdDMAT, quietly = TRUE))
init.grid()
rank <- comm.rank()
size <- comm.size()
nc <- nc_open("SLP.nc")
nrow <- nc$dim$west_east$len
ncol <- nc$dim$south_north$len
ntim <- nc$dim$Time$len
ncol.per.rank <- ceiling(ncol / size)
st <- 1 + ncol.per.rank * rank
co <- ncol.per.rank
if (st + co > ncol) co <- ncol - st + 1
x <- ncvar_get(nc, "SLP", start = c(1, st, 1), count = c(-1, co, -1))
dim(x) <- c(nrow * co, ntim)
x <- x - rowMeans(x)
nc_close(nc)
comm.print(dim(x), all.rank = TRUE)
dx <- as.ddmatrix(x, bldim = c(16, 16))
dsvd <- La.svd(dx)
svd <- lapply(dsvd, as.matrix)
if (comm.rank() == 0) print(dim(svd$v))
finalize()
Using 4x4 for the default grid size
[1] 4518 8856
[1] 4518 8856
[1] 4518 8856
[1] 4518 8856
[1] 4518 8856
[1] 4518 8856
[1] 4518 8856
[1] 4518 8856
[1] 4518 8856
[1] 4518 8856
[1] 4518 8856
[1] 4518 8856
[1] 4518 8856
[1] 4518 8856
[1] 4518 8856
[1] 3263 8856
Warning message:
In base.rpdgesvd(jobu = jobu, jobvt = jobvt, m = m, n = n, a = x@Data, :
ScaLAPACK returned INFO=-3; returned solution is likely invalid