APBS 3.0.0
Loading...
Searching...
No Matches
geoflowparm.c
Go to the documentation of this file.
1
57#include "geoflowparm.h"
58
59VEMBED(rcsid="$Id$")
60
61#if !defined(VINLINE_MGPARM)
62
63#endif /* if !defined(VINLINE_MGPARM) */
64
65
67
68 /* Set up the structure */
69 GEOFLOWparm *thee = VNULL;
70 thee = (GEOFLOWparm*)Vmem_malloc(VNULL, 1, sizeof(GEOFLOWparm));
71 VASSERT( thee != VNULL);
72 VASSERT( GEOFLOWparm_ctor2(thee, type) == VRC_SUCCESS );
73
74 return thee;
75}
76
77VPUBLIC Vrc_Codes GEOFLOWparm_ctor2(GEOFLOWparm *thee, GEOFLOWparm_CalcType type) {
78
79 int i;
80
81 if (thee == VNULL) return VRC_FAILURE;
82
83 thee->parsed = 0;
84 thee->type = type;
85 thee->vdw = 0;
86 thee->etol = 1.0e-6;
87
88 return VRC_SUCCESS;
89}
90
91VPUBLIC void GEOFLOWparm_dtor(GEOFLOWparm **thee) {
92 if ((*thee) != VNULL) {
93 GEOFLOWparm_dtor2(*thee);
94 Vmem_free(VNULL, 1, sizeof(GEOFLOWparm), (void **)thee);
95 (*thee) = VNULL;
96 }
97}
98
99VPUBLIC void GEOFLOWparm_dtor2(GEOFLOWparm *thee) { ; }
100
101VPUBLIC Vrc_Codes GEOFLOWparm_check(GEOFLOWparm *thee) {
102
103 Vrc_Codes rc;
104
105 rc = VRC_SUCCESS;
106
107 Vnm_print(0, "GEOFLOWparm_check: checking GEOFLOWparm object of type %d.\n",
108 thee->type);
109
110 /* Check to see if we were even filled... */
111 if (!thee->parsed) {
112 Vnm_print(2, "GEOFLOWparm_check: not filled!\n");
113 return VRC_FAILURE;
114 }
115
116
117 /* Check type settings */
118 //if ((thee->type != GFCT_MANUAL)&& (thee->type != GFCT_AUTO)&& (thee->type != GFCT_NONE)) {
119 if(thee->type != GFCT_AUTO) {
120 Vnm_print(2,"GEOFLOWparm_check: type not set");
121 rc = VRC_FAILURE;
122 }
123
124 return rc;
125}
126
127VPUBLIC void GEOFLOWparm_copy(GEOFLOWparm *thee, GEOFLOWparm *parm) {
128 VASSERT(thee != VNULL);
129 VASSERT(parm != VNULL);
130
131 thee->type = parm->type;
132 thee->parsed = parm->parsed;
133
134 thee->vdw = parm->vdw;
135 thee->etol = parm->etol;
136}
137
138Vrc_Codes FUBAR(const char* name){
139 Vnm_print(2, "parseGEOFLOW: ran out of tokens on %s!\n", name);
140 return VRC_WARNING;
141}
142
143Vrc_Codes parseNonNeg(double* tf, double def, int* set, char* name, Vio* sock){
144 char tok[VMAX_BUFSIZE];
145 if(Vio_scanf(sock, "%s", tok) == 0) {
146 *tf = def;
147 return FUBAR(name);
148 }
149
150 if (sscanf(tok, "%lf", tf) == 0){
151 Vnm_print(2, "NOsh: Read non-float (%s) while parsing %s keyword!\n", tok, name);
152 *tf = def;
153 return VRC_WARNING;
154 }else if(*tf < 0.0){
155 Vnm_print(2, "parseGEOFLOW: %s must be greater than 0!\n", name);
156 *tf = def;
157 return VRC_WARNING;
158 }
159
160 *set = 1;
161 return VRC_SUCCESS;
162}
163
164VPRIVATE Vrc_Codes GEOFLOWparm_parseVDW(GEOFLOWparm *thee, Vio *sock){
165 const char* name = "vdw";
166 char tok[VMAX_BUFSIZE];
167 int tf;
168 if(Vio_scanf(sock, "%s", tok) == 0) {
169 return FUBAR(name);
170 }
171
172
173 if (sscanf(tok, "%u", &tf) == 0){
174 Vnm_print(2, "NOsh: Read non-unsigned int (%s) while parsing %s keyword!\n", tok, name);
175 return VRC_WARNING;
176 }else if(tf != 0 && tf != 1){
177 Vnm_print(2, "parseGEOFLOW: %s must be 0 or 1!\n", name);
178 return VRC_WARNING;
179 }else{
180 thee->vdw = tf;
181 }
182 thee->setvdw = 1;
183 return VRC_SUCCESS;
184}
185
186VPRIVATE Vrc_Codes GEOFLOWparm_parseETOL(GEOFLOWparm *thee, Vio *sock){
187
188 char tok[VMAX_BUFSIZE];
189 double tf;
190
191 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
192 if(sscanf(tok, "%lf", &tf) == 0){
193 Vnm_print(2, "NOsh: Read non-float (%s) while parsing etol keyword!\n", tok);
194 return VRC_WARNING;
195 } else if(tf <= 0.0) {
196 Vnm_print(2,"parseGEOFLOW: etol must be greater than 0!\n");
197 return VRC_WARNING;
198 } else {
199 thee->etol = tf;
200 }
201
202
203 return VRC_SUCCESS;
204
205
206 VERROR1:
207 Vnm_print(2, "parseGEOFLOW: ran out of tokens!\n");
208 return VRC_WARNING;
209
210}
211
212VPUBLIC Vrc_Codes GEOFLOWparm_parseToken(GEOFLOWparm *thee, char tok[VMAX_BUFSIZE],
213 Vio *sock) {
214
215 if (thee == VNULL) {
216 Vnm_print(2, "parseGEOFLOW: got NULL thee!\n");
217 return VRC_WARNING;
218 }
219 if (sock == VNULL) {
220 Vnm_print(2, "parseGEOFLOW: got NULL socket!\n");
221 return VRC_WARNING;
222 }
223
224 Vnm_print(0, "GEOFLOWparm_parseToken: trying %s...\n", tok);
225
226 if (Vstring_strcasecmp(tok, "vdwdisp") == 0) {
227 return GEOFLOWparm_parseVDW(thee, sock);
228 } else if(Vstring_strcasecmp(tok, "etol") == 0){
229 return GEOFLOWparm_parseETOL(thee, sock);
230 }else {
231 Vnm_print(2, "parseGEOFLOW: Unrecognized keyword (%s)!\n", tok);
232 return VRC_WARNING;
233 }
234
235
236 return VRC_FAILURE;
237}
Contains declarations for class GEOFLOWparm.
VPUBLIC void GEOFLOWparm_dtor2(GEOFLOWparm *thee)
FORTRAN stub for object destructor ?????????!!!!!!!!!!!!
Definition geoflowparm.c:99
VPUBLIC GEOFLOWparm * GEOFLOWparm_ctor(GEOFLOWparm_CalcType type)
Construct GEOFLOWparm object.
Definition geoflowparm.c:66
VPUBLIC Vrc_Codes GEOFLOWparm_parseToken(GEOFLOWparm *thee, char tok[VMAX_BUFSIZE], Vio *sock)
Parse an MG keyword from an input file.
VPUBLIC void GEOFLOWparm_dtor(GEOFLOWparm **thee)
Object destructor.
Definition geoflowparm.c:91
VPUBLIC void GEOFLOWparm_copy(GEOFLOWparm *thee, GEOFLOWparm *parm)
copy GEOFLOWparm object int thee.
enum eGEOFLOWparm_CalcType GEOFLOWparm_CalcType
Declare GEOFLOWparm_CalcType type.
Definition geoflowparm.h:88
VPUBLIC Vrc_Codes GEOFLOWparm_check(GEOFLOWparm *thee)
Consistency check for parameter values stored in object.
VPUBLIC Vrc_Codes GEOFLOWparm_ctor2(GEOFLOWparm *thee, GEOFLOWparm_CalcType type)
FORTRAN stub to construct GEOFLOWparm object ?????????!!!!!!!
Definition geoflowparm.c:77
@ GFCT_AUTO
Definition geoflowparm.h:80
#define VEMBED(rctag)
Allows embedding of RCS ID tags in object files.
Definition vhal.h:556
@ VRC_FAILURE
Definition vhal.h:69
@ VRC_SUCCESS
Definition vhal.h:70
VPUBLIC int Vstring_strcasecmp(const char *s1, const char *s2)
Case-insensitive string comparison (BSD standard)
Definition vstring.c:66
Parameter structure for GEOFLOW-specific variables from input files.
Definition geoflowparm.h:98
GEOFLOWparm_CalcType type