-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MPI parallelization of thermodynamics (#331)
## Background This PR is part of #120, where the basis of strategy for MPI parallelisation is described. ## Change description As all thermodynamics operations are local to a grid cell all required MPI communication, is handled by NetCDF4 library. Therefore the only required steps are: - [x] Initialize and finalize MPI stack - [x] Read decomposition metadata on each rank - [x] Read and write the necessary part of the grid on each rank (depends on #330) - [x] Tests for parallel I/O **NOTE** PR #432 should be merged into this branch before it is merged into develop To run `run_simple_example.sh` you will need to generate the following netcdf file ``` $ ncdump partition.nc netcdf partition { dimensions: P = 1 ; L = 1 ; globalX = 30 ; globalY = 30 ; group: bounding_boxes { variables: int global_x(P) ; int global_y(P) ; int local_extent_x(P) ; int local_extent_y(P) ; data: global_x = 0 ; global_y = 0 ; local_extent_x = 30 ; local_extent_y = 30 ; } // group bounding_boxes } ```
- Loading branch information
Showing
25 changed files
with
1,017 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <ncCheck.h> | ||
#include <netcdf.h> | ||
#include <netcdf_par.h> | ||
|
||
#include "include/ParallelNetcdfFile.hpp" | ||
|
||
using namespace netCDF; | ||
|
||
// Not sure why it is needed but let's replicate netCDF::ncFile::open | ||
// in this respect | ||
extern int g_ncid; | ||
|
||
NcFilePar::NcFilePar( | ||
const std::string& filePath, const FileMode fMode, MPI_Comm comm, MPI_Info mpiInfo) | ||
{ | ||
open_par(filePath, fMode, comm, mpiInfo); | ||
} | ||
|
||
void NcFilePar::open_par( | ||
const std::string& filePath, const FileMode fMode, MPI_Comm comm, MPI_Info mpiInfo) | ||
{ | ||
if (!nullObject) | ||
close(); | ||
|
||
switch (fMode) { | ||
case NcFile::write: | ||
ncCheck(nc_open_par(filePath.c_str(), NC_WRITE, comm, mpiInfo, &myId), __FILE__, __LINE__); | ||
break; | ||
case NcFile::read: | ||
ncCheck( | ||
nc_open_par(filePath.c_str(), NC_NOWRITE, comm, mpiInfo, &myId), __FILE__, __LINE__); | ||
break; | ||
case NcFile::newFile: | ||
ncCheck(nc_create_par(filePath.c_str(), NC_NETCDF4 | NC_NOCLOBBER, comm, mpiInfo, &myId), | ||
__FILE__, __LINE__); | ||
break; | ||
case NcFile::replace: | ||
ncCheck(nc_create_par(filePath.c_str(), NC_NETCDF4 | NC_CLOBBER, comm, mpiInfo, &myId), | ||
__FILE__, __LINE__); | ||
break; | ||
} | ||
|
||
g_ncid = myId; | ||
|
||
nullObject = false; | ||
} |
Oops, something went wrong.