Skip to content

Commit bdb2783

Browse files
committed
Fix inconsistency betwen NumPy surface function save and load functions
This commit also adds calls to the API functions pcmsolver_save_surface_functions, pcmsolver_save_surface_function and pcmsolver_load_surface_function in the C_host and Fortran_host executables. This makes sure that these functions get exercised and provide a test against trivial API breakages.
1 parent 653e92f commit bdb2783

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

api/pcmsolver.f90

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ module pcmsolver
4747
public pcmsolver_print_surface_function
4848
public pcmsolver_save_surface_functions
4949
public pcmsolver_save_surface_function
50-
public pcmsolver_save_surface_function_to_npz
5150
public pcmsolver_load_surface_function
5251
public pcmsolver_write_timings
5352

@@ -202,14 +201,6 @@ subroutine pcmsolver_save_surface_function(context, name) bind(C)
202201
character(kind=c_char, len=1), intent(in) :: name(*)
203202
end subroutine pcmsolver_save_surface_function
204203

205-
subroutine pcmsolver_save_surface_function_to_npz(context, npz_name, name, suffix) bind(C)
206-
import
207-
type(c_ptr), value :: context
208-
character(kind=c_char, len=1), intent(in) :: npz_name(*)
209-
character(kind=c_char, len=1), intent(in) :: name(*)
210-
character(kind=c_char, len=1), intent(in) :: suffix(*)
211-
end subroutine pcmsolver_save_surface_function_to_npz
212-
213204
subroutine pcmsolver_load_surface_function(context, name) bind(C)
214205
import
215206
type(c_ptr), value :: context

src/interface/Meddle.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,7 @@ void pcmsolver_load_surface_function(pcmsolver_context_t * context,
351351
void pcm::Meddle::loadSurfaceFunction(const char * name) const {
352352
std::string functionName(name);
353353
hostWriter_("\nLoading surface function " + functionName + " from .npy file");
354-
std::string fname = functionName + ".npy";
355-
Eigen::VectorXd values = cnpy::custom::npy_load<double>(fname);
354+
Eigen::VectorXd values = cnpy::custom::npy_load<double>(functionName + ".npy");
356355
if (values.size() != cavity_->size())
357356
PCMSOLVER_ERROR("The loaded " + functionName +
358357
" surface function is bigger than the cavity!");

tests/C_host/C_host.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ int main() {
157157
test_surface_functions(
158158
output, grid_size, mep, asc_Ag, asc_B3g, asc_neq_B3g, areas);
159159

160-
pcmsolver_save_surface_function(pcm_context, mep_lbl);
160+
pcmsolver_save_surface_functions(pcm_context);
161161
pcmsolver_save_surface_function(pcm_context, asc_lbl);
162+
pcmsolver_load_surface_function(pcm_context, mep_lbl);
162163

163164
pcmsolver_write_timings(pcm_context);
164165

tests/Fortran_host/Fortran_host.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ program pcm_fortran_host
168168
! Surface functions
169169
call test_surface_functions(grid_size, mep, asc_Ag, asc_B3g, asc_neq_B3g, areas)
170170

171+
call pcmsolver_save_surface_function(pcm_context, mep_lbl)
172+
call pcmsolver_load_surface_function(pcm_context, mep_lbl)
173+
171174
call pcmsolver_write_timings(pcm_context)
172175

173176
call pcmsolver_delete(pcm_context)

0 commit comments

Comments
 (0)