• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

src/generic/mgparm.c

Go to the documentation of this file.
00001 
00049 #include "apbscfg.h"
00050 #include "apbs/apbs.h"
00051 #include "apbs/vhal.h"
00052 #include "apbs/mgparm.h"
00053 #include "apbs/vstring.h"
00054 
00055 VEMBED(rcsid="$Id: mgparm.c 1552 2010-02-10 17:46:27Z yhuang01 $")
00056 
00057 #if !defined(VINLINE_MGPARM)
00058 
00059 #endif /* if !defined(VINLINE_MGPARM) */
00060 
00061 VPUBLIC void MGparm_setCenterX(MGparm *thee, double x) {
00062     VASSERT(thee != VNULL);
00063     thee->center[0] = x;
00064 }
00065 VPUBLIC void MGparm_setCenterY(MGparm *thee, double y) {
00066     VASSERT(thee != VNULL);
00067     thee->center[1] = y;
00068 }
00069 VPUBLIC void MGparm_setCenterZ(MGparm *thee, double z) {
00070     VASSERT(thee != VNULL);
00071     thee->center[2] = z;
00072 }
00073 VPUBLIC double MGparm_getCenterX(MGparm *thee) {
00074     VASSERT(thee != VNULL);
00075     return thee->center[0];
00076 }
00077 VPUBLIC double MGparm_getCenterY(MGparm *thee) {
00078     VASSERT(thee != VNULL);
00079     return thee->center[1];
00080 }
00081 VPUBLIC double MGparm_getCenterZ(MGparm *thee) {
00082     VASSERT(thee != VNULL);
00083     return thee->center[2];
00084 }
00085 VPUBLIC int MGparm_getNx(MGparm *thee) {
00086     VASSERT(thee != VNULL);
00087     return thee->dime[0];
00088 }
00089 VPUBLIC int MGparm_getNy(MGparm *thee) {
00090     VASSERT(thee != VNULL);
00091     return thee->dime[1];
00092 }
00093 VPUBLIC int MGparm_getNz(MGparm *thee) {
00094     VASSERT(thee != VNULL);
00095     return thee->dime[2];
00096 }
00097 VPUBLIC double MGparm_getHx(MGparm *thee) {
00098     VASSERT(thee != VNULL);
00099     return thee->grid[0];
00100 }
00101 VPUBLIC double MGparm_getHy(MGparm *thee) {
00102     VASSERT(thee != VNULL);
00103     return thee->grid[1];
00104 }
00105 VPUBLIC double MGparm_getHz(MGparm *thee) {
00106     VASSERT(thee != VNULL);
00107     return thee->grid[2];
00108 }
00109 
00110 VPUBLIC MGparm* MGparm_ctor(MGparm_CalcType type) {
00111 
00112     /* Set up the structure */
00113     MGparm *thee = VNULL;
00114     thee = Vmem_malloc(VNULL, 1, sizeof(MGparm));
00115     VASSERT( thee != VNULL);
00116     VASSERT( MGparm_ctor2(thee, type) == VRC_SUCCESS );
00117 
00118     return thee;
00119 }
00120 
00121 VPUBLIC Vrc_Codes MGparm_ctor2(MGparm *thee, MGparm_CalcType type) {
00122 
00123     int i;
00124 
00125     if (thee == VNULL) return VRC_FAILURE;
00126 
00127     for (i=0; i<3; i++) {
00128         thee->dime[i] = -1;
00129         thee->pdime[i] = 1;
00130     }
00131 
00132     thee->parsed = 0;
00133     thee->type = type;
00134 
00135     /* *** GENERIC PARAMETERS *** */
00136     thee->setdime = 0;
00137     thee->setchgm = 0;
00138 
00139     /* *** TYPE 0 PARAMETERS *** */
00140     thee->nlev = VMGNLEV;
00141     thee->setnlev = 1;
00142     thee->etol = 1.0e-6;
00143     thee->setetol = 0;
00144     thee->setgrid = 0;
00145     thee->setglen = 0;
00146     thee->setgcent = 0;  
00147 
00148     /* *** TYPE 1 & 2 PARAMETERS *** */
00149     thee->setcglen = 0;
00150     thee->setfglen = 0;
00151     thee->setcgcent = 0;
00152     thee->setfgcent = 0;
00153 
00154     /* *** TYPE 2 PARAMETERS *** */
00155     thee->setpdime = 0;
00156     thee->setrank = 0;
00157     thee->setsize = 0;
00158     thee->setofrac = 0;
00159     for (i=0; i<6; i++) thee->partDisjOwnSide[i] = 0;
00160  thee->setasync = 0;
00161 
00162     /* *** Default parameters for TINKER *** */
00163     thee->chgs = VCM_CHARGE;
00164  
00165  thee->useAqua = 0; 
00166  thee->setUseAqua = 0;
00167  
00168     return VRC_SUCCESS; 
00169 }
00170 
00171 VPUBLIC void MGparm_dtor(MGparm **thee) {
00172     if ((*thee) != VNULL) {
00173         MGparm_dtor2(*thee);
00174         Vmem_free(VNULL, 1, sizeof(MGparm), (void **)thee);
00175         (*thee) = VNULL;
00176     }
00177 }
00178 
00179 VPUBLIC void MGparm_dtor2(MGparm *thee) { ; }
00180 
00181 VPUBLIC Vrc_Codes MGparm_check(MGparm *thee) { 
00182 
00183     Vrc_Codes rc;
00184  int i, tdime[3], ti, tnlev[3], nlev;
00185 
00186     rc = VRC_SUCCESS;
00187  
00188  Vnm_print(0, "MGparm_check:  checking MGparm object of type %d.\n", 
00189      thee->type);
00190 
00191     /* Check to see if we were even filled... */
00192     if (!thee->parsed) {
00193         Vnm_print(2, "MGparm_check:  not filled!\n");
00194         return VRC_FAILURE;
00195     }
00196 
00197     /* Check generic settings */
00198     if (!thee->setdime) {
00199         Vnm_print(2, "MGparm_check:  DIME not set!\n");
00200         rc = VRC_FAILURE;
00201     }
00202     if (!thee->setchgm) {
00203         Vnm_print(2, "MGparm_check: CHGM not set!\n");
00204         return VRC_FAILURE;
00205     }
00206 
00207 
00208     /* Check sequential manual & dummy settings */
00209     if ((thee->type == MCT_MANUAL) || (thee->type == MCT_DUMMY)) {
00210         if ((!thee->setgrid) && (!thee->setglen)) {
00211             Vnm_print(2, "MGparm_check:  Neither GRID nor GLEN set!\n");
00212             rc = VRC_FAILURE;
00213         }
00214         if ((thee->setgrid) && (thee->setglen)) {
00215             Vnm_print(2, "MGparm_check:  Both GRID and GLEN set!\n");
00216             rc = VRC_FAILURE;
00217         }
00218         if (!thee->setgcent) {
00219             Vnm_print(2, "MGparm_check:  GCENT not set!\n");
00220             rc = VRC_FAILURE;
00221         }
00222     }
00223  
00224     /* Check sequential and parallel automatic focusing settings */
00225     if ((thee->type == MCT_AUTO) || (thee->type == MCT_PARALLEL)) {
00226         if (!thee->setcglen) {
00227             Vnm_print(2, "MGparm_check:  CGLEN not set!\n");
00228             rc = VRC_FAILURE;
00229         }
00230         if (!thee->setfglen) {
00231             Vnm_print(2, "MGparm_check:  FGLEN not set!\n");
00232             rc = VRC_FAILURE;
00233         }
00234         if (!thee->setcgcent) {
00235             Vnm_print(2, "MGparm_check:  CGCENT not set!\n");
00236             rc = VRC_FAILURE;
00237         }
00238         if (!thee->setfgcent) {
00239             Vnm_print(2, "MGparm_check:  FGCENT not set!\n");
00240             rc = VRC_FAILURE;
00241         }
00242     }
00243 
00244     /* Check parallel automatic focusing settings */
00245     if (thee->type == MCT_PARALLEL) {
00246         if (!thee->setpdime) {
00247             Vnm_print(2, "MGparm_check:  PDIME not set!\n");
00248             rc = VRC_FAILURE;
00249         }
00250         if (!thee->setrank) {
00251             Vnm_print(2, "MGparm_check:  PROC_RANK not set!\n");
00252             rc = VRC_FAILURE;
00253         }
00254         if (!thee->setsize) {
00255             Vnm_print(2, "MGparm_check:  PROC_SIZE not set!\n");
00256             rc = VRC_FAILURE;
00257         }
00258         if (!thee->setofrac) {
00259             Vnm_print(2, "MGparm_check:  OFRAC not set!\n");
00260             rc = VRC_FAILURE;
00261         }
00262     }
00263  
00264     /* Perform a sanity check on nlev and dime, resetting values as necessary */
00265     if (rc == 1) {
00266  /* Calculate the actual number of grid points and nlev to satisfy the
00267   * formula:  n = c * 2^(l+1) + 1, where n is the number of grid points,
00268   * c is an integer, and l is the number of levels */
00269  if (thee->type != MCT_DUMMY) {
00270   for (i=0; i<3; i++) {
00271             /* See if the user picked a reasonable value, if not then fix it */
00272             ti = thee->dime[i] - 1;
00273             if (ti == VPOW(2, (thee->nlev+1))) {
00274                 tnlev[i] = thee->nlev;
00275                 tdime[i] = thee->dime[i];
00276             } else {
00277                 tdime[i] = thee->dime[i];
00278                 ti = tdime[i] - 1;
00279                 tnlev[i] = 0;
00280                 /* Find the maximum number of times this dimension can be
00281                  * divided by two */
00282                 while (VEVEN(ti)) {
00283                     (tnlev[i])++;
00284                     ti = (int)ceil(0.5*ti);
00285                 }
00286                 (tnlev[i])--;
00287                 /* We'd like to have at least VMGNLEV levels in the multigrid
00288                  * hierarchy.  This means that the dimension needs to be
00289                  * c*2^VMGNLEV + 1, where c is an integer. */
00290                 if ((tdime[i] > 65) && (tnlev[i] < VMGNLEV)) {
00291                     Vnm_print(2, "NOsh:  Bad dime[%d]  = %d (%d nlev)!\n",
00292                       i, tdime[i], tnlev[i]);
00293                     ti = (int)(tdime[i]/VPOW(2.,(VMGNLEV+1)));
00294                     if (ti < 1) ti = 1;
00295                     tdime[i] = ti*(int)(VPOW(2.,(VMGNLEV+1))) + 1;
00296                     tnlev[i] = 4;
00297                     Vnm_print(2, "NOsh:  Reset dime[%d] to %d and (nlev = %d).\n", i, tdime[i], VMGNLEV);
00298                 }
00299             }
00300         }
00301  } else { /* We are a dummy calculation, but we still need positive numbers of points */
00302   for (i=0; i<3; i++) {
00303       tnlev[i] = thee->nlev;
00304    tdime[i] = thee->dime[i];
00305     if (thee->dime[i] <= 0) {
00306      Vnm_print(2, "NOsh:  Resetting dime[%d] from %d to 3.\n", i, thee->dime[i]);
00307      thee->dime[i] = 3;
00308    }
00309   }
00310  }
00311  
00312  /* The actual number of levels we'll be using is the smallest number of
00313          * possible levels in any dimensions */
00314         nlev = VMIN2(tnlev[0], tnlev[1]);
00315         nlev = VMIN2(nlev, tnlev[2]);
00316         /* Set the number of levels and dimensions */
00317         Vnm_print(0, "NOsh:  nlev = %d, dime = (%d, %d, %d)\n", nlev, tdime[0],
00318           tdime[1], tdime[2]);
00319         thee->nlev = nlev;
00320   if (thee->nlev <= 0) {
00321    Vnm_print(2, "MGparm_check:  illegal nlev (%d); check your grid dimensions!\n", thee->nlev);
00322    rc = VRC_FAILURE;
00323   }
00324   if (thee->nlev < 2) {
00325    Vnm_print(2, "MGparm_check:  you're using a very small nlev (%d) and therefore\n", thee->nlev);
00326    Vnm_print(2, "MGparm_check:  will not get the optimal performance of the multigrid\n");
00327    Vnm_print(2, "MGparm_check:  algorithm.  Please check your grid dimensions.\n");
00328   }
00329         for (i=0; i<3; i++) thee->dime[i] = tdime[i];
00330     }
00331  
00332  if (!thee->setUseAqua) thee->useAqua = 0;
00333  
00334     return rc;
00335 }
00336 
00337 VPUBLIC void MGparm_copy(MGparm *thee, MGparm *parm) {
00338 
00339     int i;
00340 
00341     VASSERT(thee != VNULL);
00342     VASSERT(parm != VNULL);
00343 
00344     
00345     thee->type = parm->type;
00346     thee->parsed = parm->parsed;
00347 
00348     /* *** GENERIC PARAMETERS *** */
00349     for (i=0; i<3; i++) thee->dime[i] = parm->dime[i];
00350     thee->setdime = parm->setdime;
00351     thee->chgm = parm->chgm;
00352     thee->setchgm = parm->setchgm;
00353     thee->chgs = parm->chgs;
00354 
00355     /* *** TYPE 0 PARMS *** */
00356     thee->nlev = parm->nlev;
00357     thee->setnlev = parm->setnlev;
00358     thee->etol = parm->etol;
00359     thee->setetol = parm->setetol;
00360     for (i=0; i<3; i++) thee->grid[i] = parm->grid[i];
00361     thee->setgrid = parm->setgrid;
00362     for (i=0; i<3; i++) thee->glen[i] = parm->glen[i];
00363     thee->setglen = parm->setglen;
00364     thee->cmeth = parm->cmeth;
00365     for (i=0; i<3; i++) thee->center[i] = parm->center[i];
00366     thee->setgcent = parm->setgcent;
00367     thee->centmol = parm->centmol;
00368 
00369     /* *** TYPE 1 & 2 PARMS *** */
00370     for (i=0; i<3; i++) thee->cglen[i] = parm->cglen[i];
00371     thee->setcglen = parm->setcglen;
00372     for (i=0; i<3; i++) thee->fglen[i] = parm->fglen[i];
00373     thee->setfglen = parm->setfglen;
00374     thee->ccmeth = parm->ccmeth;
00375     for (i=0; i<3; i++) thee->ccenter[i] = parm->ccenter[i];
00376     thee->setcgcent = parm->setcgcent;
00377     thee->ccentmol = parm->ccentmol;
00378     thee->fcmeth = parm->fcmeth;
00379     for (i=0; i<3; i++) thee->fcenter[i] = parm->fcenter[i];
00380     thee->setfgcent = parm->setfgcent;
00381     thee->fcentmol = parm->fcentmol;
00382 
00383     /* *** TYPE 2 PARMS *** */
00384     for (i=0; i<3; i++) 
00385       thee->partDisjCenter[i] = parm->partDisjCenter[i];
00386     for (i=0; i<3; i++) 
00387       thee->partDisjLength[i] = parm->partDisjLength[i];
00388     for (i=0; i<6; i++) 
00389       thee->partDisjOwnSide[i] = parm->partDisjOwnSide[i];
00390     for (i=0; i<3; i++) thee->pdime[i] = parm->pdime[i];
00391     thee->setpdime = parm->setpdime;
00392     thee->proc_rank = parm->proc_rank;
00393     thee->setrank = parm->setrank;
00394     thee->proc_size = parm->proc_size;
00395     thee->setsize = parm->setsize;
00396     thee->ofrac = parm->ofrac;
00397     thee->setofrac = parm->setofrac;
00398  thee->setasync = parm->setasync;
00399  thee->async = parm->async;
00400  
00401  thee->nonlintype = parm->nonlintype;
00402  thee->setnonlintype = parm->setnonlintype;
00403  
00404  thee->method = parm->method;
00405  thee->method = parm->method;
00406  
00407  thee->useAqua = parm->useAqua;
00408  thee->setUseAqua = parm->setUseAqua;
00409 }
00410 
00411 VPRIVATE Vrc_Codes MGparm_parseDIME(MGparm *thee, Vio *sock) {
00412 
00413     char tok[VMAX_BUFSIZE];
00414     int ti;
00415 
00416     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00417     if (sscanf(tok, "%d", &ti) == 0){
00418         Vnm_print(2, "parseMG:  Read non-integer (%s) while parsing DIME \
00419 keyword!\n", tok);
00420         return VRC_WARNING;
00421     } else thee->dime[0] = ti;
00422     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00423     if (sscanf(tok, "%d", &ti) == 0) {
00424         Vnm_print(2, "NOsh:  Read non-integer (%s) while parsing DIME \
00425 keyword!\n", tok);
00426         return VRC_WARNING;
00427     } else thee->dime[1] = ti;
00428     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00429     if (sscanf(tok, "%d", &ti) == 0) {
00430         Vnm_print(2, "NOsh:  Read non-integer (%s) while parsing DIME \
00431 keyword!\n", tok);
00432         return VRC_WARNING;
00433     } else thee->dime[2] = ti;
00434     thee->setdime = 1;
00435     return VRC_SUCCESS;
00436 
00437     VERROR1:
00438         Vnm_print(2, "parseMG:  ran out of tokens!\n");
00439         return VRC_WARNING;
00440 }
00441 
00442 VPRIVATE Vrc_Codes MGparm_parseCHGM(MGparm *thee, Vio *sock) {
00443 
00444     char tok[VMAX_BUFSIZE];
00445     Vchrg_Meth ti;
00446 
00447     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00448     if (sscanf(tok, "%d", &ti) == 1) {
00449         thee->chgm = ti;
00450         thee->setchgm = 1;
00451         Vnm_print(2, "NOsh:  Warning -- parsed deprecated statment \"chgm %d\".\n", ti);
00452         Vnm_print(2, "NOsh:  Please use \"chgm ");
00453         switch (thee->chgm) {
00454             case VCM_TRIL:
00455                 Vnm_print(2, "spl0");
00456                 break;
00457             case VCM_BSPL2:
00458                 Vnm_print(2, "spl2");
00459                 break;
00460             case VCM_BSPL4:
00461                 Vnm_print(2, "spl4"); 
00462                 break;
00463             default:
00464                 Vnm_print(2, "UNKNOWN");
00465                 break;
00466         }
00467         Vnm_print(2, "\" instead!\n");
00468         return VRC_SUCCESS;
00469     } else if (Vstring_strcasecmp(tok, "spl0") == 0) {
00470         thee->chgm = VCM_TRIL;
00471         thee->setchgm = 1;
00472         return VRC_SUCCESS;
00473     } else if (Vstring_strcasecmp(tok, "spl2") == 0) {
00474         thee->chgm = VCM_BSPL2;
00475         thee->setchgm = 1;
00476         return VRC_SUCCESS;
00477     } else if (Vstring_strcasecmp(tok, "spl4") == 0) {
00478         thee->chgm = VCM_BSPL4;
00479         thee->setchgm = 1;
00480         return VRC_SUCCESS;
00481     } else {
00482         Vnm_print(2, "NOsh:  Unrecognized parameter (%s) when parsing \
00483 chgm!\n", tok);
00484         return VRC_WARNING;
00485     }
00486     return VRC_WARNING;
00487 
00488     VERROR1:
00489         Vnm_print(2, "parseMG:  ran out of tokens!\n");
00490         return VRC_WARNING;
00491 }
00492 
00493 VPRIVATE Vrc_Codes MGparm_parseNLEV(MGparm *thee, Vio *sock) {
00494 
00495     char tok[VMAX_BUFSIZE];
00496     int ti;
00497 
00498     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00499     if (sscanf(tok, "%d", &ti) == 0) {
00500         Vnm_print(2, "NOsh:  Read non-integer (%s) while parsing NLEV \
00501 keyword!\n", tok);
00502         return VRC_WARNING;
00503     } else thee->nlev = ti;
00504     thee->setnlev = 1;
00505     return VRC_SUCCESS;
00506 
00507     VERROR1:
00508         Vnm_print(2, "parseMG:  ran out of tokens!\n");
00509         return VRC_WARNING;
00510 }
00511 
00512 VPRIVATE Vrc_Codes MGparm_parseETOL(MGparm *thee, Vio *sock) {
00513 
00514     char tok[VMAX_BUFSIZE];
00515     double tf;
00516 
00517     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00518     if (sscanf(tok, "%lf", &tf) == 0) {
00519         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing etol \
00520 keyword!\n", tok);
00521         return VRC_WARNING;
00522     } else if (tf <= 0.0) {
00523         Vnm_print(2, "parseMG:  etol must be greater than 0!\n");
00524         return VRC_WARNING;
00525     } else thee->etol = tf;
00526     thee->setetol = 1;
00527     return VRC_SUCCESS;
00528 
00529     VERROR1:
00530         Vnm_print(2, "parseMG:  ran out of tokens!\n");
00531         return VRC_WARNING;
00532 }
00533 
00534 
00535 VPRIVATE Vrc_Codes MGparm_parseGRID(MGparm *thee, Vio *sock) {
00536 
00537     char tok[VMAX_BUFSIZE];
00538     double tf;
00539 
00540     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00541     if (sscanf(tok, "%lf", &tf) == 0) {
00542         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing GRID \
00543 keyword!\n", tok);
00544         return VRC_WARNING;
00545     } else thee->grid[0] = tf;
00546     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00547     if (sscanf(tok, "%lf", &tf) == 0) {
00548         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing GRID \
00549 keyword!\n", tok);
00550         return VRC_WARNING;
00551     } else thee->grid[1] = tf;
00552     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00553     if (sscanf(tok, "%lf", &tf) == 0) {
00554         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing GRID \
00555 keyword!\n", tok);
00556         return VRC_WARNING;
00557     } else thee->grid[2] = tf;
00558     thee->setgrid = 1;
00559     return VRC_SUCCESS;
00560 
00561     VERROR1:
00562         Vnm_print(2, "parseMG:  ran out of tokens!\n");
00563         return VRC_WARNING;
00564 }
00565 
00566 VPRIVATE Vrc_Codes MGparm_parseGLEN(MGparm *thee, Vio *sock) {
00567 
00568     char tok[VMAX_BUFSIZE];
00569     double tf;
00570 
00571     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00572     if (sscanf(tok, "%lf", &tf) == 0) {
00573         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing GLEN \
00574 keyword!\n", tok);
00575         return VRC_WARNING;
00576     } else thee->glen[0] = tf;
00577     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00578     if (sscanf(tok, "%lf", &tf) == 0) {
00579         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing GLEN \
00580 keyword!\n", tok);
00581         return VRC_WARNING;
00582     } else thee->glen[1] = tf;
00583     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00584     if (sscanf(tok, "%lf", &tf) == 0) {
00585         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing GLEN \
00586 keyword!\n", tok);
00587         return VRC_WARNING;
00588     } else thee->glen[2] = tf;
00589     thee->setglen = 1;
00590     return VRC_SUCCESS;
00591 
00592     VERROR1:
00593         Vnm_print(2, "parseMG:  ran out of tokens!\n");
00594         return VRC_WARNING;
00595 }
00596 
00597 VPRIVATE Vrc_Codes MGparm_parseGAMMA(MGparm *thee, Vio *sock) {
00598  
00599     char tok[VMAX_BUFSIZE];
00600  
00601     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00602  Vnm_print(2, "parseMG:  GAMMA keyword deprecated!\n");
00603  Vnm_print(2, "parseMG:  If you are using PyMOL or VMD and still seeing this message,\n");
00604  Vnm_print(2, "parseMG:  please contact the developers of those programs regarding this message.\n");
00605  return VRC_SUCCESS;
00606  
00607 VERROR1:
00608  Vnm_print(2, "parseMG:  ran out of tokens!\n");
00609  return VRC_WARNING;
00610 }
00611 
00612 VPRIVATE Vrc_Codes MGparm_parseGCENT(MGparm *thee, Vio *sock) {
00613 
00614     char tok[VMAX_BUFSIZE];
00615     double tf;
00616     int ti;
00617 
00618     /* If the next token isn't a float, it probably means we want to
00619      * center on a molecule */
00620     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00621     if (sscanf(tok, "%lf", &tf) == 0) {
00622         if (Vstring_strcasecmp(tok, "mol") == 0) {
00623             VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00624             if (sscanf(tok, "%d", &ti) == 0) {
00625                 Vnm_print(2, "NOsh:  Read non-int (%s) while parsing \
00626 GCENT MOL keyword!\n", tok);
00627                 return VRC_WARNING;
00628             } else {
00629                 thee->cmeth = MCM_MOLECULE;
00630     /* Subtract 1 here to convert user numbering (1, 2, 3, ...) into
00631     array index */
00632                 thee->centmol = ti - 1;
00633             }
00634         } else {
00635             Vnm_print(2, "NOsh:  Unexpected keyword (%s) while parsing \
00636 GCENT!\n", tok);
00637             return VRC_WARNING;
00638         }
00639     } else {
00640         thee->center[0] = tf;
00641         VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00642         if (sscanf(tok, "%lf", &tf) == 0) {
00643             Vnm_print(2, "NOsh:  Read non-float (%s) while parsing \
00644 GCENT keyword!\n", tok);
00645             return VRC_WARNING;
00646         }
00647         thee->center[1] = tf;
00648         VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00649         if (sscanf(tok, "%lf", &tf) == 0) {
00650             Vnm_print(2, "NOsh:  Read non-float (%s) while parsing \
00651 GCENT keyword!\n", tok);
00652             return VRC_WARNING;
00653         } 
00654         thee->center[2] = tf;
00655     }
00656     thee->setgcent = 1;
00657     return VRC_SUCCESS;
00658 
00659     VERROR1:
00660         Vnm_print(2, "parseMG:  ran out of tokens!\n");
00661         return VRC_WARNING;
00662 }
00663 
00664 VPRIVATE Vrc_Codes MGparm_parseCGLEN(MGparm *thee, Vio *sock) {
00665 
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 CGLEN \
00672 keyword!\n", tok);
00673         return VRC_WARNING;
00674     } else thee->cglen[0] = tf;
00675     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00676     if (sscanf(tok, "%lf", &tf) == 0) {
00677         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing CGLEN \
00678 keyword!\n", tok);
00679         return VRC_WARNING;
00680     } else thee->cglen[1] = tf;
00681     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00682     if (sscanf(tok, "%lf", &tf) == 0) {
00683         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing CGLEN \
00684 keyword!\n", tok);
00685         return VRC_WARNING;
00686     } else thee->cglen[2] = tf;
00687     thee->setcglen = 1;
00688     return VRC_SUCCESS;
00689 
00690     VERROR1:
00691         Vnm_print(2, "parseMG:  ran out of tokens!\n");
00692         return VRC_WARNING;
00693 }
00694 
00695 VPRIVATE Vrc_Codes MGparm_parseFGLEN(MGparm *thee, Vio *sock) {
00696 
00697     char tok[VMAX_BUFSIZE];
00698     double tf;
00699 
00700     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00701     if (sscanf(tok, "%lf", &tf) == 0) {
00702         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing FGLEN \
00703 keyword!\n", tok);
00704         return VRC_WARNING;
00705     } else thee->fglen[0] = tf;
00706     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00707     if (sscanf(tok, "%lf", &tf) == 0) {
00708         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing FGLEN \
00709 keyword!\n", tok);
00710         return VRC_WARNING;
00711     } else thee->fglen[1] = tf;
00712     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00713     if (sscanf(tok, "%lf", &tf) == 0) {
00714         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing FGLEN \
00715 keyword!\n", tok);
00716         return VRC_WARNING;
00717     } else thee->fglen[2] = tf;
00718     thee->setfglen = 1;
00719     return VRC_SUCCESS;
00720 
00721     VERROR1:
00722         Vnm_print(2, "parseMG:  ran out of tokens!\n");
00723         return VRC_WARNING;
00724 }
00725 
00726 VPRIVATE Vrc_Codes MGparm_parseCGCENT(MGparm *thee, Vio *sock) {
00727 
00728     char tok[VMAX_BUFSIZE];
00729     double tf;
00730     int ti;
00731 
00732     /* If the next token isn't a float, it probably means we want to
00733      * center on a molecule */
00734     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00735     if (sscanf(tok, "%lf", &tf) == 0) {
00736         if (Vstring_strcasecmp(tok, "mol") == 0) {
00737             VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00738             if (sscanf(tok, "%d", &ti) == 0) {
00739                 Vnm_print(2, "NOsh:  Read non-int (%s) while parsing \
00740 CGCENT MOL keyword!\n", tok);
00741                 return VRC_WARNING;
00742             } else {
00743     thee->ccmeth = MCM_MOLECULE;
00744     /* Subtract 1 here to convert user numbering (1, 2, 3, ...) into 
00745     array index */
00746                 thee->ccentmol = ti - 1;
00747    }
00748         } else {
00749             Vnm_print(2, "NOsh:  Unexpected keyword (%s) while parsing \
00750 CGCENT!\n", tok);
00751             return VRC_WARNING;
00752             }
00753     } else {
00754         thee->ccenter[0] = tf;
00755         VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00756         if (sscanf(tok, "%lf", &tf) == 0) {
00757             Vnm_print(2, "NOsh:  Read non-float (%s) while parsing \
00758 CGCENT keyword!\n", tok);
00759             return VRC_WARNING;
00760         }
00761         thee->ccenter[1] = tf;
00762         VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00763         if (sscanf(tok, "%lf", &tf) == 0) {
00764             Vnm_print(2, "NOsh:  Read non-float (%s) while parsing \
00765 CGCENT keyword!\n", tok);
00766             return VRC_WARNING;
00767         }
00768         thee->ccenter[2] = tf;
00769     }
00770     thee->setcgcent = 1;
00771     return VRC_SUCCESS;
00772 
00773     VERROR1:
00774         Vnm_print(2, "parseMG:  ran out of tokens!\n");
00775         return VRC_WARNING;
00776 }
00777 
00778 VPRIVATE Vrc_Codes MGparm_parseFGCENT(MGparm *thee, Vio *sock) {
00779 
00780     char tok[VMAX_BUFSIZE];
00781     double tf;
00782     int ti;
00783 
00784     /* If the next token isn't a float, it probably means we want to
00785      * center on a molecule */
00786     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00787     if (sscanf(tok, "%lf", &tf) == 0) {
00788         if (Vstring_strcasecmp(tok, "mol") == 0) {
00789             VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00790             if (sscanf(tok, "%d", &ti) == 0) {
00791                  Vnm_print(2, "NOsh:  Read non-int (%s) while parsing \
00792 FGCENT MOL keyword!\n", tok);
00793                  return VRC_WARNING;
00794             } else {
00795                 thee->fcmeth = MCM_MOLECULE;
00796     /* Subtract 1 here to convert user numbering (1, 2, 3, ...) into
00797     array index */
00798                 thee->fcentmol = ti - 1;
00799             }
00800         } else {
00801             Vnm_print(2, "NOsh:  Unexpected keyword (%s) while parsing \
00802 FGCENT!\n", tok);
00803             return VRC_WARNING;
00804         }
00805     } else {
00806         thee->fcenter[0] = tf;
00807         VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00808         if (sscanf(tok, "%lf", &tf) == 0) {
00809             Vnm_print(2, "NOsh:  Read non-float (%s) while parsing \
00810 FGCENT keyword!\n", tok);
00811             return VRC_WARNING;
00812         }
00813         thee->fcenter[1] = tf;
00814         VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00815         if (sscanf(tok, "%lf", &tf) == 0) {
00816             Vnm_print(2, "NOsh:  Read non-float (%s) while parsing \
00817 FGCENT keyword!\n", tok);
00818             return VRC_WARNING;
00819         }
00820         thee->fcenter[2] = tf;
00821     }
00822     thee->setfgcent = 1;
00823     return VRC_SUCCESS;
00824 
00825     VERROR1:
00826         Vnm_print(2, "parseMG:  ran out of tokens!\n");
00827         return VRC_WARNING;
00828 }
00829 
00830 VPRIVATE Vrc_Codes MGparm_parsePDIME(MGparm *thee, Vio *sock) {
00831 
00832     char tok[VMAX_BUFSIZE];
00833     int ti;
00834 
00835     /* Read the number of grid points */
00836     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00837     if (sscanf(tok, "%d", &ti) == 0) {
00838         Vnm_print(2, "NOsh:  Read non-integer (%s) while parsing PDIME \
00839 keyword!\n", tok);
00840         return VRC_WARNING;
00841     } else {
00842         thee->pdime[0] = ti;
00843     }
00844     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00845     if (sscanf(tok, "%d", &ti) == 0) {
00846         Vnm_print(2, "NOsh:  Read non-integer (%s) while parsing PDIME \
00847 keyword!\n", tok);
00848         return VRC_WARNING;
00849     } else {
00850         thee->pdime[1] = ti;
00851     }
00852     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00853     if (sscanf(tok, "%d", &ti) == 0) {
00854         Vnm_print(2, "NOsh:  Read non-integer (%s) while parsing PDIME \
00855 keyword!\n", tok);
00856         return VRC_WARNING;
00857     } else {
00858         thee->pdime[2] = ti;
00859     }
00860     thee->setpdime = 1;
00861     return VRC_SUCCESS;
00862 
00863     VERROR1:
00864         Vnm_print(2, "parseMG:  ran out of tokens!\n");
00865         return VRC_WARNING;
00866 }
00867 
00868 VPRIVATE Vrc_Codes MGparm_parseOFRAC(MGparm *thee, Vio *sock) {
00869 
00870     char tok[VMAX_BUFSIZE];
00871     double tf;
00872 
00873     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00874     if (sscanf(tok, "%lf", &tf) == 0) {
00875         Vnm_print(2, "NOsh:  Read non-int (%s) while parsing OFRAC \
00876 keyword!\n", tok);
00877         return VRC_WARNING;
00878     }
00879     thee->ofrac = tf;
00880     thee->setofrac = 1;
00881     return VRC_SUCCESS;
00882 
00883     VERROR1:
00884         Vnm_print(2, "parseMG:  ran out of tokens!\n");
00885         return VRC_WARNING;
00886 }
00887 
00888 VPRIVATE Vrc_Codes MGparm_parseASYNC(MGparm *thee, Vio *sock) {
00889 
00890     char tok[VMAX_BUFSIZE];
00891     int ti;
00892 
00893     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00894     if (sscanf(tok, "%i", &ti) == 0) {
00895         Vnm_print(2, "NOsh:  Read non-integer (%s) while parsing ASYNC \
00896 keyword!\n", tok);
00897         return VRC_WARNING;
00898     }
00899     thee->async = ti;
00900     thee->setasync = 1;
00901     return VRC_SUCCESS;
00902 
00903     VERROR1:
00904         Vnm_print(2, "parseMG:  ran out of tokens!\n");
00905         return VRC_WARNING;
00906 }
00907 
00908 VPRIVATE Vrc_Codes MGparm_parseUSEAQUA(MGparm *thee, Vio *sock) {
00909     Vnm_print(0, "NOsh: parsed useaqua\n");
00910     thee->useAqua = 1;
00911     thee->setUseAqua = 1;
00912     return VRC_SUCCESS;
00913 }
00914 
00915 VPUBLIC Vrc_Codes MGparm_parseToken(MGparm *thee, char tok[VMAX_BUFSIZE], 
00916   Vio *sock) {
00917 
00918     if (thee == VNULL) {
00919         Vnm_print(2, "parseMG:  got NULL thee!\n"); 
00920         return VRC_WARNING;
00921     }
00922     if (sock == VNULL) {
00923         Vnm_print(2, "parseMG:  got NULL socket!\n"); 
00924         return VRC_WARNING;
00925     }
00926  
00927  Vnm_print(0, "MGparm_parseToken:  trying %s...\n", tok);
00928 
00929 
00930     if (Vstring_strcasecmp(tok, "dime") == 0) {
00931         return MGparm_parseDIME(thee, sock);
00932     } else if (Vstring_strcasecmp(tok, "chgm") == 0) {
00933         return MGparm_parseCHGM(thee, sock);
00934     } else if (Vstring_strcasecmp(tok, "nlev") == 0) {
00935         Vnm_print(2, "Warning: The 'nlev' keyword is now deprecated!\n");
00936         return MGparm_parseNLEV(thee, sock);
00937     } else if (Vstring_strcasecmp(tok, "etol") == 0) {
00938         return MGparm_parseETOL(thee, sock);
00939     } else if (Vstring_strcasecmp(tok, "grid") == 0) {
00940         return MGparm_parseGRID(thee, sock);
00941     } else if (Vstring_strcasecmp(tok, "glen") == 0) {
00942         return MGparm_parseGLEN(thee, sock);
00943     } else if (Vstring_strcasecmp(tok, "gcent") == 0) {
00944         return MGparm_parseGCENT(thee, sock);
00945     } else if (Vstring_strcasecmp(tok, "cglen") == 0) {
00946         return MGparm_parseCGLEN(thee, sock);
00947     } else if (Vstring_strcasecmp(tok, "fglen") == 0) {
00948         return MGparm_parseFGLEN(thee, sock);
00949     } else if (Vstring_strcasecmp(tok, "cgcent") == 0) {
00950         return MGparm_parseCGCENT(thee, sock);
00951     } else if (Vstring_strcasecmp(tok, "fgcent") == 0) {
00952         return MGparm_parseFGCENT(thee, sock);
00953     } else if (Vstring_strcasecmp(tok, "pdime") == 0) {
00954         return MGparm_parsePDIME(thee, sock);
00955     } else if (Vstring_strcasecmp(tok, "ofrac") == 0) {
00956         return MGparm_parseOFRAC(thee, sock);
00957     } else if (Vstring_strcasecmp(tok, "async") == 0) {
00958         return MGparm_parseASYNC(thee, sock);
00959  } else if (Vstring_strcasecmp(tok, "gamma") == 0) {
00960         return MGparm_parseGAMMA(thee, sock);
00961  } else if (Vstring_strcasecmp(tok, "useaqua") == 0) {
00962         return MGparm_parseUSEAQUA(thee, sock);
00963     } else {
00964         Vnm_print(2, "parseMG:  Unrecognized keyword (%s)!\n", tok);
00965         return VRC_WARNING;
00966     }
00967    
00968     return VRC_FAILURE;
00969 
00970 }

Generated on Wed Oct 20 2010 12:01:33 for APBS by  doxygen 1.7.2