Page tree

You are able to use NCI-data-analysis module to manipulate NetCDF files in parallel. 


Example job script:

#PBS -l ncpus=4
#PBS -l mem=16GB
#PBS -l jobfs=20GB
#PBS -q normal
#PBS -P a00
#PBS -l walltime=02:00:00
#PBS -l storage=gdata/dk92+gdata/a00+scratch/a00
#PBS -l wd
module use /g/data/fp0/apps/Modules/modulefiles
module load NCI-data-analysis/2022.06

mpirun python3 >& output.log

If you run the below script in the above job script 

from mpi4py import MPI
import numpy as np
from netCDF4 import Dataset
comm = MPI.COMM_WORLD # Use the world communicator
mpi_rank = comm.Get_rank() # The process ID
mpi_size = comm.Get_size() # Total amount of ranks

with Dataset('','w',parallel=True) as f:
d = f.createDimension('dim',mpi_size)
v = f.createVariable('var', np.int64, 'dim')
v[mpi_rank] = mpi_rank


if (mpi_rank == 0):
print(mpi_size,' MPI ranks have finished writing!')

you will get a NetCDF file named "" containing outputs from all 4 MPI ranks.

$ ncdump
netcdf output {
dim = 4 ;
int64 var(dim) ;

 var = 0, 1, 2, 3 ;
  • No labels