Skip to content
Snippets Groups Projects
Commit 78dac2f4 authored by Kurt A. O'Hearn's avatar Kurt A. O'Hearn
Browse files

sPuReMD: fix bug for BGF files if no CRYSTX line supplied (simulation box dimensions).

parent 1dbd1895
No related branches found
No related tags found
No related merge requests found
......@@ -689,6 +689,40 @@ void Read_BGF( const char * const bgf_file, reax_system* system, control_params
atom_cnt = 0;
token_cnt = 0;
while ( fgets( line, MAX_LINE, bgf ) )
{
/* read new line and tokenize it */
strncpy( backup, line, MAX_LINE - 1 );
backup[MAX_LINE - 1] = '\0';
token_cnt = Tokenize( line, &tokens, MAX_TOKEN_LEN );
if ( strncmp( tokens[0], "CRYSTX", 6 ) == 0 )
{
sscanf( backup, BGF_CRYSTX_FORMAT, descriptor,
s_a, s_b, s_c, s_alpha, s_beta, s_gamma );
/* compute full volume tensor from the angles */
Setup_Box( sstrtod( s_a, __FILE__, __LINE__ ),
sstrtod( s_b, __FILE__, __LINE__ ),
sstrtod( s_c, __FILE__, __LINE__ ),
sstrtod( s_alpha, __FILE__, __LINE__ ),
sstrtod( s_beta, __FILE__, __LINE__ ),
sstrtod( s_gamma, __FILE__, __LINE__ ),
&system->box );
crystx_found = TRUE;
break;
}
}
if ( crystx_found == FALSE )
{
fprintf( stderr, "[ERROR] improperly formatted BGF file (no CRYSTX keyword found). Terminating...\n" );
exit( INVALID_INPUT );
}
fseek( bgf, 0, SEEK_SET );
while ( fgets( line, MAX_LINE, bgf ) )
{
/* read new line and tokenize it */
......@@ -777,22 +811,6 @@ void Read_BGF( const char * const bgf_file, reax_system* system, control_params
atom_cnt++;
}
else if ( strncmp( tokens[0], "CRYSTX", 6 ) == 0 )
{
sscanf( backup, BGF_CRYSTX_FORMAT, descriptor,
s_a, s_b, s_c, s_alpha, s_beta, s_gamma );
/* compute full volume tensor from the angles */
Setup_Box( sstrtod( s_a, __FILE__, __LINE__ ),
sstrtod( s_b, __FILE__, __LINE__ ),
sstrtod( s_c, __FILE__, __LINE__ ),
sstrtod( s_alpha, __FILE__, __LINE__ ),
sstrtod( s_beta, __FILE__, __LINE__ ),
sstrtod( s_gamma, __FILE__, __LINE__ ),
&system->box );
crystx_found = TRUE;
}
else if ( strncmp( tokens[0], "CONECT", 6 ) == 0 )
{
if ( control->restrict_bonds )
......@@ -835,12 +853,6 @@ void Read_BGF( const char * const bgf_file, reax_system* system, control_params
exit( INVALID_INPUT );
}
if ( crystx_found == FALSE )
{
fprintf( stderr, "[ERROR] improperly formatted BGF file (no CRYSTX keyword found). Terminating...\n" );
exit( INVALID_INPUT );
}
Deallocate_Tokenizer_Space( &line, &backup, &tokens, MAX_TOKENS );
sfclose( bgf, "Read_BGF::bgf" );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment