Skip to content
This repository has been archived by the owner on May 28, 2020. It is now read-only.

Commit

Permalink
Added streaming functionality
Browse files Browse the repository at this point in the history
Necessary for higher-level bindings. To test, instead of using
`./simulate -i test.input`, use `./simulate -s -i "`cat test.input`" -c
"`cat whatever.cif`" > output.txt`
  • Loading branch information
patrickfuller committed Aug 30, 2013
1 parent 4bb2f7f commit 72002b9
Show file tree
Hide file tree
Showing 10 changed files with 448 additions and 135 deletions.
139 changes: 109 additions & 30 deletions src/framework.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <config.h>
#endif
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
Expand Down Expand Up @@ -45,6 +46,9 @@
#include "minimization.h"
#include "rigid.h"

extern bool STREAM;
extern char *INPUT_CRYSTAL;

CRYSTALLOGRAPHIC_STATISTICS *crystallographic_stats;

int CorrectNetChargeOnPseudoAtom;
Expand Down Expand Up @@ -376,22 +380,33 @@ void ReadFrameworkDefinitionCIF(void)

strcpy(FoundSpaceGroupOption,"");

// first try to open the framework-file in the current directory,
// and next from the repository
sprintf(buffer,"%s.%s",
Framework[CurrentSystem].Name[CurrentFramework],
"cif");
if(!(FilePtr=fopen(buffer,"r")))
if (STREAM)
{
sprintf(buffer,"%s/share/raspa/structures/cif/%s.%s",
RASPA_DIRECTORY,
if (!(FilePtr=fmemopen((void *)INPUT_CRYSTAL, strlen(INPUT_CRYSTAL), "r")))
{
printf("Error reading streamed CIF molecule.");
exit(1);
}
}
else
{
// first try to open the framework-file in the current directory,
// and next from the repository
sprintf(buffer,"%s.%s",
Framework[CurrentSystem].Name[CurrentFramework],
"cif");

if(!(FilePtr=fopen(buffer,"r")))
{
fprintf(stderr, "Error: file %s does not exists.\n",buffer);
exit(1);
sprintf(buffer,"%s/share/raspa/structures/cif/%s.%s",
RASPA_DIRECTORY,
Framework[CurrentSystem].Name[CurrentFramework],
"cif");

if(!(FilePtr=fopen(buffer,"r")))
{
fprintf(stderr, "Error: file %s does not exists.\n",buffer);
exit(1);
}
}
}

Expand Down Expand Up @@ -2010,6 +2025,12 @@ void WriteFrameworkDefinitionCIF(char * string)
char symbol[256];
struct passwd *p;

if (STREAM)
{
fprintf(stderr, "File writing not allowed in streaming mode!");
return;
}

AtomIdentifier=(int*)calloc(NumberOfPseudoAtoms,sizeof(int));

curtime = time (NULL);
Expand Down Expand Up @@ -2708,23 +2729,34 @@ void ReadFrameworkDefinitionMOL(void)
Framework[CurrentSystem].FrameworkDensityPerComponent[CurrentFramework]=0.0;
Framework[CurrentSystem].FrameworkMassPerComponent[CurrentFramework]=0.0;

// first try to open the framework-file in the current directory,
// and next from the repository
sprintf(buffer,"%s.%s",
Framework[CurrentSystem].Name[CurrentFramework],
"mol");

if(!(FilePtr=fopen(buffer,"r")))
if (STREAM)
{
sprintf(buffer,"%s/share/raspa/structures/xyz/%s.%s",
RASPA_DIRECTORY,
if (!(FilePtr=fmemopen((void *)INPUT_CRYSTAL, strlen(INPUT_CRYSTAL), "r")))
{
printf("Error reading streamed MOL molecule.");
exit(1);
}
}
else
{
// first try to open the framework-file in the current directory,
// and next from the repository
sprintf(buffer,"%s.%s",
Framework[CurrentSystem].Name[CurrentFramework],
"mol");

if(!(FilePtr=fopen(buffer,"r")))
{
fprintf(stderr, "Error: file %s does not exists.\n",buffer);
exit(1);
sprintf(buffer,"%s/share/raspa/structures/xyz/%s.%s",
RASPA_DIRECTORY,
Framework[CurrentSystem].Name[CurrentFramework],
"mol");

if(!(FilePtr=fopen(buffer,"r")))
{
fprintf(stderr, "Error: file %s does not exists.\n",buffer);
exit(1);
}
}
}

Expand Down Expand Up @@ -2931,6 +2963,12 @@ void WriteFrameworkDefinitionMOL(char *string)
REAL charge;
char Name[256];

if (STREAM)
{
fprintf(stderr, "File writing not allowed in streaming mode!");
return;
}

AtomId=(int*)calloc(NumberOfPseudoAtoms,sizeof(int));
mkdir("Movies",S_IRWXU);

Expand Down Expand Up @@ -3027,15 +3065,26 @@ void ReadFrameworkDefinitionDLPOLY(void)
fprintf(stderr, "CurrentSystem: %d CurrentFramework: %d\n",CurrentSystem,CurrentFramework);
Framework[CurrentSystem].SpaceGroupIdentifier[CurrentFramework]=1;

// first try to open the framework-file in the current directory,
// and next from the repository
sprintf(buffer,"./%s.%s",
Framework[CurrentSystem].Name[CurrentFramework],
"dlpoly");
if(!(FilePtr=fopen(buffer,"r")))
if (STREAM)
{
fprintf(stderr, "Error: file %s does not exists.\n",buffer);
exit(1);
if (!(FilePtr=fmemopen((void *)INPUT_CRYSTAL, strlen(INPUT_CRYSTAL), "r")))
{
printf("Error reading streamed CSSR molecule.");
exit(1);
}
}
else
{
// first try to open the framework-file in the current directory,
// and next from the repository
sprintf(buffer,"./%s.%s",
Framework[CurrentSystem].Name[CurrentFramework],
"dlpoly");
if(!(FilePtr=fopen(buffer,"r")))
{
fprintf(stderr, "Error: file %s does not exists.\n",buffer);
exit(1);
}
}

fscanf(FilePtr,"%*[^\n]"); // skip first line
Expand Down Expand Up @@ -3324,6 +3373,12 @@ void WriteFrameworkDefinitionCSSR(char *string)
int SerialNumber; // Atom serial number
int *AtomId;

if (STREAM)
{
fprintf(stderr, "File writing not allowed in streaming mode!");
return;
}

AtomId=(int*)calloc(NumberOfPseudoAtoms,sizeof(int));
mkdir("Movies",S_IRWXU);
for(CurrentSystem=0;CurrentSystem<NumberOfSystems;CurrentSystem++)
Expand Down Expand Up @@ -3453,6 +3508,12 @@ void WriteFrameworkDefinitionPDB(char *string)
VECTOR r;
REAL MovieScale=1.0;

if (STREAM)
{
fprintf(stderr, "File writing not allowed in streaming mode!");
return;
}

mkdir("Movies",S_IRWXU);

for(CurrentSystem=0;CurrentSystem<NumberOfSystems;CurrentSystem++)
Expand Down Expand Up @@ -3520,6 +3581,12 @@ void WriteFrameworkDefinitionGulp(char *string)
int count;
int TypeA,TypeB,TypeC;

if (STREAM)
{
fprintf(stderr, "File writing not allowed in streaming mode!");
return;
}

AtomId=(int*)calloc(NumberOfPseudoAtoms,sizeof(int));
mkdir("Movies",S_IRWXU);

Expand Down Expand Up @@ -3650,6 +3717,12 @@ void WriteFrameworkDefinitionVASP(char *string)
int *AtomId;
int count;

if (STREAM)
{
fprintf(stderr, "File writing not allowed in streaming mode!");
return;
}

AtomId=(int*)calloc(NumberOfPseudoAtoms,sizeof(int));
mkdir("Movies",S_IRWXU);

Expand Down Expand Up @@ -3748,6 +3821,12 @@ void WriteFrameworkDefinitionTinker(char *string)
int *AtomId;
VECTOR r;

if (STREAM)
{
fprintf(stderr, "File writing not allowed in streaming mode!");
return;
}

AtomId=(int*)calloc(NumberOfPseudoAtoms,sizeof(int));
mkdir("Movies",S_IRWXU);

Expand Down
21 changes: 21 additions & 0 deletions src/grids.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*************************************************************************************************************/

#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
Expand Down Expand Up @@ -187,6 +188,8 @@ static int Coeff[64][64] = {
{ 8, -8, -8, 8, -8, 8, 8, -8, 4, 4, -4, -4, -4, -4, 4, 4, 4, -4, 4, -4, -4, 4, -4, 4, 4, -4, -4, 4, 4, -4, -4, 4,
2, 2, 2, 2, -2, -2, -2, -2, 2, 2, -2, -2, 2, 2, -2, -2, 2, -2, 2, -2, 2, -2, 2, -2, 1, 1, 1, 1, 1, 1, 1, 1}};

extern bool STREAM;

int UseTabularGrid;
REAL SpacingVDWGrid;
REAL SpacingCoulombGrid;
Expand Down Expand Up @@ -285,6 +288,12 @@ void MakeASCIGrid(void)
char buffer[1024];
FILE *FilePtr;

if (STREAM)
{
fprintf(stderr, "Streaming not yet supported for this function.");
exit(0);
}

CurrentSystem=0;
if(MIN3(BoxProperties[CurrentSystem].cx,BoxProperties[CurrentSystem].cy,
BoxProperties[CurrentSystem].cz)<CutOffVDW)
Expand Down Expand Up @@ -668,6 +677,12 @@ int WriteVDWGrid(int l)
FILE *FilePtr;
char buffer[256];

if (STREAM)
{
fprintf(stderr, "Streaming not yet supported for this function.");
exit(0);
}

ngrid=NumberOfVDWGridPoints.x*NumberOfVDWGridPoints.y*NumberOfVDWGridPoints.z;

sprintf(buffer,"%s/share/raspa/grids",RASPA_DIRECTORY);
Expand Down Expand Up @@ -849,6 +864,12 @@ void ReadCoulombGrid(void)
FILE *FilePtr;
char buffer[256],name[256];

if (STREAM)
{
fprintf(stderr, "Streaming not yet supported for this function.");
exit(0);
}

switch(ChargeMethod)
{
case EWALD:
Expand Down
Loading

0 comments on commit 72002b9

Please sign in to comment.