Skip to content

Commit 860360a

Browse files
author
Roberto Di Remigio
committed
Correct bug in input reading with method 2 unearthed by MI.
The char arrays needed to be cleaned up prior to usage...
1 parent d9006e8 commit 860360a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/interface/InputManager.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#ifndef INPUTMANAGER_HPP
2727
#define INPUTMANAGER_HPP
2828

29+
#include <algorithm>
2930
#include <iostream>
3031
#include <string>
3132

@@ -66,6 +67,13 @@ struct cavityInput {
6667
int pad; // Without padding the two strings are lumped together...
6768
char restart_name[20];
6869
double min_radius;
70+
/*! Cleans up the char arrays in this struct
71+
*/
72+
void cleaner() {
73+
std::fill(cavity_type, cavity_type + 8, 0);
74+
std::fill(radii_set, radii_set + 8, 0);
75+
std::fill(restart_name, restart_name + 20, 0);
76+
}
6977
friend std::ostream & operator<<(std::ostream & os, cavityInput & o) {
7078
os << "cavity type " << std::string(o.cavity_type) << std::endl;
7179
os << "patch level " << o.patch_level << std::endl;
@@ -101,6 +109,13 @@ struct solverInput {
101109
char equation_type[11];
102110
double correction;
103111
double probe_radius;
112+
/*! Cleans up the char arrays in this struct
113+
*/
114+
void cleaner() {
115+
std::fill(solver_type, solver_type + 7, 0);
116+
std::fill(solvent, solvent + 16, 0);
117+
std::fill(equation_type, equation_type + 11, 0);
118+
}
104119
friend std::ostream & operator<<(std::ostream & os, solverInput & o) {
105120
os << "solver type " << std::string(o.solver_type) << std::endl;
106121
os << "solvent " << std::string(o.solvent) << std::endl;
@@ -124,6 +139,12 @@ struct greenInput {
124139
char inside_type[7];
125140
double outside_epsilon;
126141
char outside_type[22];
142+
/*! Cleans up the char arrays in this struct
143+
*/
144+
void cleaner() {
145+
std::fill(inside_type, inside_type + 7, 0);
146+
std::fill(outside_type, outside_type + 22, 0);
147+
}
127148
friend std::ostream & operator<<(std::ostream & os, greenInput & o) {
128149
os << "inside type " << std::string(o.inside_type) << std::endl;
129150
os << "outside type " << std::string(o.outside_type) << std::endl;

src/interface/Interface.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,11 @@ void setupInput(bool from_host)
379379
{
380380
if (from_host) { // Set up input from host data structures
381381
cavityInput cav;
382+
cav.cleaner();
382383
solverInput solv;
384+
solv.cleaner();
383385
greenInput green;
386+
green.cleaner();
384387
host_input(&cav, &solv, &green);
385388
// Put string passed with the alternative method in the input structures
386389
if (!input_strings.empty()) {

0 commit comments

Comments
 (0)