|
NEP 2.7.0
NetCDF Extension Pack
|
Demonstrates parallel NetCDF-4 I/O with MPI using a 2x2 rank decomposition. More...
#include <netcdf.h>#include <netcdf_par.h>#include <mpi.h>#include <stdio.h>#include <stdlib.h>Macros | |
| #define | NDIMS 2 |
| #define | QUAD_SIZE 8 |
| #define | DIM_SIZE 16 |
| #define | ERR(e) |
Functions | |
| int | main (int argc, char **argv) |
Demonstrates parallel NetCDF-4 I/O with MPI using a 2x2 rank decomposition.
This example shows how to use NetCDF-4's parallel I/O capabilities with MPI to write and read a shared dataset concurrently from multiple processes. Four MPI ranks cooperate to write a single 16x16 integer array, each contributing an 8x8 quadrant filled with its own rank number.
The program demonstrates the fundamental parallel I/O pattern: open a file collectively, define the full dataset shape once, then have each rank write only its local portion using hyperslab selections (start/count). After writing, it performs a parallel read-back to verify correctness.
Learning Objectives:
Key Concepts:
Rank Layout (2×2 grid):
Prerequisites:
Related Examples:
Compilation:
Usage:
Expected Output:
| #define DIM_SIZE 16 |
| #define ERR | ( | e | ) |
| #define NDIMS 2 |
| #define QUAD_SIZE 8 |
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |