APBS  1.5
nosh.c
Go to the documentation of this file.
1 
57 #include "nosh.h"
58 
59 VEMBED(rcsid="$Id$")
60 
61 
62 VPRIVATE int NOsh_parseREAD(
63  NOsh *thee,
64  Vio *sock);
65 
66 VPRIVATE int NOsh_parsePRINT(
67  NOsh *thee,
68  Vio *sock);
69 
70 VPRIVATE int NOsh_parseELEC(
71  NOsh *thee,
72  Vio *sock
73  );
74 
75 VPRIVATE int NOsh_parseAPOLAR(
76  NOsh *thee,
77  Vio *sock
78  );
79 
80 VEXTERNC int NOsh_parseFEM(
81  NOsh *thee,
82  Vio *sock,
83  NOsh_calc *elec
84  );
85 
86 VEXTERNC int NOsh_parseMG(
87  NOsh *thee,
88  Vio *sock,
89  NOsh_calc *elec
90  );
91 
92 VEXTERNC int NOsh_parseBEM(
93  NOsh *thee,
94  Vio *sock,
95  NOsh_calc *elec
96  );
97 
98 VEXTERNC int NOsh_parseGEOFLOW(
99  NOsh *thee,
100  Vio *sock,
101  NOsh_calc *elec
102  );
103 
104 VEXTERNC int NOsh_parsePBAM(
105  NOsh *thee,
106  Vio *sock,
107  NOsh_calc *elec
108  );
109 
110 VEXTERNC int NOsh_parsePBSAM(
111  NOsh *thee,
112  Vio *sock,
113  NOsh_calc *elec
114  );
115 
116 VEXTERNC int NOsh_parseAPOL(
117  NOsh *thee,
118  Vio *sock,
119  NOsh_calc *elec
120  );
121 
122 VPRIVATE int NOsh_setupCalcMG(
123  NOsh *thee,
124  NOsh_calc *elec
125  );
126 
127 
128 VPRIVATE int NOsh_setupCalcMGAUTO(
129  NOsh *thee,
130  NOsh_calc *elec
131  );
132 
133 VPRIVATE int NOsh_setupCalcMGMANUAL(
134  NOsh *thee,
135  NOsh_calc *elec
136  );
137 
138 VPRIVATE int NOsh_setupCalcMGPARA(
139  NOsh *thee,
140  NOsh_calc *elec
141  );
142 
143 VPRIVATE int NOsh_setupCalcFEM(
144  NOsh *thee,
145  NOsh_calc *elec
146  );
147 
148 VPRIVATE int NOsh_setupCalcFEMANUAL(
149  NOsh *thee,
150  NOsh_calc *elec
151  );
152 
153 VPRIVATE int NOsh_setupCalcBEM(
154  NOsh *thee,
155  NOsh_calc *elec
156  );
157 
158 VPRIVATE int NOsh_setupCalcGEOFLOW(
159  NOsh *thee,
160  NOsh_calc *elec
161  );
162 
163 VPRIVATE int NOsh_setupCalcPBAM(
164  NOsh *thee,
165  NOsh_calc *elec
166  );
167 
168 VPRIVATE int NOsh_setupCalcPBSAM(
169  NOsh *thee,
170  NOsh_calc *elec
171  );
172 
173 VPRIVATE int NOsh_setupCalcBEMMANUAL(
174  NOsh *thee,
175  NOsh_calc *elec
176  );
177 
178 VPRIVATE int NOsh_setupCalcGEOFLOWMANUAL(
179  NOsh *thee,
180  NOsh_calc *elec
181  );
182 
183 VPRIVATE int NOsh_setupCalcPBAMAUTO(
184  NOsh *thee,
185  NOsh_calc *elec
186  );
187 
188 VPRIVATE int NOsh_setupCalcPBSAMAUTO(
189  NOsh *thee,
190  NOsh_calc *elec
191  );
192 
193 VPRIVATE int NOsh_setupCalcAPOL(
194  NOsh *thee,
195  NOsh_calc *elec
196  );
197 
198 #if !defined(VINLINE_NOSH)
199 
200 VPUBLIC char* NOsh_getMolpath(NOsh *thee, int imol) {
201  VASSERT(thee != VNULL);
202  VASSERT(imol < thee->nmol);
203  return thee->molpath[imol];
204 }
205 VPUBLIC char* NOsh_getDielXpath(NOsh *thee, int imol) {
206  VASSERT(thee != VNULL);
207  VASSERT(imol < thee->nmol);
208  return thee->dielXpath[imol];
209 }
210 VPUBLIC char* NOsh_getDielYpath(NOsh *thee, int imol) {
211  VASSERT(thee != VNULL);
212  VASSERT(imol < thee->nmol);
213  return thee->dielYpath[imol];
214 }
215 VPUBLIC char* NOsh_getDielZpath(NOsh *thee, int imol) {
216  VASSERT(thee != VNULL);
217  VASSERT(imol < thee->nmol);
218  return thee->dielZpath[imol];
219 }
220 VPUBLIC char* NOsh_getKappapath(NOsh *thee, int imol) {
221  VASSERT(thee != VNULL);
222  VASSERT(imol < thee->nmol);
223  return thee->kappapath[imol];
224 }
225 VPUBLIC char* NOsh_getPotpath(NOsh *thee, int imol) {
226  VASSERT(thee != VNULL);
227  VASSERT(imol < thee->nmol);
228  return thee->potpath[imol];
229 }
230 VPUBLIC char* NOsh_getChargepath(NOsh *thee, int imol) {
231  VASSERT(thee != VNULL);
232  VASSERT(imol < thee->nmol);
233  return thee->chargepath[imol];
234 }
235 VPUBLIC NOsh_calc* NOsh_getCalc(NOsh *thee, int icalc) {
236  VASSERT(thee != VNULL);
237  VASSERT(icalc < thee->ncalc);
238  return thee->calc[icalc];
239 }
240 VPUBLIC int NOsh_getDielfmt(NOsh *thee, int i) {
241  VASSERT(thee != VNULL);
242  VASSERT(i < thee->ndiel);
243  return (thee->dielfmt[i]);
244 }
245 VPUBLIC int NOsh_getKappafmt(NOsh *thee, int i) {
246  VASSERT(thee != VNULL);
247  VASSERT(i < thee->nkappa);
248  return (thee->kappafmt[i]);
249 }
250 VPUBLIC int NOsh_getPotfmt(NOsh *thee, int i) {
251  VASSERT(thee != VNULL);
252  VASSERT(i < thee->npot);
253  return (thee->potfmt[i]);
254 }
255 VPUBLIC int NOsh_getChargefmt(NOsh *thee, int i) {
256  VASSERT(thee != VNULL);
257  VASSERT(i < thee->ncharge);
258  return (thee->chargefmt[i]);
259 }
260 
261 
262 #endif /* if !defined(VINLINE_NOSH) */
263 
264 VPUBLIC NOsh_PrintType NOsh_printWhat(NOsh *thee, int iprint) {
265  VASSERT(thee != VNULL);
266  VASSERT(iprint < thee->nprint);
267  return thee->printwhat[iprint];
268 }
269 
270 VPUBLIC int NOsh_printNarg(NOsh *thee, int iprint) {
271  VASSERT(thee != VNULL);
272  VASSERT(iprint < thee->nprint);
273  return thee->printnarg[iprint];
274 }
275 
276 VPUBLIC int NOsh_elec2calc(NOsh *thee, int icalc) {
277  VASSERT(thee != VNULL);
278  VASSERT(icalc < thee->ncalc);
279  return thee->elec2calc[icalc];
280 }
281 
282 VPUBLIC int NOsh_apol2calc(NOsh *thee, int icalc) {
283  VASSERT(thee != VNULL);
284  VASSERT(icalc < thee->ncalc);
285  return thee->apol2calc[icalc];
286 }
287 
288 VPUBLIC char* NOsh_elecname(NOsh *thee, int ielec) {
289  VASSERT(thee != VNULL);
290  VASSERT(ielec < thee->nelec + 1);
291  return thee->elecname[ielec];
292 }
293 
294 VPUBLIC int NOsh_printOp(NOsh *thee, int iprint, int iarg) {
295  VASSERT(thee != VNULL);
296  VASSERT(iprint < thee->nprint);
297  VASSERT(iarg < thee->printnarg[iprint]);
298  return thee->printop[iprint][iarg];
299 }
300 
301 VPUBLIC int NOsh_printCalc(NOsh *thee, int iprint, int iarg) {
302  VASSERT(thee != VNULL);
303  VASSERT(iprint < thee->nprint);
304  VASSERT(iarg < thee->printnarg[iprint]);
305  return thee->printcalc[iprint][iarg];
306 }
307 
308 VPUBLIC NOsh* NOsh_ctor(int rank, int size) {
309 
310  /* Set up the structure */
311  NOsh *thee = VNULL;
312  thee = (NOsh*)Vmem_malloc(VNULL, 1, sizeof(NOsh) );
313  VASSERT( thee != VNULL);
314  VASSERT( NOsh_ctor2(thee, rank, size) );
315 
316  return thee;
317 }
318 
319 VPUBLIC int NOsh_ctor2(NOsh *thee, int rank, int size) {
320 
321  int i;
322 
323  if (thee == VNULL) return 0;
324 
325  thee->proc_rank = rank;
326  thee->proc_size = size;
327 
328  thee->ispara = 0;
329  thee->parsed = 0;
330 
331  thee->nmol = 0;
332  thee->gotparm = 0;
333  thee->ncharge = 0;
334  thee->ndiel = 0;
335  thee->nkappa = 0;
336  thee->npot = 0;
337  thee->nprint = 0;
338 
339  for (i=0; i<NOSH_MAXCALC; i++) {
340  thee->calc[i] = VNULL;
341  thee->elec[i] = VNULL;
342  thee->apol[i] = VNULL;
343  }
344  for (i=0; i<NOSH_MAXMOL; i++) {
345  thee->alist[i] = VNULL;
346  }
347  thee->ncalc = 0;
348  thee->nelec = 0;
349  thee->napol = 0;
350 
351  return 1;
352 }
353 
354 VPUBLIC void NOsh_dtor(NOsh **thee) {
355  if ((*thee) != VNULL) {
356  NOsh_dtor2(*thee);
357  Vmem_free(VNULL, 1, sizeof(NOsh), (void **)thee);
358  (*thee) = VNULL;
359  }
360 }
361 
362 VPUBLIC void NOsh_dtor2(NOsh *thee) {
363 
364  int i;
365 
366  if (thee != VNULL) {
367  for (i=0; i<(thee->ncalc); i++) NOsh_calc_dtor(&(thee->calc[i]));
368  for (i=0; i<(thee->nelec); i++) NOsh_calc_dtor(&(thee->elec[i]));
369  for (i=0; i<(thee->napol); i++) NOsh_calc_dtor(&(thee->apol[i]));
370  }
371 
372 }
373 
375  NOsh_CalcType calctype
376  ) {
377  NOsh_calc *thee;
378  thee = (NOsh_calc *)Vmem_malloc(VNULL, 1, sizeof(NOsh_calc));
379  thee->calctype = calctype;
380 
381  thee->mgparm = VNULL;
382  thee->femparm = VNULL;
383  thee->apolparm = VNULL;
384  thee->bemparm = VNULL;
385  thee->geoflowparm = VNULL;
386  thee->pbamparm = VNULL;
387  thee->pbsamparm = VNULL;
388 
389  switch (calctype) {
390  case NCT_MG:
391  thee->mgparm = MGparm_ctor(MCT_NONE);
392  break;
393  case NCT_FEM:
394  thee->femparm = FEMparm_ctor(FCT_NONE);
395  break;
396  case NCT_APOL:
397  thee->apolparm = APOLparm_ctor();
398  break;
399  case NCT_BEM:
401  break;
402  case NCT_GEOFLOW:
404  thee->apolparm = APOLparm_ctor();
405  break;
406  case NCT_PBAM:
408  break;
409  case NCT_PBSAM:
412  break;
413  default:
414  Vnm_print(2, "NOsh_calc_ctor: unknown calculation type (%d)!\n",
415  calctype);
416  VASSERT(0);
417  }
418  thee->pbeparm = PBEparm_ctor();
419 
420  return thee;
421 }
422 
423 VPUBLIC void NOsh_calc_dtor(
424  NOsh_calc **thee
425  ) {
426 
427  NOsh_calc *calc = VNULL;
428  calc = *thee;
429  if (calc == VNULL) return;
430 
431  switch (calc->calctype) {
432  case NCT_MG:
433  MGparm_dtor(&(calc->mgparm));
434  break;
435  case NCT_FEM:
436  FEMparm_dtor(&(calc->femparm));
437  break;
438  case NCT_APOL:
439  APOLparm_dtor(&(calc->apolparm));
440  break;
441  case NCT_BEM:
442  BEMparm_dtor(&(calc->bemparm));
443  break;
444  case NCT_GEOFLOW:
445  GEOFLOWparm_dtor(&(calc->geoflowparm));
446  APOLparm_dtor(&(calc->apolparm));
447  break;
448  case NCT_PBAM:
449  PBAMparm_dtor(&(calc->pbamparm));
450  break;
451  case NCT_PBSAM:
452  PBAMparm_dtor(&(calc->pbamparm));
453  PBSAMparm_dtor(&(calc->pbsamparm));
454  break;
455  default:
456  Vnm_print(2, "NOsh_calc_ctor: unknown calculation type (%d)!\n",
457  calc->calctype);
458  VASSERT(0);
459  }
460  PBEparm_dtor(&(calc->pbeparm));
461 
462  Vmem_free(VNULL, 1, sizeof(NOsh_calc), (void **)thee);
463  calc = VNULL;
464 
465 }
466 
467 VPUBLIC int NOsh_calc_copy(
468  NOsh_calc *thee,
469  NOsh_calc *source
470  ) {
471 
472  VASSERT(thee != VNULL);
473  VASSERT(source != VNULL);
474  VASSERT(thee->calctype == source->calctype);
475  if (source->mgparm != VNULL)
476  MGparm_copy(thee->mgparm, source->mgparm);
477  if (source->femparm != VNULL)
478  FEMparm_copy(thee->femparm, source->femparm);
479  if (source->bemparm != VNULL)
480  BEMparm_copy(thee->bemparm, source->bemparm);
481  if (source->pbeparm != VNULL)
482  PBEparm_copy(thee->pbeparm, source->pbeparm);
483  if (source->apolparm != VNULL)
484  APOLparm_copy(thee->apolparm, source->apolparm);
485  /*I think here is where the the geoflow changes get lost*/
486  if(source->geoflowparm != VNULL)
487  GEOFLOWparm_copy(thee->geoflowparm, source->geoflowparm);
488  if(source->pbamparm != VNULL)
489  PBAMparm_copy(thee->pbamparm, source->pbamparm);
490  if(source->pbsamparm != VNULL)
491  PBSAMparm_copy(thee->pbsamparm, source->pbsamparm);
492 
493 
494  return 1;
495 
496 }
497 
499  NOsh *thee,
500  char *filename
501  ) {
502 
503  Vio *sock;
504  int rc;
505 
506  sock = Vio_ctor("FILE", "ASC", VNULL, filename, "r");
507  rc = NOsh_parseInput(thee, sock);
508  Vio_dtor(&sock);
509 
510  return rc;
511 }
512 
513 VPUBLIC int NOsh_parseInput(
514  NOsh *thee,
515  Vio *sock
516  ) {
517 
518  char *MCwhiteChars = " =,;\t\r\n";
519  char *MCcommChars = "#%";
520  char tok[VMAX_BUFSIZE];
521 
522  if (thee == VNULL) {
523  Vnm_print(2, "NOsh_parseInput: Got NULL thee!\n");
524  return 0;
525  }
526 
527  if (sock == VNULL) {
528  Vnm_print(2, "NOsh_parseInput: Got pointer to NULL socket!\n");
529  Vnm_print(2, "NOsh_parseInput: The specified input file was not found!\n");
530  return 0;
531  }
532 
533  if (thee->parsed) {
534  Vnm_print(2, "NOsh_parseInput: Already parsed an input file!\n");
535  return 0;
536  }
537 
538  if (Vio_accept(sock, 0) < 0) {
539  Vnm_print(2, "NOsh_parseInput: Problem reading from socket!\n");
540  return 0;
541  }
542 
543  /* Set up the whitespace and comment character definitions */
544  Vio_setWhiteChars(sock, MCwhiteChars);
545  Vio_setCommChars(sock, MCcommChars);
546 
547  /* We parse the file until we run out of tokens */
548  Vnm_print(0, "NOsh_parseInput: Starting file parsing...\n");
549  while (Vio_scanf(sock, "%s", tok) == 1) {
550  /* At the highest level, we look for keywords that indicate functions like:
551 
552  read => Read in a molecule file
553  elec => Do an electrostatics calculation
554  print => Print some results
555  apolar => do a non-polar calculation
556  quit => Quit
557 
558  These cause the code to go to a lower-level parser routine which
559  handles keywords specific to the particular function. Each
560  lower-level parser routine then returns when it hits the "end"
561  keyword. Due to this simple layout, no nesting of these "function"
562  sections is allowed.
563  */
564  if (Vstring_strcasecmp(tok, "read") == 0) {
565  printf("read\n");
566  Vnm_print(0, "NOsh: Parsing READ section\n");
567  if (!NOsh_parseREAD(thee, sock)) return 0;
568  Vnm_print(0, "NOsh: Done parsing READ section \
569 (nmol=%d, ndiel=%d, nkappa=%d, ncharge=%d, npot=%d)\n", thee->nmol, thee->ndiel,
570  thee->nkappa, thee->ncharge,thee->npot);
571  } else if (Vstring_strcasecmp(tok, "print") == 0) {
572  Vnm_print(0, "NOsh: Parsing PRINT section\n");
573  if (!NOsh_parsePRINT(thee, sock)) return 0;
574  Vnm_print(0, "NOsh: Done parsing PRINT section\n");
575  } else if (Vstring_strcasecmp(tok, "elec") == 0) {
576  Vnm_print(0, "NOsh: Parsing ELEC section\n");
577  if (!NOsh_parseELEC(thee, sock)) return 0;
578  Vnm_print(0, "NOsh: Done parsing ELEC section (nelec = %d)\n",
579  thee->nelec);
580  } else if (Vstring_strcasecmp(tok, "apolar") == 0) {
581  Vnm_print(0, "NOsh: Parsing APOLAR section\n");
582  if (!NOsh_parseAPOLAR(thee, sock)) return 0;
583  Vnm_print(0, "NOsh: Done parsing APOLAR section (nelec = %d)\n",
584  thee->nelec);
585  } else if (Vstring_strcasecmp(tok, "quit") == 0) {
586  Vnm_print(0, "NOsh: Done parsing file (got QUIT)\n");
587  break;
588  } else {
589  Vnm_print(2, "NOsh_parseInput: Ignoring undefined keyword %s!\n", tok);
590  }
591  }
592 
593  thee->parsed = 1;
594  return 1;
595 
596 }
597 
598 VPRIVATE int NOsh_parseREAD_MOL(NOsh *thee, Vio *sock) {
599 
600  char tok[VMAX_BUFSIZE], str[VMAX_BUFSIZE]="", strnew[VMAX_BUFSIZE]="";
601  NOsh_MolFormat molfmt;
602 
603  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
604  if (Vstring_strcasecmp(tok, "pqr") == 0) {
605  molfmt = NMF_PQR;
606  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
607  if (tok[0]=='"') {
608  strcpy(strnew, "");
609  while (tok[strlen(tok)-1] != '"') {
610  strcat(str, tok);
611  strcat(str, " ");
612  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
613  }
614  strcat(str, tok);
615  strncpy(strnew, str+1, strlen(str)-2);
616  strcpy(tok, strnew);
617  }
618  Vnm_print(0, "NOsh: Storing molecule %d path %s\n",
619  thee->nmol, tok);
620  thee->molfmt[thee->nmol] = molfmt;
621  strncpy(thee->molpath[thee->nmol], tok, VMAX_ARGLEN);
622  (thee->nmol)++;
623  } else if (Vstring_strcasecmp(tok, "pdb") == 0) {
624  molfmt = NMF_PDB;
625  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
626  if (tok[0]=='"') {
627  strcpy(strnew, "");
628  while (tok[strlen(tok)-1] != '"') {
629  strcat(str, tok);
630  strcat(str, " ");
631  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
632  }
633  strcat(str, tok);
634  strncpy(strnew, str+1, strlen(str)-2);
635  strcpy(tok, strnew);
636  }
637  Vnm_print(0, "NOsh: Storing molecule %d path %s\n",
638  thee->nmol, tok);
639  thee->molfmt[thee->nmol] = molfmt;
640  strncpy(thee->molpath[thee->nmol], tok, VMAX_ARGLEN);
641  (thee->nmol)++;
642  } else if (Vstring_strcasecmp(tok, "xml") == 0) {
643  molfmt = NMF_XML;
644  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
645  if (tok[0]=='"') {
646  strcpy(strnew, "");
647  while (tok[strlen(tok)-1] != '"') {
648  strcat(str, tok);
649  strcat(str, " ");
650  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
651  }
652  strcat(str, tok);
653  strncpy(strnew, str+1, strlen(str)-2);
654  strcpy(tok, strnew);
655  }
656  Vnm_print(0, "NOsh: Storing molecule %d path %s\n",
657  thee->nmol, tok);
658  thee->molfmt[thee->nmol] = molfmt;
659  strncpy(thee->molpath[thee->nmol], tok, VMAX_ARGLEN);
660  (thee->nmol)++;
661  } else {
662  Vnm_print(2, "NOsh_parseREAD: Ignoring undefined mol format \
663 %s!\n", tok);
664  }
665 
666  return 1;
667 
668 
669 VERROR1:
670  Vnm_print(2, "NOsh_parseREAD_MOL: Ran out of tokens while parsing READ section!\n");
671  return 0;
672 
673 }
674 
675 VPRIVATE int NOsh_parseREAD_PARM(NOsh *thee, Vio *sock) {
676 
677  char tok[VMAX_BUFSIZE], str[VMAX_BUFSIZE]="", strnew[VMAX_BUFSIZE]="";
678  NOsh_ParmFormat parmfmt;
679 
680  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
681  if (Vstring_strcasecmp(tok, "flat") == 0) {
682  parmfmt = NPF_FLAT;
683  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
684  if (tok[0]=='"') {
685  strcpy(strnew, "");
686  while (tok[strlen(tok)-1] != '"') {
687  strcat(str, tok);
688  strcat(str, " ");
689  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
690  }
691  strcat(str, tok);
692  strncpy(strnew, str+1, strlen(str)-2);
693  strcpy(tok, strnew);
694  }
695  if (thee->gotparm) {
696  Vnm_print(2, "NOsh: Hey! You already specified a parameterfile (%s)!\n", thee->parmpath);
697  Vnm_print(2, "NOsh: I'm going to ignore this one (%s)!\n", tok);
698  } else {
699  thee->parmfmt = parmfmt;
700  thee->gotparm = 1;
701  strncpy(thee->parmpath, tok, VMAX_ARGLEN);
702  }
703  } else if(Vstring_strcasecmp(tok, "xml") == 0) {
704  parmfmt = NPF_XML;
705  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
706  if (tok[0]=='"') {
707  strcpy(strnew, "");
708  while (tok[strlen(tok)-1] != '"') {
709  strcat(str, tok);
710  strcat(str, " ");
711  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
712  }
713  strcat(str, tok);
714  strncpy(strnew, str+1, strlen(str)-2);
715  strcpy(tok, strnew);
716  }
717  if (thee->gotparm) {
718  Vnm_print(2, "NOsh: Hey! You already specified a parameterfile (%s)!\n", thee->parmpath);
719  Vnm_print(2, "NOsh: I'm going to ignore this one (%s)!\n", tok);
720  } else {
721  thee->parmfmt = parmfmt;
722  thee->gotparm = 1;
723  strncpy(thee->parmpath, tok, VMAX_ARGLEN);
724  }
725 
726  } else {
727  Vnm_print(2, "NOsh_parseREAD: Ignoring undefined parm format \
728 %s!\n", tok);
729  }
730 
731  return 1;
732 
733 VERROR1:
734  Vnm_print(2, "NOsh_parseREAD_PARM: Ran out of tokens while parsing READ section!\n");
735  return 0;
736 
737 }
738 
739 VPRIVATE int NOsh_parseREAD_DIEL(NOsh *thee, Vio *sock) {
740 
741  char tok[VMAX_BUFSIZE], str[VMAX_BUFSIZE]="", strnew[VMAX_BUFSIZE]="";
742  Vdata_Format dielfmt;
743 
744  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
745  if (Vstring_strcasecmp(tok, "dx") == 0) {
746  dielfmt = VDF_DX;
747  //added VDF_BIN to take binary files.
748  } else if (Vstring_strcasecmp(tok, "dxbin") == 0){
749  dielfmt = VDF_DXBIN;
750  }else if (Vstring_strcasecmp(tok, "gz") == 0) {
751  dielfmt = VDF_GZ;
752  } else {
753  Vnm_print(2, "NOsh_parseREAD: Ignoring undefined format \
754  %s!\n", tok);
755  return VRC_FAILURE;
756  }
757 
758  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
759  if (tok[0]=='"') {
760  strcpy(strnew, "");
761  while (tok[strlen(tok)-1] != '"') {
762  strcat(str, tok);
763  strcat(str, " ");
764  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
765  }
766  strcat(str, tok);
767  strncpy(strnew, str+1, strlen(str)-2);
768  strcpy(tok, strnew);
769  }
770  Vnm_print(0, "NOsh: Storing x-shifted dielectric map %d path \
771  %s\n", thee->ndiel, tok);
772  strncpy(thee->dielXpath[thee->ndiel], tok, VMAX_ARGLEN);
773  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
774  Vnm_print(0, "NOsh: Storing y-shifted dielectric map %d path \
775  %s\n", thee->ndiel, tok);
776  strncpy(thee->dielYpath[thee->ndiel], tok, VMAX_ARGLEN);
777  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
778  Vnm_print(0, "NOsh: Storing z-shifted dielectric map %d path \
779  %s\n", thee->ndiel, tok);
780  strncpy(thee->dielZpath[thee->ndiel], tok, VMAX_ARGLEN);
781  thee->dielfmt[thee->ndiel] = dielfmt;
782  (thee->ndiel)++;
783 
784  return 1;
785 
786 VERROR1:
787  Vnm_print(2, "NOsh_parseREAD_DIEL: Ran out of tokens while parsing READ \
788 section!\n");
789  return 0;
790 
791 }
792 
793 VPRIVATE int NOsh_parseREAD_KAPPA(NOsh *thee, Vio *sock) {
794 
795  char tok[VMAX_BUFSIZE], str[VMAX_BUFSIZE]="", strnew[VMAX_BUFSIZE]="";
796  Vdata_Format kappafmt;
797 
798  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
799  if (Vstring_strcasecmp(tok, "dx") == 0) {
800  kappafmt = VDF_DX;
801  } else if (Vstring_strcasecmp(tok, "gz") == 0) {
802  kappafmt = VDF_GZ;
803  } else if (Vstring_strcasecmp(tok,"dxbin") == 0) {
804  kappafmt = VDF_DXBIN;
805  } else {
806 
807  Vnm_print(2, "NOsh_parseREAD: Ignoring undefined format \
808  %s!\n", tok);
809  return VRC_FAILURE;
810  }
811 
812  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
813  if (tok[0]=='"') {
814  strcpy(strnew, "");
815  while (tok[strlen(tok)-1] != '"') {
816  strcat(str, tok);
817  strcat(str, " ");
818  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
819  }
820  strcat(str, tok);
821  strncpy(strnew, str+1, strlen(str)-2);
822  strcpy(tok, strnew);
823  }
824  Vnm_print(0, "NOsh: Storing kappa map %d path %s\n",
825  thee->nkappa, tok);
826  thee->kappafmt[thee->nkappa] = kappafmt;
827  strncpy(thee->kappapath[thee->nkappa], tok, VMAX_ARGLEN);
828  (thee->nkappa)++;
829 
830  return 1;
831 
832 VERROR1:
833  Vnm_print(2, "NOsh_parseREAD: Ran out of tokens while parsing READ \
834 section!\n");
835  return 0;
836 
837 }
838 
839 VPRIVATE int NOsh_parseREAD_POTENTIAL(NOsh *thee, Vio *sock) {
840 
841  char tok[VMAX_BUFSIZE], str[VMAX_BUFSIZE]="", strnew[VMAX_BUFSIZE]="";
842  Vdata_Format potfmt;
843 
844  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
845  if (Vstring_strcasecmp(tok, "dx") == 0) {
846  potfmt = VDF_DX;
847  } else if (Vstring_strcasecmp(tok, "gz") == 0) {
848  potfmt = VDF_GZ;
849  } else if(Vstring_strcasecmp(tok, "dxbin") == 0){
850  potfmt = VDF_DXBIN;
851  } else {
852  Vnm_print(2, "NOsh_parseREAD: Ignoring undefined format \
853  %s!\n", tok);
854  return VRC_FAILURE;
855  }
856 
857  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
858  if (tok[0]=='"') {
859  strcpy(strnew, "");
860  while (tok[strlen(tok)-1] != '"') {
861  strcat(str, tok);
862  strcat(str, " ");
863  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
864  }
865  strcat(str, tok);
866  strncpy(strnew, str+1, strlen(str)-2);
867  strcpy(tok, strnew);
868  }
869  Vnm_print(0, "NOsh: Storing potential map %d path %s\n",
870  thee->npot, tok);
871  thee->potfmt[thee->npot] = potfmt;
872  strncpy(thee->potpath[thee->npot], tok, VMAX_ARGLEN);
873  (thee->npot)++;
874 
875  return 1;
876 
877 VERROR1:
878  Vnm_print(2, "NOsh_parseREAD: Ran out of tokens while parsing READ \
879  section!\n");
880  return 0;
881 
882 }
883 
884 VPRIVATE int NOsh_parseREAD_CHARGE(NOsh *thee, Vio *sock) {
885 
886  char tok[VMAX_BUFSIZE], str[VMAX_BUFSIZE]="", strnew[VMAX_BUFSIZE]="";
887  Vdata_Format chargefmt;
888 
889  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
890  if (Vstring_strcasecmp(tok, "dx") == 0) {
891  chargefmt = VDF_DX;
892  }
893  else if(Vstring_strcasecmp(tok, "dxbin") == 0){
894  chargefmt = VDF_DXBIN;
895  }else if (Vstring_strcasecmp(tok, "gz") == 0) {
896  chargefmt = VDF_GZ;
897  } else {
898  Vnm_print(2, "NOsh_parseREAD: Ignoring undefined format \
899  %s!\n", tok);
900  return VRC_FAILURE;
901  }
902 
903  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
904  if (tok[0]=='"') {
905  strcpy(strnew, "");
906  while (tok[strlen(tok)-1] != '"') {
907  strcat(str, tok);
908  strcat(str, " ");
909  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
910  }
911  strcat(str, tok);
912  strncpy(strnew, str+1, strlen(str)-2);
913  strcpy(tok, strnew);
914  }
915  Vnm_print(0, "NOsh: Storing charge map %d path %s\n",
916  thee->ncharge, tok);
917  thee->chargefmt[thee->ncharge] = chargefmt;
918  strncpy(thee->chargepath[thee->ncharge], tok, VMAX_ARGLEN);
919  (thee->ncharge)++;
920 
921  return 1;
922 
923 VERROR1:
924  Vnm_print(2, "NOsh_parseREAD: Ran out of tokens while parsing READ \
925 section!\n");
926  return 0;
927 
928 }
929 
930 VPRIVATE int NOsh_parseREAD_MESH(NOsh *thee, Vio *sock) {
931 
932  char tok[VMAX_BUFSIZE], str[VMAX_BUFSIZE]="", strnew[VMAX_BUFSIZE]="";
933  Vdata_Format meshfmt;
934 
935  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
936  if (Vstring_strcasecmp(tok, "mcsf") == 0) {
937  meshfmt = VDF_MCSF;
938  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
939  if (tok[0]=='"') {
940  strcpy(strnew, "");
941  while (tok[strlen(tok)-1] != '"') {
942  strcat(str, tok);
943  strcat(str, " ");
944  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
945  }
946  strcat(str, tok);
947  strncpy(strnew, str+1, strlen(str)-2);
948  strcpy(tok, strnew);
949  }
950  Vnm_print(0, "NOsh: Storing mesh %d path %s\n",
951  thee->nmesh, tok);
952  thee->meshfmt[thee->nmesh] = meshfmt;
953  strncpy(thee->meshpath[thee->nmesh], tok, VMAX_ARGLEN);
954  (thee->nmesh)++;
955  } else {
956  Vnm_print(2, "NOsh_parseREAD: Ignoring undefined mesh format \
957  %s!\n", tok);
958  }
959 
960  return 1;
961 
962 VERROR1:
963  Vnm_print(2, "NOsh_parseREAD: Ran out of tokens while parsing READ \
964  section!\n");
965  return 0;
966 
967 }
968 
969 
970 VPRIVATE int NOsh_parseREAD(NOsh *thee, Vio *sock) {
971 
972  char tok[VMAX_BUFSIZE];
973 
974  if (thee == VNULL) {
975  Vnm_print(2, "NOsh_parseREAD: Got NULL thee!\n");
976  return 0;
977  }
978 
979  if (sock == VNULL) {
980  Vnm_print(2, "NOsh_parseREAD: Got pointer to NULL socket!\n");
981  return 0;
982  }
983 
984  if (thee->parsed) {
985  Vnm_print(2, "NOsh_parseREAD: Already parsed an input file!\n");
986  return 0;
987  }
988 
989  /* Read until we run out of tokens (bad) or hit the "END" keyword (good) */
990  while (Vio_scanf(sock, "%s", tok) == 1) {
991  if (Vstring_strcasecmp(tok, "end") == 0) {
992  Vnm_print(0, "NOsh: Done parsing READ section\n");
993  return 1;
994  } else if (Vstring_strcasecmp(tok, "mol") == 0) {
995  NOsh_parseREAD_MOL(thee, sock);
996  } else if (Vstring_strcasecmp(tok, "parm") == 0) {
997  NOsh_parseREAD_PARM(thee,sock);
998  } else if (Vstring_strcasecmp(tok, "diel") == 0) {
999  NOsh_parseREAD_DIEL(thee,sock);
1000  } else if (Vstring_strcasecmp(tok, "kappa") == 0) {
1001  NOsh_parseREAD_KAPPA(thee,sock);
1002  } else if (Vstring_strcasecmp(tok, "pot") == 0) {
1003  NOsh_parseREAD_POTENTIAL(thee,sock);
1004  } else if (Vstring_strcasecmp(tok, "charge") == 0) {
1005  NOsh_parseREAD_CHARGE(thee,sock);
1006  } else if (Vstring_strcasecmp(tok, "mesh") == 0) {
1007  NOsh_parseREAD_MESH(thee,sock);
1008  } else {
1009  Vnm_print(2, "NOsh_parseREAD: Ignoring undefined keyword %s!\n",
1010  tok);
1011  }
1012  }
1013 
1014  /* We ran out of tokens! */
1015  Vnm_print(2, "NOsh_parseREAD: Ran out of tokens while parsing READ \
1016 section!\n");
1017  return 0;
1018 
1019 }
1020 
1021 VPRIVATE int NOsh_parsePRINT(NOsh *thee, Vio *sock) {
1022 
1023  char tok[VMAX_BUFSIZE];
1024  char name[VMAX_BUFSIZE];
1025  int ti, idx, expect, ielec, iapol;
1026 
1027  if (thee == VNULL) {
1028  Vnm_print(2, "NOsh_parsePRINT: Got NULL thee!\n");
1029  return 0;
1030  }
1031 
1032  if (sock == VNULL) {
1033  Vnm_print(2, "NOsh_parsePRINT: Got pointer to NULL socket!\n");
1034  return 0;
1035  }
1036 
1037  if (thee->parsed) {
1038  Vnm_print(2, "NOsh_parsePRINT: Already parsed an input file!\n");
1039  return 0;
1040  }
1041 
1042  idx = thee->nprint;
1043  if (thee->nprint >= NOSH_MAXPRINT) {
1044  Vnm_print(2, "NOsh_parsePRINT: Exceeded max number (%d) of PRINT \
1045 sections\n",
1046  NOSH_MAXPRINT);
1047  return 0;
1048  }
1049 
1050 
1051  /* The first thing we read is the thing we want to print */
1052  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
1053  if (Vstring_strcasecmp(tok, "energy") == 0) {
1054  thee->printwhat[idx] = NPT_ENERGY;
1055  thee->printnarg[idx] = 0;
1056  } else if (Vstring_strcasecmp(tok, "force") == 0) {
1057  thee->printwhat[idx] = NPT_FORCE;
1058  thee->printnarg[idx] = 0;
1059  } else if (Vstring_strcasecmp(tok, "elecEnergy") == 0) {
1060  thee->printwhat[idx] = NPT_ELECENERGY;
1061  thee->printnarg[idx] = 0;
1062  } else if (Vstring_strcasecmp(tok, "elecForce") == 0) {
1063  thee->printwhat[idx] = NPT_ELECFORCE;
1064  thee->printnarg[idx] = 0;
1065  } else if (Vstring_strcasecmp(tok, "apolEnergy") == 0) {
1066  thee->printwhat[idx] = NPT_APOLENERGY;
1067  thee->printnarg[idx] = 0;
1068  } else if (Vstring_strcasecmp(tok, "apolForce") == 0) {
1069  thee->printwhat[idx] = NPT_APOLFORCE;
1070  thee->printnarg[idx] = 0;
1071  } else {
1072  Vnm_print(2, "NOsh_parsePRINT: Undefined keyword %s while parsing \
1073 PRINT section!\n", tok);
1074  return 0;
1075  }
1076 
1077  expect = 0; /* We first expect a calculation ID (0) then an op (1) */
1078 
1079  /* Read until we run out of tokens (bad) or hit the "END" keyword (good) */
1080  while (Vio_scanf(sock, "%s", tok) == 1) {
1081 
1082  /* The next thing we read is either END or an ARG OP ARG statement */
1083  if (Vstring_strcasecmp(tok, "end") == 0) {
1084  if (expect != 0) {
1085  (thee->nprint)++;
1086  (thee->printnarg[idx])++;
1087  Vnm_print(0, "NOsh: Done parsing PRINT section\n");
1088  return 1;
1089  } else {
1090  Vnm_print(2, "NOsh_parsePRINT: Got premature END to PRINT!\n");
1091  return 0;
1092  }
1093  } else {
1094 
1095  /* Grab a calculation ID */
1096  if ((sscanf(tok, "%d", &ti) == 1) &&
1097  (Vstring_isdigit(tok) == 1)) {
1098  if (expect == 0) {
1099  thee->printcalc[idx][thee->printnarg[idx]] = ti-1;
1100  expect = 1;
1101  } else {
1102  Vnm_print(2, "NOsh_parsePRINT: Syntax error in PRINT \
1103 section while reading %s!\n", tok);
1104  return 0;
1105  }
1106  /* Grab addition operation */
1107  } else if (Vstring_strcasecmp(tok, "+") == 0) {
1108  if (expect == 1) {
1109  thee->printop[idx][thee->printnarg[idx]] = 0;
1110  (thee->printnarg[idx])++;
1111  expect = 0;
1112  if (thee->printnarg[idx] >= NOSH_MAXPOP) {
1113  Vnm_print(2, "NOsh_parsePRINT: Exceeded max number \
1114 (%d) of arguments for PRINT section!\n",
1115  NOSH_MAXPOP);
1116  return 0;
1117  }
1118  } else {
1119  Vnm_print(2, "NOsh_parsePRINT: Syntax error in PRINT \
1120 section while reading %s!\n", tok);
1121  return 0;
1122  }
1123  /* Grab subtraction operation */
1124  } else if (Vstring_strcasecmp(tok, "-") == 0) {
1125  if (expect == 1) {
1126  thee->printop[idx][thee->printnarg[idx]] = 1;
1127  (thee->printnarg[idx])++;
1128  expect = 0;
1129  if (thee->printnarg[idx] >= NOSH_MAXPOP) {
1130  Vnm_print(2, "NOsh_parseREAD: Exceeded max number \
1131 (%d) of arguments for PRINT section!\n",
1132  NOSH_MAXPOP);
1133  return 0;
1134  }
1135  } else {
1136  Vnm_print(2, "NOsh_parsePRINT: Syntax error in PRINT \
1137 section while reading %s!\n", tok);
1138  return 0;
1139  }
1140  /* Grab a calculation name from elec ID */
1141  } else if (sscanf(tok, "%s", name) == 1) {
1142  if (expect == 0) {
1143  for (ielec=0; ielec<thee->nelec; ielec++) {
1144  if (Vstring_strcasecmp(thee->elecname[ielec], name) == 0) {
1145  thee->printcalc[idx][thee->printnarg[idx]] = ielec;
1146  expect = 1;
1147  break;
1148  }
1149  }
1150  for (iapol=0; iapol<thee->napol; iapol++) {
1151  if (Vstring_strcasecmp(thee->apolname[iapol], name) == 0) {
1152  thee->printcalc[idx][thee->printnarg[idx]] = iapol;
1153  expect = 1;
1154  break;
1155  }
1156  }
1157  if (expect == 0) {
1158  Vnm_print(2, "No ELEC or APOL statement has been named %s!\n",
1159  name);
1160  return 0;
1161  }
1162  } else {
1163  Vnm_print(2, "NOsh_parsePRINT: Syntax error in PRINT \
1164 section while reading %s!\n", tok);
1165  return 0;
1166  }
1167  /* Got bad operation */
1168  } else {
1169  Vnm_print(2, "NOsh_parsePRINT: Undefined keyword %s while \
1170 parsing PRINT section!\n", tok);
1171  return 0;
1172  }
1173  } /* end parse token */
1174 
1175  } /* end while */
1176 
1177  VJMPERR1(0);
1178 
1179  /* We ran out of tokens! */
1180 VERROR1:
1181  Vnm_print(2, "NOsh_parsePRINT: Ran out of tokens while parsing PRINT \
1182 section!\n");
1183  return 0;
1184 
1185 }
1186 
1187 VPRIVATE int NOsh_parseELEC(NOsh *thee, Vio *sock) {
1188 
1189  NOsh_calc *calc = VNULL;
1190 
1191  char tok[VMAX_BUFSIZE];
1192 
1193  if (thee == VNULL) {
1194  Vnm_print(2, "NOsh_parseELEC: Got NULL thee!\n");
1195  return 0;
1196  }
1197 
1198  if (sock == VNULL) {
1199  Vnm_print(2, "NOsh_parseELEC: Got pointer to NULL socket!\n");
1200  return 0;
1201  }
1202 
1203  if (thee->parsed) {
1204  Vnm_print(2, "NOsh_parseELEC: Already parsed an input file!\n");
1205  return 0;
1206  }
1207 
1208  /* Get a pointer to the latest ELEC calc object and update the ELEC
1209  statement number */
1210  if (thee->nelec >= NOSH_MAXCALC) {
1211  Vnm_print(2, "NOsh: Too many electrostatics calculations in this \
1212 run!\n");
1213  Vnm_print(2, "NOsh: Current max is %d; ignoring this calculation\n",
1214  NOSH_MAXCALC);
1215  return 1;
1216  }
1217 
1218  /* The next token HAS to be the method OR "name" */
1219  if (Vio_scanf(sock, "%s", tok) == 1) {
1220  if (Vstring_strcasecmp(tok, "name") == 0) {
1221  Vio_scanf(sock, "%s", tok);
1222  strncpy(thee->elecname[thee->nelec], tok, VMAX_ARGLEN);
1223  if (Vio_scanf(sock, "%s", tok) != 1) {
1224  Vnm_print(2, "NOsh_parseELEC: Ran out of tokens while reading \
1225 ELEC section!\n");
1226  return 0;
1227  }
1228  }
1229  if (Vstring_strcasecmp(tok, "mg-manual") == 0) {
1230  thee->elec[thee->nelec] = NOsh_calc_ctor(NCT_MG);
1231  calc = thee->elec[thee->nelec];
1232  (thee->nelec)++;
1233  calc->mgparm->type = MCT_MANUAL;
1234  return NOsh_parseMG(thee, sock, calc);
1235  } else if (Vstring_strcasecmp(tok, "mg-auto") == 0) {
1236  thee->elec[thee->nelec] = NOsh_calc_ctor(NCT_MG);
1237  calc = thee->elec[thee->nelec];
1238  (thee->nelec)++;
1239  calc->mgparm->type = MCT_AUTO;
1240  return NOsh_parseMG(thee, sock, calc);
1241  } else if (Vstring_strcasecmp(tok, "mg-para") == 0) {
1242  thee->elec[thee->nelec] = NOsh_calc_ctor(NCT_MG);
1243  calc = thee->elec[thee->nelec];
1244  (thee->nelec)++;
1245  calc->mgparm->type = MCT_PARALLEL;
1246  return NOsh_parseMG(thee, sock, calc);
1247  } else if (Vstring_strcasecmp(tok, "mg-dummy") == 0) {
1248  thee->elec[thee->nelec] = NOsh_calc_ctor(NCT_MG);
1249  calc = thee->elec[thee->nelec];
1250  (thee->nelec)++;
1251  calc->mgparm->type = MCT_DUMMY;
1252  return NOsh_parseMG(thee, sock, calc);
1253  } else if (Vstring_strcasecmp(tok, "fe-manual") == 0) {
1254  thee->elec[thee->nelec] = NOsh_calc_ctor(NCT_FEM);
1255  calc = thee->elec[thee->nelec];
1256  (thee->nelec)++;
1257  calc->femparm->type = FCT_MANUAL;
1258  return NOsh_parseFEM(thee, sock, calc);
1259  } else if (Vstring_strcasecmp(tok, "bem-manual") == 0) {
1260  thee->elec[thee->nelec] = NOsh_calc_ctor(NCT_BEM);
1261  calc = thee->elec[thee->nelec];
1262  (thee->nelec)++;
1263  calc->bemparm->type = BCT_MANUAL;
1264  return NOsh_parseBEM(thee, sock, calc);
1265  } else if (Vstring_strcasecmp(tok, "geoflow-manual") == 0) {
1266 // thee->elec[thee->nelec] = NOsh_calc_ctor(NCT_GEOFLOW);
1267 // calc = thee->elec[thee->nelec];
1268 // (thee->nelec)++;
1269 // calc->geoflowparm->type = GFCT_MANUAL;
1270 // return NOsh_parseGEOFLOW(thee, sock, calc);
1271  Vnm_print(2, "Geoflow currently does not support geoflow-manual please use geoflow-auto instead!\n");
1272  return 0;
1273  } else if(Vstring_strcasecmp(tok, "geoflow-none") == 0) {
1274  Vnm_print(2, "Geoflow currently does not support geoflow-none please use geoflow-auto instead!\n");
1275  return 0;
1276  } else if (Vstring_strcasecmp(tok, "geoflow-auto") == 0) {
1277  thee->elec[thee->nelec] = NOsh_calc_ctor(NCT_GEOFLOW);
1278  calc = thee->elec[thee->nelec];
1279  (thee->nelec)++;
1280  calc->geoflowparm->type = GFCT_AUTO;
1281  return NOsh_parseGEOFLOW(thee, sock, calc);
1282  } else if (Vstring_strcasecmp(tok, "pbam-auto") == 0) {
1283  thee->elec[thee->nelec] = NOsh_calc_ctor(NCT_PBAM);
1284  calc = thee->elec[thee->nelec];
1285  (thee->nelec)++;
1286  calc->pbamparm->type = PBAMCT_AUTO;
1287  return NOsh_parsePBAM(thee, sock, calc);
1288  } else if (Vstring_strcasecmp(tok, "pbsam-auto") == 0) {
1289  thee->elec[thee->nelec] = NOsh_calc_ctor(NCT_PBSAM);
1290  calc = thee->elec[thee->nelec];
1291  (thee->nelec)++;
1292  calc->pbsamparm->type = PBSAMCT_AUTO;
1293  return NOsh_parsePBSAM(thee, sock, calc);
1294  } else {
1295  Vnm_print(2, "NOsh_parseELEC: The method (\"mg\",\"fem\", \"bem\", \"geoflow\" \"pbam\", \"pbsam\") or \
1296 \"name\" must be the first keyword in the ELEC section\n");
1297  return 0;
1298  }
1299  }
1300 
1301  Vnm_print(2, "NOsh_parseELEC: Ran out of tokens while reading ELEC section!\n");
1302  return 0;
1303 
1304 }
1305 
1306 VPRIVATE int NOsh_parseAPOLAR(NOsh *thee, Vio *sock) {
1307 
1308  NOsh_calc *calc = VNULL;
1309 
1310  char tok[VMAX_BUFSIZE];
1311 
1312  if (thee == VNULL) {
1313  Vnm_print(2, "NOsh_parseAPOLAR: Got NULL thee!\n");
1314  return 0;
1315  }
1316 
1317  if (sock == VNULL) {
1318  Vnm_print(2, "NOsh_parseAPOLAR: Got pointer to NULL socket!\n");
1319  return 0;
1320  }
1321 
1322  if (thee->parsed) {
1323  Vnm_print(2, "NOsh_parseAPOLAR: Already parsed an input file!\n");
1324  return 0;
1325  }
1326 
1327  /* Get a pointer to the latest ELEC calc object and update the ELEC
1328  statement number */
1329  if (thee->napol >= NOSH_MAXCALC) {
1330  Vnm_print(2, "NOsh: Too many non-polar calculations in this \
1331 run!\n");
1332  Vnm_print(2, "NOsh: Current max is %d; ignoring this calculation\n",
1333  NOSH_MAXCALC);
1334  return 1;
1335  }
1336 
1337  /* The next token HAS to be the method OR "name" */
1338  if (Vio_scanf(sock, "%s", tok) == 1) {
1339  if (Vstring_strcasecmp(tok, "name") == 0) {
1340  Vio_scanf(sock, "%s", tok);
1341  strncpy(thee->apolname[thee->napol], tok, VMAX_ARGLEN);
1342 
1343  /* Parse the non-polar parameters */
1344  thee->apol[thee->napol] = NOsh_calc_ctor(NCT_APOL);
1345  calc = thee->apol[thee->napol];
1346  (thee->napol)++;
1347  return NOsh_parseAPOL(thee, sock, calc);
1348 // } else if (Vstring_strcasecmp(tok, "geoflow-manual") == 0) {
1349 // thee->elec[thee->nelec] = NOsh_calc_ctor(NCT_GEOFLOW);
1350 // calc = thee->elec[thee->nelec];
1351 // (thee->nelec)++;
1352 // calc->geoflowparm->type = GFCT_MANUAL;
1353 // return NOsh_parseGEOFLOW(thee, sock, calc);
1354 // } else if (Vstring_strcasecmp(tok, "geoflow-auto") == 0) {
1355 // thee->elec[thee->nelec] = NOsh_calc_ctor(NCT_GEOFLOW);
1356 // calc = thee->elec[thee->nelec];
1357 // (thee->nelec)++;
1358 // calc->geoflowparm->type = GFCT_AUTO;
1359 // return NOsh_parseGEOFLOW(thee, sock, calc);
1360  }
1361  }
1362 
1363  return 1;
1364 
1365 }
1366 
1368  NOsh *thee,
1369  Valist *alist[NOSH_MAXMOL]
1370  ) {
1371  int ielec, imol, i;
1372  NOsh_calc *elec = VNULL;
1373  MGparm *mgparm = VNULL;
1374  Valist *mymol = VNULL;
1375 
1376  VASSERT(thee != VNULL);
1377  for (imol=0; imol<thee->nmol; imol++) {
1378  thee->alist[imol] = alist[imol];
1379  }
1380 
1381 
1382  for (ielec=0; ielec<(thee->nelec); ielec++) {
1383  /* Unload the calculation object containing the ELEC information */
1384  elec = thee->elec[ielec];
1385 
1386  if (((thee->ndiel != 0) || (thee->nkappa != 0) ||
1387  (thee->ncharge != 0) || (thee->npot != 0)) &&
1388  (elec->pbeparm->calcforce != PCF_NO)) {
1389  Vnm_print(2, "NOsh_setupElecCalc: Calculation of forces disabled because surface \
1390 map is used!\n");
1391  elec->pbeparm->calcforce = PCF_NO;
1392  }
1393 
1394  /* Setup the calculation */
1395  switch (elec->calctype) {
1396  case NCT_MG:
1397  /* Center on the molecules, if requested */
1398  mgparm = elec->mgparm;
1399  VASSERT(mgparm != VNULL);
1400  if (elec->mgparm->cmeth == MCM_MOLECULE) {
1401  VASSERT(mgparm->centmol >= 0);
1402  VASSERT(mgparm->centmol < thee->nmol);
1403  mymol = thee->alist[mgparm->centmol];
1404  VASSERT(mymol != VNULL);
1405  for (i=0; i<3; i++) {
1406  mgparm->center[i] = mymol->center[i];
1407  }
1408  }
1409  if (elec->mgparm->fcmeth == MCM_MOLECULE) {
1410  VASSERT(mgparm->fcentmol >= 0);
1411  VASSERT(mgparm->fcentmol < thee->nmol);
1412  mymol = thee->alist[mgparm->fcentmol];
1413  VASSERT(mymol != VNULL);
1414  for (i=0; i<3; i++) {
1415  mgparm->fcenter[i] = mymol->center[i];
1416  }
1417  }
1418  if (elec->mgparm->ccmeth == MCM_MOLECULE) {
1419  VASSERT(mgparm->ccentmol >= 0);
1420  VASSERT(mgparm->ccentmol < thee->nmol);
1421  mymol = thee->alist[mgparm->ccentmol];
1422  VASSERT(mymol != VNULL);
1423  for (i=0; i<3; i++) {
1424  mgparm->ccenter[i] = mymol->center[i];
1425  }
1426  }
1427  NOsh_setupCalcMG(thee, elec);
1428  break;
1429  case NCT_FEM:
1430  NOsh_setupCalcFEM(thee, elec);
1431  break;
1432  case NCT_PBAM:
1433  NOsh_setupCalcPBAM(thee, elec);
1434  break;
1435  case NCT_PBSAM:
1436  NOsh_setupCalcPBSAM(thee, elec);
1437  break;
1438  case NCT_BEM:
1439  NOsh_setupCalcBEM(thee, elec);
1440  break;
1441  case NCT_GEOFLOW:
1442  NOsh_setupCalcGEOFLOW(thee, elec);
1443  break;
1444  default:
1445  Vnm_print(2, "NOsh_setupCalc: Invalid calculation type (%d)!\n",
1446  elec->calctype);
1447  return 0;
1448  }
1449 
1450  /* At this point, the most recently-created NOsh_calc object should be the
1451  one we use for results for this ELEC statement. Assign it. */
1452  /* Associate ELEC statement with the calculation */
1453  thee->elec2calc[ielec] = thee->ncalc-1;
1454  Vnm_print(0, "NOsh_setupCalc: Mapping ELEC statement %d (%d) to \
1455 calculation %d (%d)\n", ielec, ielec+1, thee->elec2calc[ielec],
1456  thee->elec2calc[ielec]+1);
1457  }
1458 
1459  return 1;
1460 }
1461 
1463  NOsh *thee,
1464  Valist *alist[NOSH_MAXMOL]
1465  ) {
1466  int iapol, imol;
1467  int doCalc = ACD_NO;
1468  NOsh_calc *calc = VNULL;
1469 
1470  VASSERT(thee != VNULL);
1471  for (imol=0; imol<thee->nmol; imol++) {
1472  thee->alist[imol] = alist[imol];
1473  }
1474 
1475  for (iapol=0; iapol<(thee->napol); iapol++) {
1476  /* Unload the calculation object containing the APOL information */
1477  calc = thee->apol[iapol];
1478 
1479  /* Setup the calculation */
1480  switch (calc->calctype) {
1481  case NCT_APOL:
1482  NOsh_setupCalcAPOL(thee, calc);
1483  doCalc = ACD_YES;
1484  break;
1485  default:
1486  Vnm_print(2, "NOsh_setupCalc: Invalid calculation type (%d)!\n", calc->calctype);
1487  return ACD_ERROR;
1488  }
1489  /* At this point, the most recently-created NOsh_calc object should be the
1490  one we use for results for this APOL statement. Assign it. */
1491  /* Associate APOL statement with the calculation */
1492  thee->apol2calc[iapol] = thee->ncalc-1;
1493  Vnm_print(0, "NOsh_setupCalc: Mapping APOL statement %d (%d) to calculation %d (%d)\n", iapol, iapol+1, thee->apol2calc[iapol], thee->apol2calc[iapol]+1);
1494  }
1495 
1496  if(doCalc == ACD_YES){
1497  return ACD_YES;
1498  }else{
1499  return ACD_NO;
1500  }
1501 }
1502 
1503 VPUBLIC int NOsh_parseMG(
1504  NOsh *thee,
1505  Vio *sock,
1506  NOsh_calc *elec
1507  ) {
1508 
1509  char tok[VMAX_BUFSIZE];
1510  MGparm *mgparm = VNULL;
1511  PBEparm *pbeparm = VNULL;
1512  int rc;
1513 
1514  /* Check the arguments */
1515  if (thee == VNULL) {
1516  Vnm_print(2, "NOsh: Got NULL thee!\n");
1517  return 0;
1518  }
1519  if (sock == VNULL) {
1520  Vnm_print(2, "NOsh: Got pointer to NULL socket!\n");
1521  return 0;
1522  }
1523  if (elec == VNULL) {
1524  Vnm_print(2, "NOsh: Got pointer to NULL elec object!\n");
1525  return 0;
1526  }
1527  mgparm = elec->mgparm;
1528  if (mgparm == VNULL) {
1529  Vnm_print(2, "NOsh: Got pointer to NULL mgparm object!\n");
1530  return 0;
1531  }
1532  pbeparm = elec->pbeparm;
1533  if (pbeparm == VNULL) {
1534  Vnm_print(2, "NOsh: Got pointer to NULL pbeparm object!\n");
1535  return 0;
1536  }
1537 
1538  Vnm_print(0, "NOsh_parseMG: Parsing parameters for MG calculation\n");
1539 
1540  /* Parallel stuff */
1541  if (mgparm->type == MCT_PARALLEL) {
1542  mgparm->proc_rank = thee->proc_rank;
1543  mgparm->proc_size = thee->proc_size;
1544  mgparm->setrank = 1;
1545  mgparm->setsize = 1;
1546  }
1547 
1548 
1549  /* Start snarfing tokens from the input stream */
1550  rc = 1;
1551  while (Vio_scanf(sock, "%s", tok) == 1) {
1552 
1553  Vnm_print(0, "NOsh_parseMG: Parsing %s...\n", tok);
1554 
1555  /* See if it's an END token */
1556  if (Vstring_strcasecmp(tok, "end") == 0) {
1557  mgparm->parsed = 1;
1558  pbeparm->parsed = 1;
1559  rc = 1;
1560  break;
1561  }
1562 
1563  /* Pass the token through a series of parsers */
1564  rc = PBEparm_parseToken(pbeparm, tok, sock);
1565  if (rc == -1) {
1566  Vnm_print(0, "NOsh_parseMG: parsePBE error!\n");
1567  break;
1568  } else if (rc == 0) {
1569  /* Pass the token to the generic MG parser */
1570  rc = MGparm_parseToken(mgparm, tok, sock);
1571  if (rc == -1) {
1572  Vnm_print(0, "NOsh_parseMG: parseMG error!\n");
1573  break;
1574  } else if (rc == 0) {
1575  /* We ran out of parsers! */
1576  Vnm_print(2, "NOsh: Unrecognized keyword: %s\n", tok);
1577  break;
1578  }
1579  }
1580  }
1581 
1582  /* Handle various errors arising in the token-snarfing loop -- these all
1583  just result in simple returns right now */
1584  if (rc == -1) return 0;
1585  if (rc == 0) return 0;
1586 
1587  /* Check the status of the parameter objects */
1588  if ((MGparm_check(mgparm) == VRC_FAILURE) || (!PBEparm_check(pbeparm))) {
1589  Vnm_print(2, "NOsh: MG parameters not set correctly!\n");
1590  return 0;
1591  }
1592 
1593  return 1;
1594 }
1595 
1596 VPRIVATE int NOsh_setupCalcMG(
1597  NOsh *thee,
1598  NOsh_calc *calc
1599  ) {
1600 
1601  MGparm *mgparm = VNULL;
1602 
1603  VASSERT(thee != VNULL);
1604  VASSERT(calc != VNULL);
1605  mgparm = calc->mgparm;
1606  VASSERT(mgparm != VNULL);
1607 
1608 
1609  /* Now we're ready to whatever sorts of post-processing operations that are
1610  necessary for the various types of calculations */
1611  switch (mgparm->type) {
1612  case MCT_MANUAL:
1613  return NOsh_setupCalcMGMANUAL(thee, calc);
1614  case MCT_DUMMY:
1615  return NOsh_setupCalcMGMANUAL(thee, calc);
1616  case MCT_AUTO:
1617  return NOsh_setupCalcMGAUTO(thee, calc);
1618  case MCT_PARALLEL:
1619  return NOsh_setupCalcMGPARA(thee, calc);
1620  default:
1621  Vnm_print(2, "NOsh_setupCalcMG: undefined MG calculation type (%d)!\n",
1622  mgparm->type);
1623  return 0;
1624  }
1625 
1626  /* Shouldn't get here */
1627  return 0;
1628 }
1629 
1630 
1631 VPRIVATE int NOsh_setupCalcBEM(
1632  NOsh *thee,
1633  NOsh_calc *calc
1634  ) {
1635 
1636  BEMparm *bemparm = VNULL;
1637 
1638  VASSERT(thee != VNULL);
1639  VASSERT(calc != VNULL);
1640  bemparm = calc->bemparm;
1641  VASSERT(bemparm != VNULL);
1642 
1643 
1644  /* Now we're ready to whatever sorts of post-processing operations that are
1645  necessary for the various types of calculations */
1646  switch (bemparm->type) {
1647  case BCT_MANUAL:
1648  return NOsh_setupCalcBEMMANUAL(thee, calc);
1649  default:
1650  Vnm_print(2, "NOsh_setupCalcBEM: undefined BEM calculation type (%d)!\n",
1651  bemparm->type);
1652  return 0;
1653  }
1654 
1655  /* Shouldn't get here */
1656  return 0;
1657 }
1658 
1659 VPRIVATE int NOsh_setupCalcGEOFLOW(NOsh *thee, NOsh_calc *calc) {
1660 
1661  GEOFLOWparm *parm = VNULL;
1662 
1663  VASSERT(thee != VNULL);
1664  VASSERT(calc != VNULL);
1665  parm = calc->geoflowparm;
1666  VASSERT(parm != VNULL);
1667 
1668 
1669  /* Now we're ready to whatever sorts of post-processing operations that are
1670  necessary for the various types of calculations */
1671  if(/*parm->type == GFCT_MANUAL ||*/ parm->type == GFCT_AUTO){
1672  return NOsh_setupCalcGEOFLOWMANUAL(thee, calc);
1673  }else{
1674  Vnm_print(2, "NOsh_setupCalcGEOFLOW: undefined GEOFLOW calculation type (%d)!\n", parm->type);
1675  return 0;
1676  }
1677 }
1678 
1679 VPRIVATE int NOsh_setupCalcPBAM(NOsh *thee, NOsh_calc *calc){
1680 
1681  PBAMparm *parm = VNULL;
1682 
1683  VASSERT(thee!=VNULL);
1684  VASSERT(calc!=VNULL);
1685  parm = calc->pbamparm;
1686  VASSERT(parm!=VNULL);
1687 
1688  if(parm->type == PBAMCT_AUTO){
1689  return NOsh_setupCalcPBAMAUTO(thee, calc);
1690  } else {
1691  Vnm_print(2, "NOsh_setupCalcPBAM: undefined PBAM calculation type (%d)!\n", parm->type);
1692  return 0;
1693  }
1694 }
1695 
1696 
1697 VPRIVATE int NOsh_setupCalcPBSAM(NOsh *thee, NOsh_calc *calc){
1698 
1699  PBSAMparm *parm = VNULL;
1700 
1701  VASSERT(thee!=VNULL);
1702  VASSERT(calc!=VNULL);
1703  parm = calc->pbsamparm;
1704  VASSERT(parm!=VNULL);
1705 
1706  if(parm->type == PBSAMCT_AUTO){
1707  return NOsh_setupCalcPBSAMAUTO(thee, calc);
1708  } else {
1709  Vnm_print(2, "NOsh_setupCalcPBSAM: undefined PBSAM calculation type (%d)!\n", parm->type);
1710  return 0;
1711  }
1712 }
1713 
1714 
1715 VPRIVATE int NOsh_setupCalcFEM(
1716  NOsh *thee,
1717  NOsh_calc *calc
1718  ) {
1719 
1720  VASSERT(thee != VNULL);
1721  VASSERT(calc != VNULL);
1722  VASSERT(calc->femparm != VNULL);
1723 
1724  /* Now we're ready to whatever sorts of post-processing operations that are
1725  * necessary for the various types of calculations */
1726  switch (calc->femparm->type) {
1727  case FCT_MANUAL:
1728  return NOsh_setupCalcFEMANUAL(thee, calc);
1729  default:
1730  Vnm_print(2, "NOsh_parseFEM: unknown calculation type (%d)!\n",
1731  calc->femparm->type);
1732  return 0;
1733  }
1734 
1735  /* Shouldn't get here */
1736  return 0;
1737 }
1738 
1739 
1740 VPRIVATE int NOsh_setupCalcMGMANUAL(
1741  NOsh *thee,
1742  NOsh_calc *elec
1743  ) {
1744 
1745  MGparm *mgparm = VNULL;
1746  PBEparm *pbeparm = VNULL;
1747  NOsh_calc *calc = VNULL;
1748 
1749  if (thee == VNULL) {
1750  Vnm_print(2, "NOsh_setupCalcMGMANUAL: Got NULL thee!\n");
1751  return 0;
1752  }
1753  if (elec == VNULL) {
1754  Vnm_print(2, "NOsh_setupCalcMGMANUAL: Got NULL calc!\n");
1755  return 0;
1756  }
1757  mgparm = elec->mgparm;
1758  if (mgparm == VNULL) {
1759  Vnm_print(2, "NOsh_setupCalcMGMANUAL: Got NULL mgparm -- was this calculation \
1760 set up?\n");
1761  return 0;
1762  }
1763  pbeparm = elec->pbeparm;
1764  if (pbeparm == VNULL) {
1765  Vnm_print(2, "NOsh_setupCalcMGMANUAL: Got NULL pbeparm -- was this calculation \
1766 set up?\n");
1767  return 0;
1768  }
1769 
1770  /* Set up missing MG parameters */
1771  if (mgparm->setgrid == 0) {
1772  VASSERT(mgparm->setglen);
1773  mgparm->grid[0] = mgparm->glen[0]/((double)(mgparm->dime[0]-1));
1774  mgparm->grid[1] = mgparm->glen[1]/((double)(mgparm->dime[1]-1));
1775  mgparm->grid[2] = mgparm->glen[2]/((double)(mgparm->dime[2]-1));
1776  }
1777  if (mgparm->setglen == 0) {
1778  VASSERT(mgparm->setgrid);
1779  mgparm->glen[0] = mgparm->grid[0]*((double)(mgparm->dime[0]-1));
1780  mgparm->glen[1] = mgparm->grid[1]*((double)(mgparm->dime[1]-1));
1781  mgparm->glen[2] = mgparm->grid[2]*((double)(mgparm->dime[2]-1));
1782  }
1783 
1784  /* Check to see if he have any room left for this type of calculation, if
1785  so: set the calculation type, update the number of calculations of this type,
1786  and parse the rest of the section */
1787  if (thee->ncalc >= NOSH_MAXCALC) {
1788  Vnm_print(2, "NOsh: Too many calculations in this run!\n");
1789  Vnm_print(2, "NOsh: Current max is %d; ignoring this calculation\n",
1790  NOSH_MAXCALC);
1791  return 0;
1792  }
1793 
1794  /* Get the next calculation object and increment the number of calculations */
1795  thee->calc[thee->ncalc] = NOsh_calc_ctor(NCT_MG);
1796  calc = thee->calc[thee->ncalc];
1797  (thee->ncalc)++;
1798 
1799 
1800 
1801  /* Copy over contents of ELEC */
1802  NOsh_calc_copy(calc, elec);
1803 
1804 
1805  return 1;
1806 }
1807 
1808 VPUBLIC int NOsh_setupCalcMGAUTO(
1809  NOsh *thee,
1810  NOsh_calc *elec
1811  ) {
1812 
1813  NOsh_calc *calcf = VNULL;
1814  NOsh_calc *calcc = VNULL;
1815  double fgrid[3], cgrid[3];
1816  double d[3], minf[3], maxf[3], minc[3], maxc[3];
1817  double redfrac, redrat[3], td;
1818  int ifocus, nfocus, tnfocus[3];
1819  int j;
1820  int icalc;
1821  int dofix;
1822 
1823  /* A comment about the coding style in this function. I use lots and lots
1824  and lots of pointer deferencing. I could (and probably should) save
1825  these in temporary variables. However, since there are so many MGparm,
1826  etc. and NOsh_calc, etc. objects running around in this function, the
1827  current scheme is easiest to debug. */
1828 
1829 
1830  if (thee == VNULL) {
1831  Vnm_print(2, "NOsh_setupCalcMGAUTO: Got NULL thee!\n");
1832  return 0;
1833  }
1834  if (elec == VNULL) {
1835  Vnm_print(2, "NOsh_setupCalcMGAUTO: Got NULL elec!\n");
1836  return 0;
1837  }
1838  if (elec->mgparm == VNULL) {
1839  Vnm_print(2, "NOsh_setupCalcMGAUTO: Got NULL mgparm!\n");
1840  return 0;
1841  }
1842  if (elec->pbeparm == VNULL) {
1843  Vnm_print(2, "NOsh_setupCalcMGAUTO: Got NULL pbeparm!\n");
1844  return 0;
1845  }
1846 
1847  Vnm_print(0, "NOsh_setupCalcMGAUTO(%s, %d): coarse grid center = %g %g %g\n",
1848  __FILE__, __LINE__,
1849  elec->mgparm->ccenter[0],
1850  elec->mgparm->ccenter[1],
1851  elec->mgparm->ccenter[2]);
1852  Vnm_print(0, "NOsh_setupCalcMGAUTO(%s, %d): fine grid center = %g %g %g\n",
1853  __FILE__, __LINE__,
1854  elec->mgparm->fcenter[0],
1855  elec->mgparm->fcenter[1],
1856  elec->mgparm->fcenter[2]);
1857 
1858  /* Calculate the grid spacing on the coarse and fine levels */
1859  for (j=0; j<3; j++) {
1860  cgrid[j] = (elec->mgparm->cglen[j])/((double)(elec->mgparm->dime[j]-1));
1861  fgrid[j] = (elec->mgparm->fglen[j])/((double)(elec->mgparm->dime[j]-1));
1862  d[j] = elec->mgparm->fcenter[j] - elec->mgparm->ccenter[j];
1863  }
1864  Vnm_print(0, "NOsh_setupCalcMGAUTO (%s, %d): Coarse grid spacing = %g, %g, %g\n",
1865  __FILE__, __LINE__, cgrid[0], cgrid[1], cgrid[2]);
1866  Vnm_print(0, "NOsh_setupCalcMGAUTO (%s, %d): Fine grid spacing = %g, %g, %g\n",
1867  __FILE__, __LINE__, fgrid[0], fgrid[1], fgrid[2]);
1868  Vnm_print(0, "NOsh_setupCalcMGAUTO (%s, %d): Displacement between fine and \
1869 coarse grids = %g, %g, %g\n", __FILE__, __LINE__, d[0], d[1], d[2]);
1870 
1871  /* Now calculate the number of focusing levels, never reducing the grid
1872  spacing by more than redfrac at each level */
1873  for (j=0; j<3; j++) {
1874  if (fgrid[j]/cgrid[j] < VREDFRAC) {
1875  redfrac = fgrid[j]/cgrid[j];
1876  td = log(redfrac)/log(VREDFRAC);
1877  tnfocus[j] = (int)ceil(td) + 1;
1878  } else tnfocus[j] = 2;
1879  }
1880  nfocus = VMAX2(VMAX2(tnfocus[0], tnfocus[1]), tnfocus[2]);
1881 
1882  /* Now set redrat to the actual value by which the grid spacing is reduced
1883  at each level of focusing */
1884  for (j=0; j<3; j++) {
1885  redrat[j] = VPOW((fgrid[j]/cgrid[j]), 1.0/((double)nfocus-1.0));
1886  }
1887  Vnm_print(0, "NOsh: %d levels of focusing with %g, %g, %g reductions\n",
1888  nfocus, redrat[0], redrat[1], redrat[2]);
1889 
1890  /* Now that we know how many focusing levels to use, we're ready to set up
1891  the parameter objects */
1892  if (nfocus > (NOSH_MAXCALC-(thee->ncalc))) {
1893  Vnm_print(2, "NOsh: Require more calculations than max (%d)!\n",
1894  NOSH_MAXCALC);
1895  return 0;
1896  }
1897 
1898  for (ifocus=0; ifocus<nfocus; ifocus++) {
1899 
1900  /* Generate the new calc object */
1901  icalc = thee->ncalc;
1902  thee->calc[icalc] = NOsh_calc_ctor(NCT_MG);
1903  (thee->ncalc)++;
1904 
1905  /* This is the _current_ NOsh_calc object */
1906  calcf = thee->calc[icalc];
1907  /* This is the _previous_ Nosh_calc object */
1908  if (ifocus != 0) {
1909  calcc = thee->calc[icalc-1];
1910  } else {
1911  calcc = VNULL;
1912  }
1913 
1914  /* Copy over most of the parameters from the ELEC object */
1915  NOsh_calc_copy(calcf, elec);
1916 
1917  /* Set up the grid lengths and spacings */
1918  if (ifocus == 0) {
1919  for (j=0; j<3; j++) {
1920  calcf->mgparm->grid[j] = cgrid[j];
1921  calcf->mgparm->glen[j] = elec->mgparm->cglen[j];
1922  }
1923  } else {
1924  for (j=0; j<3; j++) {
1925  calcf->mgparm->grid[j] = redrat[j]*(calcc->mgparm->grid[j]);
1926  calcf->mgparm->glen[j] = redrat[j]*(calcc->mgparm->glen[j]);
1927  }
1928  }
1929  calcf->mgparm->setgrid = 1;
1930  calcf->mgparm->setglen = 1;
1931 
1932  /* Get centers and centering method from coarse and fine meshes */
1933  if (ifocus == 0) {
1934  calcf->mgparm->cmeth = elec->mgparm->ccmeth;
1935  calcf->mgparm->centmol = elec->mgparm->ccentmol;
1936  for (j=0; j<3; j++) {
1937  calcf->mgparm->center[j] = elec->mgparm->ccenter[j];
1938  }
1939  } else if (ifocus == (nfocus-1)) {
1940  calcf->mgparm->cmeth = elec->mgparm->fcmeth;
1941  calcf->mgparm->centmol = elec->mgparm->fcentmol;
1942  for (j=0; j<3; j++) {
1943  calcf->mgparm->center[j] = elec->mgparm->fcenter[j];
1944  }
1945  } else {
1946  calcf->mgparm->cmeth = MCM_FOCUS;
1947  /* TEMPORARILY move the current grid center
1948  to the fine grid center. In general, this will move portions of
1949  the current mesh off the immediately-coarser mesh. We'll fix that
1950  in the next step. */
1951  for (j=0; j<3; j++) {
1952  calcf->mgparm->center[j] = elec->mgparm->fcenter[j];
1953  }
1954  }
1955 
1956 
1957  /* As mentioned above, it is highly likely that the previous "jump"
1958  to the fine grid center put portions of the current mesh off the
1959  previous (coarser) mesh. Fix this by displacing the current mesh
1960  back onto the previous coarser mesh. */
1961  if (ifocus != 0) {
1962  Vnm_print(0, "NOsh_setupCalcMGAUTO (%s, %d): starting mesh \
1963 repositioning.\n", __FILE__, __LINE__);
1964  Vnm_print(0, "NOsh_setupCalcMGAUTO (%s, %d): coarse mesh center = \
1965 %g %g %g\n", __FILE__, __LINE__,
1966  calcc->mgparm->center[0],
1967  calcc->mgparm->center[1],
1968  calcc->mgparm->center[2]);
1969  Vnm_print(0, "NOsh_setupCalcMGAUTO (%s, %d): coarse mesh upper corner = \
1970 %g %g %g\n", __FILE__, __LINE__,
1971  calcc->mgparm->center[0]+0.5*(calcc->mgparm->glen[0]),
1972  calcc->mgparm->center[1]+0.5*(calcc->mgparm->glen[1]),
1973  calcc->mgparm->center[2]+0.5*(calcc->mgparm->glen[2]));
1974  Vnm_print(0, "NOsh_setupCalcMGAUTO (%s, %d): coarse mesh lower corner = \
1975 %g %g %g\n", __FILE__, __LINE__,
1976  calcc->mgparm->center[0]-0.5*(calcc->mgparm->glen[0]),
1977  calcc->mgparm->center[1]-0.5*(calcc->mgparm->glen[1]),
1978  calcc->mgparm->center[2]-0.5*(calcc->mgparm->glen[2]));
1979  Vnm_print(0, "NOsh_setupCalcMGAUTO (%s, %d): initial fine mesh upper corner = \
1980 %g %g %g\n", __FILE__, __LINE__,
1981  calcf->mgparm->center[0]+0.5*(calcf->mgparm->glen[0]),
1982  calcf->mgparm->center[1]+0.5*(calcf->mgparm->glen[1]),
1983  calcf->mgparm->center[2]+0.5*(calcf->mgparm->glen[2]));
1984  Vnm_print(0, "NOsh_setupCalcMGAUTO (%s, %d): initial fine mesh lower corner = \
1985 %g %g %g\n", __FILE__, __LINE__,
1986  calcf->mgparm->center[0]-0.5*(calcf->mgparm->glen[0]),
1987  calcf->mgparm->center[1]-0.5*(calcf->mgparm->glen[1]),
1988  calcf->mgparm->center[2]-0.5*(calcf->mgparm->glen[2]));
1989  for (j=0; j<3; j++) {
1990  /* Check if we've fallen off of the lower end of the mesh */
1991  dofix = 0;
1992  minf[j] = calcf->mgparm->center[j]
1993  - 0.5*(calcf->mgparm->glen[j]);
1994  minc[j] = calcc->mgparm->center[j]
1995  - 0.5*(calcc->mgparm->glen[j]);
1996  d[j] = minc[j] - minf[j];
1997  if (d[j] >= VSMALL) {
1998  if (ifocus == (nfocus-1)) {
1999  Vnm_print(2, "NOsh_setupCalcMGAUTO: Error! Finest \
2000 mesh has fallen off the coarser meshes!\n");
2001  Vnm_print(2, "NOsh_setupCalcMGAUTO: difference in min %d-\
2002 direction = %g\n", j, d[j]);
2003  Vnm_print(2, "NOsh_setupCalcMGAUTO: min fine = %g %g %g\n",
2004  minf[0], minf[1], minf[2]);
2005  Vnm_print(2, "NOsh_setupCalcMGAUTO: min coarse = %g %g %g\n",
2006  minc[0], minc[1], minc[2]);
2007  VASSERT(0);
2008  } else {
2009  Vnm_print(0, "NOsh_setupCalcMGAUTO (%s, %d): ifocus = %d, \
2010 fixing mesh min violation (%g in %d-direction).\n", __FILE__, __LINE__, ifocus,
2011  d[j], j);
2012  calcf->mgparm->center[j] += d[j];
2013  dofix = 1;
2014  }
2015  }
2016  /* Check if we've fallen off of the upper end of the mesh */
2017  maxf[j] = calcf->mgparm->center[j] \
2018  + 0.5*(calcf->mgparm->glen[j]);
2019  maxc[j] = calcc->mgparm->center[j] \
2020  + 0.5*(calcc->mgparm->glen[j]);
2021  d[j] = maxf[j] - maxc[j];
2022  if (d[j] >= VSMALL) {
2023  if (ifocus == (nfocus-1)) {
2024  Vnm_print(2, "NOsh_setupCalcMGAUTO: Error! Finest \
2025 mesh has fallen off the coarser meshes!\n");
2026  Vnm_print(2, "NOsh_setupCalcMGAUTO: difference in %d-\
2027 direction = %g\n", j, d[j]);
2028  VASSERT(0);
2029  } else {
2030  /* If we already fixed the lower boundary and we now need
2031  to fix the upper boundary, we have a serious problem. */
2032  if (dofix) {
2033  Vnm_print(2, "NOsh_setupCalcMGAUTO: Error! Both \
2034 ends of the finer mesh do not fit in the bigger mesh!\n");
2035  VASSERT(0);
2036  }
2037  Vnm_print(0, "NOsh_setupCalcMGAUTO(%s, %d): ifocus = %d, \
2038 fixing mesh max violation (%g in %d-direction).\n", __FILE__, __LINE__, ifocus,
2039  d[j], j);
2040  calcf->mgparm->center[j] -= d[j];
2041  dofix = 1;
2042  }
2043  }
2044  }
2045  Vnm_print(0, "NOsh_setupCalcMGAUTO (%s, %d): final fine mesh upper corner = \
2046 %g %g %g\n", __FILE__, __LINE__,
2047  calcf->mgparm->center[0]+0.5*(calcf->mgparm->glen[0]),
2048  calcf->mgparm->center[1]+0.5*(calcf->mgparm->glen[1]),
2049  calcf->mgparm->center[2]+0.5*(calcf->mgparm->glen[2]));
2050  Vnm_print(0, "NOsh_setupCalcMGAUTO (%s, %d): final fine mesh lower corner = \
2051 %g %g %g\n", __FILE__, __LINE__,
2052  calcf->mgparm->center[0]-0.5*(calcf->mgparm->glen[0]),
2053  calcf->mgparm->center[1]-0.5*(calcf->mgparm->glen[1]),
2054  calcf->mgparm->center[2]-0.5*(calcf->mgparm->glen[2]));
2055  }
2056 
2057  /* Finer levels have focusing boundary conditions */
2058  if (ifocus != 0) calcf->pbeparm->bcfl = BCFL_FOCUS;
2059 
2060  /* Only the finest level handles I/O and needs to worry about disjoint
2061  partitioning */
2062  if (ifocus != (nfocus-1)) calcf->pbeparm->numwrite = 0;
2063 
2064  /* Reset boundary flags for everything except parallel focusing */
2065  if (calcf->mgparm->type != MCT_PARALLEL) {
2066  Vnm_print(0, "NOsh_setupMGAUTO: Resetting boundary flags\n");
2067  for (j=0; j<6; j++) calcf->mgparm->partDisjOwnSide[j] = 0;
2068  for (j=0; j<3; j++) {
2069  calcf->mgparm->partDisjCenter[j] = 0;
2070  calcf->mgparm->partDisjLength[j] = calcf->mgparm->glen[j];
2071  }
2072  }
2073 
2074 
2075  calcf->mgparm->parsed = 1;
2076  }
2077 
2078 
2079  return 1;
2080 }
2081 
2082 /* Author: Nathan Baker and Todd Dolinsky */
2083 VPUBLIC int NOsh_setupCalcMGPARA(
2084  NOsh *thee,
2085  NOsh_calc *elec
2086  ) {
2087 
2088  /* NEW (25-Jul-2006): This code should produce modify the ELEC statement
2089  and pass it on to MGAUTO for further processing. */
2090 
2091  MGparm *mgparm = VNULL;
2092  double ofrac;
2093  double hx, hy, hzed;
2094  double xofrac, yofrac, zofrac;
2095  int rank, size, npx, npy, npz, nproc, ip, jp, kp;
2096  int xeffGlob, yeffGlob, zeffGlob, xDisj, yDisj, zDisj;
2097  int xigminDisj, xigmaxDisj, yigminDisj, yigmaxDisj, zigminDisj, zigmaxDisj;
2098  int xigminOlap, xigmaxOlap, yigminOlap, yigmaxOlap, zigminOlap, zigmaxOlap;
2099  int xOlapReg, yOlapReg, zOlapReg;
2100  double xlenDisj, ylenDisj, zlenDisj;
2101  double xcentDisj, ycentDisj, zcentDisj;
2102  double xcentOlap, ycentOlap, zcentOlap;
2103  double xlenOlap, ylenOlap, zlenOlap;
2104  double xminOlap, xmaxOlap, yminOlap, ymaxOlap, zminOlap, zmaxOlap;
2105  double xminDisj, xmaxDisj, yminDisj, ymaxDisj, zminDisj, zmaxDisj;
2106  double xcent, ycent, zcent;
2107 
2108  /* Grab some useful variables */
2109  VASSERT(thee != VNULL);
2110  VASSERT(elec != VNULL);
2111  mgparm = elec->mgparm;
2112  VASSERT(mgparm != VNULL);
2113 
2114  /* Grab some useful variables */
2115  ofrac = mgparm->ofrac;
2116  npx = mgparm->pdime[0];
2117  npy = mgparm->pdime[1];
2118  npz = mgparm->pdime[2];
2119  nproc = npx*npy*npz;
2120 
2121  /* If this is not an asynchronous calculation, then we need to make sure we
2122  have all the necessary MPI information */
2123  if (mgparm->setasync == 0) {
2124 
2125 #ifndef HAVE_MPI_H
2126 
2127  Vnm_tprint(2, "NOsh_setupCalcMGPARA: Oops! You're trying to perform \
2128 an 'mg-para' (parallel) calculation\n");
2129  Vnm_tprint(2, "NOsh_setupCalcMGPARA: with a version of APBS that wasn't \
2130 compiled with MPI!\n");
2131  Vnm_tprint(2, "NOsh_setupCalcMGPARA: Perhaps you meant to use the \
2132 'async' flag?\n");
2133  Vnm_tprint(2, "NOsh_setupCalcMGPARA: Bailing out!\n");
2134 
2135  return 0;
2136 
2137 #endif
2138 
2139  rank = thee->proc_rank;
2140  size = thee->proc_size;
2141  Vnm_print(0, "NOsh_setupCalcMGPARA: Hello from processor %d of %d\n", rank,
2142  size);
2143 
2144  /* Check to see if we have too many processors. If so, then simply set
2145  this processor to duplicating the work of processor 0. */
2146  if (rank > (nproc-1)) {
2147  Vnm_print(2, "NOsh_setupMGPARA: There are more processors available than\
2148 the %d you requested.\n", nproc);
2149  Vnm_print(2, "NOsh_setupMGPARA: Eliminating processor %d\n", rank);
2150  thee->bogus = 1;
2151  rank = 0;
2152  }
2153 
2154  /* Check to see if we have too few processors. If so, this is a fatal
2155  error. */
2156  if (size < nproc) {
2157  Vnm_print(2, "NOsh_setupMGPARA: There are too few processors (%d) to \
2158 satisfy requirements (%d)\n", size, nproc);
2159  return 0;
2160  }
2161 
2162  Vnm_print(0, "NOsh_setupMGPARA: Hello (again) from processor %d of %d\n",
2163  rank, size);
2164 
2165  } else { /* Setting up for an asynchronous calculation. */
2166 
2167  rank = mgparm->async;
2168 
2169  thee->ispara = 1;
2170  thee->proc_rank = rank;
2171 
2172  /* Check to see if the async id is greater than the number of
2173  * processors. If so, this is a fatal error. */
2174  if (rank > (nproc-1)) {
2175  Vnm_print(2, "NOsh_setupMGPARA: The processor id you requested (%d) \
2176 is not within the range of processors available (0-%d)\n", rank, (nproc-1));
2177  return 0;
2178  }
2179  }
2180 
2181  /* Calculate the processor's coordinates in the processor grid */
2182  kp = (int)floor(rank/(npx*npy));
2183  jp = (int)floor((rank-kp*npx*npy)/npx);
2184  ip = rank - kp*npx*npy - jp*npx;
2185  Vnm_print(0, "NOsh_setupMGPARA: Hello world from PE (%d, %d, %d)\n",
2186  ip, jp, kp);
2187 
2188  /* Calculate effective overlap fractions for uneven processor distributions */
2189  if (npx == 1) xofrac = 0.0;
2190  else xofrac = ofrac;
2191  if (npy == 1) yofrac = 0.0;
2192  else yofrac = ofrac;
2193  if (npz == 1) zofrac = 0.0;
2194  else zofrac = ofrac;
2195 
2196  /* Calculate the global grid size and spacing */
2197  xDisj = (int)VFLOOR(mgparm->dime[0]/(1 + 2*xofrac) + 0.5);
2198  xeffGlob = npx*xDisj;
2199  hx = mgparm->fglen[0]/(double)(xeffGlob-1);
2200  yDisj = (int)VFLOOR(mgparm->dime[1]/(1 + 2*yofrac) + 0.5);
2201  yeffGlob = npy*yDisj;
2202  hy = mgparm->fglen[1]/(double)(yeffGlob-1);
2203  zDisj = (int)VFLOOR(mgparm->dime[2]/(1 + 2*zofrac) + 0.5);
2204  zeffGlob = npz*zDisj;
2205  hzed = mgparm->fglen[2]/(double)(zeffGlob-1);
2206  Vnm_print(0, "NOsh_setupMGPARA: Global Grid size = (%d, %d, %d)\n",
2207  xeffGlob, yeffGlob, zeffGlob);
2208  Vnm_print(0, "NOsh_setupMGPARA: Global Grid Spacing = (%.3f, %.3f, %.3f)\n",
2209  hx, hy, hzed);
2210  Vnm_print(0, "NOsh_setupMGPARA: Processor Grid Size = (%d, %d, %d)\n",
2211  xDisj, yDisj, zDisj);
2212 
2213  /* Calculate the maximum and minimum processor grid points */
2214  xigminDisj = ip*xDisj;
2215  xigmaxDisj = xigminDisj + xDisj - 1;
2216  yigminDisj = jp*yDisj;
2217  yigmaxDisj = yigminDisj + yDisj - 1;
2218  zigminDisj = kp*zDisj;
2219  zigmaxDisj = zigminDisj + zDisj - 1;
2220  Vnm_print(0, "NOsh_setupMGPARA: Min Grid Points for this proc. (%d, %d, %d)\n",
2221  xigminDisj, yigminDisj, zigminDisj);
2222  Vnm_print(0, "NOsh_setupMGPARA: Max Grid Points for this proc. (%d, %d, %d)\n",
2223  xigmaxDisj, yigmaxDisj, zigmaxDisj);
2224 
2225 
2226  /* Calculate the disjoint partition length and center displacement */
2227  xminDisj = VMAX2(hx*(xigminDisj-0.5), 0.0);
2228  xmaxDisj = VMIN2(hx*(xigmaxDisj+0.5), mgparm->fglen[0]);
2229  xlenDisj = xmaxDisj - xminDisj;
2230  yminDisj = VMAX2(hy*(yigminDisj-0.5), 0.0);
2231  ymaxDisj = VMIN2(hy*(yigmaxDisj+0.5), mgparm->fglen[1]);
2232  ylenDisj = ymaxDisj - yminDisj;
2233  zminDisj = VMAX2(hzed*(zigminDisj-0.5), 0.0);
2234  zmaxDisj = VMIN2(hzed*(zigmaxDisj+0.5), mgparm->fglen[2]);
2235  zlenDisj = zmaxDisj - zminDisj;
2236 
2237  xcent = 0.5*mgparm->fglen[0];
2238  ycent = 0.5*mgparm->fglen[1];
2239  zcent = 0.5*mgparm->fglen[2];
2240 
2241  xcentDisj = xminDisj + 0.5*xlenDisj - xcent;
2242  ycentDisj = yminDisj + 0.5*ylenDisj - ycent;
2243  zcentDisj = zminDisj + 0.5*zlenDisj - zcent;
2244  if (VABS(xcentDisj) < VSMALL) xcentDisj = 0.0;
2245  if (VABS(ycentDisj) < VSMALL) ycentDisj = 0.0;
2246  if (VABS(zcentDisj) < VSMALL) zcentDisj = 0.0;
2247 
2248  Vnm_print(0, "NOsh_setupMGPARA: Disj part length = (%g, %g, %g)\n",
2249  xlenDisj, ylenDisj, zlenDisj);
2250  Vnm_print(0, "NOsh_setupMGPARA: Disj part center displacement = (%g, %g, %g)\n",
2251  xcentDisj, ycentDisj, zcentDisj);
2252 
2253  /* Calculate the overlapping partition length and center displacement */
2254  xOlapReg = 0;
2255  yOlapReg = 0;
2256  zOlapReg = 0;
2257  if (npx != 1) xOlapReg = (int)VFLOOR(xofrac*mgparm->fglen[0]/npx/hx + 0.5) + 1;
2258  if (npy != 1) yOlapReg = (int)VFLOOR(yofrac*mgparm->fglen[1]/npy/hy + 0.5) + 1;
2259  if (npz != 1) zOlapReg = (int)VFLOOR(zofrac*mgparm->fglen[2]/npz/hzed + 0.5) + 1;
2260 
2261  Vnm_print(0, "NOsh_setupMGPARA: No. of Grid Points in Overlap (%d, %d, %d)\n",
2262  xOlapReg, yOlapReg, zOlapReg);
2263 
2264  if (ip == 0) xigminOlap = 0;
2265  else if (ip == (npx - 1)) xigminOlap = xeffGlob - mgparm->dime[0];
2266  else xigminOlap = xigminDisj - xOlapReg;
2267  xigmaxOlap = xigminOlap + mgparm->dime[0] - 1;
2268 
2269  if (jp == 0) yigminOlap = 0;
2270  else if (jp == (npy - 1)) yigminOlap = yeffGlob - mgparm->dime[1];
2271  else yigminOlap = yigminDisj - yOlapReg;
2272  yigmaxOlap = yigminOlap + mgparm->dime[1] - 1;
2273 
2274  if (kp == 0) zigminOlap = 0;
2275  else if (kp == (npz - 1)) zigminOlap = zeffGlob - mgparm->dime[2];
2276  else zigminOlap = zigminDisj - zOlapReg;
2277  zigmaxOlap = zigminOlap + mgparm->dime[2] - 1;
2278 
2279  Vnm_print(0, "NOsh_setupMGPARA: Min Grid Points with Overlap (%d, %d, %d)\n",
2280  xigminOlap, yigminOlap, zigminOlap);
2281  Vnm_print(0, "NOsh_setupMGPARA: Max Grid Points with Overlap (%d, %d, %d)\n",
2282  xigmaxOlap, yigmaxOlap, zigmaxOlap);
2283 
2284  xminOlap = hx * xigminOlap;
2285  xmaxOlap = hx * xigmaxOlap;
2286  yminOlap = hy * yigminOlap;
2287  ymaxOlap = hy * yigmaxOlap;
2288  zminOlap = hzed * zigminOlap;
2289  zmaxOlap = hzed * zigmaxOlap;
2290 
2291  xlenOlap = xmaxOlap - xminOlap;
2292  ylenOlap = ymaxOlap - yminOlap;
2293  zlenOlap = zmaxOlap - zminOlap;
2294 
2295  xcentOlap = (xminOlap + 0.5*xlenOlap) - xcent;
2296  ycentOlap = (yminOlap + 0.5*ylenOlap) - ycent;
2297  zcentOlap = (zminOlap + 0.5*zlenOlap) - zcent;
2298  if (VABS(xcentOlap) < VSMALL) xcentOlap = 0.0;
2299  if (VABS(ycentOlap) < VSMALL) ycentOlap = 0.0;
2300  if (VABS(zcentOlap) < VSMALL) zcentOlap = 0.0;
2301 
2302  Vnm_print(0, "NOsh_setupMGPARA: Olap part length = (%g, %g, %g)\n",
2303  xlenOlap, ylenOlap, zlenOlap);
2304  Vnm_print(0, "NOsh_setupMGPARA: Olap part center displacement = (%g, %g, %g)\n",
2305  xcentOlap, ycentOlap, zcentOlap);
2306 
2307 
2308  /* Calculate the boundary flags:
2309  Flags are set to 1 when another processor is present along the boundary
2310  Flags are otherwise set to 0. */
2311 
2312  if (ip == 0) mgparm->partDisjOwnSide[VAPBS_LEFT] = 0;
2313  else mgparm->partDisjOwnSide[VAPBS_LEFT] = 1;
2314  if (ip == (npx-1)) mgparm->partDisjOwnSide[VAPBS_RIGHT] = 0;
2315  else mgparm->partDisjOwnSide[VAPBS_RIGHT] = 1;
2316  if (jp == 0) mgparm->partDisjOwnSide[VAPBS_BACK] = 0;
2317  else mgparm->partDisjOwnSide[VAPBS_BACK] = 1;
2318  if (jp == (npy-1)) mgparm->partDisjOwnSide[VAPBS_FRONT] = 0;
2319  else mgparm->partDisjOwnSide[VAPBS_FRONT] = 1;
2320  if (kp == 0) mgparm->partDisjOwnSide[VAPBS_DOWN] = 0;
2321  else mgparm->partDisjOwnSide[VAPBS_DOWN] = 1;
2322  if (kp == (npz-1)) mgparm->partDisjOwnSide[VAPBS_UP] = 0;
2323  else mgparm->partDisjOwnSide[VAPBS_UP] = 1;
2324 
2325  Vnm_print(0, "NOsh_setupMGPARA: partDisjOwnSide[LEFT] = %d\n",
2326  mgparm->partDisjOwnSide[VAPBS_LEFT]);
2327  Vnm_print(0, "NOsh_setupMGPARA: partDisjOwnSide[RIGHT] = %d\n",
2328  mgparm->partDisjOwnSide[VAPBS_RIGHT]);
2329  Vnm_print(0, "NOsh_setupMGPARA: partDisjOwnSide[FRONT] = %d\n",
2330  mgparm->partDisjOwnSide[VAPBS_FRONT]);
2331  Vnm_print(0, "NOsh_setupMGPARA: partDisjOwnSide[BACK] = %d\n",
2332  mgparm->partDisjOwnSide[VAPBS_BACK]);
2333  Vnm_print(0, "NOsh_setupMGPARA: partDisjOwnSide[UP] = %d\n",
2334  mgparm->partDisjOwnSide[VAPBS_UP]);
2335  Vnm_print(0, "NOsh_setupMGPARA: partDisjOwnSide[DOWN] = %d\n",
2336  mgparm->partDisjOwnSide[VAPBS_DOWN]);
2337 
2338  /* Set the mesh parameters */
2339  mgparm->fglen[0] = xlenOlap;
2340  mgparm->fglen[1] = ylenOlap;
2341  mgparm->fglen[2] = zlenOlap;
2342  mgparm->partDisjLength[0] = xlenDisj;
2343  mgparm->partDisjLength[1] = ylenDisj;
2344  mgparm->partDisjLength[2] = zlenDisj;
2345  mgparm->partDisjCenter[0] = mgparm->fcenter[0] + xcentDisj;
2346  mgparm->partDisjCenter[1] = mgparm->fcenter[1] + ycentDisj;
2347  mgparm->partDisjCenter[2] = mgparm->fcenter[2] + zcentDisj;
2348  mgparm->fcenter[0] += xcentOlap;
2349  mgparm->fcenter[1] += ycentOlap;
2350  mgparm->fcenter[2] += zcentOlap;
2351 
2352  Vnm_print(0, "NOsh_setupCalcMGPARA (%s, %d): Set up *relative* partition \
2353 centers...\n", __FILE__, __LINE__);
2354  Vnm_print(0, "NOsh_setupCalcMGPARA (%s, %d): Absolute centers will be set \
2355 in NOsh_setupMGAUTO\n", __FILE__, __LINE__);
2356  Vnm_print(0, "NOsh_setupCalcMGPARA (%s, %d): partDisjCenter = %g %g %g\n",
2357  __FILE__, __LINE__,
2358  mgparm->partDisjCenter[0],
2359  mgparm->partDisjCenter[1],
2360  mgparm->partDisjCenter[2]);
2361  Vnm_print(0, "NOsh_setupCalcMGPARA (%s, %d): ccenter = %g %g %g\n",
2362  __FILE__, __LINE__,
2363  mgparm->ccenter[0],
2364  mgparm->ccenter[1],
2365  mgparm->ccenter[2]);
2366  Vnm_print(0, "NOsh_setupCalcMGPARA (%s, %d): fcenter = %g %g %g\n",
2367  __FILE__, __LINE__,
2368  mgparm->fcenter[0],
2369  mgparm->fcenter[1],
2370  mgparm->fcenter[2]);
2371 
2372 
2373  /* Setup the automatic focusing calculations associated with this processor */
2374  return NOsh_setupCalcMGAUTO(thee, elec);
2375 
2376 }
2377 
2378 VPUBLIC int NOsh_parseFEM(
2379  NOsh *thee,
2380  Vio *sock,
2381  NOsh_calc *elec
2382  ) {
2383 
2384  char tok[VMAX_BUFSIZE];
2385  FEMparm *feparm = VNULL;
2386  PBEparm *pbeparm = VNULL;
2387  int rc;
2388  Vrc_Codes vrc;
2389 
2390  /* Check the arguments */
2391  if (thee == VNULL) {
2392  Vnm_print(2, "NOsh_parseFEM: Got NULL thee!\n");
2393  return 0;
2394  }
2395  if (sock == VNULL) {
2396  Vnm_print(2, "NOsh_parseFEM: Got pointer to NULL socket!\n");
2397  return 0;
2398  }
2399  if (elec == VNULL) {
2400  Vnm_print(2, "NOsh_parseFEM: Got pointer to NULL elec object!\n");
2401  return 0;
2402  }
2403  feparm = elec->femparm;
2404  if (feparm == VNULL) {
2405  Vnm_print(2, "NOsh_parseFEM: Got pointer to NULL feparm object!\n");
2406  return 0;
2407  }
2408  pbeparm = elec->pbeparm;
2409  if (feparm == VNULL) {
2410  Vnm_print(2, "NOsh_parseFEM: Got pointer to NULL pbeparm object!\n");
2411  return 0;
2412  }
2413 
2414  Vnm_print(0, "NOsh_parseFEM: Parsing parameters for FEM calculation\n");
2415 
2416  /* Start snarfing tokens from the input stream */
2417  rc = 1;
2418  while (Vio_scanf(sock, "%s", tok) == 1) {
2419 
2420  Vnm_print(0, "NOsh_parseFEM: Parsing %s...\n", tok);
2421 
2422  /* See if it's an END token */
2423  if (Vstring_strcasecmp(tok, "end") == 0) {
2424  feparm->parsed = 1;
2425  pbeparm->parsed = 1;
2426  rc = 1;
2427  break;
2428  }
2429 
2430  /* Pass the token through a series of parsers */
2431  rc = PBEparm_parseToken(pbeparm, tok, sock);
2432  if (rc == -1) {
2433  Vnm_print(0, "NOsh_parseFEM: parsePBE error!\n");
2434  break;
2435  } else if (rc == 0) {
2436  /* Pass the token to the generic MG parser */
2437  vrc = FEMparm_parseToken(feparm, tok, sock);
2438  if (vrc == VRC_FAILURE) {
2439  Vnm_print(0, "NOsh_parseFEM: parseMG error!\n");
2440  break;
2441  } else if (vrc == VRC_WARNING) {
2442  /* We ran out of parsers! */
2443  Vnm_print(2, "NOsh: Unrecognized keyword: %s\n", tok);
2444  break;
2445  }
2446  }
2447  }
2448 
2449  /* Handle various errors arising in the token-snarfing loop -- these all
2450  * just result in simple returns right now */
2451  if (rc == -1) return 0;
2452  if (rc == 0) return 0;
2453 
2454  /* Check the status of the parameter objects */
2455  if ((!FEMparm_check(feparm)) || (!PBEparm_check(pbeparm))) {
2456  Vnm_print(2, "NOsh: FEM parameters not set correctly!\n");
2457  return 0;
2458  }
2459 
2460  return 1;
2461 
2462 }
2463 
2464 VPRIVATE int NOsh_setupCalcFEMANUAL(
2465  NOsh *thee,
2466  NOsh_calc *elec
2467  ) {
2468 
2469  FEMparm *feparm = VNULL;
2470  PBEparm *pbeparm = VNULL;
2471  NOsh_calc *calc = VNULL;
2472 
2473  VASSERT(thee != VNULL);
2474  VASSERT(elec != VNULL);
2475  feparm = elec->femparm;
2476  VASSERT(feparm != VNULL);
2477  pbeparm = elec->pbeparm;
2478  VASSERT(pbeparm);
2479 
2480  /* Check to see if he have any room left for this type of
2481  * calculation, if so: set the calculation type, update the number
2482  * of calculations of this type, and parse the rest of the section
2483  */
2484  if (thee->ncalc >= NOSH_MAXCALC) {
2485  Vnm_print(2, "NOsh: Too many calculations in this run!\n");
2486  Vnm_print(2, "NOsh: Current max is %d; ignoring this calculation\n",
2487  NOSH_MAXCALC);
2488  return 0;
2489  }
2490  thee->calc[thee->ncalc] = NOsh_calc_ctor(NCT_FEM);
2491  calc = thee->calc[thee->ncalc];
2492  (thee->ncalc)++;
2493 
2494  /* Copy over contents of ELEC */
2495  NOsh_calc_copy(calc, elec);
2496 
2497 
2498  return 1;
2499 }
2500 
2501 VPUBLIC int NOsh_parseAPOL(
2502  NOsh *thee,
2503  Vio *sock,
2504  NOsh_calc *elec
2505  ) {
2506 
2507  char tok[VMAX_BUFSIZE];
2508  APOLparm *apolparm = VNULL;
2509  int rc;
2510 
2511  /* Check the arguments */
2512  if (thee == VNULL) {
2513  Vnm_print(2, "NOsh_parseAPOL: Got NULL thee!\n");
2514  return 0;
2515  }
2516  if (sock == VNULL) {
2517  Vnm_print(2, "NOsh_parseAPOL: Got pointer to NULL socket!\n");
2518  return 0;
2519  }
2520  if (elec == VNULL) {
2521  Vnm_print(2, "NOsh_parseAPOL: Got pointer to NULL elec object!\n");
2522  return 0;
2523  }
2524  apolparm = elec->apolparm;
2525  if (apolparm == VNULL) {
2526  Vnm_print(2, "NOsh_parseAPOL: Got pointer to NULL apolparm object!\n");
2527  return 0;
2528  }
2529 
2530  Vnm_print(0, "NOsh_parseAPOL: Parsing parameters for APOL calculation\n");
2531 
2532  /* Start snarfing tokens from the input stream */
2533  rc = 1;
2534  while (Vio_scanf(sock, "%s", tok) == 1) {
2535 
2536  Vnm_print(0, "NOsh_parseAPOL: Parsing %s...\n", tok);
2537  /* See if it's an END token */
2538  if (Vstring_strcasecmp(tok, "end") == 0) {
2539  apolparm->parsed = 1;
2540  rc = 1;
2541  break;
2542  }
2543 
2544  /* Pass the token through a series of parsers */
2545  /* Pass the token to the generic non-polar parser */
2546  rc = APOLparm_parseToken(apolparm, tok, sock);
2547  if (rc == -1) {
2548  Vnm_print(0, "NOsh_parseFEM: parseMG error!\n");
2549  break;
2550  } else if (rc == 0) {
2551  /* We ran out of parsers! */
2552  Vnm_print(2, "NOsh: Unrecognized keyword: %s\n", tok);
2553  break;
2554  }
2555 
2556  }
2557 
2558  /* Handle various errors arising in the token-snarfing loop -- these all
2559  * just result in simple returns right now */
2560  if (rc == -1) return 0;
2561  if (rc == 0) return 0;
2562 
2563  /* Check the status of the parameter objects */
2564  if (!APOLparm_check(apolparm)) {
2565  Vnm_print(2, "NOsh: APOL parameters not set correctly!\n");
2566  return 0;
2567  }
2568 
2569  return 1;
2570 
2571 }
2572 
2573 
2574 VPRIVATE int NOsh_setupCalcAPOL(
2575  NOsh *thee,
2576  NOsh_calc *apol
2577  ) {
2578 
2579  NOsh_calc *calc = VNULL;
2580 
2581  VASSERT(thee != VNULL);
2582  VASSERT(apol != VNULL);
2583 
2584  /* Check to see if he have any room left for this type of
2585  * calculation, if so: set the calculation type, update the number
2586  * of calculations of this type, and parse the rest of the section
2587  */
2588  if (thee->ncalc >= NOSH_MAXCALC) {
2589  Vnm_print(2, "NOsh: Too many calculations in this run!\n");
2590  Vnm_print(2, "NOsh: Current max is %d; ignoring this calculation\n",
2591  NOSH_MAXCALC);
2592  return 0;
2593  }
2594  thee->calc[thee->ncalc] = NOsh_calc_ctor(NCT_APOL);
2595  calc = thee->calc[thee->ncalc];
2596  (thee->ncalc)++;
2597 
2598  /* Copy over contents of APOL */
2599  NOsh_calc_copy(calc, apol);
2600 
2601  return 1;
2602 }
2603 
2604 
2605 VPRIVATE int NOsh_setupCalcBEMMANUAL(
2606  NOsh *thee,
2607  NOsh_calc *elec
2608  ) {
2609 
2610  BEMparm *bemparm = VNULL;
2611  PBEparm *pbeparm = VNULL;
2612  NOsh_calc *calc = VNULL;
2613 
2614  if (thee == VNULL) {
2615  Vnm_print(2, "NOsh_setupCalcBEMMANUAL: Got NULL thee!\n");
2616  return 0;
2617  }
2618  if (elec == VNULL) {
2619  Vnm_print(2, "NOsh_setupCalcBEMMANUAL: Got NULL calc!\n");
2620  return 0;
2621  }
2622  bemparm = elec->bemparm;
2623  if (bemparm == VNULL) {
2624  Vnm_print(2, "NOsh_setupCalcBEMMANUAL: Got NULL bemparm -- was this calculation \
2625 set up?\n");
2626  return 0;
2627  }
2628  pbeparm = elec->pbeparm;
2629  if (pbeparm == VNULL) {
2630  Vnm_print(2, "NOsh_setupCalcBEMMANUAL: Got NULL pbeparm -- was this calculation \
2631 set up?\n");
2632  return 0;
2633  }
2634 
2635  /* Set up missing BEM parameters */
2636  if (bemparm->settree_order == 0) {
2637  bemparm->tree_order=1;
2638  }
2639 
2640  if (bemparm->settree_n0 == 0) {
2641  bemparm->tree_n0=500;
2642  }
2643 
2644  if (bemparm->setmac == 0) {
2645  bemparm->mac=0.8;
2646  }
2647 
2648  /* Check to see if he have any room left for this type of calculation, if
2649  so: set the calculation type, update the number of calculations of this type,
2650  and parse the rest of the section */
2651  if (thee->ncalc >= NOSH_MAXCALC) {
2652  Vnm_print(2, "NOsh: Too many calculations in this run!\n");
2653  Vnm_print(2, "NOsh: Current max is %d; ignoring this calculation\n",
2654  NOSH_MAXCALC);
2655  return 0;
2656  }
2657 
2658  /* Get the next calculation object and increment the number of calculations */
2659  thee->calc[thee->ncalc] = NOsh_calc_ctor(NCT_BEM);
2660  calc = thee->calc[thee->ncalc];
2661  (thee->ncalc)++;
2662 
2663  /* Copy over contents of ELEC */
2664  NOsh_calc_copy(calc, elec);
2665 
2666 
2667  return 1;
2668 }
2669 
2670 VPRIVATE int NOsh_setupCalcGEOFLOWMANUAL(
2671  NOsh *thee,
2672  NOsh_calc *elec
2673  ) {
2674 
2675  GEOFLOWparm *parm = VNULL;
2676  APOLparm *apolparm = VNULL;
2677  PBEparm *pbeparm = VNULL;
2678  NOsh_calc *calc = VNULL;
2679 
2680  if (thee == VNULL) {
2681  Vnm_print(2, "NOsh_setupCalcGEOFLOWMANUAL: Got NULL thee!\n");
2682  return 0;
2683  }
2684  if (elec == VNULL) {
2685  Vnm_print(2, "NOsh_setupCalcGEOFLOWMANUAL: Got NULL calc!\n");
2686  return 0;
2687  }
2688  parm = elec->geoflowparm;
2689  if (parm == VNULL) {
2690  Vnm_print(2, "NOsh_setupCalcGEOFLOWMANUAL: Got NULL geoflowparm -- was this calculation \
2691 set up?\n");
2692  return 0;
2693  }
2694  apolparm = elec->apolparm;
2695  if (parm == VNULL) {
2696  Vnm_print(2, "NOsh_setupCalcGEOFLOWMANUAL: Got NULL apolparm -- was this calculation \
2697 set up?\n");
2698  return 0;
2699  }
2700  pbeparm = elec->pbeparm;
2701  if (pbeparm == VNULL) {
2702  Vnm_print(2, "NOsh_setupCalcGEOFLOWMANUAL: Got NULL pbeparm -- was this calculation \
2703 set up?\n");
2704  return 0;
2705  }
2706 
2707  /* Check to see if he have any room left for this type of calculation, if
2708  so: set the calculation type, update the number of calculations of this type,
2709  and parse the rest of the section */
2710  if (thee->ncalc >= NOSH_MAXCALC) {
2711  Vnm_print(2, "NOsh: Too many calculations in this run!\n");
2712  Vnm_print(2, "NOsh: Current max is %d; ignoring this calculation\n",
2713  NOSH_MAXCALC);
2714  return 0;
2715  }
2716 
2717  /* Get the next calculation object and increment the number of calculations */
2718  thee->calc[thee->ncalc] = NOsh_calc_ctor(NCT_GEOFLOW);
2719  calc = thee->calc[thee->ncalc];
2720  (thee->ncalc)++;
2721 
2722  /* Copy over contents of ELEC */
2723  NOsh_calc_copy(calc, elec);
2724 
2725  return 1;
2726 }
2727 
2728 VPRIVATE int NOsh_setupCalcPBAMAUTO(
2729  NOsh *thee,
2730  NOsh_calc *elec
2731  ) {
2732 
2733  PBAMparm *parm = VNULL;
2734  PBEparm *pbeparm = VNULL;
2735  NOsh_calc *calc = VNULL;
2736 
2737  if (thee == VNULL) {
2738  Vnm_print(2, "NOsh_setupCalcPBAMAUTO: Got NULL thee!\n");
2739  return 0;
2740  }
2741  if (elec == VNULL) {
2742  Vnm_print(2, "NOsh_setupCalcPBAMAUTO: Got NULL calc!\n");
2743  return 0;
2744  }
2745  parm = elec->pbamparm;
2746  if (parm == VNULL) {
2747  Vnm_print(2, "NOsh_setupCalcPBAMAUTO: Got NULL pbamparm -- was this calculation \
2748 set up?\n");
2749  return 0;
2750  }
2751  pbeparm = elec->pbeparm;
2752  if (pbeparm == VNULL) {
2753  Vnm_print(2, "NOsh_setupCalcPBAMAUTO: Got NULL pbeparm -- was this calculation \
2754 set up?\n");
2755  return 0;
2756  }
2757 
2758  /* Check to see if he have any room left for this type of calculation, if
2759  so: set the calculation type, update the number of calculations of this type,
2760  and parse the rest of the section */
2761  if (thee->ncalc >= NOSH_MAXCALC) {
2762  Vnm_print(2, "NOsh: Too many calculations in this run!\n");
2763  Vnm_print(2, "NOsh: Current max is %d; ignoring this calculation\n",
2764  NOSH_MAXCALC);
2765  return 0;
2766  }
2767 
2768  /* Get the next calculation object and increment the number of calculations */
2769  thee->calc[thee->ncalc] = NOsh_calc_ctor(NCT_PBAM);
2770  calc = thee->calc[thee->ncalc];
2771  (thee->ncalc)++;
2772 
2773  /* Copy over contents of ELEC */
2774  NOsh_calc_copy(calc, elec);
2775 
2776  return 1;
2777 }
2778 
2779 VPRIVATE int NOsh_setupCalcPBSAMAUTO(
2780  NOsh *thee,
2781  NOsh_calc *elec
2782  ) {
2783 
2784  PBAMparm *parm = VNULL;
2785  PBSAMparm *samparm = VNULL;
2786  PBEparm *pbeparm = VNULL;
2787  NOsh_calc *calc = VNULL;
2788 
2789  if (thee == VNULL) {
2790  Vnm_print(2, "NOsh_setupCalcPBSAMAUTO: Got NULL thee!\n");
2791  return 0;
2792  }
2793  if (elec == VNULL) {
2794  Vnm_print(2, "NOsh_setupCalcPBSAMAUTO: Got NULL calc!\n");
2795  return 0;
2796  }
2797  parm = elec->pbamparm;
2798  if (parm == VNULL) {
2799  Vnm_print(2, "NOsh_setupCalcPBSAMAUTO: Got NULL pbamparm -- was this calculation \
2800 set up?\n");
2801  return 0;
2802  }
2803  samparm = elec->pbsamparm;
2804  if (samparm == VNULL) {
2805  Vnm_print(2, "NOsh_setupCalcPBSAMAUTO: Got NULL pbsamparm -- was this calculation \
2806 set up?\n");
2807  return 0;
2808  }
2809  pbeparm = elec->pbeparm;
2810  if (pbeparm == VNULL) {
2811  Vnm_print(2, "NOsh_setupCalcPBAMAUTO: Got NULL pbeparm -- was this calculation \
2812 set up?\n");
2813  return 0;
2814  }
2815 
2816  /* Check to see if he have any room left for this type of calculation, if
2817  so: set the calculation type, update the number of calculations of this type,
2818  and parse the rest of the section */
2819  if (thee->ncalc >= NOSH_MAXCALC) {
2820  Vnm_print(2, "NOsh: Too many calculations in this run!\n");
2821  Vnm_print(2, "NOsh: Current max is %d; ignoring this calculation\n",
2822  NOSH_MAXCALC);
2823  return 0;
2824  }
2825 
2826  /* Get the next calculation object and increment the number of calculations */
2827  thee->calc[thee->ncalc] = NOsh_calc_ctor(NCT_PBSAM);
2828  calc = thee->calc[thee->ncalc];
2829  (thee->ncalc)++;
2830 
2831  /* Copy over contents of ELEC */
2832  NOsh_calc_copy(calc, elec);
2833 
2834  return 1;
2835 }
2836 
2837 
2838 VPUBLIC int NOsh_parseBEM(
2839  NOsh *thee,
2840  Vio *sock,
2841  NOsh_calc *elec
2842  ) {
2843 
2844  char tok[VMAX_BUFSIZE];
2845  BEMparm *bemparm = VNULL;
2846  PBEparm *pbeparm = VNULL;
2847  int rc;
2848 
2849  /* Check the arguments */
2850  if (thee == VNULL) {
2851  Vnm_print(2, "NOsh: Got NULL thee!\n");
2852  return 0;
2853  }
2854  if (sock == VNULL) {
2855  Vnm_print(2, "NOsh: Got pointer to NULL socket!\n");
2856  return 0;
2857  }
2858  if (elec == VNULL) {
2859  Vnm_print(2, "NOsh: Got pointer to NULL elec object!\n");
2860  return 0;
2861  }
2862  bemparm = elec->bemparm;
2863  if (bemparm == VNULL) {
2864  Vnm_print(2, "NOsh: Got pointer to NULL bemparm object!\n");
2865  return 0;
2866  }
2867  pbeparm = elec->pbeparm;
2868  if (pbeparm == VNULL) {
2869  Vnm_print(2, "NOsh: Got pointer to NULL pbeparm object!\n");
2870  return 0;
2871  }
2872 
2873  Vnm_print(0, "NOsh_parseBEM: Parsing parameters for BEM calculation\n");
2874 
2875 
2876  /* Start snarfing tokens from the input stream */
2877  rc = 1;
2878  while (Vio_scanf(sock, "%s", tok) == 1) {
2879 
2880  Vnm_print(0, "NOsh_parseBEM: Parsing %s...\n", tok);
2881 
2882  /* See if it's an END token */
2883  if (Vstring_strcasecmp(tok, "end") == 0) {
2884  bemparm->parsed = 1;
2885  pbeparm->parsed = 1;
2886  rc = 1;
2887  break;
2888  }
2889 
2890  /* Pass the token through a series of parsers */
2891  rc = PBEparm_parseToken(pbeparm, tok, sock);
2892  if (rc == -1) {
2893  Vnm_print(0, "NOsh_parseBEM: parsePBE error!\n");
2894  break;
2895  } else if (rc == 0) {
2896  /* Pass the token to the generic BEM parser */
2897  rc = BEMparm_parseToken(bemparm, tok, sock);
2898  if (rc == -1) {
2899  Vnm_print(0, "NOsh_parseBEM: parseBEM error!\n");
2900  break;
2901  } else if (rc == 0) {
2902  /* We ran out of parsers! */
2903  Vnm_print(2, "NOsh: Unrecognized keyword: %s\n", tok);
2904  break;
2905  }
2906  }
2907  }
2908 
2909  /* Handle various errors arising in the token-snarfing loop -- these all
2910  just result in simple returns right now */
2911  if (rc == -1) return 0;
2912  if (rc == 0) return 0;
2913 
2914  /* Check the status of the parameter objects */
2915  if ((BEMparm_check(bemparm) == VRC_FAILURE) || (!PBEparm_check(pbeparm))) {
2916  Vnm_print(2, "NOsh: BEM parameters not set correctly!\n");
2917  return 0;
2918  }
2919 
2920  return 1;
2921 }
2922 
2923 VPUBLIC int NOsh_parseGEOFLOW(
2924  NOsh *thee,
2925  Vio *sock,
2926  NOsh_calc *elec
2927  ) {
2928 
2929  char tok[VMAX_BUFSIZE];
2930  GEOFLOWparm *parm = VNULL;
2931  APOLparm *apolparm = VNULL;
2932  PBEparm *pbeparm = VNULL;
2933  int rc;
2934 
2935  /* Check the arguments */
2936  if (thee == VNULL) {
2937  Vnm_print(2, "NOsh: Got NULL thee!\n");
2938  return 0;
2939  }
2940  if (sock == VNULL) {
2941  Vnm_print(2, "NOsh: Got pointer to NULL socket!\n");
2942  return 0;
2943  }
2944  if (elec == VNULL) {
2945  Vnm_print(2, "NOsh: Got pointer to NULL elec object!\n");
2946  return 0;
2947  }
2948  parm = elec->geoflowparm;
2949  if (parm == VNULL) {
2950  Vnm_print(2, "NOsh: Got pointer to NULL geoflowparm object!\n");
2951  return 0;
2952  }
2953  apolparm = elec->apolparm;
2954  if (parm == VNULL) {
2955  Vnm_print(2, "NOsh: Got pointer to NULL apolparm object!\n");
2956  return 0;
2957  }
2958  pbeparm = elec->pbeparm;
2959  if (pbeparm == VNULL) {
2960  Vnm_print(2, "NOsh: Got pointer to NULL pbeparm object!\n");
2961  return 0;
2962  }
2963 
2964  Vnm_print(0, "NOsh_parseGEOFLOW: Parsing parameters for GEOFLOW calculation\n");
2965 
2966 
2967  /* Start snarfing tokens from the input stream */
2968  rc = 1;
2969  while (Vio_scanf(sock, "%s", tok) == 1) {
2970 
2971  Vnm_print(0, "NOsh_parseGEOFLOW: Parsing %s...\n", tok);
2972 
2973  /* See if it's an END token */
2974  if (Vstring_strcasecmp(tok, "end") == 0) {
2975  parm->parsed = 1;
2976  pbeparm->parsed = 1;
2977  apolparm->parsed = 1;
2978  rc = 1;
2979  break;
2980  }
2981 
2982  if (Vstring_strcasecmp(tok, "ion") == 0) {
2983  Vnm_print(2, "parseGEOFLOW: WARNING! ion not implemented for geometric flow!\n");
2984  }
2985 
2986  /* Pass the token through a series of parsers */
2987  rc = PBEparm_parseToken(pbeparm, tok, sock);
2988  if (rc == -1) {
2989  Vnm_print(0, "NOsh_parseGEOFLOW: parsePBE error!\n");
2990  break;
2991  } else if (rc == 0) {
2992  /* Pass the token to the generic GEOFLOW parser */
2993  rc = APOLparm_parseToken(apolparm, tok, sock);
2994  if (rc == -1) {
2995  Vnm_print(0, "NOsh_parseAPOL: parseAPOL error!\n");
2996  break;
2997  } else if (rc == 0) {
2998  rc = GEOFLOWparm_parseToken(parm, tok, sock);
2999  if (rc == -1) {
3000  Vnm_print(0, "NOsh_parseGEOFLOW: parseGEOFLOW error!\n");
3001  break;
3002  } else if (rc == 0) {
3003  /* We ran out of parsers! */
3004  Vnm_print(2, "NOsh: Unrecognized keyword: %s\n", tok);
3005  break;
3006  }
3007  }
3008  }
3009  }
3010 
3011  pbeparm->setsrfm=1;
3012  pbeparm->srad=0.0;
3013  pbeparm->setsrad=1;
3014  pbeparm->settemp=1;
3015 
3016  /* Handle various errors arising in the token-snarfing loop -- these all
3017  just result in simple returns right now */
3018  if (rc == -1) return 0;
3019  if (rc == 0) return 0;
3020 
3021  /* Check the status of the parameter objects */
3022  if ((GEOFLOWparm_check(parm) == VRC_FAILURE) || (!PBEparm_check(pbeparm))) {
3023  Vnm_print(2, "NOsh: GEOFLOW parameters not set correctly!\n");
3024  return 0;
3025  }
3026  /*currently the only bc handle by geoflow is mdh so we check here if mdh was read*/
3027  if(pbeparm->bcfl != BCFL_MDH){
3028  Vnm_print(2, "NOsh_parseGEOFLOW: Geoflow currently only supports mdh boundary conditions!\n");
3029  Vnm_print(2, "NOsh_parseGEOFLOW: please change bcfl keyword.\n");
3030  return 0;
3031  }
3032 
3033  return 1;
3034 }
3035 
3036 
3037 VPUBLIC int NOsh_parsePBAM(
3038  NOsh *thee,
3039  Vio *sock,
3040  NOsh_calc *elec
3041  ) {
3042 
3043  char tok[VMAX_BUFSIZE];
3044  PBAMparm *parm = VNULL;
3045  PBEparm *pbeparm = VNULL;
3046  int rc;
3047 
3048  /* Check the arguments */
3049  if (thee == VNULL) {
3050  Vnm_print(2, "NOsh: Got NULL thee!\n");
3051  return 0;
3052  }
3053  if (sock == VNULL) {
3054  Vnm_print(2, "NOsh: Got pointer to NULL socket!\n");
3055  return 0;
3056  }
3057  if (elec == VNULL) {
3058  Vnm_print(2, "NOsh: Got pointer to NULL elec object!\n");
3059  return 0;
3060  }
3061  parm = elec->pbamparm;
3062  if (parm == VNULL) {
3063  Vnm_print(2, "NOsh: Got pointer to NULL pbam object!\n");
3064  return 0;
3065  }
3066  pbeparm = elec->pbeparm;
3067  if (pbeparm == VNULL) {
3068  Vnm_print(2, "NOsh: Got pointer to NULL pbeparm object!\n");
3069  return 0;
3070  }
3071  Vnm_print(0, "NOsh_parsePBAM: Parsing parameters for PBAM calculation\n");
3072 
3073  /* Start snarfing tokens from the input stream */
3074  rc = 1;
3075  while (Vio_scanf(sock, "%s", tok) == 1) {
3076 
3077  Vnm_print(0, "NOsh_parsePBAM: Parsing %s...\n", tok);
3078 
3079  /* See if it's an END token */
3080  if (Vstring_strcasecmp(tok, "end") == 0) {
3081  parm->parsed = 1;
3082  pbeparm->parsed = 1;
3083  rc = 1;
3084  break;
3085  }
3086 
3087  if (Vstring_strcasecmp(tok, "ion") == 0) {
3088  Vnm_print(2, "parsePBAM: WARNING! ion not implemented for PBAM!\n");
3089  }
3090 
3091  /* Pass the token through a series of parsers */
3092  rc = PBEparm_parseToken(pbeparm, tok, sock);
3093  if (rc == -1) {
3094  Vnm_print(0, "NOsh_parsePBAM: parsePBE error!\n");
3095  break;
3096  } else if (rc == 0) {
3097  rc = PBAMparm_parseToken(parm, tok, sock);
3098  if (rc == -1) {
3099  Vnm_print(0, "NOsh_parsePBAM: parsePBAM error!\n");
3100  break;
3101  } else if (rc == 0) {
3102  /* We ran out of parsers! */
3103  Vnm_print(2, "NOsh: Unrecognized keyword: %s\n", tok);
3104  break;
3105  }
3106  }
3107  }
3108 
3109  pbeparm->setsrfm=1;
3110  pbeparm->setsrad=1;
3111  pbeparm->settemp=1; // do need temp, but have default, incase
3112  pbeparm->setmolid=1; // for unneeded mol flag
3113  pbeparm->setpbetype=1; // unneeded pbe type
3114  pbeparm->setbcfl=1; // unneeded bcfl
3115  pbeparm->setsdens=1;
3116 
3117 
3118  /* Handle various errors arising in the token-snarfing loop -- these all
3119  just result in simple returns right now */
3120  if (rc == -1) return 0;
3121  if (rc == 0) return 0;
3122 
3123  /* Check the status of the parameter objects */
3124  if ((PBAMparm_check(parm) == VRC_FAILURE) || (!PBEparm_check(pbeparm))) {
3125  Vnm_print(2, "NOsh: PBAM parameters not set correctly!\n");
3126  return 0;
3127  }
3128  return 1;
3129 }
3130 
3131 VPUBLIC int NOsh_parsePBSAM(
3132  NOsh *thee,
3133  Vio *sock,
3134  NOsh_calc *elec
3135  ) {
3136 
3137  char tok[VMAX_BUFSIZE];
3138  PBAMparm *parm = VNULL;
3139  PBSAMparm *samparm = VNULL;
3140  PBEparm *pbeparm = VNULL;
3141  int rc;
3142 
3143  /* Check the arguments */
3144  if (thee == VNULL) {
3145  Vnm_print(2, "NOsh: Got NULL thee!\n");
3146  return 0;
3147  }
3148  if (sock == VNULL) {
3149  Vnm_print(2, "NOsh: Got pointer to NULL socket!\n");
3150  return 0;
3151  }
3152  if (elec == VNULL) {
3153  Vnm_print(2, "NOsh: Got pointer to NULL elec object!\n");
3154  return 0;
3155  }
3156  parm = elec->pbamparm;
3157  if (parm == VNULL) {
3158  Vnm_print(2, "NOsh: Got pointer to NULL pbam object!\n");
3159  return 0;
3160  }
3161  samparm = elec->pbsamparm;
3162  if (samparm == VNULL) {
3163  Vnm_print(2, "NOsh: Got pointer to NULL pbsam object!\n");
3164  return 0;
3165  }
3166  pbeparm = elec->pbeparm;
3167  if (pbeparm == VNULL) {
3168  Vnm_print(2, "NOsh: Got pointer to NULL pbeparm object!\n");
3169  return 0;
3170  }
3171  Vnm_print(0, "NOsh_parsePBSAM: Parsing parameters for PBSAM calculation\n");
3172 
3173  /* Start snarfing tokens from the input stream */
3174  rc = 1;
3175  while (Vio_scanf(sock, "%s", tok) == 1) {
3176 
3177  Vnm_print(0, "NOsh_parsePBSAM: Parsing %s...\n", tok);
3178 
3179  /* See if it's an END token */
3180  if (Vstring_strcasecmp(tok, "end") == 0) {
3181  parm->parsed = 1;
3182  samparm->parsed = 1;
3183  pbeparm->parsed = 1;
3184  rc = 1;
3185  break;
3186  }
3187 
3188  if (Vstring_strcasecmp(tok, "ion") == 0) {
3189  Vnm_print(2, "parsePBSAM: WARNING! ion not implemented for PBSAM!\n");
3190  }
3191 
3192  /* Pass the token through a series of parsers */
3193  rc = PBEparm_parseToken(pbeparm, tok, sock);
3194  if (rc == -1) {
3195  Vnm_print(0, "NOsh_parsePBSAM: parsePBE error!\n");
3196  break;
3197  } else if (rc == 0) {
3198  rc = PBAMparm_parseToken(parm, tok, sock);
3199  if (rc == -1) {
3200  Vnm_print(0, "NOsh_parsePBSAM: parsePBAM error!\n");
3201  break;
3202  } else if ( rc == 0 ) {
3203  rc = PBSAMparm_parseToken(samparm, tok, sock);
3204  if (rc == -1) {
3205  Vnm_print(0, "NOsh_parsePBSAM: parsePBSAM error!\n");
3206  break;
3207  } else if (rc == 0) {
3208  /* We ran out of parsers! */
3209  Vnm_print(2, "NOsh: Unrecognized keyword: %s\n", tok);
3210  break;
3211  }
3212  }
3213  }
3214  }
3215 
3216  pbeparm->setsrfm=1;
3217  pbeparm->setsrad=1;
3218  pbeparm->settemp=1; // do need temp, but have default, incase
3219  pbeparm->setmolid=1; // for unneeded mol flag
3220  pbeparm->setpbetype=1; // unneeded pbe type
3221  pbeparm->setbcfl=1; // unneeded bcfl
3222  pbeparm->setsdens=1;
3223 
3224  /* Handle various errors arising in the token-snarfing loop -- these all
3225  just result in simple returns right now */
3226  if (rc == -1) return 0;
3227  if (rc == 0) return 0;
3228 
3229  /* Check the status of the parameter objects */
3230  if ((PBSAMparm_check(samparm)==VRC_FAILURE) ||
3231  (PBAMparm_check(parm) == VRC_FAILURE) ||
3232  (!PBEparm_check(pbeparm))) {
3233  Vnm_print(2, "NOsh: PBSAM parameters not set correctly!\n");
3234  return 0;
3235  }
3236  return 1;
3237 }
VPUBLIC Vrc_Codes MGparm_parseToken(MGparm *thee, char tok[VMAX_BUFSIZE], Vio *sock)
Parse an MG keyword from an input file.
Definition: mgparm.c:919
VPUBLIC FEMparm * FEMparm_ctor(FEMparm_CalcType type)
Construct FEMparm.
Definition: femparm.c:65
Definition: vhal.h:314
VPUBLIC int NOsh_setupApolCalc(NOsh *thee, Valist *alist[NOSH_MAXMOL])
Setup the series of non-polar calculations.
Definition: nosh.c:1462
MGparm * mgparm
Definition: nosh.h:173
Vdata_Format meshfmt[NOSH_MAXMOL]
Definition: nosh.h:258
int settree_n0
Definition: bemparm.h:107
#define VFLOOR(value)
Wrapped floor to fix floating point issues in the Intel compiler.
Definition: vhal.h:547
VPUBLIC int NOsh_apol2calc(NOsh *thee, int icalc)
Return the name of an apol statement.
Definition: nosh.c:282
VPUBLIC int NOsh_printNarg(NOsh *thee, int iprint)
Return number of arguments to PRINT statement (.
Definition: nosh.c:270
Parameter structure for GEOFLOW-specific variables from input files.
Definition: geoflowparm.h:98
enum eVdata_Format Vdata_Format
Declaration of the Vdata_Format type as the Vdata_Format enum.
Definition: vhal.h:323
int apol2calc[NOSH_MAXCALC]
Definition: nosh.h:229
VPUBLIC char * NOsh_getPotpath(NOsh *thee, int imol)
Returns path to specified potential map.
Definition: nosh.c:225
Definition: nosh.h:120
int tree_n0
Definition: bemparm.h:106
int gotparm
Definition: nosh.h:236
VPUBLIC Vrc_Codes APOLparm_parseToken(APOLparm *thee, char tok[VMAX_BUFSIZE], Vio *sock)
Parse an MG keyword from an input file.
Definition: apolparm.c:577
#define NOSH_MAXMOL
Maximum number of molecules in a run.
Definition: nosh.h:83
VPUBLIC int NOsh_ctor2(NOsh *thee, int rank, int size)
FORTRAN stub to construct NOsh.
Definition: nosh.c:319
int parsed
Definition: bemparm.h:99
Vdata_Format dielfmt[NOSH_MAXMOL]
Definition: nosh.h:246
#define NOSH_MAXPRINT
Maximum number of PRINT statements in a run.
Definition: nosh.h:91
MGparm_CentMeth cmeth
Definition: mgparm.h:137
int setmolid
Definition: pbeparm.h:120
#define VAPBS_DOWN
Face definition for a volume.
Definition: vhal.h:438
Definition: nosh.h:123
VPUBLIC Vrc_Codes PBSAMparm_check(PBSAMparm *thee)
Consistency check for parameter values stored in object.
Definition: pbsamparm.c:110
char potpath[NOSH_MAXMOL][VMAX_ARGLEN]
Definition: nosh.h:251
Parameter structure for PBAM-specific variables from input files.
Definition: pbamparm.h:105
int setasync
Definition: mgparm.h:187
VPUBLIC char * NOsh_getDielXpath(NOsh *thee, int imol)
Returns path to specified x-shifted dielectric map.
Definition: nosh.c:205
FEMparm_CalcType type
Definition: femparm.h:138
int setsize
Definition: mgparm.h:183
NOsh_PrintType printwhat[NOSH_MAXPRINT]
Definition: nosh.h:260
enum eNOsh_PrintType NOsh_PrintType
Declare NOsh_PrintType type.
Definition: nosh.h:165
int nprint
Definition: nosh.h:259
VPUBLIC void MGparm_dtor(MGparm **thee)
Object destructor.
Definition: mgparm.c:175
VPUBLIC void NOsh_dtor(NOsh **thee)
Object destructor.
Definition: nosh.c:354
Definition: nosh.h:103
int setsdens
Definition: pbeparm.h:147
char elecname[NOSH_MAXCALC][VMAX_ARGLEN]
Definition: nosh.h:267
VPUBLIC void FEMparm_copy(FEMparm *thee, FEMparm *source)
Copy target object into thee.
Definition: femparm.c:100
VPUBLIC void PBSAMparm_dtor(PBSAMparm **thee)
Object destructor.
Definition: pbsamparm.c:100
VPUBLIC void BEMparm_copy(BEMparm *thee, BEMparm *parm)
Copy object info into thee.
Definition: bemparm.c:174
VPUBLIC PBEparm * PBEparm_ctor()
Construct PBEparm object.
Definition: pbeparm.c:104
NOsh_calc * calc[NOSH_MAXCALC]
Definition: nosh.h:197
Definition: nosh.h:102
int setmac
Definition: bemparm.h:109
double cglen[3]
Definition: mgparm.h:152
int proc_size
Definition: mgparm.h:182
Contains declarations for class NOsh.
int setgrid
Definition: mgparm.h:134
VPRIVATE char * MCcommChars
Comment characters for socket reads.
Definition: vparam.c:71
int setbcfl
Definition: pbeparm.h:137
VPUBLIC void PBAMparm_dtor(PBAMparm **thee)
Object destructor.
Definition: pbamparm.c:122
VPUBLIC Vrc_Codes FEMparm_parseToken(FEMparm *thee, char tok[VMAX_BUFSIZE], Vio *sock)
Parse an MG keyword from an input file.
Definition: femparm.c:431
int settree_order
Definition: bemparm.h:105
GEOFLOWparm_CalcType type
Definition: geoflowparm.h:100
VPUBLIC BEMparm * BEMparm_ctor(BEMparm_CalcType type)
Construct BEMparm object.
Definition: bemparm.c:66
#define VAPBS_UP
Face definition for a volume.
Definition: vhal.h:420
double fcenter[3]
Definition: mgparm.h:163
GEOFLOWparm * geoflowparm
Definition: nosh.h:176
VPUBLIC void PBSAMparm_copy(PBSAMparm *thee, PBSAMparm *parm)
copy PBSAMparm object int thee.
Definition: pbsamparm.c:135
VPUBLIC int FEMparm_check(FEMparm *thee)
Consistency check for parameter values stored in object.
Definition: femparm.c:143
int fcentmol
Definition: mgparm.h:164
VPUBLIC int NOsh_parseInputFile(NOsh *thee, char *filename)
Parse an input file only from a file.
Definition: nosh.c:498
VPUBLIC void NOsh_calc_dtor(NOsh_calc **thee)
Object destructor.
Definition: nosh.c:423
char dielXpath[NOSH_MAXMOL][VMAX_ARGLEN]
Definition: nosh.h:240
Definition: nosh.h:118
double center[3]
Definition: mgparm.h:138
PBAMparm * pbamparm
Definition: nosh.h:177
int ncalc
Definition: nosh.h:200
VPUBLIC void FEMparm_dtor(FEMparm **thee)
Object destructor.
Definition: femparm.c:133
NOsh_CalcType calctype
Definition: nosh.h:181
VPUBLIC Vrc_Codes APOLparm_check(APOLparm *thee)
Consistency check for parameter values stored in object.
Definition: apolparm.c:179
double fglen[3]
Definition: mgparm.h:154
#define NOSH_MAXPOP
Maximum number of operations in a PRINT statement.
Definition: nosh.h:95
double glen[3]
Definition: mgparm.h:135
VPUBLIC NOsh_PrintType NOsh_printWhat(NOsh *thee, int iprint)
Return an integer ID of the observable to print (.
Definition: nosh.c:264
VPUBLIC void BEMparm_dtor(BEMparm **thee)
Object destructor.
Definition: bemparm.c:114
MGparm_CentMeth fcmeth
Definition: mgparm.h:162
Definition: vhal.h:313
Definition: pbeparm.h:98
APOLparm * apolparm
Definition: nosh.h:180
VPUBLIC char * NOsh_getDielZpath(NOsh *thee, int imol)
Returns path to specified z-shifted dielectric map.
Definition: nosh.c:215
PBAMparm_CalcType type
Definition: pbamparm.h:107
int nkappa
Definition: nosh.h:247
VPUBLIC MGparm * MGparm_ctor(MGparm_CalcType type)
Construct MGparm object.
Definition: mgparm.c:114
Vdata_Format potfmt[NOSH_MAXMOL]
Definition: nosh.h:252
VPUBLIC NOsh_calc * NOsh_getCalc(NOsh *thee, int icalc)
Returns specified calculation object.
Definition: nosh.c:235
NOsh_calc * elec[NOSH_MAXCALC]
Definition: nosh.h:202
PBEparm * pbeparm
Definition: nosh.h:179
int parsed
Definition: mgparm.h:117
VPUBLIC int PBEparm_parseToken(PBEparm *thee, char tok[VMAX_BUFSIZE], Vio *sock)
Parse a keyword from an input file.
Definition: pbeparm.c:1209
VPUBLIC void PBAMparm_copy(PBAMparm *thee, PBAMparm *parm)
copy PBAMparm object int thee.
Definition: pbamparm.c:157
double mac
Definition: bemparm.h:108
MGparm_CalcType type
Definition: mgparm.h:116
int npot
Definition: nosh.h:250
int parsed
Definition: pbamparm.h:108
int proc_rank
Definition: nosh.h:215
Vdata_Format kappafmt[NOSH_MAXMOL]
Definition: nosh.h:249
VPUBLIC void MGparm_copy(MGparm *thee, MGparm *parm)
Copy MGparm object into thee.
Definition: mgparm.c:341
int setsrad
Definition: pbeparm.h:153
Definition: nosh.h:119
VPUBLIC Vrc_Codes GEOFLOWparm_parseToken(GEOFLOWparm *thee, char tok[VMAX_BUFSIZE], Vio *sock)
Parse an MG keyword from an input file.
Definition: geoflowparm.c:212
Parameter structure for PBSAM-specific variables from input files.
Definition: pbsamparm.h:105
VPUBLIC Vrc_Codes GEOFLOWparm_check(GEOFLOWparm *thee)
Consistency check for parameter values stored in object.
Definition: geoflowparm.c:101
#define VEMBED(rctag)
Allows embedding of RCS ID tags in object files.
Definition: vhal.h:556
int nelec
Definition: nosh.h:205
int setrank
Definition: mgparm.h:181
int ncharge
Definition: nosh.h:253
int setglen
Definition: mgparm.h:136
VPUBLIC int NOsh_setupElecCalc(NOsh *thee, Valist *alist[NOSH_MAXMOL])
Setup the series of electrostatics calculations.
Definition: nosh.c:1367
VPUBLIC int NOsh_parseInput(NOsh *thee, Vio *sock)
Parse an input file from a socket.
Definition: nosh.c:513
Definition: vhal.h:310
BEMparm_CalcType type
Definition: bemparm.h:98
VPUBLIC int Vstring_strcasecmp(const char *s1, const char *s2)
Case-insensitive string comparison (BSD standard)
Definition: vstring.c:66
double center[3]
Definition: valist.h:81
int async
Definition: mgparm.h:186
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
VPUBLIC void GEOFLOWparm_copy(GEOFLOWparm *thee, GEOFLOWparm *parm)
copy GEOFLOWparm object int thee.
Definition: geoflowparm.c:127
int ndiel
Definition: nosh.h:239
VPUBLIC int Vstring_isdigit(const char *tok)
A modified sscanf that examines the complete string.
Definition: vstring.c:130
VPUBLIC void PBEparm_copy(PBEparm *thee, PBEparm *parm)
Copy PBEparm object into thee.
Definition: pbeparm.c:283
Parameter structure for BEM-specific variables from input files.
Definition: bemparm.h:96
VPUBLIC int NOsh_printOp(NOsh *thee, int iprint, int iarg)
Return integer ID for specified operation (.
Definition: nosh.c:294
Parameter structure for FEM-specific variables from input files.
Definition: femparm.h:133
double grid[3]
Definition: mgparm.h:133
VPUBLIC void APOLparm_copy(APOLparm *thee, APOLparm *source)
Copy target object into thee.
Definition: apolparm.c:108
PBSAMparm * pbsamparm
Definition: nosh.h:178
VPUBLIC void PBEparm_dtor(PBEparm **thee)
Object destructor.
Definition: pbeparm.c:173
int setpbetype
Definition: pbeparm.h:135
Definition: nosh.h:138
int napol
Definition: nosh.h:211
VPUBLIC int NOsh_getPotfmt(NOsh *thee, int i)
Returns format of specified potential map.
Definition: nosh.c:250
int printcalc[NOSH_MAXPRINT][NOSH_MAXPOP]
Definition: nosh.h:263
VPUBLIC int PBEparm_check(PBEparm *thee)
Consistency check for parameter values stored in object.
Definition: pbeparm.c:183
Definition: nosh.h:121
NOsh_ParmFormat parmfmt
Definition: nosh.h:238
#define VAPBS_BACK
Face definition for a volume.
Definition: vhal.h:432
int pdime[3]
Definition: mgparm.h:178
NOsh_MolFormat molfmt[NOSH_MAXMOL]
Definition: nosh.h:233
char chargepath[NOSH_MAXMOL][VMAX_ARGLEN]
Definition: nosh.h:254
Valist * alist[NOSH_MAXMOL]
Definition: nosh.h:234
VPUBLIC Vrc_Codes MGparm_check(MGparm *thee)
Consistency check for parameter values stored in object.
Definition: mgparm.c:185
Parameter structure for PBE variables from input files.
Definition: pbeparm.h:117
int proc_size
Definition: nosh.h:216
Definition: nosh.h:139
Definition: vhal.h:211
VPUBLIC Vrc_Codes PBAMparm_parseToken(PBAMparm *thee, char tok[VMAX_BUFSIZE], Vio *sock)
Parse an MG keyword from an input file.
Definition: pbamparm.c:646
enum eNOsh_ParmFormat NOsh_ParmFormat
Declare NOsh_ParmFormat type.
Definition: nosh.h:146
PBSAMparm_CalcType type
Definition: pbsamparm.h:107
int parsed
Definition: femparm.h:135
#define VAPBS_FRONT
Face definition for a volume.
Definition: vhal.h:414
int settemp
Definition: pbeparm.h:157
PBEparm_calcForce calcforce
Definition: pbeparm.h:167
Vbcfl bcfl
Definition: pbeparm.h:136
int printnarg[NOSH_MAXPRINT]
Definition: nosh.h:262
enum eNOsh_CalcType NOsh_CalcType
Declare NOsh_CalcType type.
Definition: nosh.h:131
int tree_order
Definition: bemparm.h:104
double partDisjLength[3]
Definition: mgparm.h:173
NOsh_calc * apol[NOSH_MAXCALC]
Definition: nosh.h:208
char dielZpath[NOSH_MAXMOL][VMAX_ARGLEN]
Definition: nosh.h:244
int parsed
Definition: pbsamparm.h:108
VPUBLIC PBAMparm * PBAMparm_ctor(PBAMparm_CalcType type)
Construct PBAMparm object.
Definition: pbamparm.c:66
Parameter structure for MG-specific variables from input files.
Definition: mgparm.h:114
Vdata_Format chargefmt[NOSH_MAXMOL]
Definition: nosh.h:255
int nmol
Definition: nosh.h:231
int bogus
Definition: nosh.h:217
VPUBLIC char * NOsh_getMolpath(NOsh *thee, int imol)
Returns path to specified molecule.
Definition: nosh.c:200
VPUBLIC void NOsh_dtor2(NOsh *thee)
FORTRAN stub for object destructor.
Definition: nosh.c:362
VPUBLIC NOsh * NOsh_ctor(int rank, int size)
Construct NOsh.
Definition: nosh.c:308
VPUBLIC APOLparm * APOLparm_ctor()
Construct APOLparm.
Definition: apolparm.c:65
double ofrac
Definition: mgparm.h:184
VPUBLIC void APOLparm_dtor(APOLparm **thee)
Object destructor.
Definition: apolparm.c:167
int dime[3]
Definition: mgparm.h:120
Container class for list of atom objects.
Definition: valist.h:78
MGparm_CentMeth ccmeth
Definition: mgparm.h:156
VPUBLIC int NOsh_getChargefmt(NOsh *thee, int i)
Returns format of specified charge map.
Definition: nosh.c:255
VPUBLIC char * NOsh_getKappapath(NOsh *thee, int imol)
Returns path to specified kappa map.
Definition: nosh.c:220
VPUBLIC int NOsh_printCalc(NOsh *thee, int iprint, int iarg)
Return calculation ID for specified PRINT statement (.
Definition: nosh.c:301
Class for parsing fixed format input files.
Definition: nosh.h:195
char meshpath[NOSH_MAXMOL][VMAX_ARGLEN]
Definition: nosh.h:257
double srad
Definition: pbeparm.h:152
Calculation class for use when parsing fixed format input files.
Definition: nosh.h:172
int elec2calc[NOSH_MAXCALC]
Definition: nosh.h:221
VPUBLIC char * NOsh_getDielYpath(NOsh *thee, int imol)
Returns path to specified y-shifted dielectric map.
Definition: nosh.c:210
int proc_rank
Definition: mgparm.h:180
VPUBLIC char * NOsh_elecname(NOsh *thee, int ielec)
Return an integer mapping of an ELEC statement to a calculation ID (.
Definition: nosh.c:288
#define NOSH_MAXCALC
Maximum number of calculations in a run.
Definition: nosh.h:87
int partDisjOwnSide[6]
Definition: mgparm.h:175
VPUBLIC Vrc_Codes PBAMparm_check(PBAMparm *thee)
Consistency check for parameter values stored in object.
Definition: pbamparm.c:132
enum eNOsh_MolFormat NOsh_MolFormat
Declare NOsh_MolFormat type.
Definition: nosh.h:111
VPUBLIC void GEOFLOWparm_dtor(GEOFLOWparm **thee)
Object destructor.
Definition: geoflowparm.c:91
VPUBLIC int NOsh_calc_copy(NOsh_calc *thee, NOsh_calc *source)
Copy NOsh_calc object into thee.
Definition: nosh.c:467
VPUBLIC NOsh_calc * NOsh_calc_ctor(NOsh_CalcType calctype)
Construct NOsh_calc.
Definition: nosh.c:374
int parsed
Definition: nosh.h:266
int centmol
Definition: mgparm.h:146
int numwrite
Definition: pbeparm.h:185
int parsed
Definition: apolparm.h:131
double partDisjCenter[3]
Definition: mgparm.h:171
char parmpath[VMAX_ARGLEN]
Definition: nosh.h:237
VPUBLIC Vrc_Codes BEMparm_parseToken(BEMparm *thee, char tok[VMAX_BUFSIZE], Vio *sock)
Parse an MG keyword from an input file.
Definition: bemparm.c:327
int ispara
Definition: nosh.h:214
VPUBLIC Vrc_Codes BEMparm_check(BEMparm *thee)
Consistency check for parameter values stored in object.
Definition: bemparm.c:124
int ccentmol
Definition: mgparm.h:158
int printop[NOSH_MAXPRINT][NOSH_MAXPOP]
Definition: nosh.h:264
char molpath[NOSH_MAXMOL][VMAX_ARGLEN]
Definition: nosh.h:232
Definition: nosh.h:104
VPUBLIC int NOsh_getKappafmt(NOsh *thee, int i)
Returns format of specified kappa map.
Definition: nosh.c:245
VPRIVATE char * MCwhiteChars
Whitespace characters for socket reads.
Definition: vparam.c:65
int parsed
Definition: pbeparm.h:201
VPUBLIC int NOsh_elec2calc(NOsh *thee, int icalc)
Return the name of an elec statement.
Definition: nosh.c:276
FEMparm * femparm
Definition: nosh.h:174
char apolname[NOSH_MAXCALC][VMAX_ARGLEN]
Definition: nosh.h:269
VPUBLIC char * NOsh_getChargepath(NOsh *thee, int imol)
Returns path to specified charge distribution map.
Definition: nosh.c:230
Parameter structure for APOL-specific variables from input files.
Definition: apolparm.h:129
double ccenter[3]
Definition: mgparm.h:157
int setsrfm
Definition: pbeparm.h:151
VPUBLIC PBSAMparm * PBSAMparm_ctor(PBSAMparm_CalcType type)
Construct PBSAMparm object.
Definition: pbsamparm.c:66
VPUBLIC int NOsh_getDielfmt(NOsh *thee, int i)
Returns format of specified dielectric map.
Definition: nosh.c:240
int nmesh
Definition: nosh.h:256
#define VREDFRAC
Maximum reduction of grid spacing during a focusing calculation.
Definition: vhal.h:392
VPUBLIC GEOFLOWparm * GEOFLOWparm_ctor(GEOFLOWparm_CalcType type)
Construct GEOFLOWparm object.
Definition: geoflowparm.c:66
#define VAPBS_LEFT
Face definition for a volume.
Definition: vhal.h:426
BEMparm * bemparm
Definition: nosh.h:175
#define VAPBS_RIGHT
Face definition for a volume.
Definition: vhal.h:408
char dielYpath[NOSH_MAXMOL][VMAX_ARGLEN]
Definition: nosh.h:242
char kappapath[NOSH_MAXMOL][VMAX_ARGLEN]
Definition: nosh.h:248