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

src/generic/vparam.c

Go to the documentation of this file.
00001 
00049 #include "apbscfg.h"
00050 #include "apbs/vparam.h"
00051 
00052 #if defined(HAVE_MC_H)
00053 #include "mc/mc.h"
00054 #endif
00055 
00056 VEMBED(rcsid="$Id: vparam.c 1552 2010-02-10 17:46:27Z yhuang01 $")
00057 
00058 
00062 VPRIVATE char *MCwhiteChars = " =,;\t\n\r";
00063 
00068 VPRIVATE char *MCcommChars  = "#%";
00069 
00074 VPRIVATE char *MCxmlwhiteChars = " =,;\t\n\r<>";
00075 
00084 VPRIVATE int readFlatFileLine(Vio *sock, Vparam_AtomData *atom);
00085 
00094 VPRIVATE int readXMLFileAtom(Vio *sock, Vparam_AtomData *atom);
00095 
00096 
00097 #if !defined(VINLINE_VPARAM)
00098 
00099 VPUBLIC unsigned long int Vparam_memChk(Vparam *thee) {
00100     if (thee == VNULL) return 0;
00101     return Vmem_bytes(thee->vmem);
00102 }
00103 
00104 #endif /* if !defined(VINLINE_VPARAM) */
00105 
00106 VPUBLIC Vparam_AtomData* Vparam_AtomData_ctor() {
00107 
00108     Vparam_AtomData *thee = VNULL;
00109 
00110     /* Set up the structure */
00111     thee = Vmem_malloc(VNULL, 1, sizeof(Vparam_AtomData) );
00112     VASSERT(thee != VNULL);
00113     VASSERT(Vparam_AtomData_ctor2(thee));
00114 
00115     return thee;
00116 }
00117 
00118 VPUBLIC int Vparam_AtomData_ctor2(Vparam_AtomData *thee) { return 1; }
00119 
00120 VPUBLIC void Vparam_AtomData_dtor(Vparam_AtomData **thee) {
00121     
00122     if ((*thee) != VNULL) {
00123         Vparam_AtomData_dtor2(*thee);
00124         Vmem_free(VNULL, 1, sizeof(Vparam_AtomData), (void **)thee);
00125         (*thee) = VNULL;
00126     }
00127 
00128 }
00129 
00130 VPUBLIC void Vparam_AtomData_dtor2(Vparam_AtomData *thee) { ; }
00131 
00132 VPUBLIC Vparam_ResData* Vparam_ResData_ctor(Vmem *mem) {
00133 
00134     Vparam_ResData *thee = VNULL;
00135 
00136     /* Set up the structure */
00137     thee = Vmem_malloc(mem, 1, sizeof(Vparam_ResData) );
00138     VASSERT(thee != VNULL);
00139     VASSERT(Vparam_ResData_ctor2(thee, mem));
00140 
00141     return thee;
00142 }
00143 
00144 VPUBLIC int Vparam_ResData_ctor2(Vparam_ResData *thee, Vmem *mem) { 
00145     
00146     if (thee == VNULL) {
00147         Vnm_print(2, "Vparam_ResData_ctor2:  Got VNULL thee!\n");
00148         return 0;
00149     }
00150     thee->vmem = mem;
00151     thee->nAtomData = 0;
00152     thee->atomData = VNULL;
00153 
00154     return 1;
00155 }
00156 
00157 VPUBLIC void Vparam_ResData_dtor(Vparam_ResData **thee) {
00158     
00159     if ((*thee) != VNULL) {
00160         Vparam_ResData_dtor2(*thee);
00161         Vmem_free((*thee)->vmem, 1, sizeof(Vparam_ResData), (void **)thee);
00162         (*thee) = VNULL;
00163     }
00164 
00165 }
00166 
00167 VPUBLIC void Vparam_ResData_dtor2(Vparam_ResData *thee) { 
00168     
00169     if (thee == VNULL) return; 
00170     if (thee->nAtomData > 0) {
00171         Vmem_free(thee->vmem, thee->nAtomData, sizeof(Vparam_AtomData), 
00172           (void **)&(thee->atomData));
00173     }
00174     thee->nAtomData = 0;
00175     thee->atomData = VNULL;
00176 }
00177 
00178 VPUBLIC Vparam* Vparam_ctor() {
00179 
00180     Vparam *thee = VNULL;
00181 
00182     /* Set up the structure */
00183     thee = Vmem_malloc(VNULL, 1, sizeof(Vparam) );
00184     VASSERT(thee != VNULL);
00185     VASSERT(Vparam_ctor2(thee));
00186 
00187     return thee;
00188 }
00189 
00190 VPUBLIC int Vparam_ctor2(Vparam *thee) {
00191 
00192     if (thee == VNULL) {
00193         Vnm_print(2, "Vparam_ctor2: got VNULL thee!\n");
00194         return 0;
00195     }
00196 
00197     thee->vmem = VNULL;
00198     thee->vmem = Vmem_ctor("APBS:VPARAM");
00199     if (thee->vmem == VNULL) {
00200         Vnm_print(2, "Vparam_ctor2:  failed to init Vmem!\n");
00201         return 0;
00202     }
00203 
00204     thee->nResData = 0;
00205     thee->resData = VNULL;
00206 
00207     return 1;
00208 }
00209 
00210 VPUBLIC void Vparam_dtor(Vparam **thee) {
00211     
00212     if ((*thee) != VNULL) {
00213         Vparam_dtor2(*thee);
00214         Vmem_free(VNULL, 1, sizeof(Vparam), (void **)thee);
00215         (*thee) = VNULL;
00216     }
00217 
00218 }
00219 
00220 VPUBLIC void Vparam_dtor2(Vparam *thee) {
00221 
00222     int i;
00223 
00224     if (thee == VNULL) return;
00225 
00226     /* Destroy the residue data */
00227     for (i=0; i<thee->nResData; i++) Vparam_ResData_dtor2(&(thee->resData[i]));
00228     if (thee->nResData > 0) Vmem_free(thee->vmem, thee->nResData, 
00229       sizeof(Vparam_ResData), (void **)&(thee->resData));
00230     thee->nResData = 0;
00231     thee->resData = VNULL;
00232 
00233     if (thee->vmem != VNULL) Vmem_dtor(&(thee->vmem));
00234     thee->vmem = VNULL;
00235 
00236 }
00237 
00238 VPUBLIC Vparam_ResData* Vparam_getResData(Vparam *thee, 
00239   char resName[VMAX_ARGLEN]) {
00240 
00241     int i;
00242     Vparam_ResData *res = VNULL;
00243 
00244     VASSERT(thee != VNULL);
00245 
00246     if ((thee->nResData == 0) || (thee->resData == VNULL)) {
00247         res = VNULL;
00248         return res;
00249     }
00250 
00251     /* Look for the matching residue */
00252     for (i=0; i<thee->nResData; i++) {
00253         res = &(thee->resData[i]);
00254         if (Vstring_strcasecmp(resName, res->name) == 0) return res;
00255 
00256     }
00257 
00258     /* Didn't find a matching residue */
00259     res = VNULL;
00260     Vnm_print(2, "Vparam_getResData:  unable to find res=%s\n", resName);
00261     return res;
00262 }
00263 
00264 VPUBLIC Vparam_AtomData* Vparam_getAtomData(Vparam *thee, 
00265   char resName[VMAX_ARGLEN], char atomName[VMAX_ARGLEN]) {
00266 
00267     int i;
00268     Vparam_ResData *res = VNULL;
00269     Vparam_AtomData *atom = VNULL;
00270 
00271     VASSERT(thee != VNULL);
00272 
00273     if ((thee->nResData == 0) || (thee->resData == VNULL)) {
00274         atom = VNULL;
00275         return atom;
00276     }
00277 
00278     /* Look for the matching residue */
00279     res = Vparam_getResData(thee, resName);
00280     if (res == VNULL) {
00281         atom = VNULL;
00282   Vnm_print(2, "Vparam_getAtomData:  Unable to find residue %s!\n", resName);
00283         return atom;
00284     }
00285     for (i=0; i<res->nAtomData; i++) {
00286         atom = &(res->atomData[i]);
00287   if (atom == VNULL) {
00288    Vnm_print(2, "Vparam_getAtomData:  got NULL atom!\n");
00289    return VNULL;
00290   }
00291         if (Vstring_strcasecmp(atomName, atom->atomName) == 0) {
00292             return atom;
00293         }
00294     }
00295 
00296     /* Didn't find a matching atom/residue */
00297     atom = VNULL;
00298     Vnm_print(2, "Vparam_getAtomData:  unable to find atom '%s', res '%s'\n",
00299       atomName, resName);
00300     return atom;
00301 }
00302 
00303 VPUBLIC int Vparam_readXMLFile(Vparam *thee, const char *iodev,
00304   const char *iofmt, const char *thost, const char *fname) {
00305 
00306     int i, ires, natoms, nalloc, ralloc;
00307     Vparam_AtomData *atoms = VNULL;
00308     Vparam_AtomData *tatoms = VNULL;
00309     Vparam_AtomData *atom = VNULL;
00310     Vparam_ResData *res = VNULL;
00311     Vparam_ResData *residues = VNULL;
00312     Vparam_ResData *tresidues = VNULL;
00313     Vio *sock = VNULL;
00314     char currResName[VMAX_ARGLEN];
00315     char tok[VMAX_ARGLEN];
00316     char endtag[VMAX_ARGLEN];
00317 
00318     VASSERT(thee != VNULL);
00319 
00320     /* Setup communication */
00321     sock = Vio_ctor(iodev,iofmt,thost,fname,"r");
00322     if (sock == VNULL) {
00323         Vnm_print(2, "Vparam_readXMLFile: Problem opening virtual socket %s\n",
00324           fname);
00325         return 0;
00326     }
00327     if (Vio_accept(sock, 0) < 0) {
00328         Vnm_print(2, "Vparam_readXMLFile: Problem accepting virtual socket %s\n",
00329           fname);
00330         return 0;
00331     }
00332     Vio_setWhiteChars(sock, MCxmlwhiteChars);
00333     Vio_setCommChars(sock, MCcommChars);
00334 
00335     /* Clear existing parameters */
00336     if (thee->nResData > 0) {
00337         Vnm_print(2, "WARNING -- CLEARING PARAMETER DATABASE!\n");
00338         for (i=0; i<thee->nResData; i++) {
00339             Vparam_ResData_dtor2(&(thee->resData[i]));
00340         }
00341         Vmem_free(thee->vmem, thee->nResData, 
00342           sizeof(Vparam_ResData), (void **)&(thee->resData));
00343     }
00344 
00345     strcpy(endtag,"/");
00346 
00347     /* Set up temporary residue list */
00348     
00349     ralloc = 50;
00350     residues = Vmem_malloc(thee->vmem, ralloc, sizeof(Vparam_ResData));
00351 
00352     /* Read until we run out of entries, allocating space as needed */
00353     while (1) {
00354       
00355         VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00356 
00357         /* The first token should be the start tag */
00358       
00359         if (Vstring_strcasecmp(endtag, "/") == 0) strcat(endtag, tok);
00360         
00361         if (Vstring_strcasecmp(tok, "residue") == 0) {
00362           if (thee->nResData >= ralloc) {
00363                 tresidues = Vmem_malloc(thee->vmem, 2*ralloc, sizeof(Vparam_ResData));
00364                 VASSERT(tresidues != VNULL);
00365                 for (i=0; i<thee->nResData; i++) {
00366                     Vparam_ResData_copyTo(&(residues[i]), &(tresidues[i]));
00367                 }
00368                 Vmem_free(thee->vmem, ralloc, sizeof(Vparam_ResData), 
00369                           (void **)&(residues));
00370                 residues = tresidues; 
00371                 tresidues = VNULL;
00372                 ralloc = 2*ralloc;
00373             }
00374 
00375           /* Initial space for this residue's atoms */
00376           nalloc = 20;
00377           natoms = 0;
00378           atoms = Vmem_malloc(thee->vmem, nalloc, sizeof(Vparam_AtomData));
00379 
00380         } else if (Vstring_strcasecmp(tok, "name") == 0) {
00381             VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);  /* value */
00382             strcpy(currResName, tok);
00383             VJMPERR1(Vio_scanf(sock, "%s", tok) == 1); /* </name> */
00384         } else if (Vstring_strcasecmp(tok, "atom") == 0) {
00385             if (natoms >= nalloc) {
00386                 tatoms = Vmem_malloc(thee->vmem, 2*nalloc, sizeof(Vparam_AtomData));
00387                 VASSERT(tatoms != VNULL);
00388                 for (i=0; i<natoms; i++) {
00389                     Vparam_AtomData_copyTo(&(atoms[i]), &(tatoms[i]));
00390                 }
00391                 Vmem_free(thee->vmem, nalloc, sizeof(Vparam_AtomData), 
00392                           (void **)&(atoms));
00393                 atoms = tatoms; 
00394                 tatoms = VNULL;
00395                 nalloc = 2*nalloc;
00396             }
00397             atom = &(atoms[natoms]);
00398             if (!readXMLFileAtom(sock, atom)) break;
00399             natoms++;
00400 
00401         } else if (Vstring_strcasecmp(tok, "/residue") == 0) {
00402 
00403           res = &(residues[thee->nResData]);
00404           Vparam_ResData_ctor2(res, thee->vmem);
00405           res->atomData = Vmem_malloc(thee->vmem, natoms, 
00406                                       sizeof(Vparam_AtomData));
00407           res->nAtomData = natoms;
00408           strcpy(res->name, currResName);
00409           for (i=0; i<natoms; i++) {
00410               strcpy(atoms[i].resName, currResName);
00411               Vparam_AtomData_copyTo(&(atoms[i]), &(res->atomData[i]));
00412           }
00413           Vmem_free(thee->vmem, nalloc, sizeof(Vparam_AtomData), (void **)&(atoms));
00414           (thee->nResData)++;
00415 
00416         } else if (Vstring_strcasecmp(tok, endtag) == 0) break;
00417     }
00418 
00419     /* Initialize and copy the residues into the Vparam object */
00420       
00421     thee->resData = Vmem_malloc(thee->vmem, thee->nResData, 
00422                                 sizeof(Vparam_ResData));
00423     for (ires=0; ires<thee->nResData; ires++) {
00424         Vparam_ResData_copyTo(&(residues[ires]), &(thee->resData[ires]));
00425     }
00426 
00427     /* Destroy temporary atom space */
00428     Vmem_free(thee->vmem, ralloc, sizeof(Vparam_ResData), (void **)&(residues));
00429 
00430     /* Shut down communication */
00431     Vio_acceptFree(sock);
00432     Vio_dtor(&sock);
00433 
00434     return 1;
00435 
00436 VERROR1:
00437     Vnm_print(2, "Vparam_readXMLFile: Got unexpected EOF reading parameter file!\n");
00438     return 0;
00439 
00440 }
00441 
00442 VPUBLIC int Vparam_readFlatFile(Vparam *thee, const char *iodev,
00443   const char *iofmt, const char *thost, const char *fname) {
00444 
00445     int i, iatom, jatom, ires, natoms, nalloc;
00446     Vparam_AtomData *atoms = VNULL;
00447     Vparam_AtomData *tatoms = VNULL;
00448     Vparam_AtomData *atom = VNULL;
00449     Vparam_ResData *res = VNULL;
00450     Vio *sock = VNULL;
00451     char currResName[VMAX_ARGLEN];
00452 
00453     VASSERT(thee != VNULL);
00454 
00455     /* Setup communication */
00456     sock = Vio_ctor(iodev,iofmt,thost,fname,"r");
00457     if (sock == VNULL) {
00458         Vnm_print(2, "Vparam_readFlatFile: Problem opening virtual socket %s\n",
00459           fname);
00460         return 0;
00461     }
00462     if (Vio_accept(sock, 0) < 0) {
00463         Vnm_print(2, "Vparam_readFlatFile: Problem accepting virtual socket %s\n",
00464           fname);
00465         return 0;
00466     }
00467     Vio_setWhiteChars(sock, MCwhiteChars);
00468     Vio_setCommChars(sock, MCcommChars);
00469 
00470     /* Clear existing parameters */
00471     if (thee->nResData > 0) {
00472         Vnm_print(2, "WARNING -- CLEARING PARAMETER DATABASE!\n");
00473         for (i=0; i<thee->nResData; i++) {
00474             Vparam_ResData_dtor2(&(thee->resData[i]));
00475         }
00476         Vmem_free(thee->vmem, thee->nResData, 
00477           sizeof(Vparam_ResData), (void **)&(thee->resData));
00478     }
00479 
00480     /* Initial space for atoms */
00481     nalloc = 200;
00482     natoms = 0;
00483     atoms = Vmem_malloc(thee->vmem, nalloc, sizeof(Vparam_AtomData));
00484 
00485     /* Read until we run out of entries, allocating space as needed */
00486     while (1) {
00487         if (natoms >= nalloc) {
00488             tatoms = Vmem_malloc(thee->vmem, 2*nalloc, sizeof(Vparam_AtomData));
00489             VASSERT(tatoms != VNULL);
00490             for (i=0; i<natoms; i++) {
00491                 Vparam_AtomData_copyTo(&(atoms[i]), &(tatoms[i]));
00492             }
00493             Vmem_free(thee->vmem, nalloc, sizeof(Vparam_AtomData), 
00494               (void **)&(atoms));
00495             atoms = tatoms; 
00496             tatoms = VNULL;
00497             nalloc = 2*nalloc;
00498         }
00499         atom = &(atoms[natoms]);
00500         if (!readFlatFileLine(sock, atom)) break;
00501         natoms++;
00502     }
00503     if (natoms == 0) return 0;
00504 
00505     /* Count the number of residues */
00506     thee->nResData = 1;
00507     strcpy(currResName, atoms[0].resName);
00508     for (i=1; i<natoms; i++) {
00509         if (Vstring_strcasecmp(atoms[i].resName, currResName) != 0) {
00510             strcpy(currResName, atoms[i].resName);
00511             (thee->nResData)++;
00512         }
00513     }
00514 
00515     /* Create the residues */
00516     thee->resData = Vmem_malloc(thee->vmem, thee->nResData, 
00517       sizeof(Vparam_ResData));
00518     VASSERT(thee->resData != VNULL);
00519     for (i=0; i<(thee->nResData); i++) {
00520         res = &(thee->resData[i]);
00521         Vparam_ResData_ctor2(res, thee->vmem);
00522     }
00523 
00524     /* Count the number of atoms per residue */
00525     ires = 0;
00526     res = &(thee->resData[ires]);
00527     res->nAtomData = 1;
00528     strcpy(res->name, atoms[0].resName);
00529     for (i=1; i<natoms; i++) {
00530         if (Vstring_strcasecmp(atoms[i].resName, res->name) != 0) {
00531             (ires)++;
00532             res = &(thee->resData[ires]);
00533             res->nAtomData = 1;
00534             strcpy(res->name, atoms[i].resName);
00535         } else (res->nAtomData)++;
00536     }
00537 
00538     /* Allocate per-residue space for atoms */
00539     for (ires=0; ires<thee->nResData; ires++) {
00540         res = &(thee->resData[ires]);
00541   res->atomData = Vmem_malloc(thee->vmem, res->nAtomData, 
00542           sizeof(Vparam_AtomData));
00543     }
00544 
00545     /* Copy atoms into residues */
00546     iatom = 0;
00547     Vparam_AtomData_copyTo(&(atoms[0]), &(res->atomData[iatom]));
00548     for (ires=0; ires<thee->nResData; ires++) {
00549         res = &(thee->resData[ires]);
00550         for (jatom=0; jatom<res->nAtomData; jatom++) {
00551             Vparam_AtomData_copyTo(&(atoms[iatom]), &(res->atomData[jatom]));
00552             iatom++;
00553         }
00554     }
00555  
00556 
00557     /* Shut down communication */
00558     Vio_acceptFree(sock);
00559     Vio_dtor(&sock);
00560 
00561     /* Destroy temporary atom space */
00562     Vmem_free(thee->vmem, nalloc, sizeof(Vparam_AtomData), (void **)&(atoms));
00563 
00564     return 1;
00565 
00566 }
00567 
00568 VEXTERNC void Vparam_AtomData_copyTo(Vparam_AtomData *thee,
00569   Vparam_AtomData *dest) {
00570 
00571     VASSERT(thee != VNULL);
00572     VASSERT(dest != VNULL);
00573 
00574     strcpy(dest->atomName, thee->atomName);
00575     strcpy(dest->resName, thee->resName);
00576     dest->charge = thee->charge;
00577     dest->radius = thee->radius;
00578     dest->epsilon = thee->epsilon;
00579 
00580 }
00581 
00582 VEXTERNC void Vparam_ResData_copyTo(Vparam_ResData *thee,
00583   Vparam_ResData *dest) {
00584 
00585     int i;
00586 
00587     VASSERT(thee != VNULL);
00588     VASSERT(dest != VNULL);
00589     
00590     strcpy(dest->name, thee->name);
00591     dest->vmem = thee->vmem;
00592     dest->nAtomData = thee->nAtomData;
00593 
00594     dest->atomData = Vmem_malloc(thee->vmem, dest->nAtomData, 
00595                                  sizeof(Vparam_AtomData));
00596     
00597     for (i=0; i<dest->nAtomData; i++) {
00598       Vparam_AtomData_copyTo(&(thee->atomData[i]), &(dest->atomData[i]));
00599     }
00600     Vmem_free(thee->vmem, thee->nAtomData, sizeof(Vparam_AtomData), 
00601               (void **)&(thee->atomData));
00602 }
00603 
00604 VEXTERNC void Vparam_AtomData_copyFrom(Vparam_AtomData *thee,
00605   Vparam_AtomData *src) {  Vparam_AtomData_copyTo(src, thee); }
00606 
00607 VPRIVATE int readXMLFileAtom(Vio *sock, Vparam_AtomData *atom) {
00608   
00609     double dtmp;
00610     char tok[VMAX_BUFSIZE];
00611     int chgflag, radflag, nameflag;
00612    
00613     VASSERT(atom != VNULL);
00614 
00615     if (Vio_scanf(sock, "%s", tok) != 1) return 0;
00616 
00617     chgflag = 0;
00618     radflag = 0;
00619     nameflag = 0;
00620 
00621     while (1)
00622       {
00623           if (Vstring_strcasecmp(tok, "name") == 0) {
00624               VJMPERR1(Vio_scanf(sock, "%s", tok) == 1); 
00625               if (strlen(tok) > VMAX_ARGLEN) {
00626                   Vnm_print(2, "Vparam_readXMLFileAtom:  string (%s) too long \
00627 (%d)!\n", tok, strlen(tok));
00628                   return 0;
00629               }
00630               nameflag = 1;
00631               strcpy(atom->atomName, tok);
00632           } else if (Vstring_strcasecmp(tok, "charge") == 0) {
00633               VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00634               if (sscanf(tok, "%lf", &dtmp) != 1) {
00635                   Vnm_print(2, "Vparam_readXMLFileAtom:  Unexpected token (%s) while \
00636 parsing charge!\n", tok);
00637                   return 0;
00638               }
00639               chgflag = 1;
00640               atom->charge = dtmp;
00641           }  else if (Vstring_strcasecmp(tok, "radius") == 0) {
00642               VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00643               if (sscanf(tok, "%lf", &dtmp) != 1) {
00644                   Vnm_print(2, "Vparam_readXMLFileAtom:  Unexpected token (%s) while \
00645 parsing radius!\n", tok);
00646                   return 0;
00647               }
00648               radflag = 1;
00649               atom->radius = dtmp;
00650           }  else if (Vstring_strcasecmp(tok, "epsilon") == 0) {
00651               VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00652               if (sscanf(tok, "%lf", &dtmp) != 1) {
00653                   Vnm_print(2, "Vparam_readXMLFileAtom:  Unexpected token (%s) while \
00654 parsing epsilon!\n", tok);
00655                   return 0;
00656               }
00657               atom->epsilon = dtmp;
00658           } else if ((Vstring_strcasecmp(tok, "/atom") == 0) || 
00659                      (Vstring_strcasecmp(tok, "atom") == 0)){
00660                 if (chgflag && radflag && nameflag) return 1;
00661                 else if (!chgflag) {
00662                   Vnm_print(2, "Vparam_readXMLFileAtom: Reached end of atom without \
00663 setting the charge!\n");
00664                   return 0;
00665                 } else if (!radflag) {
00666                   Vnm_print(2, "Vparam_readXMLFileAtom: Reached end of atom without \
00667 setting the radius!\n");
00668                   return 0;
00669                 } else if (!nameflag) {
00670                   Vnm_print(2, "Vparam_readXMLFileAtom: Reached end of atom without \
00671 setting the name!\n");
00672                   return 0;
00673                 }
00674           } 
00675           VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00676       }
00677  
00678     /* If we get here something wrong has happened */
00679 
00680     VJMPERR1(1);
00681 
00682 VERROR1:
00683     Vnm_print(2, "Vparam_readXMLFileAtom: Got unexpected EOF reading parameter file!\n");
00684     return 0;
00685 
00686 }
00687 
00688 VPRIVATE int readFlatFileLine(Vio *sock, Vparam_AtomData *atom) {
00689 
00690     double dtmp;
00691     char tok[VMAX_BUFSIZE];
00692 
00693     VASSERT(atom != VNULL);
00694 
00695     if (Vio_scanf(sock, "%s", tok) != 1) return 0;
00696     if (strlen(tok) > VMAX_ARGLEN) {
00697         Vnm_print(2, "Vparam_readFlatFile:  string (%s) too long (%d)!\n", 
00698           tok, strlen(tok));
00699         return 0;
00700     }
00701     strcpy(atom->resName, tok);
00702     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00703     if (strlen(tok) > VMAX_ARGLEN) {
00704         Vnm_print(2, "Vparam_readFlatFile:  string (%s) too long (%d)!\n", 
00705           tok, strlen(tok));
00706         return 0;
00707     }
00708     strcpy(atom->atomName, tok);
00709     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00710     if (sscanf(tok, "%lf", &dtmp) != 1) {
00711         Vnm_print(2, "Vparam_readFlatFile:  Unexpected token (%s) while \
00712 parsing charge!\n", tok);
00713         return 0;
00714     }
00715     atom->charge = dtmp;
00716     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00717     if (sscanf(tok, "%lf", &dtmp) != 1) {
00718         Vnm_print(2, "Vparam_readFlatFile:  Unexpected token (%s) while \
00719 parsing radius!\n", tok);
00720         return 0;
00721     }
00722     atom->radius = dtmp;
00723     VJMPERR1(Vio_scanf(sock, "%s", tok) == 1);
00724     if (sscanf(tok, "%lf", &dtmp) != 1) {
00725         Vnm_print(2, "Vparam_readFlatFile:  Unexpected token (%s) while \
00726 parsing radius!\n", tok);
00727         return 0;
00728     }
00729     atom->epsilon = dtmp;
00730 
00731     return 1;
00732 
00733 VERROR1:
00734     Vnm_print(2, "Vparam_readFlatFile: Got unexpected EOF reading parameter file!\n");
00735     return 0;
00736 }

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