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

src/generic/apolparm.c

Go to the documentation of this file.
00001 
00050 #include "apbscfg.h"
00051 #include "apbs/apolparm.h"
00052 
00053 VEMBED(rcsid="$Id: apolparm.c 1552 2010-02-10 17:46:27Z yhuang01 $")
00054 
00055 #if !defined(VINLINE_MGPARM)
00056 
00057 #endif /* if !defined(VINLINE_MGPARM) */
00058 
00059 VPUBLIC APOLparm* APOLparm_ctor() {
00060 
00061     /* Set up the structure */
00062     APOLparm *thee = VNULL;
00063     thee = Vmem_malloc(VNULL, 1, sizeof(APOLparm));
00064     VASSERT( thee != VNULL);
00065     VASSERT( APOLparm_ctor2(thee) == VRC_SUCCESS );
00066 
00067     return thee;
00068 }
00069 
00070 VPUBLIC Vrc_Codes APOLparm_ctor2(APOLparm *thee) {
00071 
00072     int i;
00073 
00074     if (thee == VNULL) return VRC_FAILURE;
00075 
00076     thee->parsed = 0;
00077  
00078     thee->setgrid = 0;
00079     thee->setmolid = 0;
00080     thee->setbconc = 0;
00081     thee->setsdens = 0;
00082     thee->setdpos = 0;
00083     thee->setpress = 0;
00084     thee->setsrfm = 0;
00085     thee->setsrad = 0;
00086     thee->setswin = 0;
00087  
00088  thee->settemp = 0;
00089     thee->setgamma = 0;
00090  
00091  thee->setwat = 0;
00092  
00093  thee->sav = 0.0;
00094  thee->sasa = 0.0;
00095  thee->wcaEnergy = 0.0;
00096  
00097  for(i=0;i<3;i++) thee->totForce[i] = 0.0;
00098  
00099     return VRC_SUCCESS; 
00100 }
00101 
00102 VPUBLIC void APOLparm_copy(
00103         APOLparm *thee,
00104         APOLparm *source
00105         ) {
00106  
00107  int i;
00108  
00109  thee->parsed = source->parsed;
00110  
00111  for (i=0; i<3; i++) thee->grid[i] = source->grid[i];
00112  thee->setgrid = source->setgrid;
00113  
00114  thee->molid = source->molid;
00115  thee->setmolid = source->setmolid;
00116  
00117  thee->bconc = source->bconc ;
00118  thee->setbconc= source->setbconc ;
00119  
00120  thee->sdens = source->sdens ;
00121  thee->setsdens= source->setsdens ;
00122  
00123  thee->dpos = source->dpos ;
00124  thee->setdpos= source->setdpos ;
00125  
00126  thee->press = source->press ;
00127  thee->setpress = source->setpress ;
00128  
00129  thee->srfm = source->srfm ;
00130  thee->setsrfm = source->setsrfm ;
00131  
00132  thee->srad = source->srad ;
00133  thee->setsrad = source->setsrad ;
00134  
00135  thee->swin = source->swin ;
00136  thee->setswin = source->setswin ;
00137  
00138  thee->temp = source->temp ;
00139  thee->settemp = source->settemp ;
00140  
00141  thee->gamma = source->gamma ;
00142  thee->setgamma = source->setgamma ;
00143  
00144  thee->calcenergy = source->calcenergy ;
00145  thee->setcalcenergy = source->setcalcenergy ;
00146  
00147  thee->calcforce = source->calcforce ;
00148  thee->setcalcforce = source->setcalcforce ;
00149  
00150  thee->setwat = source->setwat ;
00151  
00152  thee->sav = source->sav;
00153  thee->sasa = source->sasa;
00154  thee->wcaEnergy = source->wcaEnergy;
00155  
00156  for(i=0;i<3;i++) thee->totForce[i] = source->totForce[i];
00157  
00158  return;
00159 }
00160 
00161 VPUBLIC void APOLparm_dtor(APOLparm **thee) {
00162     if ((*thee) != VNULL) {
00163         APOLparm_dtor2(*thee);
00164         Vmem_free(VNULL, 1, sizeof(APOLparm), (void **)thee);
00165         (*thee) = VNULL;
00166     }
00167  
00168  return;
00169 }
00170 
00171 VPUBLIC void APOLparm_dtor2(APOLparm *thee) { ; }
00172 
00173 VPUBLIC Vrc_Codes APOLparm_check(APOLparm *thee) { 
00174 
00175     
00176     Vrc_Codes rc;
00177     rc = VRC_SUCCESS;
00178  
00179     if (!thee->parsed) {
00180         Vnm_print(2, "APOLparm_check:  not filled!\n");
00181         return VRC_FAILURE;
00182     }
00183     if (!thee->setgrid) {
00184         Vnm_print(2, "APOLparm_check:  grid not set!\n");
00185         rc = VRC_FAILURE;
00186     }
00187     if (!thee->setmolid) {
00188         Vnm_print(2, "APOLparm_check:  molid not set!\n");
00189         rc = VRC_FAILURE;
00190     }
00191     if (!thee->setbconc) {
00192         Vnm_print(2, "APOLparm_check:  bconc not set!\n");
00193         rc = VRC_FAILURE;
00194     }
00195     if (!thee->setsdens) {
00196         Vnm_print(2, "APOLparm_check:  sdens not set!\n");
00197         rc = VRC_FAILURE;
00198     }
00199     if (!thee->setdpos) {
00200         Vnm_print(2, "APOLparm_check:  dpos not set!\n");
00201         rc = VRC_FAILURE;
00202     }
00203     if (!thee->setpress) {
00204         Vnm_print(2, "APOLparm_check:  press not set!\n");
00205         rc = VRC_FAILURE;
00206     }
00207     if (!thee->setsrfm) {
00208         Vnm_print(2, "APOLparm_check:  srfm not set!\n");
00209         rc = VRC_FAILURE;
00210     }
00211     if (!thee->setsrad) {
00212         Vnm_print(2, "APOLparm_check:  srad not set!\n");
00213         rc = VRC_FAILURE;
00214     }
00215     if (!thee->setswin) {
00216         Vnm_print(2, "APOLparm_check:  swin not set!\n");
00217         rc = VRC_FAILURE;
00218     }
00219     if (!thee->settemp) {
00220         Vnm_print(2, "APOLparm_check:  temp not set!\n");
00221         rc = VRC_FAILURE;
00222     }
00223  if (!thee->setgamma) {
00224         Vnm_print(2, "APOLparm_check:  gamma not set!\n");
00225         rc = VRC_FAILURE;
00226     }
00227     return rc;
00228  
00229 }
00230 
00231 VPRIVATE Vrc_Codes APOLparm_parseGRID(APOLparm *thee, Vio *sock) {
00232  
00233  char tok[VMAX_BUFSIZE];
00234  double tf;
00235  
00236  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00237  if (sscanf(tok, "%lf", &tf) == 0) {
00238   Vnm_print(2, "NOsh:  Read non-float (%s) while parsing GRID \
00239 keyword!\n", tok);
00240   return VRC_WARNING;
00241  } else thee->grid[0] = tf;
00242  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00243  if (sscanf(tok, "%lf", &tf) == 0) {
00244   Vnm_print(2, "NOsh:  Read non-float (%s) while parsing GRID \
00245 keyword!\n", tok);
00246   return VRC_WARNING;
00247  } else thee->grid[1] = tf;
00248  VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00249  if (sscanf(tok, "%lf", &tf) == 0) {
00250   Vnm_print(2, "NOsh:  Read non-float (%s) while parsing GRID \
00251 keyword!\n", tok);
00252   return VRC_WARNING;
00253  } else thee->grid[2] = tf;
00254     thee->setgrid = 1;
00255     return VRC_SUCCESS;
00256  
00257 VERROR1:
00258         Vnm_print(2, "parseAPOL:  ran out of tokens!\n");
00259  return VRC_WARNING;
00260 }
00261 
00262 VPRIVATE Vrc_Codes APOLparm_parseMOL(APOLparm *thee, Vio *sock) {
00263     int ti;
00264     char tok[VMAX_BUFSIZE];
00265  
00266     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00267     if (sscanf(tok, "%d", &ti) == 0) {
00268         Vnm_print(2, "NOsh:  Read non-int (%s) while parsing MOL \
00269 keyword!\n", tok);
00270         return VRC_WARNING;
00271     } 
00272     thee->molid = ti;
00273     thee->setmolid = 1;
00274     return VRC_SUCCESS;
00275  
00276 VERROR1:
00277         Vnm_print(2, "parseAPOL:  ran out of tokens!\n");
00278  return VRC_WARNING;
00279 }
00280 
00281 VPRIVATE Vrc_Codes APOLparm_parseSRFM(APOLparm *thee, Vio *sock) {
00282     char tok[VMAX_BUFSIZE];
00283  
00284     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00285  
00286     if (Vstring_strcasecmp(tok, "sacc") == 0) {
00287         thee->srfm = VSM_MOL;
00288         thee->setsrfm = 1;
00289         return VRC_SUCCESS;
00290     } else {
00291         printf("parseAPOL: Unrecongnized keyword (%s) when parsing srfm!\n", tok);
00292   printf("parseAPOL: Accepted values for srfm = sacc\n");
00293         return VRC_WARNING;
00294     }
00295  
00296     return VRC_FAILURE;
00297  
00298 VERROR1:
00299         Vnm_print(2, "parseAPOL:  ran out of tokens!\n");
00300  return VRC_WARNING;
00301 }
00302 
00303 VPRIVATE Vrc_Codes APOLparm_parseSRAD(APOLparm *thee, Vio *sock) {
00304     char tok[VMAX_BUFSIZE];
00305     double tf;
00306  
00307     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00308     if (sscanf(tok, "%lf", &tf) == 0) {
00309         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing SRAD \
00310 keyword!\n", tok);
00311         return VRC_WARNING;
00312     }
00313     thee->srad = tf;
00314     thee->setsrad = 1;
00315     return VRC_SUCCESS;
00316  
00317 VERROR1:
00318         Vnm_print(2, "parseAPOL:  ran out of tokens!\n");
00319  return VRC_WARNING;
00320 }
00321 
00322 VPRIVATE Vrc_Codes APOLparm_parseSWIN(APOLparm *thee, Vio *sock) {
00323     char tok[VMAX_BUFSIZE];
00324     double tf;
00325  
00326     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00327     if (sscanf(tok, "%lf", &tf) == 0) {
00328         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing SWIN \
00329 keyword!\n", tok);
00330         return VRC_WARNING;
00331     }
00332     thee->swin = tf;
00333     thee->setswin = 1;
00334     return VRC_SUCCESS;
00335  
00336 VERROR1:
00337         Vnm_print(2, "parseAPOL:  ran out of tokens!\n");
00338  return VRC_WARNING;
00339 }
00340 
00341 VPRIVATE Vrc_Codes APOLparm_parseTEMP(APOLparm *thee, Vio *sock) {
00342     char tok[VMAX_BUFSIZE];
00343     double tf;
00344  
00345     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00346     if (sscanf(tok, "%lf", &tf) == 0) {
00347         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing TEMP \
00348 keyword!\n", tok);
00349         return VRC_WARNING;
00350     }
00351     thee->temp = tf;
00352     thee->settemp = 1;
00353     return VRC_SUCCESS;
00354  
00355 VERROR1:
00356         Vnm_print(2, "parseAPOL:  ran out of tokens!\n");
00357  return VRC_WARNING;
00358 }
00359 
00360 VPRIVATE Vrc_Codes APOLparm_parseGAMMA(APOLparm *thee, Vio *sock) {
00361     char tok[VMAX_BUFSIZE];
00362     double tf;
00363  
00364     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00365     if (sscanf(tok, "%lf", &tf) == 0) {
00366         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing GAMMA \
00367 keyword!\n", tok);
00368         return VRC_WARNING;
00369     }
00370     thee->gamma = tf;
00371     thee->setgamma = 1;
00372     return VRC_SUCCESS;
00373  
00374 VERROR1:
00375         Vnm_print(2, "parseAPOL:  ran out of tokens!\n");
00376  return VRC_WARNING;
00377 }
00378 
00379 VPRIVATE Vrc_Codes APOLparm_parseCALCENERGY(APOLparm *thee, Vio *sock) {
00380     char tok[VMAX_BUFSIZE];
00381     int ti;
00382  
00383     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00384     /* Parse number */
00385     if (sscanf(tok, "%d", &ti) == 1) {
00386         thee->calcenergy = ti;
00387         thee->setcalcenergy = 1;
00388   
00389         Vnm_print(2, "parseAPOL:  Warning -- parsed deprecated \"calcenergy \
00390 %d\" statement.\n", ti);
00391         Vnm_print(2, "parseAPOL:  Please use \"calcenergy ");
00392         switch (thee->calcenergy) {
00393             case ACE_NO:
00394                 Vnm_print(2, "no");
00395                 break;
00396             case ACE_TOTAL:
00397                 Vnm_print(2, "total");
00398                 break;
00399             case ACE_COMPS:
00400                 Vnm_print(2, "comps");
00401                 break;
00402             default:
00403                 Vnm_print(2, "UNKNOWN");
00404                 break;
00405         }
00406         Vnm_print(2, "\" instead.\n");
00407         return VRC_SUCCESS;
00408     } else if (Vstring_strcasecmp(tok, "no") == 0) {
00409         thee->calcenergy = ACE_NO;
00410         thee->setcalcenergy = 1;
00411         return VRC_SUCCESS;
00412     } else if (Vstring_strcasecmp(tok, "total") == 0) {
00413         thee->calcenergy = ACE_TOTAL;
00414         thee->setcalcenergy = 1;
00415         return VRC_SUCCESS;
00416     } else if (Vstring_strcasecmp(tok, "comps") == 0) {
00417         thee->calcenergy = ACE_COMPS;
00418         thee->setcalcenergy = 1;
00419         return VRC_SUCCESS;
00420     } else {
00421         Vnm_print(2, "NOsh:  Unrecognized parameter (%s) while parsing \
00422 calcenergy!\n", tok);
00423         return VRC_WARNING;
00424     }
00425     return VRC_FAILURE;
00426  
00427 VERROR1:
00428         Vnm_print(2, "parseAPOL:  ran out of tokens!\n");
00429  return VRC_WARNING;
00430 }
00431 
00432 VPRIVATE Vrc_Codes APOLparm_parseCALCFORCE(APOLparm *thee, Vio *sock) {
00433     char tok[VMAX_BUFSIZE];
00434     int ti;
00435  
00436     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00437     /* Parse number */
00438     if (sscanf(tok, "%d", &ti) == 1) {
00439         thee->calcforce = ti;
00440         thee->setcalcforce = 1;
00441   
00442         Vnm_print(2, "parseAPOL:  Warning -- parsed deprecated \"calcforce \
00443 %d\" statement.\n", ti);
00444         Vnm_print(2, "parseAPOL:  Please use \"calcforce ");
00445         switch (thee->calcenergy) {
00446             case ACF_NO:
00447                 Vnm_print(2, "no");
00448                 break;
00449             case ACF_TOTAL:
00450                 Vnm_print(2, "total");
00451                 break;
00452             case ACF_COMPS:
00453                 Vnm_print(2, "comps");
00454                 break;
00455             default:
00456                 Vnm_print(2, "UNKNOWN");
00457                 break;
00458         }
00459         Vnm_print(2, "\" instead.\n");
00460         return VRC_SUCCESS;
00461     } else if (Vstring_strcasecmp(tok, "no") == 0) {
00462         thee->calcforce = ACF_NO;
00463         thee->setcalcforce = 1;
00464         return VRC_SUCCESS;
00465     } else if (Vstring_strcasecmp(tok, "total") == 0) {
00466         thee->calcforce = ACF_TOTAL;
00467         thee->setcalcforce = 1;
00468         return VRC_SUCCESS;
00469     } else if (Vstring_strcasecmp(tok, "comps") == 0) {
00470         thee->calcforce = ACF_COMPS;
00471         thee->setcalcforce = 1;
00472         return VRC_SUCCESS;
00473     } else {
00474         Vnm_print(2, "NOsh:  Unrecognized parameter (%s) while parsing \
00475 calcforce!\n", tok);
00476         return VRC_WARNING;
00477     }
00478     return VRC_FAILURE;
00479  
00480 VERROR1:
00481         Vnm_print(2, "parseAPOL:  ran out of tokens!\n");
00482  return VRC_WARNING;
00483 }
00484 
00485 VPRIVATE Vrc_Codes APOLparm_parseBCONC(APOLparm *thee, Vio *sock) {
00486     char tok[VMAX_BUFSIZE];
00487     double tf;
00488  
00489     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00490     if (sscanf(tok, "%lf", &tf) == 0) {
00491         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing BCONC \
00492 keyword!\n", tok);
00493         return VRC_WARNING;
00494     }
00495     thee->bconc = tf;
00496     thee->setbconc = 1;
00497     return VRC_SUCCESS;
00498  
00499 VERROR1:
00500         Vnm_print(2, "parseAPOL:  ran out of tokens!\n");
00501  return VRC_WARNING;
00502 }
00503 
00504 VPRIVATE Vrc_Codes APOLparm_parseSDENS(APOLparm *thee, Vio *sock) {
00505     char tok[VMAX_BUFSIZE];
00506     double tf;
00507  
00508     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00509     if (sscanf(tok, "%lf", &tf) == 0) {
00510         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing SDENS \
00511 keyword!\n", tok);
00512         return VRC_WARNING;
00513     }
00514     thee->sdens = tf;
00515     thee->setsdens = 1;
00516     return VRC_SUCCESS;
00517  
00518 VERROR1:
00519         Vnm_print(2, "parseAPOL:  ran out of tokens!\n");
00520  return VRC_WARNING;
00521 }
00522 
00523 VPRIVATE Vrc_Codes APOLparm_parseDPOS(APOLparm *thee, Vio *sock) {
00524     char tok[VMAX_BUFSIZE];
00525     double tf;
00526  
00527     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00528     if (sscanf(tok, "%lf", &tf) == 0) {
00529         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing SDENS \
00530 keyword!\n", tok);
00531         return VRC_WARNING;
00532     }
00533     thee->dpos = tf;
00534     thee->setdpos = 1;
00535  
00536  if(thee->dpos < 0.001){
00537   Vnm_print(1,"\nWARNING WARNING WARNING WARNING WARNING\n");
00538   Vnm_print(1,"NOsh: dpos is set to a very small value.\n");
00539   Vnm_print(1,"NOsh: If you are not using a PQR file, you can \
00540 safely ignore this message.\n");
00541   Vnm_print(1,"NOsh: Otherwise please choose a value greater than \
00542 or equal to 0.001.\n\n");
00543  }
00544  
00545     return VRC_SUCCESS;
00546  
00547 VERROR1:
00548         Vnm_print(2, "parseAPOL:  ran out of tokens!\n");
00549  return VRC_WARNING;
00550 }
00551 
00552 VPRIVATE Vrc_Codes APOLparm_parsePRESS(APOLparm *thee, Vio *sock) {
00553     char tok[VMAX_BUFSIZE];
00554     double tf;
00555  
00556     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00557     if (sscanf(tok, "%lf", &tf) == 0) {
00558         Vnm_print(2, "NOsh:  Read non-float (%s) while parsing PRESS \
00559 keyword!\n", tok);
00560         return VRC_WARNING;
00561     }
00562     thee->press = tf;
00563     thee->setpress = 1;
00564     return VRC_SUCCESS;
00565  
00566 VERROR1:
00567         Vnm_print(2, "parseAPOL:  ran out of tokens!\n");
00568  return VRC_WARNING;
00569 }
00570 
00571 VPUBLIC Vrc_Codes APOLparm_parseToken(APOLparm *thee, char tok[VMAX_BUFSIZE],
00572   Vio *sock) {
00573 
00574     if (thee == VNULL) {
00575         Vnm_print(2, "parseAPOL:  got NULL thee!\n");
00576         return VRC_WARNING;
00577     }
00578 
00579     if (sock == VNULL) {
00580         Vnm_print(2, "parseAPOL:  got NULL socket!\n");
00581         return VRC_WARNING;
00582     }
00583  
00584  if (Vstring_strcasecmp(tok, "mol") == 0) {
00585   return APOLparm_parseMOL(thee, sock);
00586  } else if (Vstring_strcasecmp(tok, "grid") == 0) {
00587   return APOLparm_parseGRID(thee, sock);
00588  } else if (Vstring_strcasecmp(tok, "dime") == 0) {
00589   Vnm_print(2, "APOLparm_parseToken:  The DIME and GLEN keywords for APOLAR have been replaced with GRID.\n");
00590   Vnm_print(2, "APOLparm_parseToken:  Please see the APBS User Guide for more information.\n");
00591   return VRC_WARNING;
00592  } else if (Vstring_strcasecmp(tok, "glen") == 0) {
00593   Vnm_print(2, "APOLparm_parseToken:  The DIME and GLEN keywords for APOLAR have been replaced with GRID.\n");
00594   Vnm_print(2, "APOLparm_parseToken:  Please see the APBS User Guide for more information.\n");
00595   return VRC_WARNING;
00596  } else if (Vstring_strcasecmp(tok, "bconc") == 0) {
00597   return APOLparm_parseBCONC(thee, sock);
00598     } else if (Vstring_strcasecmp(tok, "sdens") == 0) {
00599         return APOLparm_parseSDENS(thee, sock);
00600     } else if (Vstring_strcasecmp(tok, "dpos") == 0) {
00601         return APOLparm_parseDPOS(thee, sock);
00602     }  else if (Vstring_strcasecmp(tok, "srfm") == 0) {
00603         return APOLparm_parseSRFM(thee, sock);
00604     } else if (Vstring_strcasecmp(tok, "srad") == 0) {
00605         return APOLparm_parseSRAD(thee, sock);
00606     } else if (Vstring_strcasecmp(tok, "swin") == 0) {
00607         return APOLparm_parseSWIN(thee, sock);
00608     } else if (Vstring_strcasecmp(tok, "temp") == 0) {
00609         return APOLparm_parseTEMP(thee, sock);
00610     } else if (Vstring_strcasecmp(tok, "gamma") == 0) {
00611         return APOLparm_parseGAMMA(thee, sock);
00612     } else if (Vstring_strcasecmp(tok, "press") == 0) {
00613         return APOLparm_parsePRESS(thee, sock);
00614     } else if (Vstring_strcasecmp(tok, "calcenergy") == 0) {
00615         return APOLparm_parseCALCENERGY(thee, sock);
00616     } else if (Vstring_strcasecmp(tok, "calcforce") == 0) {
00617         return APOLparm_parseCALCFORCE(thee, sock);
00618     } else {
00619         Vnm_print(2, "parseAPOL:  Unrecognized keyword (%s)!\n", tok);
00620         return VRC_WARNING;
00621     }
00622  
00623     
00624  return VRC_FAILURE;
00625 
00626 }

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