APBS  1.5
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 = "surf";
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  thee->setmsms = 1;
184  return VRC_SUCCESS;
185 }
186 //Parsing imat prefix file
187 VPRIVATE Vrc_Codes PBSAMparm_parseImat(PBSAMparm *thee, Vio *sock){
188  const char* name = "imat";
189  char tok[VMAX_BUFSIZE];
190 
191  if(Vio_scanf(sock, "%s", tok) == 0) {
192  Vnm_print(2, "parsePBSAM: ran out of tokens on %s!\n", name);
193  return VRC_WARNING;
194  } else {
195  strncpy(thee->imatfil[thee->imatct], tok, CHR_MAXLEN);
196  thee->imatct += 1;
197  }
198  return VRC_SUCCESS;
199 }
200 
201 //Parsing imat prefix file
202 VPRIVATE Vrc_Codes PBSAMparm_parseExp(PBSAMparm *thee, Vio *sock){
203  const char* name = "exp";
204  char tok[VMAX_BUFSIZE];
205 
206  if(Vio_scanf(sock, "%s", tok) == 0) {
207  Vnm_print(2, "parsePBSAM: ran out of tokens on %s!\n", name);
208  return VRC_WARNING;
209  } else {
210  strncpy(thee->expfil[thee->expct], tok, CHR_MAXLEN);
211  thee->expct += 1;
212  }
213  return VRC_SUCCESS;
214 }
215 
216 VPRIVATE Vrc_Codes PBSAMparm_parseTolsp(PBSAMparm *thee, Vio *sock){
217  const char* name = "tolsp";
218  char tok[VMAX_BUFSIZE];
219  double tf;
220  if(Vio_scanf(sock, "%s", tok) == 0) {
221  Vnm_print(2, "parsePBAM: ran out of tokens on %s!\n", name);
222  return VRC_WARNING;
223  }
224 
225  if (sscanf(tok, "%lf", &tf) == 0){
226  Vnm_print(2, "NOsh: Read non-float (%s) while parsing %s keyword!\n", tok, name);
227  return VRC_WARNING;
228  }else{
229  thee->tolsp = tf;
230  }
231  thee->settolsp = 1;
232  return VRC_SUCCESS;
233 }
234 
235 
236 VPUBLIC Vrc_Codes PBSAMparm_parseToken(PBSAMparm *thee, char tok[VMAX_BUFSIZE],
237  Vio *sock) {
238 
239  if (thee == VNULL) {
240  Vnm_print(2, "parsePBSAM: got NULL thee!\n");
241  return VRC_WARNING;
242  }
243  if (sock == VNULL) {
244  Vnm_print(2, "parsePBSAM: got NULL socket!\n");
245  return VRC_WARNING;
246  }
247 
248  Vnm_print(0, "PBSAMparm_parseToken: trying %s...\n", tok);
249 
250  // Molecule terms
251  if (Vstring_strcasecmp(tok, "surf") == 0) {
252  return PBSAMparm_parseSurf(thee, sock);
253  }else if (Vstring_strcasecmp(tok, "msms") == 0) {
254  return PBSAMparm_parseMSMS(thee, sock);
255  }else if (Vstring_strcasecmp(tok, "imat") == 0) {
256  return PBSAMparm_parseImat(thee, sock);
257  }else if (Vstring_strcasecmp(tok, "exp") == 0) {
258  return PBSAMparm_parseExp(thee, sock);
259  }else if (Vstring_strcasecmp(tok, "tolsp") == 0) {
260  return PBSAMparm_parseTolsp(thee, sock);
261  }
262 
263  else {
264  Vnm_print(2, "parsePBSAM: Unrecognized keyword (%s)!\n", tok);
265  return VRC_WARNING;
266  }
267  return VRC_FAILURE;
268 }
enum ePBSAMparm_CalcType PBSAMparm_CalcType
Declare PBSAMparm_CalcType type.
Definition: pbsamparm.h:95
#define CHR_MAXLEN
Number of things that can be written out in a single calculation.
Definition: pbamparm.h:76
VPUBLIC Vrc_Codes PBSAMparm_check(PBSAMparm *thee)
Consistency check for parameter values stored in object.
Definition: pbsamparm.c:110
VPUBLIC void PBSAMparm_dtor(PBSAMparm **thee)
Object destructor.
Definition: pbsamparm.c:100
Contains declarations for class PBSAMparm.
VPRIVATE Vrc_Codes PBSAMparm_parseTolsp(PBSAMparm *thee, Vio *sock)
Find sphere tolerance for coarse-graining.
Definition: pbsamparm.c:216
VPUBLIC void PBSAMparm_copy(PBSAMparm *thee, PBSAMparm *parm)
copy PBSAMparm object int thee.
Definition: pbsamparm.c:135
VPRIVATE Vrc_Codes PBSAMparm_parseExp(PBSAMparm *thee, Vio *sock)
Find expansion files for each molecule and save them.
Definition: pbsamparm.c:202
Parameter structure for PBSAM-specific variables from input files.
Definition: pbsamparm.h:105
#define VEMBED(rctag)
Allows embedding of RCS ID tags in object files.
Definition: vhal.h:556
VPUBLIC int Vstring_strcasecmp(const char *s1, const char *s2)
Case-insensitive string comparison (BSD standard)
Definition: vstring.c:66
VPUBLIC Vrc_Codes PBSAMparm_parseToken(PBSAMparm *thee, char tok[VMAX_BUFSIZE], Vio *sock)
Parse an MG keyword from an input file.
Definition: pbsamparm.c:236
PBSAMparm_CalcType type
Definition: pbsamparm.h:107
int parsed
Definition: pbsamparm.h:108
VPUBLIC Vrc_Codes PBSAMparm_ctor2(PBSAMparm *thee, PBSAMparm_CalcType type)
FORTRAN stub to construct PBSAMparm object ?????????!!!!!!!
Definition: pbsamparm.c:77
VPUBLIC void PBSAMparm_dtor2(PBSAMparm *thee)
FORTRAN stub for object destructor ?????????!!!!!!!!!!!!
Definition: pbsamparm.c:108
VPRIVATE Vrc_Codes PBSAMparm_parseImat(PBSAMparm *thee, Vio *sock)
Find IMAT files for each molecule and save them.
Definition: pbsamparm.c:187
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 PBSAMparm * PBSAMparm_ctor(PBSAMparm_CalcType type)
Construct PBSAMparm object.
Definition: pbsamparm.c:66