00001
00049 #include "apbscfg.h"
00050 #include "apbs/pbeparm.h"
00051 #include "apbs/vstring.h"
00052
00053 VEMBED(rcsid="$Id: pbeparm.c 1585 2010-05-13 16:21:17Z sdg0919 $")
00054
00055 #if !defined(VINLINE_MGPARM)
00056
00057 #endif
00058
00059 VPUBLIC double PBEparm_getIonCharge(PBEparm *thee, int i) {
00060 VASSERT(thee != VNULL);
00061 VASSERT(i < thee->nion);
00062 return thee->ionq[i];
00063 }
00064
00065 VPUBLIC double PBEparm_getIonConc(PBEparm *thee, int i) {
00066 VASSERT(thee != VNULL);
00067 VASSERT(i < thee->nion);
00068 return thee->ionc[i];
00069 }
00070
00071 VPUBLIC double PBEparm_getIonRadius(PBEparm *thee, int i) {
00072 VASSERT(thee != VNULL);
00073 VASSERT(i < thee->nion);
00074 return thee->ionr[i];
00075 }
00076
00077
00078
00079
00080
00081 VPUBLIC double PBEparm_getzmem(PBEparm *thee) {
00082 VASSERT(thee != VNULL);
00083 return thee->zmem;
00084 }
00085 VPUBLIC double PBEparm_getLmem(PBEparm *thee) {
00086 VASSERT(thee != VNULL);
00087 return thee->Lmem;
00088 }
00089 VPUBLIC double PBEparm_getmembraneDiel(PBEparm *thee) {
00090 VASSERT(thee != VNULL);
00091 return thee->mdie;
00092 }
00093 VPUBLIC double PBEparm_getmemv(PBEparm *thee) {
00094 VASSERT(thee != VNULL);
00095 return thee->memv;
00096 }
00097
00098 VPUBLIC PBEparm* PBEparm_ctor() {
00099
00100
00101 PBEparm *thee = VNULL;
00102 thee = Vmem_malloc(VNULL, 1, sizeof(PBEparm));
00103 VASSERT( thee != VNULL);
00104 VASSERT( PBEparm_ctor2(thee) );
00105
00106 return thee;
00107 }
00108
00109 VPUBLIC int PBEparm_ctor2(PBEparm *thee) {
00110
00111 int i;
00112
00113 if (thee == VNULL) return 0;
00114
00115 thee->parsed = 0;
00116
00117 thee->setmolid = 0;
00118 thee->setpbetype = 0;
00119 thee->setbcfl = 0;
00120 thee->setnion = 0;
00121 for (i=0; i<MAXION; i++){
00122 thee->setion[i] = 0;
00123 thee->ionq[i] = 0.0;
00124 thee->ionc[i] = 0.0;
00125 thee->ionr[i] = 0.0;
00126 }
00127 thee->setpdie = 0;
00128 thee->setsdie = 0;
00129 thee->setsrfm = 0;
00130 thee->setsrad = 0;
00131 thee->setswin = 0;
00132 thee->settemp = 0;
00133 thee->setcalcenergy = 0;
00134 thee->setcalcforce = 0;
00135 thee->setsdens = 0;
00136 thee->numwrite = 0;
00137 thee->setwritemat = 0;
00138 thee->nion = 0;
00139 thee->sdens = 0;
00140 thee->swin = 0;
00141 thee->srad = 1.4;
00142 thee->useDielMap = 0;
00143 thee->useKappaMap = 0;
00144 thee->usePotMap = 0;
00145 thee->useChargeMap = 0;
00146
00147
00148
00149
00150
00151 thee->setzmem = 0;
00152 thee->setLmem = 0;
00153 thee->setmdie = 0;
00154 thee->setmemv = 0;
00155
00156
00157
00158 thee->smsize = 0.0;
00159 thee->smvolume = 0.0;
00160
00161 thee->setsmsize = 0;
00162 thee->setsmvolume = 0;
00163
00164 return 1;
00165 }
00166
00167 VPUBLIC void PBEparm_dtor(PBEparm **thee) {
00168 if ((*thee) != VNULL) {
00169 PBEparm_dtor2(*thee);
00170 Vmem_free(VNULL, 1, sizeof(PBEparm), (void **)thee);
00171 (*thee) = VNULL;
00172 }
00173 }
00174
00175 VPUBLIC void PBEparm_dtor2(PBEparm *thee) { ; }
00176
00177 VPUBLIC int PBEparm_check(PBEparm *thee) {
00178
00179 int i;
00180
00181
00182 if (!thee->parsed) {
00183 Vnm_print(2, "PBEparm_check: not filled!\n");
00184 return 0;
00185 }
00186
00187 if (!thee->setmolid) {
00188 Vnm_print(2, "PBEparm_check: MOL not set!\n");
00189 return 0;
00190 }
00191 if (!thee->setpbetype) {
00192 Vnm_print(2, "PBEparm_check: LPBE/NPBE/LRPBE/NRPBE/SMPBE not set!\n");
00193 return 0;
00194 }
00195 if (!thee->setbcfl) {
00196 Vnm_print(2, "PBEparm_check: BCFL not set!\n");
00197 return 0;
00198 }
00199 if (!thee->setnion) {
00200 thee->setnion = 1;
00201 thee->nion = 0;
00202 }
00203 for (i=0; i<thee->nion; i++) {
00204 if (!thee->setion[i]) {
00205 Vnm_print(2, "PBEparm_check: ION #%d not set!\n",i);
00206 return 0;
00207 }
00208 }
00209 if (!thee->setpdie) {
00210 Vnm_print(2, "PBEparm_check: PDIE not set!\n");
00211 return 0;
00212 }
00213 if (((thee->srfm==VSM_MOL) || (thee->srfm==VSM_MOLSMOOTH)) \
00214 && (!thee->setsdens) && (thee->srad > VSMALL)) {
00215 Vnm_print(2, "PBEparm_check: SDENS not set!\n");
00216 return 0;
00217 }
00218 if (!thee->setsdie) {
00219 Vnm_print(2, "PBEparm_check: SDIE not set!\n");
00220 return 0;
00221 }
00222 if (!thee->setsrfm) {
00223 Vnm_print(2, "PBEparm_check: SRFM not set!\n");
00224 return 0;
00225 }
00226 if (((thee->srfm==VSM_MOL) || (thee->srfm==VSM_MOLSMOOTH)) \
00227 && (!thee->setsrad)) {
00228 Vnm_print(2, "PBEparm_check: SRAD not set!\n");
00229 return 0;
00230 }
00231 if ((thee->srfm==VSM_SPLINE) && (!thee->setswin)) {
00232 Vnm_print(2, "PBEparm_check: SWIN not set!\n");
00233 return 0;
00234 }
00235 if ((thee->srfm==VSM_SPLINE3) && (!thee->setswin)) {
00236 Vnm_print(2, "PBEparm_check: SWIN not set!\n");
00237 return 0;
00238 }
00239 if ((thee->srfm==VSM_SPLINE4) && (!thee->setswin)) {
00240 Vnm_print(2, "PBEparm_check: SWIN not set!\n");
00241 return 0;
00242 }
00243 if (!thee->settemp) {
00244 Vnm_print(2, "PBEparm_check: TEMP not set!\n");
00245 return 0;
00246 }
00247 if (!thee->setcalcenergy) thee->calcenergy = PCE_NO;
00248 if (!thee->setcalcforce) thee->calcforce = PCF_NO;
00249 if (!thee->setwritemat) thee->writemat = 0;
00250
00251
00252
00253
00254
00255 if ((!thee->setzmem) && (thee->bcfl == 3)){
00256 Vnm_print(2, "PBEparm_check: ZMEM not set!\n");
00257 return 0;
00258 }
00259 if ((!thee->setLmem) && (thee->bcfl == 3)){
00260 Vnm_print(2, "PBEparm_check: LMEM not set!\n");
00261 return 0;
00262 }
00263 if ((!thee->setmdie) && (thee->bcfl == 3)){
00264 Vnm_print(2, "PBEparm_check: MDIE not set!\n");
00265 return 0;
00266 }
00267 if ((!thee->setmemv) && (thee->bcfl == 3)){
00268 Vnm_print(2, "PBEparm_check: MEMV not set!\n");
00269 return 0;
00270 }
00271
00272
00273
00274 return 1;
00275 }
00276
00277 VPUBLIC void PBEparm_copy(PBEparm *thee, PBEparm *parm) {
00278
00279 int i, j;
00280
00281 VASSERT(thee != VNULL);
00282 VASSERT(parm != VNULL);
00283
00284 thee->molid = parm->molid;
00285 thee->setmolid = parm->setmolid;
00286 thee->useDielMap = parm->useDielMap;
00287 thee->dielMapID = parm->dielMapID;
00288 thee->useKappaMap = parm->useKappaMap;
00289 thee->kappaMapID = parm->kappaMapID;
00290 thee->usePotMap = parm->usePotMap;
00291 thee->potMapID = parm->potMapID;
00292 thee->useChargeMap = parm->useChargeMap;
00293 thee->chargeMapID = parm->chargeMapID;
00294 thee->pbetype = parm->pbetype;
00295 thee->setpbetype = parm->setpbetype;
00296 thee->bcfl = parm->bcfl;
00297 thee->setbcfl = parm->setbcfl;
00298 thee->nion = parm->nion;
00299 thee->setnion = parm->setnion;
00300 for (i=0; i<MAXION; i++) {
00301 thee->ionq[i] = parm->ionq[i];
00302 thee->ionc[i] = parm->ionc[i];
00303 thee->ionr[i] = parm->ionr[i];
00304 thee->setion[i] = parm->setion[i];
00305 };
00306 thee->pdie = parm->pdie;
00307 thee->setpdie = parm->setpdie;
00308 thee->sdens = parm->sdens;
00309 thee->setsdens = parm->setsdens;
00310 thee->sdie = parm->sdie;
00311 thee->setsdie = parm->setsdie;
00312 thee->srfm = parm->srfm;
00313 thee->setsrfm = parm->setsrfm;
00314 thee->srad = parm->srad;
00315 thee->setsrad = parm->setsrad;
00316 thee->swin = parm->swin;
00317 thee->setswin = parm->setswin;
00318 thee->temp = parm->temp;
00319 thee->settemp = parm->settemp;
00320 thee->calcenergy = parm->calcenergy;
00321 thee->setcalcenergy = parm->setcalcenergy;
00322 thee->calcforce = parm->calcforce;
00323 thee->setcalcforce = parm->setcalcforce;
00324
00325
00326
00327
00328
00329 thee->zmem = parm->zmem;
00330 thee->setzmem = parm->setzmem;
00331 thee->Lmem = parm->Lmem;
00332 thee->setLmem = parm->setLmem;
00333 thee->mdie = parm->mdie;
00334 thee->setmdie = parm->setmdie;
00335 thee->memv = parm->memv;
00336 thee->setmemv = parm->setmemv;
00337
00338
00339
00340 thee->numwrite = parm->numwrite;
00341 for (i=0; i<PBEPARM_MAXWRITE; i++) {
00342 thee->writetype[i] = parm->writetype[i];
00343 thee->writefmt[i] = parm->writefmt[i];
00344 for (j=0; j<VMAX_ARGLEN; j++)
00345 thee->writestem[i][j] = parm->writestem[i][j];
00346 }
00347 thee->writemat = parm->writemat;
00348 thee->setwritemat = parm->setwritemat;
00349 for (i=0; i<VMAX_ARGLEN; i++) thee->writematstem[i] = parm->writematstem[i];
00350 thee->writematflag = parm->writematflag;
00351
00352 thee->smsize = parm->smsize;
00353 thee->smvolume = parm->smvolume;
00354
00355 thee->setsmsize = parm->setsmsize;
00356 thee->setsmvolume = parm->setsmvolume;
00357
00358 thee->parsed = parm->parsed;
00359
00360 }
00361
00362 VPRIVATE int PBEparm_parseLPBE(PBEparm *thee, Vio *sock) {
00363 Vnm_print(0, "NOsh: parsed lpbe\n");
00364 thee->pbetype = PBE_LPBE;
00365 thee->setpbetype = 1;
00366 return 1;
00367 }
00368
00369 VPRIVATE int PBEparm_parseNPBE(PBEparm *thee, Vio *sock) {
00370 Vnm_print(0, "NOsh: parsed npbe\n");
00371 thee->pbetype = PBE_NPBE;
00372 thee->setpbetype = 1;
00373 return 1;
00374 }
00375
00376 VPRIVATE int PBEparm_parseMOL(PBEparm *thee, Vio *sock) {
00377 int ti;
00378 char tok[VMAX_BUFSIZE];
00379
00380 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00381 if (sscanf(tok, "%d", &ti) == 0) {
00382 Vnm_print(2, "NOsh: Read non-int (%s) while parsing MOL \
00383 keyword!\n", tok);
00384 return -1;
00385 }
00386 thee->molid = ti;
00387 thee->setmolid = 1;
00388 return 1;
00389
00390 VERROR1:
00391 Vnm_print(2, "parsePBE: ran out of tokens!\n");
00392 return -1;
00393 }
00394
00395 VPRIVATE int PBEparm_parseLRPBE(PBEparm *thee, Vio *sock) {
00396 Vnm_print(0, "NOsh: parsed lrpbe\n");
00397 thee->pbetype = PBE_LRPBE;
00398 thee->setpbetype = 1;
00399 return 1;
00400 }
00401
00402 VPRIVATE int PBEparm_parseNRPBE(PBEparm *thee, Vio *sock) {
00403 Vnm_print(0, "NOsh: parsed nrpbe\n");
00404 thee->pbetype = PBE_NRPBE;
00405 thee->setpbetype = 1;
00406 return 1;
00407 }
00408
00409 VPRIVATE int PBEparm_parseSMPBE(PBEparm *thee, Vio *sock) {
00410
00411 int i;
00412
00413 char type[VMAX_BUFSIZE];
00414 char value[VMAX_BUFSIZE];
00415
00416 char setVol = 1;
00417 char setSize = 1;
00418 char keyValuePairs = 2;
00419
00420 double size, volume;
00421
00422 for(i=0;i<keyValuePairs;i++){
00423
00424
00425 VJMPERR1(Vio_scanf(sock, "%s", type) == 1);
00426 VJMPERR1(Vio_scanf(sock, "%s", value) == 1);
00427
00428 if(!strcmp(type,"vol")){
00429 if ((setVol = sscanf(value, "%lf", &volume)) == 0){
00430 Vnm_print(2,"NOsh: Read non-float (%s) while parsing smpbe keyword!\n", value);
00431 return VRC_FAILURE;
00432 }
00433 }else if(!strcmp(type,"size")){
00434 if ((setSize = sscanf(value, "%lf", &size)) == 0){
00435 Vnm_print(2,"NOsh: Read non-float (%s) while parsing smpbe keyword!\n", value);
00436 return VRC_FAILURE;
00437 }
00438 }else{
00439 Vnm_print(2,"NOsh: Read non-float (%s) while parsing smpbe keyword!\n", value);
00440 return VRC_FAILURE;
00441 }
00442 }
00443
00444
00445 if((setVol == 0) || (setSize == 0)){
00446 Vnm_print(2,"NOsh: Error while parsing smpbe keywords! Only size or vol was specified.\n");
00447 return VRC_FAILURE;
00448 }
00449
00450 Vnm_print(0, "NOsh: parsed smpbe\n");
00451 thee->pbetype = PBE_SMPBE;
00452 thee->setpbetype = 1;
00453
00454 thee->smsize = size;
00455 thee->setsmsize = 1;
00456
00457 thee->smvolume = volume;
00458 thee->setsmvolume = 1;
00459
00460 return VRC_SUCCESS;
00461
00462 VERROR1:
00463 Vnm_print(2, "parsePBE: ran out of tokens!\n");
00464 return VRC_FAILURE;
00465
00466 }
00467
00468 VPRIVATE int PBEparm_parseBCFL(PBEparm *thee, Vio *sock) {
00469 char tok[VMAX_BUFSIZE];
00470 int ti;
00471
00472 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00473
00474
00475 if (sscanf(tok, "%d", &ti) == 1) {
00476
00477 thee->bcfl = ti;
00478 thee->setbcfl = 1;
00479
00480 Vnm_print(2, "parsePBE: Warning -- parsed deprecated \"bcfl %d\" \
00481 statement\n", ti);
00482 Vnm_print(2, "parsePBE: Please use \"bcfl ");
00483 switch (thee->bcfl) {
00484 case BCFL_ZERO:
00485 Vnm_print(2, "zero");
00486 break;
00487 case BCFL_SDH:
00488 Vnm_print(2, "sdh");
00489 break;
00490 case BCFL_MDH:
00491 Vnm_print(2, "mdh");
00492 break;
00493 case BCFL_FOCUS:
00494 Vnm_print(2, "focus");
00495 break;
00496 case BCFL_MEM:
00497 Vnm_print(2, "mem");
00498 break;
00499 case BCFL_MAP:
00500 Vnm_print(2, "map");
00501 break;
00502 default:
00503 Vnm_print(2, "UKNOWN");
00504 break;
00505 }
00506 Vnm_print(2, "\" instead.\n");
00507 return 1;
00508
00509
00510 } else {
00511
00512 if (Vstring_strcasecmp(tok, "zero") == 0) {
00513 thee->bcfl = BCFL_ZERO;
00514 thee->setbcfl = 1;
00515 return 1;
00516 } else if (Vstring_strcasecmp(tok, "sdh") == 0) {
00517 thee->bcfl = BCFL_SDH;
00518 thee->setbcfl = 1;
00519 return 1;
00520 } else if (Vstring_strcasecmp(tok, "mdh") == 0) {
00521 thee->bcfl = BCFL_MDH;
00522 thee->setbcfl = 1;
00523 return 1;
00524 } else if (Vstring_strcasecmp(tok, "focus") == 0) {
00525 thee->bcfl = BCFL_FOCUS;
00526 thee->setbcfl = 1;
00527 return 1;
00528 } else if (Vstring_strcasecmp(tok, "mem") == 0) {
00529 thee->bcfl = BCFL_MEM;
00530 thee->setbcfl = 1;
00531 return 1;
00532 } else if (Vstring_strcasecmp(tok, "map") == 0) {
00533 thee->bcfl = BCFL_MAP;
00534 thee->setbcfl = 1;
00535 return 1;
00536 } else {
00537 Vnm_print(2, "NOsh: parsed unknown BCFL parameter (%s)!\n",
00538 tok);
00539 return -1;
00540 }
00541 }
00542 return 0;
00543
00544 VERROR1:
00545 Vnm_print(2, "parsePBE: ran out of tokens!\n");
00546 return -1;
00547 }
00548
00549 VPRIVATE int PBEparm_parseION(PBEparm *thee, Vio *sock) {
00550
00551 int i;
00552 int meth = 0;
00553
00554 char tok[VMAX_BUFSIZE];
00555 char value[VMAX_BUFSIZE];
00556
00557 double tf;
00558 double charge, conc, radius;
00559
00560 int setCharge = 0;
00561 int setConc = 0;
00562 int setRadius = 0;
00563 int keyValuePairs = 3;
00564
00565
00566 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00567
00568
00569 meth = sscanf(tok, "%lf", &tf);
00570
00571 if(meth != 0){
00572
00573 Vnm_print(2, "NOsh: Deprecated use of ION keyword! Use key-value pairs\n", tok);
00574
00575 if (sscanf(tok, "%lf", &tf) == 0) {
00576 Vnm_print(2, "NOsh: Read non-float (%s) while parsing ION keyword!\n", tok);
00577 return VRC_FAILURE;
00578 }
00579 thee->ionq[thee->nion] = tf;
00580 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00581 if (sscanf(tok, "%lf", &tf) == 0) {
00582 Vnm_print(2, "NOsh: Read non-float (%s) while parsing ION keyword!\n", tok);
00583 return VRC_FAILURE;
00584 }
00585 thee->ionc[thee->nion] = tf;
00586 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00587 if (sscanf(tok, "%lf", &tf) == 0) {
00588 Vnm_print(2, "NOsh: Read non-float (%s) while parsing ION keyword!\n", tok);
00589 return VRC_FAILURE;
00590 }
00591 thee->ionr[thee->nion] = tf;
00592
00593 }else{
00594
00595
00596 for(i=0;i<keyValuePairs;i++){
00597
00598
00599
00600 VJMPERR1(Vio_scanf(sock, "%s", value) == 1);
00601 if(!strcmp(tok,"charge")){
00602 setCharge = sscanf(value, "%lf", &charge);
00603 if (setCharge == 0){
00604 Vnm_print(2,"NOsh: Read non-float (%s) while parsing ION %s keyword!\n", value, tok);
00605 return VRC_FAILURE;
00606 }
00607 thee->ionq[thee->nion] = charge;
00608 }else if(!strcmp(tok,"radius")){
00609 setRadius = sscanf(value, "%lf", &radius);
00610 if (setRadius == 0){
00611 Vnm_print(2,"NOsh: Read non-float (%s) while parsing ION %s keyword!\n", value, tok);
00612 return VRC_FAILURE;
00613 }
00614 thee->ionr[thee->nion] = radius;
00615 }else if(!strcmp(tok,"conc")){
00616 setConc = sscanf(value, "%lf", &conc);
00617 if (setConc == 0){
00618 Vnm_print(2,"NOsh: Read non-float (%s) while parsing ION %s keyword!\n", value, tok);
00619 return VRC_FAILURE;
00620 }
00621 thee->ionc[thee->nion] = conc;
00622 }else{
00623 Vnm_print(2,"NOsh: Illegal or missing key-value pair for ION keyword!\n");
00624 return VRC_FAILURE;
00625 }
00626
00627
00628 if((setCharge != 1) || (setConc != 1) || (setRadius != 1)){
00629 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00630 }
00631
00632 }
00633 }
00634
00635
00636 thee->setion[thee->nion] = 1;
00637 (thee->nion)++;
00638 thee->setnion = 1;
00639 return VRC_SUCCESS;
00640
00641 VERROR1:
00642 Vnm_print(2, "parsePBE: ran out of tokens!\n");
00643 return VRC_FAILURE;
00644 }
00645
00646 VPRIVATE int PBEparm_parsePDIE(PBEparm *thee, Vio *sock) {
00647 char tok[VMAX_BUFSIZE];
00648 double tf;
00649
00650 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00651 if (sscanf(tok, "%lf", &tf) == 0) {
00652 Vnm_print(2, "NOsh: Read non-float (%s) while parsing PDIE \
00653 keyword!\n", tok);
00654 return -1;
00655 }
00656 thee->pdie = tf;
00657 thee->setpdie = 1;
00658 return 1;
00659
00660 VERROR1:
00661 Vnm_print(2, "parsePBE: ran out of tokens!\n");
00662 return -1;
00663 }
00664
00665 VPRIVATE int PBEparm_parseSDENS(PBEparm *thee, Vio *sock) {
00666 char tok[VMAX_BUFSIZE];
00667 double tf;
00668
00669 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00670 if (sscanf(tok, "%lf", &tf) == 0) {
00671 Vnm_print(2, "NOsh: Read non-float (%s) while parsing SDENS \
00672 keyword!\n", tok);
00673 return -1;
00674 }
00675 thee->sdens = tf;
00676 thee->setsdens = 1;
00677 return 1;
00678
00679 VERROR1:
00680 Vnm_print(2, "parsePBE: ran out of tokens!\n");
00681 return -1;
00682 }
00683
00684 VPRIVATE int PBEparm_parseSDIE(PBEparm *thee, Vio *sock) {
00685 char tok[VMAX_BUFSIZE];
00686 double tf;
00687
00688 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00689 if (sscanf(tok, "%lf", &tf) == 0) {
00690 Vnm_print(2, "NOsh: Read non-float (%s) while parsing SDIE \
00691 keyword!\n", tok);
00692 return -1;
00693 }
00694 thee->sdie = tf;
00695 thee->setsdie = 1;
00696 return 1;
00697
00698 VERROR1:
00699 Vnm_print(2, "parsePBE: ran out of tokens!\n");
00700 return -1;
00701 }
00702
00703 VPRIVATE int PBEparm_parseSRFM(PBEparm *thee, Vio *sock) {
00704 char tok[VMAX_BUFSIZE];
00705 int ti;
00706
00707 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00708
00709
00710 if (sscanf(tok, "%d", &ti) == 1) {
00711 thee->srfm = ti;
00712 thee->setsrfm = 1;
00713
00714 Vnm_print(2, "parsePBE: Warning -- parsed deprecated \"srfm %d\" \
00715 statement.\n", ti);
00716 Vnm_print(2, "parsePBE: Please use \"srfm ");
00717 switch (thee->srfm) {
00718 case VSM_MOL:
00719 Vnm_print(2, "mol");
00720 break;
00721 case VSM_MOLSMOOTH:
00722 Vnm_print(2, "smol");
00723 break;
00724 case VSM_SPLINE:
00725 Vnm_print(2, "spl2");
00726 break;
00727 case VSM_SPLINE3:
00728 Vnm_print(2, "spl3");
00729 break;
00730 case VSM_SPLINE4:
00731 Vnm_print(2, "spl4");
00732 break;
00733 default:
00734 Vnm_print(2, "UNKNOWN");
00735 break;
00736 }
00737 Vnm_print(2, "\" instead.\n");
00738 return 1;
00739
00740
00741 } else if (Vstring_strcasecmp(tok, "mol") == 0) {
00742 thee->srfm = VSM_MOL;
00743 thee->setsrfm = 1;
00744 return 1;
00745 } else if (Vstring_strcasecmp(tok, "smol") == 0) {
00746 thee->srfm = VSM_MOLSMOOTH;
00747 thee->setsrfm = 1;
00748 return 1;
00749 } else if (Vstring_strcasecmp(tok, "spl2") == 0) {
00750 thee->srfm = VSM_SPLINE;
00751 thee->setsrfm = 1;
00752 return 1;
00753 } else if (Vstring_strcasecmp(tok, "spl3") == 0) {
00754 thee->srfm = VSM_SPLINE3;
00755 thee->setsrfm = 1;
00756 return 1;
00757 } else if (Vstring_strcasecmp(tok, "spl4") == 0) {
00758 thee->srfm = VSM_SPLINE4;
00759 thee->setsrfm = 1;
00760 return 1;
00761 } else {
00762 Vnm_print(2, "NOsh: Unrecongnized keyword (%s) when parsing \
00763 srfm!\n", tok);
00764 return -1;
00765 }
00766
00767 return 0;
00768
00769 VERROR1:
00770 Vnm_print(2, "parsePBE: ran out of tokens!\n");
00771 return -1;
00772 }
00773
00774 VPRIVATE int PBEparm_parseSRAD(PBEparm *thee, Vio *sock) {
00775 char tok[VMAX_BUFSIZE];
00776 double tf;
00777
00778 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00779 if (sscanf(tok, "%lf", &tf) == 0) {
00780 Vnm_print(2, "NOsh: Read non-float (%s) while parsing SRAD \
00781 keyword!\n", tok);
00782 return -1;
00783 }
00784 thee->srad = tf;
00785 thee->setsrad = 1;
00786 return 1;
00787
00788 VERROR1:
00789 Vnm_print(2, "parsePBE: ran out of tokens!\n");
00790 return -1;
00791 }
00792
00793 VPRIVATE int PBEparm_parseSWIN(PBEparm *thee, Vio *sock) {
00794 char tok[VMAX_BUFSIZE];
00795 double tf;
00796
00797 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00798 if (sscanf(tok, "%lf", &tf) == 0) {
00799 Vnm_print(2, "NOsh: Read non-float (%s) while parsing SWIN \
00800 keyword!\n", tok);
00801 return -1;
00802 }
00803 thee->swin = tf;
00804 thee->setswin = 1;
00805 return 1;
00806
00807 VERROR1:
00808 Vnm_print(2, "parsePBE: ran out of tokens!\n");
00809 return -1;
00810 }
00811
00812 VPRIVATE int PBEparm_parseTEMP(PBEparm *thee, Vio *sock) {
00813 char tok[VMAX_BUFSIZE];
00814 double tf;
00815
00816 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00817 if (sscanf(tok, "%lf", &tf) == 0) {
00818 Vnm_print(2, "NOsh: Read non-float (%s) while parsing TEMP \
00819 keyword!\n", tok);
00820 return -1;
00821 }
00822 thee->temp = tf;
00823 thee->settemp = 1;
00824 return 1;
00825
00826 VERROR1:
00827 Vnm_print(2, "parsePBE: ran out of tokens!\n");
00828 return -1;
00829 }
00830
00831 VPRIVATE int PBEparm_parseUSEMAP(PBEparm *thee, Vio *sock) {
00832 char tok[VMAX_BUFSIZE];
00833 int ti;
00834
00835 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00836 Vnm_print(0, "PBEparm_parseToken: Read %s...\n", tok);
00837 if (Vstring_strcasecmp(tok, "diel") == 0) {
00838 thee->useDielMap = 1;
00839 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00840 if (sscanf(tok, "%d", &ti) == 0) {
00841 Vnm_print(2, "NOsh: Read non-int (%s) while parsing \
00842 USEMAP DIEL keyword!\n", tok);
00843 return -1;
00844 }
00845 thee->dielMapID = ti;
00846 return 1;
00847 } else if (Vstring_strcasecmp(tok, "kappa") == 0) {
00848 thee->useKappaMap = 1;
00849 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00850 if (sscanf(tok, "%d", &ti) == 0) {
00851 Vnm_print(2, "NOsh: Read non-int (%s) while parsing \
00852 USEMAP KAPPA keyword!\n", tok);
00853 return -1;
00854 }
00855 thee->kappaMapID = ti;
00856 return 1;
00857 } else if (Vstring_strcasecmp(tok, "pot") == 0) {
00858 thee->usePotMap = 1;
00859 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00860 if (sscanf(tok, "%d", &ti) == 0) {
00861 Vnm_print(2, "NOsh: Read non-int (%s) while parsing \
00862 USEMAP POT keyword!\n", tok);
00863 return -1;
00864 }
00865 thee->potMapID = ti;
00866 return 1;
00867 } else if (Vstring_strcasecmp(tok, "charge") == 0) {
00868 thee->useChargeMap = 1;
00869 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00870 if (sscanf(tok, "%d", &ti) == 0) {
00871 Vnm_print(2, "NOsh: Read non-int (%s) while parsing \
00872 USEMAP CHARGE keyword!\n", tok);
00873 return -1;
00874 }
00875 thee->chargeMapID = ti;
00876 return 1;
00877 } else {
00878 Vnm_print(2, "NOsh: Read undefined keyword (%s) while parsing \
00879 USEMAP statement!\n", tok);
00880 return -1;
00881 }
00882 return 0;
00883
00884 VERROR1:
00885 Vnm_print(2, "parsePBE: ran out of tokens!\n");
00886 return -1;
00887 }
00888
00889 VPRIVATE int PBEparm_parseCALCENERGY(PBEparm *thee, Vio *sock) {
00890 char tok[VMAX_BUFSIZE];
00891 int ti;
00892
00893 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00894
00895 if (sscanf(tok, "%d", &ti) == 1) {
00896 thee->calcenergy = ti;
00897 thee->setcalcenergy = 1;
00898
00899 Vnm_print(2, "parsePBE: Warning -- parsed deprecated \"calcenergy \
00900 %d\" statement.\n", ti);
00901 Vnm_print(2, "parsePBE: Please use \"calcenergy ");
00902 switch (thee->calcenergy) {
00903 case PCE_NO:
00904 Vnm_print(2, "no");
00905 break;
00906 case PCE_TOTAL:
00907 Vnm_print(2, "total");
00908 break;
00909 case PCE_COMPS:
00910 Vnm_print(2, "comps");
00911 break;
00912 default:
00913 Vnm_print(2, "UNKNOWN");
00914 break;
00915 }
00916 Vnm_print(2, "\" instead.\n");
00917 return 1;
00918 } else if (Vstring_strcasecmp(tok, "no") == 0) {
00919 thee->calcenergy = PCE_NO;
00920 thee->setcalcenergy = 1;
00921 return 1;
00922 } else if (Vstring_strcasecmp(tok, "total") == 0) {
00923 thee->calcenergy = PCE_TOTAL;
00924 thee->setcalcenergy = 1;
00925 return 1;
00926 } else if (Vstring_strcasecmp(tok, "comps") == 0) {
00927 thee->calcenergy = PCE_COMPS;
00928 thee->setcalcenergy = 1;
00929 return 1;
00930 } else {
00931 Vnm_print(2, "NOsh: Unrecognized parameter (%s) while parsing \
00932 calcenergy!\n", tok);
00933 return -1;
00934 }
00935 return 0;
00936
00937 VERROR1:
00938 Vnm_print(2, "parsePBE: ran out of tokens!\n");
00939 return -1;
00940 }
00941
00942 VPRIVATE int PBEparm_parseCALCFORCE(PBEparm *thee, Vio *sock) {
00943 char tok[VMAX_BUFSIZE];
00944 int ti;
00945
00946 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00947
00948 if (sscanf(tok, "%d", &ti) == 1) {
00949 thee->calcforce = ti;
00950 thee->setcalcforce = 1;
00951
00952 Vnm_print(2, "parsePBE: Warning -- parsed deprecated \"calcforce \
00953 %d\" statement.\n", ti);
00954 Vnm_print(2, "parsePBE: Please use \"calcforce ");
00955 switch (thee->calcenergy) {
00956 case PCF_NO:
00957 Vnm_print(2, "no");
00958 break;
00959 case PCF_TOTAL:
00960 Vnm_print(2, "total");
00961 break;
00962 case PCF_COMPS:
00963 Vnm_print(2, "comps");
00964 break;
00965 default:
00966 Vnm_print(2, "UNKNOWN");
00967 break;
00968 }
00969 Vnm_print(2, "\" instead.\n");
00970 return 1;
00971 } else if (Vstring_strcasecmp(tok, "no") == 0) {
00972 thee->calcforce = PCF_NO;
00973 thee->setcalcforce = 1;
00974 return 1;
00975 } else if (Vstring_strcasecmp(tok, "total") == 0) {
00976 thee->calcforce = PCF_TOTAL;
00977 thee->setcalcforce = 1;
00978 return 1;
00979 } else if (Vstring_strcasecmp(tok, "comps") == 0) {
00980 thee->calcforce = PCF_COMPS;
00981 thee->setcalcforce = 1;
00982 return 1;
00983 } else {
00984 Vnm_print(2, "NOsh: Unrecognized parameter (%s) while parsing \
00985 calcforce!\n", tok);
00986 return -1;
00987 }
00988 return 0;
00989
00990 VERROR1:
00991 Vnm_print(2, "parsePBE: ran out of tokens!\n");
00992 return -1;
00993 }
00994
00995
00996
00997
00998
00999 VPRIVATE int PBEparm_parseZMEM(PBEparm *thee, Vio *sock) {
01000 char tok[VMAX_BUFSIZE];
01001 double tf;
01002
01003 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
01004 if (sscanf(tok, "%lf", &tf) == 0) {
01005 Vnm_print(2, "NOsh: Read non-float (%s) while parsing ZMEM \
01006 keyword!\n", tok);
01007 return -1;
01008 }
01009 thee->zmem = tf;
01010 thee->setzmem = 1;
01011 return 1;
01012
01013 VERROR1:
01014 Vnm_print(2, "parsePBE: ran out of tokens!\n");
01015 return -1;
01016 }
01017
01018
01019 VPRIVATE int PBEparm_parseLMEM(PBEparm *thee, Vio *sock) {
01020 char tok[VMAX_BUFSIZE];
01021 double tf;
01022
01023 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
01024 if (sscanf(tok, "%lf", &tf) == 0) {
01025 Vnm_print(2, "NOsh: Read non-float (%s) while parsing LMEM \
01026 keyword!\n", tok);
01027 return -1;
01028 }
01029 thee->Lmem = tf;
01030 thee->setLmem = 1;
01031 return 1;
01032
01033 VERROR1:
01034 Vnm_print(2, "parsePBE: ran out of tokens!\n");
01035 return -1;
01036 }
01037
01038 VPRIVATE int PBEparm_parseMDIE(PBEparm *thee, Vio *sock) {
01039 char tok[VMAX_BUFSIZE];
01040 double tf;
01041
01042 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
01043 if (sscanf(tok, "%lf", &tf) == 0) {
01044 Vnm_print(2, "NOsh: Read non-float (%s) while parsing MDIE \
01045 keyword!\n", tok);
01046 return -1;
01047 }
01048 thee->mdie = tf;
01049 thee->setmdie = 1;
01050 return 1;
01051
01052 VERROR1:
01053 Vnm_print(2, "parsePBE: ran out of tokens!\n");
01054 return -1;
01055 }
01056
01057 VPRIVATE int PBEparm_parseMEMV(PBEparm *thee, Vio *sock) {
01058 char tok[VMAX_BUFSIZE];
01059 double tf;
01060
01061 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
01062 if (sscanf(tok, "%lf", &tf) == 0) {
01063 Vnm_print(2, "NOsh: Read non-float (%s) while parsing MEMV \
01064 keyword!\n", tok);
01065 return -1;
01066 }
01067 thee->memv = tf;
01068 thee->setmemv = 1;
01069 return 1;
01070
01071 VERROR1:
01072 Vnm_print(2, "parsePBE: ran out of tokens!\n");
01073 return -1;
01074 }
01075
01076
01077
01078 VPRIVATE int PBEparm_parseWRITE(PBEparm *thee, Vio *sock) {
01079 char tok[VMAX_BUFSIZE], str[VMAX_BUFSIZE]="", strnew[VMAX_BUFSIZE]="";
01080 Vdata_Type writetype;
01081 Vdata_Format writefmt;
01082
01083 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
01084 if (Vstring_strcasecmp(tok, "pot") == 0) {
01085 writetype = VDT_POT;
01086 } else if (Vstring_strcasecmp(tok, "atompot") == 0) {
01087 writetype = VDT_ATOMPOT;
01088 } else if (Vstring_strcasecmp(tok, "charge") == 0) {
01089 writetype = VDT_CHARGE;
01090 } else if (Vstring_strcasecmp(tok, "smol") == 0) {
01091 writetype = VDT_SMOL;
01092 } else if (Vstring_strcasecmp(tok, "dielx") == 0) {
01093 writetype = VDT_DIELX;
01094 } else if (Vstring_strcasecmp(tok, "diely") == 0) {
01095 writetype = VDT_DIELY;
01096 } else if (Vstring_strcasecmp(tok, "dielz") == 0) {
01097 writetype = VDT_DIELZ;
01098 } else if (Vstring_strcasecmp(tok, "kappa") == 0) {
01099 writetype = VDT_KAPPA;
01100 } else if (Vstring_strcasecmp(tok, "sspl") == 0) {
01101 writetype = VDT_SSPL;
01102 } else if (Vstring_strcasecmp(tok, "vdw") == 0) {
01103 writetype = VDT_VDW;
01104 } else if (Vstring_strcasecmp(tok, "ivdw") == 0) {
01105 writetype = VDT_IVDW;
01106 } else if (Vstring_strcasecmp(tok, "lap") == 0) {
01107 writetype = VDT_LAP;
01108 } else if (Vstring_strcasecmp(tok, "edens") == 0) {
01109 writetype = VDT_EDENS;
01110 } else if (Vstring_strcasecmp(tok, "ndens") == 0) {
01111 writetype = VDT_NDENS;
01112 } else if (Vstring_strcasecmp(tok, "qdens") == 0) {
01113 writetype = VDT_QDENS;
01114 } else {
01115 Vnm_print(2, "PBEparm_parse: Invalid data type (%s) to write!\n",
01116 tok);
01117 return -1;
01118 }
01119 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
01120 if (Vstring_strcasecmp(tok, "dx") == 0) {
01121 writefmt = VDF_DX;
01122 } else if (Vstring_strcasecmp(tok, "uhbd") == 0) {
01123 writefmt = VDF_UHBD;
01124 } else if (Vstring_strcasecmp(tok, "avs") == 0) {
01125 writefmt = VDF_AVS;
01126 } else if (Vstring_strcasecmp(tok, "gz") == 0) {
01127 writefmt = VDF_GZ;
01128 } else if (Vstring_strcasecmp(tok, "flat") == 0) {
01129 writefmt = VDF_FLAT;
01130 } else {
01131 Vnm_print(2, "PBEparm_parse: Invalid data format (%s) to write!\n",
01132 tok);
01133 return -1;
01134 }
01135 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
01136 if (tok[0]=='"') {
01137 strcpy(strnew, "");
01138 while (tok[strlen(tok)-1] != '"') {
01139 strcat(str, tok);
01140 strcat(str, " ");
01141 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
01142 }
01143 strcat(str, tok);
01144 strncpy(strnew, str+1, strlen(str)-2);
01145 strcpy(tok, strnew);
01146 }
01147 if (thee->numwrite < (PBEPARM_MAXWRITE-1)) {
01148 strncpy(thee->writestem[thee->numwrite], tok, VMAX_ARGLEN);
01149 thee->writetype[thee->numwrite] = writetype;
01150 thee->writefmt[thee->numwrite] = writefmt;
01151 (thee->numwrite)++;
01152 } else {
01153 Vnm_print(2, "PBEparm_parse: You have exceeded the maximum number of write statements!\n");
01154 Vnm_print(2, "PBEparm_parse: Ignoring additional write statements!\n");
01155 }
01156 return 1;
01157
01158 VERROR1:
01159 Vnm_print(2, "parsePBE: ran out of tokens!\n");
01160 return -1;
01161 }
01162
01163 VPRIVATE int PBEparm_parseWRITEMAT(PBEparm *thee, Vio *sock) {
01164 char tok[VMAX_BUFSIZE], str[VMAX_BUFSIZE]="", strnew[VMAX_BUFSIZE]="";
01165
01166 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
01167 if (Vstring_strcasecmp(tok, "poisson") == 0) {
01168 thee->writematflag = 0;
01169 } else if (Vstring_strcasecmp(tok, "full") == 0) {
01170 thee->writematflag = 1;
01171 } else {
01172 Vnm_print(2, "NOsh: Invalid format (%s) while parsing \
01173 WRITEMAT keyword!\n", tok);
01174 return -1;
01175 }
01176
01177 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
01178 if (tok[0]=='"') {
01179 strcpy(strnew, "");
01180 while (tok[strlen(tok)-1] != '"') {
01181 strcat(str, tok);
01182 strcat(str, " ");
01183 VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
01184 }
01185 strcat(str, tok);
01186 strncpy(strnew, str+1, strlen(str)-2);
01187 strcpy(tok, strnew);
01188 }
01189 strncpy(thee->writematstem, tok, VMAX_ARGLEN);
01190 thee->setwritemat = 1;
01191 thee->writemat = 1;
01192 return 1;
01193
01194 VERROR1:
01195 Vnm_print(2, "parsePBE: ran out of tokens!\n");
01196 return -1;
01197
01198 }
01199
01200 VPUBLIC int PBEparm_parseToken(PBEparm *thee, char tok[VMAX_BUFSIZE],
01201 Vio *sock) {
01202
01203 if (thee == VNULL) {
01204 Vnm_print(2, "parsePBE: got NULL thee!\n");
01205 return -1;
01206 }
01207 if (sock == VNULL) {
01208 Vnm_print(2, "parsePBE: got NULL socket!\n");
01209 return -1;
01210 }
01211
01212 Vnm_print(0, "PBEparm_parseToken: trying %s...\n", tok);
01213
01214 if (Vstring_strcasecmp(tok, "mol") == 0) {
01215 return PBEparm_parseMOL(thee, sock);
01216 } else if (Vstring_strcasecmp(tok, "lpbe") == 0) {
01217 return PBEparm_parseLPBE(thee, sock);
01218 } else if (Vstring_strcasecmp(tok, "npbe") == 0) {
01219 return PBEparm_parseNPBE(thee, sock);
01220 } else if (Vstring_strcasecmp(tok, "lrpbe") == 0) {
01221 return PBEparm_parseLRPBE(thee, sock);
01222 } else if (Vstring_strcasecmp(tok, "nrpbe") == 0) {
01223 return PBEparm_parseNRPBE(thee, sock);
01224 } else if (Vstring_strcasecmp(tok, "smpbe") == 0) {
01225 return PBEparm_parseSMPBE(thee, sock);
01226 } else if (Vstring_strcasecmp(tok, "bcfl") == 0) {
01227 return PBEparm_parseBCFL(thee, sock);
01228 } else if (Vstring_strcasecmp(tok, "ion") == 0) {
01229 return PBEparm_parseION(thee, sock);
01230 } else if (Vstring_strcasecmp(tok, "pdie") == 0) {
01231 return PBEparm_parsePDIE(thee, sock);
01232 } else if (Vstring_strcasecmp(tok, "sdens") == 0) {
01233 return PBEparm_parseSDENS(thee, sock);
01234 } else if (Vstring_strcasecmp(tok, "sdie") == 0) {
01235 return PBEparm_parseSDIE(thee, sock);
01236 } else if (Vstring_strcasecmp(tok, "srfm") == 0) {
01237 return PBEparm_parseSRFM(thee, sock);
01238 } else if (Vstring_strcasecmp(tok, "srad") == 0) {
01239 return PBEparm_parseSRAD(thee, sock);
01240 } else if (Vstring_strcasecmp(tok, "swin") == 0) {
01241 return PBEparm_parseSWIN(thee, sock);
01242 } else if (Vstring_strcasecmp(tok, "temp") == 0) {
01243 return PBEparm_parseTEMP(thee, sock);
01244 } else if (Vstring_strcasecmp(tok, "usemap") == 0) {
01245 return PBEparm_parseUSEMAP(thee, sock);
01246 } else if (Vstring_strcasecmp(tok, "calcenergy") == 0) {
01247 return PBEparm_parseCALCENERGY(thee, sock);
01248 } else if (Vstring_strcasecmp(tok, "calcforce") == 0) {
01249 return PBEparm_parseCALCFORCE(thee, sock);
01250 } else if (Vstring_strcasecmp(tok, "write") == 0) {
01251 return PBEparm_parseWRITE(thee, sock);
01252 } else if (Vstring_strcasecmp(tok, "writemat") == 0) {
01253 return PBEparm_parseWRITEMAT(thee, sock);
01254
01255
01256
01257
01258
01259 } else if (Vstring_strcasecmp(tok, "zmem") == 0) {
01260 return PBEparm_parseZMEM(thee, sock);
01261 } else if (Vstring_strcasecmp(tok, "Lmem") == 0) {
01262 return PBEparm_parseLMEM(thee, sock);
01263 } else if (Vstring_strcasecmp(tok, "mdie") == 0) {
01264 return PBEparm_parseMDIE(thee, sock);
01265 } else if (Vstring_strcasecmp(tok, "memv") == 0) {
01266 return PBEparm_parseMEMV(thee, sock);
01267 }
01268
01269
01270
01271 return 0;
01272
01273 }