Skip to content

Commit 159f630

Browse files
authored
Merge pull request #169 from slayoo/mpi_cleanup
draft of stop handling in C/C++
2 parents dff88d1 + 94c3551 commit 159f630

File tree

9 files changed

+36
-209
lines changed

9 files changed

+36
-209
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
shallow = true
55
[submodule "partmc"]
66
path = gitmodules/partmc
7-
url = https://github.com/compdyn/partmc
7+
url = https://github.com/slayoo/partmc
88
shallow = true
99
[submodule "pybind11_json"]
1010
path = gitmodules/pybind11_json

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ repos:
1212
rev: 5.10.1
1313
hooks:
1414
- id: isort
15+
args: ["--profile", "black"]
1516

1617
- repo: https://github.com/pre-commit/pre-commit-hooks
1718
rev: v4.3.0
1819
hooks:
1920
- id: trailing-whitespace
2021
- id: end-of-file-fixer
21-
- id: debug-statements
22+
- id: debug-statements

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ add_definitions("-DSUNDIALS_INT64_T=1")
3636
### sources ########################################################################################
3737

3838
set(PyPartMC_sources
39-
pypartmc.cpp gimmicks.cpp fake_netcdf.cpp fake_mpi.cpp fake_spec_file.cpp
39+
pypartmc.cpp gimmicks.cpp fake_netcdf.cpp fake_spec_file.cpp sys.cpp
4040
run_part.F90 run_part_opt.F90 util.F90 aero_data.F90 aero_state.F90 env_state.F90 gas_data.F90
4141
gas_state.F90 scenario.F90 condense.F90 aero_particle.F90 bin_grid.F90
4242
camp_core.F90 photolysis.F90
@@ -136,7 +136,7 @@ set(partmclib_SOURCES condense_solver.c aero_state.F90 integer_varray.F90 intege
136136
photolysis.F90
137137
)
138138
add_prefix(gitmodules/partmc/src/ partmclib_SOURCES)
139-
list(APPEND partmclib_SOURCES src/fake_mpi.F90 src/fake_netcdf.F90 src/fake_spec_file.F90)
139+
list(APPEND partmclib_SOURCES src/fake_netcdf.F90 src/fake_spec_file.F90 src/sys.F90)
140140

141141
set(klu_SOURCES
142142
KLU/Source/klu_analyze.c
@@ -271,7 +271,6 @@ target_include_directories(camplib PRIVATE
271271

272272
add_library(partmclib STATIC ${partmclib_SOURCES})
273273
target_compile_definitions(partmclib PRIVATE PMC_USE_SUNDIALS="1")
274-
target_compile_definitions(partmclib PRIVATE PMC_USE_MPI="1")
275274
target_compile_definitions(partmclib PRIVATE PMC_USE_CAMP="1")
276275
add_dependencies(partmclib ${SUNDIALS_items})
277276
target_include_directories(partmclib PRIVATE

PyPartMC/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ def __build_extension_env():
4343
with __build_extension_env():
4444
import _PyPartMC
4545
from _PyPartMC import *
46-
from _PyPartMC import __all__, __version__
46+
from _PyPartMC import __all__, __version__ # pylint: disable=no-name-in-module

src/fake_mpi.F90

Lines changed: 0 additions & 194 deletions
This file was deleted.

src/fake_spec_file.F90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module pmc_spec_file
22
use pmc_spec_line
3+
use iso_c_binding
34
implicit none
45

56
integer, parameter :: SPEC_FILE_MAX_LIST_LINES = 1000

src/sys.F90

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
!###################################################################################################
2+
! This file is a part of PyPartMC licensed under the GNU General Public License v3 (LICENSE file) #
3+
! Copyright (C) 2022 University of Illinois Urbana-Champaign #
4+
! Authors: https://github.com/open-atmos/PyPartMC/graphs/contributors #
5+
!###################################################################################################
6+
7+
module pmc_sys
8+
use iso_c_binding
9+
10+
interface
11+
subroutine c_stop(code) bind(C)
12+
integer, intent(in) :: code
13+
end subroutine
14+
end interface
15+
16+
contains
17+
18+
subroutine pmc_stop(code)
19+
integer, intent(in) :: code
20+
call c_stop(code)
21+
end subroutine
22+
end module

src/fake_mpi.cpp renamed to src/sys.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
#include <stdexcept>
88
#include <sstream>
99

10-
void _mpi_abort(const int errorcode) {
11-
std::ostringstream oss;
12-
oss << errorcode << std::endl;
13-
auto err = std::runtime_error(oss.str());
14-
throw err;
10+
void cpp_stop(int code) {
11+
std::ostringstream str;
12+
str << code;
13+
throw std::runtime_error(str.str());
1514
}
1615

17-
extern "C" void mpi_abort(const int *comm, const int *errorcode, const int *ierror) {
18-
_mpi_abort(*errorcode);
16+
extern "C" void c_stop(int code) {
17+
cpp_stop(code);
1918
}
20-

0 commit comments

Comments
 (0)