APBS  3.0.0
pbsamparm.c
Go to the documentation of this file.
1 
57 #include "pbsamparm.h"
58 
59 VEMBED(rcsid="$Id$")
60 
61 #if !defined(VINLINE_MGPARM)
62 
63 #endif /* if !defined(VINLINE_MGPARM) */
64 
65 
67 
68  /* Set up the structure */
69  PBSAMparm *thee = VNULL;
70  thee = (PBSAMparm*)Vmem_malloc(VNULL, 1, sizeof(PBSAMparm));
71  VASSERT( thee != VNULL);
72  VASSERT( PBSAMparm_ctor2(thee, type) == VRC_SUCCESS );
73 
74  return thee;
75 }
76 
77 VPUBLIC Vrc_Codes PBSAMparm_ctor2(PBSAMparm *thee, PBSAMparm_CalcType type) {
78 
79  int i;
80 
81  if (thee == VNULL) return VRC_FAILURE;
82 
83  thee->tolsp = 2.5;
84  thee->setmsms = 0;
85  thee->probe_radius = 1.5;
86  thee->density = 3.0;
87 
88  thee->setsurf = 0;
89  thee->surfct = 0;
90 
91  thee->setimat = 0;
92  thee->imatct = 0;
93 
94  thee->setexp = 0;
95  thee->expct = 0;
96 
97  return VRC_SUCCESS;
98 }
99 
100 VPUBLIC void PBSAMparm_dtor(PBSAMparm **thee) {
101  if ((*thee) != VNULL) {
102  PBSAMparm_dtor2(*thee);
103  Vmem_free(VNULL, 1, sizeof(PBSAMparm), (void **)thee);
104  (*thee) = VNULL;
105  }
106 }
107 
108 VPUBLIC void PBSAMparm_dtor2(PBSAMparm *thee) { ; }
109 
110 VPUBLIC Vrc_Codes PBSAMparm_check(PBSAMparm *thee) {
111 
112  Vrc_Codes rc;
113 
114  rc = VRC_SUCCESS;
115 
116  Vnm_print(0, "PBSAMparm_check: checking PBSAMparm object of type %d.\n",
117  thee->type);
118 
119  /* Check to see if we were even filled... */
120  if (!thee->parsed) {
121  Vnm_print(2, "PBSAMparm_check: not filled!\n");
122  return VRC_FAILURE;
123  }
124 
125 
126  /* Check type settings */
127  if(thee->type != PBSAMCT_AUTO) {
128  Vnm_print(2,"PBSAMparm_check: type not set");
129  rc = VRC_FAILURE;
130  }
131 
132  return rc;
133 }
134 
135 VPUBLIC void PBSAMparm_copy(PBSAMparm *thee, PBSAMparm *parm) {
136  int i, j;
137  VASSERT(thee != VNULL);
138  VASSERT(parm != VNULL);
139 
140 
141  thee->settolsp = parm->settolsp;
142  thee->tolsp = parm->tolsp;
143 
144  thee->setmsms = parm->setmsms;
145  thee->probe_radius = parm->probe_radius;
146  thee->density = parm->density;
147  thee->setsurf = parm->setsurf;
148  thee->surfct = parm->surfct;
149  thee->setimat = parm->setimat;
150  thee->imatct = parm->imatct;
151  thee->setexp = parm->setexp;
152  thee->expct = parm->expct;
153 
154  for (i=0; i<PBSAMPARM_MAXWRITE; i++)
155  {
156  for (j=0; j<CHR_MAXLEN; j++)
157  {
158  thee->surffil[i][j] = parm->surffil[i][j];
159  thee->imatfil[i][j] = parm->imatfil[i][j];
160  thee->expfil[i][j] = parm->expfil[i][j];
161  }
162  }
163 }
164 
165 //Parsing vertex file
166 VPRIVATE Vrc_Codes PBSAMparm_parseSurf(PBSAMparm *thee, Vio *sock){
167  const char* name = "usemesh";
168  char tok[VMAX_BUFSIZE];
169 
170  if(Vio_scanf(sock, "%s", tok) == 0) {
171  Vnm_print(2, "parsePBSAM: ran out of tokens on %s!\n", name);
172  return VRC_WARNING;
173  } else {
174  strncpy(thee->surffil[thee->surfct], tok, CHR_MAXLEN);
175  thee->surfct += 1;
176  }
177  return VRC_SUCCESS;
178 }
179 
180 
181 //Parsing imat prefix file
182 VPRIVATE Vrc_Codes PBSAMparm_parseMSMS(PBSAMparm *thee, Vio *sock){
183  int td;
184  char tok[VMAX_BUFSIZE];
185  const char *name = "mesh";
186 
187  if(Vio_scanf(sock, "%s", tok) == 0){
188  Vnm_print(2, "parsePBSAM: ran out of tokens on %s!\n", name);
189  return VRC_WARNING;
190  }
191 
192  if(strcmp(tok, "msms") == 0){
193  thee->setmsms = 1;
194  }
195  else{
196  Vnm_print(2, "parsePBSAM: %s is not currently supported in PBSAM! Change to msms\n", tok);
197  return VRC_WARNING;
198  }
199 
200  return VRC_SUCCESS;
201 }
202 //Parsing imat prefix file
203 VPRIVATE Vrc_Codes PBSAMparm_parseImat(PBSAMparm *thee, Vio *sock){
204  const char* name = "imat";
205  char tok[VMAX_BUFSIZE];
206 
207  if(Vio_scanf(sock, "%s", tok) == 0) {
208  Vnm_print(2, "parsePBSAM: ran out of tokens on %s!\n", name);
209  return VRC_WARNING;
210  } else {
211  strncpy(thee->imatfil[thee->imatct], tok, CHR_MAXLEN);
212  thee->imatct += 1;
213  }
214  return VRC_SUCCESS;
215 }
216 
217 //Parsing imat prefix file
218 VPRIVATE Vrc_Codes PBSAMparm_parseExp(PBSAMparm *thee, Vio *sock){
219  const char* name = "exp";
220  char tok[VMAX_BUFSIZE];
221 
222  if(Vio_scanf(sock, "%s", tok) == 0) {
223  Vnm_print(2, "parsePBSAM: ran out of tokens on %s!\n", name);
224  return VRC_WARNING;
225  } else {
226  strncpy(thee->expfil[thee->expct], tok, CHR_MAXLEN);
227  thee->expct += 1;
228  }
229  return VRC_SUCCESS;
230 }
231 
232 VPRIVATE Vrc_Codes PBSAMparm_parseTolsp(PBSAMparm *thee, Vio *sock){
233  const char* name = "tolsp";
234  char tok[VMAX_BUFSIZE];
235  double tf;
236  if(Vio_scanf(sock, "%s", tok) == 0) {
237  Vnm_print(2, "parsePBAM: ran out of tokens on %s!\n", name);
238  return VRC_WARNING;
239  }
240 
241  if (sscanf(tok, "%lf", &tf) == 0){
242  Vnm_print(2, "NOsh: Read non-float (%s) while parsing %s keyword!\n", tok, name);
243  return VRC_WARNING;
244  }else{
245  thee->tolsp = tf;
246  }
247  thee->settolsp = 1;
248  return VRC_SUCCESS;
249 }
250 
251 
252 VPUBLIC Vrc_Codes PBSAMparm_parseToken(PBSAMparm *thee, char tok[VMAX_BUFSIZE],
253  Vio *sock) {
254 
255  if (thee == VNULL) {
256  Vnm_print(2, "parsePBSAM: got NULL thee!\n");
257  return VRC_WARNING;
258  }
259  if (sock == VNULL) {
260  Vnm_print(2, "parsePBSAM: got NULL socket!\n");
261  return VRC_WARNING;
262  }
263 
264  Vnm_print(0, "PBSAMparm_parseToken: trying %s...\n", tok);
265 
266  // Molecule terms
267  if (Vstring_strcasecmp(tok, "usemesh") == 0) {
268  return PBSAMparm_parseSurf(thee, sock);
269  }else if (Vstring_strcasecmp(tok, "mesh") == 0) {
270  return PBSAMparm_parseMSMS(thee, sock);
271  }else if (Vstring_strcasecmp(tok, "imat") == 0) {
272  return PBSAMparm_parseImat(thee, sock);
273  }else if (Vstring_strcasecmp(tok, "exp") == 0) {
274  return PBSAMparm_parseExp(thee, sock);
275  }else if (Vstring_strcasecmp(tok, "tolsp") == 0) {
276  return PBSAMparm_parseTolsp(thee, sock);
277  }
278 
279  else {
280  Vnm_print(2, "parsePBSAM: Unrecognized keyword (%s)!\n", tok);
281  return VRC_WARNING;
282  }
283  return VRC_FAILURE;
284 }
#define CHR_MAXLEN
Number of things that can be written out in a single calculation.
Definition: pbamparm.h:76
VPUBLIC void PBSAMparm_copy(PBSAMparm *thee, PBSAMparm *parm)
copy PBSAMparm object int thee.
Definition: pbsamparm.c:135
VPUBLIC PBSAMparm * PBSAMparm_ctor(PBSAMparm_CalcType type)
Construct PBSAMparm object.
Definition: pbsamparm.c:66
VPRIVATE Vrc_Codes PBSAMparm_parseSurf(PBSAMparm *thee, Vio *sock)
Find vertex files for each molecule and save them.
Definition: pbsamparm.c:166
VPRIVATE Vrc_Codes PBSAMparm_parseMSMS(PBSAMparm *thee, Vio *sock)
Find msms flag for if MSMS is to be run.
Definition: pbsamparm.c:182
VPUBLIC void PBSAMparm_dtor(PBSAMparm **thee)
Object destructor.
Definition: pbsamparm.c:100
VPUBLIC Vrc_Codes PBSAMparm_check(PBSAMparm *thee)
Consistency check for parameter values stored in object.
Definition: pbsamparm.c:110
VPRIVATE Vrc_Codes PBSAMparm_parseExp(PBSAMparm *thee, Vio *sock)
Find expansion files for each molecule and save them.
Definition: pbsamparm.c:218
VPRIVATE Vrc_Codes PBSAMparm_parseTolsp(PBSAMparm *thee, Vio *sock)
Find sphere tolerance for coarse-graining.
Definition: pbsamparm.c:232
VPUBLIC void PBSAMparm_dtor2(PBSAMparm *thee)
FORTRAN stub for object destructor ?????????!!!!!!!!!!!!
Definition: pbsamparm.c:108
VPUBLIC Vrc_Codes PBSAMparm_ctor2(PBSAMparm *thee, PBSAMparm_CalcType type)
FORTRAN stub to construct PBSAMparm object ?????????!!!!!!!
Definition: pbsamparm.c:77
enum ePBSAMparm_CalcType PBSAMparm_CalcType
Declare PBSAMparm_CalcType type.
Definition: pbsamparm.h:95
VPUBLIC Vrc_Codes PBSAMparm_parseToken(PBSAMparm *thee, char tok[VMAX_BUFSIZE], Vio *sock)
Parse an MG keyword from an input file.
Definition: pbsamparm.c:252
VPRIVATE Vrc_Codes PBSAMparm_parseImat(PBSAMparm *thee, Vio *sock)
Find IMAT files for each molecule and save them.
Definition: pbsamparm.c:203
@ PBSAMCT_AUTO
Definition: pbsamparm.h:87
#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
Contains declarations for class PBSAMparm.
Parameter structure for PBSAM-specific variables from input files.
Definition: pbsamparm.h:105
int parsed
Definition: pbsamparm.h:108
PBSAMparm_CalcType type
Definition: pbsamparm.h:107