diff --git a/sPuReMD/src/allocate.c b/sPuReMD/src/allocate.c index 92c1d80dba39f85a214db63c377b210d741f2843..4f980bc8c07a26672966c18420cfbfd2eb3f77cd 100644 --- a/sPuReMD/src/allocate.c +++ b/sPuReMD/src/allocate.c @@ -36,24 +36,19 @@ void PreAllocate_Space( reax_system * const system, { system->prealloc_allocated = TRUE; - system->atoms = scalloc( n, sizeof(reax_atom), - "PreAllocate_Space::system->atoms" ); - workspace->orig_id = scalloc( n, sizeof(int), - "PreAllocate_Space::workspace->orid_id" ); + system->atoms = scalloc( n, sizeof(reax_atom), __FILE__, __LINE__ ); + workspace->orig_id = scalloc( n, sizeof(int), __FILE__, __LINE__ ); /* bond restriction info */ if ( control->restrict_bonds ) { - workspace->restricted = scalloc( n, sizeof(int), - "PreAllocate_Space::workspace->restricted_atoms" ); - - workspace->restricted_list = scalloc( n, sizeof(int*), - "PreAllocate_Space::workspace->restricted_list" ); + workspace->restricted = scalloc( n, sizeof(int), __FILE__, __LINE__ ); + workspace->restricted_list = scalloc( n, sizeof(int*), __FILE__, __LINE__ ); for ( i = 0; i < n; ++i ) { workspace->restricted_list[i] = scalloc( MAX_RESTRICT, sizeof(int), - "PreAllocate_Space::workspace->restricted_list[i]" ); + __FILE__, __LINE__ ); } } @@ -62,48 +57,40 @@ void PreAllocate_Space( reax_system * const system, || control->geo_format == BINARY_RESTART ) { workspace->map_serials = scalloc( MAX_ATOM_ID, sizeof(int), - "Read_BGF::workspace->map_serials" ); + __FILE__, __LINE__ ); } } else { - sfree( system->atoms, "PreAllocate_Space::system->atoms" ); - sfree( workspace->orig_id, "PreAllocate_Space::workspace->orid_id" ); + sfree( system->atoms, __FILE__, __LINE__ ); + sfree( workspace->orig_id, __FILE__, __LINE__ ); /* bond restriction info */ if ( control->restrict_bonds ) { - sfree( workspace->restricted, - "PreAllocate_Space::workspace->restricted_atoms" ); + sfree( workspace->restricted, __FILE__, __LINE__ ); for ( i = 0; i < n; ++i ) { - sfree( workspace->restricted_list[i], - "PreAllocate_Space::workspace->restricted_list[i]" ); + sfree( workspace->restricted_list[i], __FILE__, __LINE__ ); } - sfree( workspace->restricted_list, - "PreAllocate_Space::workspace->restricted_list" ); + sfree( workspace->restricted_list, __FILE__, __LINE__ ); } - system->atoms = scalloc( n, sizeof(reax_atom), - "PreAllocate_Space::system->atoms" ); - workspace->orig_id = scalloc( n, sizeof(int), - "PreAllocate_Space::workspace->orid_id" ); + system->atoms = scalloc( n, sizeof(reax_atom), __FILE__, __LINE__ ); + workspace->orig_id = scalloc( n, sizeof(int), __FILE__, __LINE__ ); /* bond restriction info */ if ( control->restrict_bonds ) { - workspace->restricted = scalloc( n, sizeof(int), - "PreAllocate_Space::workspace->restricted_atoms" ); - - workspace->restricted_list = scalloc( n, sizeof(int*), - "PreAllocate_Space::workspace->restricted_list" ); + workspace->restricted = scalloc( n, sizeof(int), __FILE__, __LINE__ ); + workspace->restricted_list = scalloc( n, sizeof(int*), __FILE__, __LINE__ ); for ( i = 0; i < n; ++i ) { workspace->restricted_list[i] = scalloc( MAX_RESTRICT, sizeof(int), - "PreAllocate_Space::workspace->restricted_list[i]" ); + __FILE__, __LINE__ ); } } } @@ -136,9 +123,9 @@ void Allocate_Matrix( sparse_matrix * const H, int n, int n_max, int m ) H->n_max = n_max; H->m = m; - H->start = smalloc( sizeof(unsigned int) * (n_max + 1), "Allocate_Matrix::H->start" ); - H->j = smalloc( sizeof(unsigned int) * m, "Allocate_Matrix::H->j" ); - H->val = smalloc( sizeof(real) * m, "Allocate_Matrix::H->val" ); + H->start = smalloc( sizeof(unsigned int) * (n_max + 1), __FILE__, __LINE__ ); + H->j = smalloc( sizeof(unsigned int) * m, __FILE__, __LINE__ ); + H->val = smalloc( sizeof(real) * m, __FILE__, __LINE__ ); } @@ -150,9 +137,9 @@ void Deallocate_Matrix( sparse_matrix * const H ) { H->allocated = FALSE; - sfree( H->start, "Deallocate_Matrix::H->start" ); - sfree( H->j, "Deallocate_Matrix::H->j" ); - sfree( H->val, "Deallocate_Matrix::H->val" ); + sfree( H->start, __FILE__, __LINE__ ); + sfree( H->j, __FILE__, __LINE__ ); + sfree( H->val, __FILE__, __LINE__ ); } @@ -196,8 +183,7 @@ static void Reallocate_Initialize_HBond_List( int n, int num_h, int num_h_max, { int i, num_hbonds, *hb_top; - hb_top = scalloc( n, sizeof(int), - "Reallocate_Initialize_HBond_List::hb_top" ); + hb_top = scalloc( n, sizeof(int), __FILE__, __LINE__ ); num_hbonds = 0; for ( i = 0; i < n; ++i ) @@ -218,7 +204,7 @@ static void Reallocate_Initialize_HBond_List( int n, int num_h, int num_h_max, Initialize_HBond_List( n, h_index, hb_top, hbond_list ); - sfree( hb_top, "Reallocate_Initialize_HBond_List::hb_top" ); + sfree( hb_top, __FILE__, __LINE__ ); } @@ -249,8 +235,7 @@ static void Reallocate_Initialize_Bond_List( int n, int n_max, int i; int *bond_top; - bond_top = (int *) scalloc( n, sizeof(int), - "Reallocate_Initialize_Bond_List::hb_top" ); + bond_top = scalloc( n, sizeof(int), __FILE__, __LINE__ ); *num_bonds = 0; *est_3body = 0; @@ -270,7 +255,7 @@ static void Reallocate_Initialize_Bond_List( int n, int n_max, Initialize_Bond_List( bond_top, bond_list ); - sfree( bond_top, "Reallocate_Initialize_Bond_List::bond_top" ); + sfree( bond_top, __FILE__, __LINE__ ); } @@ -357,9 +342,9 @@ void Reallocate( reax_system * const system, control_params const * const contro { for ( k = 0; k < g->ncell_max[2]; k++ ) { - sfree( g->atoms[i][j][k], "Reallocate::g->atoms[i][j][k]" ); + sfree( g->atoms[i][j][k], __FILE__, __LINE__ ); g->atoms[i][j][k] = scalloc( workspace->realloc.gcell_atoms, sizeof(int), - "Reallocate::g->atoms[i][j][k]" ); + __FILE__, __LINE__ ); } } } diff --git a/sPuReMD/src/analyze.c b/sPuReMD/src/analyze.c index 33e5e1cdf0644add0906051fd8de36fa5002b7bd..e75da430ac5a29e48ccab8d85e3fd5341660e009 100644 --- a/sPuReMD/src/analyze.c +++ b/sPuReMD/src/analyze.c @@ -1069,28 +1069,28 @@ void Analysis( reax_system *system, control_params *control, steps = data->step - data->prev_steps; - if ( steps == 1 ) + /****** Molecular Analysis ******/ + if ( control->molec_anal + && steps % control->freq_molec_anal == 0 ) { - if ( lists[OLD_BONDS]->allocated == FALSE ) + if ( steps == 1 ) { - Make_List( lists[BONDS]->n, lists[BONDS]->n_max, lists[BONDS]->total_intrs, - TYP_BOND, lists[OLD_BONDS] ); - } + if ( lists[OLD_BONDS]->allocated == FALSE ) + { + Make_List( lists[BONDS]->n, lists[BONDS]->n_max, lists[BONDS]->total_intrs, + TYP_BOND, lists[OLD_BONDS] ); + } - if ( control->molec_anal == REACTIONS ) - { - Copy_Bond_List( system, control, lists ); - } - if ( control->diffusion_coef ) - { - Copy_Positions( system, workspace ); + if ( control->molec_anal == REACTIONS ) + { + Copy_Bond_List( system, control, lists ); + } + if ( control->diffusion_coef ) + { + Copy_Positions( system, workspace ); + } } - } - /****** Molecular Analysis ******/ - if ( control->molec_anal - && steps % control->freq_molec_anal == 0 ) - { if ( control->molec_anal == FRAGMENTS ) { /* discover molecules */ diff --git a/sPuReMD/src/charges.c b/sPuReMD/src/charges.c index 998357a81743362acc038fceddef5dcfb7f33b11..3b760d682c96a22f223f316f305041bea0f80ad7 100644 --- a/sPuReMD/src/charges.c +++ b/sPuReMD/src/charges.c @@ -107,13 +107,13 @@ int is_refactoring_step( control_params * const control, #if defined(HAVE_TENSORFLOW) static void TF_Tensor_Deallocator( void* data, size_t length, void* arg ) { -// sfree( data, "TF_Tensor_Deallocator::data" ); +// sfree( data, __FILE__, __LINE__ ); } static void TF_free( void* data, size_t length ) { - sfree( data, "TF_free::data" ); + sfree( data, __FILE__, __LINE__ ); } @@ -226,8 +226,8 @@ static void Predict_Charges_TF_LSTM( const reax_system * const system, // batch_size = 3; win_size = control->cm_init_guess_win_size; batch_size = system->N_cm; - obs_flat = smalloc( sizeof(float) * batch_size * win_size, "Predict_Charges_TF_LSTM:obs_flat" ); - obs_norm = smalloc( sizeof(float) * batch_size, "Predict_Charges_TF_LSTM:obs_norm" ); + obs_flat = smalloc( sizeof(float) * batch_size * win_size, __FILE__, __LINE__ ); + obs_norm = smalloc( sizeof(float) * batch_size, __FILE__, __LINE__ ); /* load the frozen model from file in GraphDef format * @@ -327,8 +327,8 @@ static void Predict_Charges_TF_LSTM( const reax_system * const system, workspace->s[0][i] = predictions[i] + obs_norm[i]; } - sfree( obs_norm, "Predict_Charges_TF_LSTM:obs_norm" ); - sfree( obs_flat, "Predict_Charges_TF_LSTM:obs_flat" ); + sfree( obs_norm, __FILE__, __LINE__ ); + sfree( obs_flat, __FILE__, __LINE__ ); TF_DeleteTensor( input_tensor[0] ); TF_DeleteTensor( output_tensor[0] ); TF_DeleteSession( s.session, status ); @@ -930,13 +930,12 @@ static void Setup_Preconditioner_QEq( const reax_system * const system, if ( workspace->Hdia_inv == NULL ) { workspace->Hdia_inv = scalloc( Hptr->n_max, sizeof( real ), - "Setup_Preconditioner_QEq::workspace->Hdia_inv" ); + __FILE__, __LINE__ ); } else if ( realloc == TRUE ) { workspace->Hdia_inv = srealloc( workspace->Hdia_inv, - sizeof( real ) * Hptr->n_max, - "Setup_Preconditioner_QEq::workspace->Hdia_inv" ); + sizeof( real ) * Hptr->n_max, __FILE__, __LINE__ ); } break; @@ -1056,13 +1055,12 @@ static void Setup_Preconditioner_EE( const reax_system * const system, if ( workspace->Hdia_inv == NULL ) { workspace->Hdia_inv = scalloc( Hptr->n_max, sizeof( real ), - "Setup_Preconditioner_EE::workspace->Hdiv_inv" ); + __FILE__, __LINE__ ); } else if ( realloc == TRUE ) { workspace->Hdia_inv = srealloc( workspace->Hdia_inv, - sizeof( real ) * Hptr->n_max, - "Setup_Preconditioner_EE::workspace->Hdiv_inv" ); + sizeof( real ) * Hptr->n_max, __FILE__, __LINE__ ); } break; @@ -1179,13 +1177,12 @@ static void Setup_Preconditioner_ACKS2( const reax_system * const system, if ( workspace->Hdia_inv == NULL ) { workspace->Hdia_inv = scalloc( Hptr->n_max, sizeof( real ), - "Setup_Preconditioner_ACKS2::workspace->Hdiv_inv" ); + __FILE__, __LINE__ ); } else if ( realloc == TRUE ) { workspace->Hdia_inv = srealloc( workspace->Hdia_inv, - sizeof( real ) * Hptr->n_max, - "Setup_Preconditioner_ACKS2::workspace->Hdiv_inv" ); + sizeof( real ) * Hptr->n_max, __FILE__, __LINE__ ); } break; @@ -1627,9 +1624,9 @@ static void ACKS2( reax_system * const system, control_params * const control, if ( data->step % 10 == 0 ) { snprintf( fname, SIZE, "s_%d_%s.out", data->step, control->sim_name ); - fp = sfopen( fname, "w" ); + fp = sfopen( fname, "w", __FILE__, __LINE__ ); Vector_Print( fp, NULL, workspace->s[0], system->N_cm ); - sfclose( fp, "ACKS2::fp" ); + sfclose( fp, __FILE__, __LINE__ ); } #undef SIZE #endif @@ -1712,14 +1709,14 @@ void Compute_Charges( reax_system * const system, control_params * const control // Print_Sparse_Matrix_Binary( workspace->H, fname ); snprintf( fname, SIZE, "b_s_%d_%s.out", data->step, control->sim_name ); - fp = sfopen( fname, "w" ); + fp = sfopen( fname, "w", __FILE__, __LINE__ ); Vector_Print( fp, NULL, workspace->b_s, system->N_cm ); - sfclose( fp, "Compute_Charges::fp" ); + sfclose( fp, __FILE__, __LINE__ ); // snprintf( fname, SIZE, "b_t_%d_%s.out", data->step, control->sim_name ); -// fp = sfopen( fname, "w" ); +// fp = sfopen( fname, "w", __FILE__, __LINE__ ); // Vector_Print( fp, NULL, workspace->b_t, system->N_cm ); -// sfclose( fp, "Compute_Charges::fp" ); +// sfclose( fp, __FILE__, __LINE__ ); } #undef SIZE #endif diff --git a/sPuReMD/src/control.c b/sPuReMD/src/control.c index c46775a4261b8739a62a0a49c8139db44371b125..8803e10bac2f2604f23103512814c4bc90426d09 100644 --- a/sPuReMD/src/control.c +++ b/sPuReMD/src/control.c @@ -562,17 +562,17 @@ void Read_Control_File( const char * const control_file, reax_system * const sys int c, i, ret; FILE *fp; - fp = sfopen( control_file, "r" ); + fp = sfopen( control_file, "r", __FILE__, __LINE__ ); assert( fp != NULL ); if ( fp != NULL ) { - s = smalloc( sizeof(char) * MAX_LINE, "Read_Control_File::s" ); - tmp = smalloc( sizeof(char*) * MAX_TOKENS, "Read_Control_File::tmp" ); + s = smalloc( sizeof(char) * MAX_LINE, __FILE__, __LINE__ ); + tmp = smalloc( sizeof(char*) * MAX_TOKENS, __FILE__, __LINE__ ); for ( i = 0; i < MAX_TOKENS; i++ ) { - tmp[i] = smalloc( sizeof(char) * MAX_LINE, "Read_Control_File::tmp[i]" ); + tmp[i] = smalloc( sizeof(char) * MAX_LINE, __FILE__, __LINE__ ); } /* read control parameters file */ @@ -601,13 +601,13 @@ void Read_Control_File( const char * const control_file, reax_system * const sys for ( i = 0; i < MAX_TOKENS; i++ ) { - sfree( tmp[i], "Read_Control_File::tmp[i]" ); + sfree( tmp[i], __FILE__, __LINE__ ); } - sfree( tmp, "Read_Control_File::tmp" ); - sfree( s, "Read_Control_File::s" ); + sfree( tmp, __FILE__, __LINE__ ); + sfree( s, __FILE__, __LINE__ ); } - sfclose( fp, "Read_Control_File::fp" ); + sfclose( fp, __FILE__, __LINE__ ); } diff --git a/sPuReMD/src/ffield.c b/sPuReMD/src/ffield.c index 39d78b2026a56c217ca3ab32dc55e8bd93f09f89..b611538d4bc9e366da75d35d2e139f0fbae32151 100644 --- a/sPuReMD/src/ffield.c +++ b/sPuReMD/src/ffield.c @@ -36,17 +36,17 @@ void Read_Force_Field( const char * const ffield_file, real val; FILE *fp; - fp = sfopen( ffield_file, "r" ); + fp = sfopen( ffield_file, "r", __FILE__, __LINE__ ); assert( fp != NULL ); if ( fp != NULL ) { - s = smalloc( sizeof(char) * MAX_LINE, "Read_Force_Field::s" ); - tmp = smalloc( sizeof(char*) * MAX_TOKENS, "Read_Force_Field::tmp" ); + s = smalloc( sizeof(char) * MAX_LINE, __FILE__, __LINE__ ); + tmp = smalloc( sizeof(char*) * MAX_TOKENS, __FILE__, __LINE__ ); for ( i = 0; i < MAX_TOKENS; i++ ) { - tmp[i] = smalloc( sizeof(char) * MAX_TOKEN_LEN, "Read_Force_Field::tmp[i]" ); + tmp[i] = smalloc( sizeof(char) * MAX_TOKEN_LEN, __FILE__, __LINE__ ); } /* reading first header comment */ @@ -66,15 +66,13 @@ void Read_Force_Field( const char * const ffield_file, if ( system->ffield_params_allocated == FALSE ) { - reax->gp.l = (real*) smalloc( sizeof(real) * n, - "Read_Force_Field::reax->gp-l" ); + reax->gp.l = (real*) smalloc( sizeof(real) * n, __FILE__, __LINE__ ); reax->gp.max_n_global = n; } else if ( reax->gp.max_n_global < n ) { - reax->gp.l = (real*) srealloc( reax->gp.l, sizeof(real) * n, - "Read_Force_Field::reax->gp-l" ); + reax->gp.l = srealloc( reax->gp.l, sizeof(real) * n, __FILE__, __LINE__ ); reax->gp.max_n_global = n; } @@ -106,41 +104,28 @@ void Read_Force_Field( const char * const ffield_file, system->ffield_params_allocated = TRUE; /* Allocating structures in reax_interaction */ - reax->sbp = (single_body_parameters*) scalloc( n, sizeof(single_body_parameters), - "Read_Force_Field::reax->sbp" ); - reax->tbp = (two_body_parameters**) scalloc( n, sizeof(two_body_parameters*), - "Read_Force_Field::reax->tbp" ); - reax->thbp = (three_body_header***) scalloc( n, sizeof(three_body_header**), - "Read_Force_Field::reax->thbp" ); - reax->hbp = (hbond_parameters***) scalloc( n, sizeof(hbond_parameters**), - "Read_Force_Field::reax->hbp" ); - reax->fbp = (four_body_header****) scalloc( n, sizeof(four_body_header***), - "Read_Force_Field::reax->fbp" ); + reax->sbp = scalloc( n, sizeof(single_body_parameters), __FILE__, __LINE__ ); + reax->tbp = scalloc( n, sizeof(two_body_parameters*), __FILE__, __LINE__ ); + reax->thbp = scalloc( n, sizeof(three_body_header**), __FILE__, __LINE__ ); + reax->hbp = scalloc( n, sizeof(hbond_parameters**), __FILE__, __LINE__ ); + reax->fbp = scalloc( n, sizeof(four_body_header***), __FILE__, __LINE__ ); for ( i = 0; i < n; i++ ) { - reax->tbp[i] = (two_body_parameters*) scalloc( n, sizeof(two_body_parameters), - "Read_Force_Field::reax->tbp[i]" ); - reax->thbp[i] = (three_body_header**) scalloc( n, sizeof(three_body_header*), - "Read_Force_Field::reax->thbp[i]" ); - reax->hbp[i] = (hbond_parameters**) scalloc( n, sizeof(hbond_parameters*), - "Read_Force_Field::reax->hbp[i]" ); - reax->fbp[i] = (four_body_header***) scalloc( n, sizeof(four_body_header**), - "Read_Force_Field::reax->fbp[i]" ); + reax->tbp[i] = scalloc( n, sizeof(two_body_parameters), __FILE__, __LINE__ ); + reax->thbp[i] = scalloc( n, sizeof(three_body_header*), __FILE__, __LINE__ ); + reax->hbp[i] = scalloc( n, sizeof(hbond_parameters*), __FILE__, __LINE__ ); + reax->fbp[i] = scalloc( n, sizeof(four_body_header**), __FILE__, __LINE__ ); for ( j = 0; j < n; j++ ) { - reax->thbp[i][j] = (three_body_header*) scalloc( n, sizeof(three_body_header), - "Read_Force_Field::reax->thbp[i][j]" ); - reax->hbp[i][j] = (hbond_parameters*) scalloc( n, sizeof(hbond_parameters), - "Read_Force_Field::reax->hbp[i][j]" ); - reax->fbp[i][j] = (four_body_header**) scalloc( n, sizeof(four_body_header*), - "Read_Force_Field::reax->fbp[i][j]" ); + reax->thbp[i][j] = scalloc( n, sizeof(three_body_header), __FILE__, __LINE__ ); + reax->hbp[i][j] = scalloc( n, sizeof(hbond_parameters), __FILE__, __LINE__ ); + reax->fbp[i][j] = scalloc( n, sizeof(four_body_header*), __FILE__, __LINE__ ); for ( k = 0; k < n; k++ ) { - reax->fbp[i][j][k] = (four_body_header*) scalloc( n, sizeof(four_body_header), - "Read_Force_Field::reax->fbp[i][j][k]" ); + reax->fbp[i][j][k] = scalloc( n, sizeof(four_body_header), __FILE__, __LINE__ ); } } } @@ -152,66 +137,53 @@ void Read_Force_Field( const char * const ffield_file, for ( i = 0; i < reax->max_num_atom_types; i++ ) for ( j = 0; j < reax->max_num_atom_types; j++ ) for ( k = 0; k < reax->max_num_atom_types; k++ ) - sfree( reax->fbp[i][j][k], "Finalize_System::reax->fbp[i][j][k]" ); + sfree( reax->fbp[i][j][k], __FILE__, __LINE__ ); for ( i = 0; i < reax->max_num_atom_types; i++ ) for ( j = 0; j < reax->max_num_atom_types; j++ ) { - sfree( reax->thbp[i][j], "Finalize_System::reax->thbp[i][j]" ); - sfree( reax->hbp[i][j], "Finalize_System::reax->hbp[i][j]" ); - sfree( reax->fbp[i][j], "Finalize_System::reax->fbp[i][j]" ); + sfree( reax->thbp[i][j], __FILE__, __LINE__ ); + sfree( reax->hbp[i][j], __FILE__, __LINE__ ); + sfree( reax->fbp[i][j], __FILE__, __LINE__ ); } for ( i = 0; i < reax->max_num_atom_types; i++ ) { - sfree( reax->tbp[i], "Finalize_System::reax->tbp[i]" ); - sfree( reax->thbp[i], "Finalize_System::reax->thbp[i]" ); - sfree( reax->hbp[i], "Finalize_System::reax->hbp[i]" ); - sfree( reax->fbp[i], "Finalize_System::reax->fbp[i]" ); + sfree( reax->tbp[i], __FILE__, __LINE__ ); + sfree( reax->thbp[i], __FILE__, __LINE__ ); + sfree( reax->hbp[i], __FILE__, __LINE__ ); + sfree( reax->fbp[i], __FILE__, __LINE__ ); } - sfree( reax->sbp, "Finalize_System::reax->sbp" ); - sfree( reax->tbp, "Finalize_System::reax->tbp" ); - sfree( reax->thbp, "Finalize_System::reax->thbp" ); - sfree( reax->hbp, "Finalize_System::reax->hbp" ); - sfree( reax->fbp, "Finalize_System::reax->fbp" ); + sfree( reax->sbp, __FILE__, __LINE__ ); + sfree( reax->tbp, __FILE__, __LINE__ ); + sfree( reax->thbp, __FILE__, __LINE__ ); + sfree( reax->hbp, __FILE__, __LINE__ ); + sfree( reax->fbp, __FILE__, __LINE__ ); /* Allocating structures in reax_interaction */ - reax->sbp = (single_body_parameters*) scalloc( n, sizeof(single_body_parameters), - "Read_Force_Field::reax->sbp" ); - reax->tbp = (two_body_parameters**) scalloc( n, sizeof(two_body_parameters*), - "Read_Force_Field::reax->tbp" ); - reax->thbp = (three_body_header***) scalloc( n, sizeof(three_body_header**), - "Read_Force_Field::reax->thbp" ); - reax->hbp = (hbond_parameters***) scalloc( n, sizeof(hbond_parameters**), - "Read_Force_Field::reax->hbp" ); - reax->fbp = (four_body_header****) scalloc( n, sizeof(four_body_header***), - "Read_Force_Field::reax->fbp" ); + reax->sbp = scalloc( n, sizeof(single_body_parameters), __FILE__, __LINE__ ); + reax->tbp = scalloc( n, sizeof(two_body_parameters*), __FILE__, __LINE__ ); + reax->thbp = scalloc( n, sizeof(three_body_header**), __FILE__, __LINE__ ); + reax->hbp = scalloc( n, sizeof(hbond_parameters**), __FILE__, __LINE__ ); + reax->fbp = scalloc( n, sizeof(four_body_header***), __FILE__, __LINE__ ); for ( i = 0; i < n; i++ ) { - reax->tbp[i] = (two_body_parameters*) scalloc( n, sizeof(two_body_parameters), - "Read_Force_Field::reax->tbp[i]" ); - reax->thbp[i] = (three_body_header**) scalloc( n, sizeof(three_body_header*), - "Read_Force_Field::reax->thbp[i]" ); - reax->hbp[i] = (hbond_parameters**) scalloc( n, sizeof(hbond_parameters*), - "Read_Force_Field::reax->hbp[i]" ); - reax->fbp[i] = (four_body_header***) scalloc( n, sizeof(four_body_header**), - "Read_Force_Field::reax->fbp[i]" ); + reax->tbp[i] = scalloc( n, sizeof(two_body_parameters), __FILE__, __LINE__ ); + reax->thbp[i] = scalloc( n, sizeof(three_body_header*), __FILE__, __LINE__ ); + reax->hbp[i] = scalloc( n, sizeof(hbond_parameters*), __FILE__, __LINE__ ); + reax->fbp[i] = scalloc( n, sizeof(four_body_header**), __FILE__, __LINE__ ); for ( j = 0; j < n; j++ ) { - reax->thbp[i][j] = (three_body_header*) scalloc( n, sizeof(three_body_header), - "Read_Force_Field::reax->thbp[i][j]" ); - reax->hbp[i][j] = (hbond_parameters*) scalloc( n, sizeof(hbond_parameters), - "Read_Force_Field::reax->hbp[i][j]" ); - reax->fbp[i][j] = (four_body_header**) scalloc( n, sizeof(four_body_header*), - "Read_Force_Field::reax->fbp[i][j]" ); + reax->thbp[i][j] = scalloc( n, sizeof(three_body_header), __FILE__, __LINE__ ); + reax->hbp[i][j] = scalloc( n, sizeof(hbond_parameters), __FILE__, __LINE__ ); + reax->fbp[i][j] = scalloc( n, sizeof(four_body_header*), __FILE__, __LINE__ ); for ( k = 0; k < n; k++ ) { - reax->fbp[i][j][k] = (four_body_header*) scalloc( n, sizeof(four_body_header), - "Read_Force_Field::reax->fbp[i][j][k]" ); + reax->fbp[i][j][k] = scalloc( n, sizeof(four_body_header), __FILE__, __LINE__ ); } } } @@ -219,23 +191,19 @@ void Read_Force_Field( const char * const ffield_file, reax->max_num_atom_types = n; } - tor_flag = (char****) smalloc( n * sizeof(char***), - "Read_Force_Field::tor_flag" ); + tor_flag = smalloc( n * sizeof(char***), __FILE__, __LINE__ ); for ( i = 0; i < n; i++ ) { - tor_flag[i] = (char***) smalloc( n * sizeof(char**), - "Read_Force_Field::tor_flag[i]" ); + tor_flag[i] = smalloc( n * sizeof(char**), __FILE__, __LINE__ ); for ( j = 0; j < n; j++ ) { - tor_flag[i][j] = (char**) smalloc( n * sizeof(char*), - "Read_Force_Field::tor_flag[i][j]" ); + tor_flag[i][j] = smalloc( n * sizeof(char*), __FILE__, __LINE__ ); for ( k = 0; k < n; k++ ) { - tor_flag[i][j][k] = (char*) smalloc( n * sizeof(char), - "Read_Force_Field::tor_flag[i][j][k]" ); + tor_flag[i][j][k] = smalloc( n * sizeof(char), __FILE__, __LINE__ ); } } } @@ -847,10 +815,10 @@ void Read_Force_Field( const char * const ffield_file, /* deallocate helper storage */ for ( i = 0; i < MAX_TOKENS; i++ ) { - sfree( tmp[i], "Read_Force_Field::tmp[i]" ); + sfree( tmp[i], __FILE__, __LINE__ ); } - sfree( tmp, "Read_Force_Field::tmp" ); - sfree( s, "Read_Force_Field::s" ); + sfree( tmp, __FILE__, __LINE__ ); + sfree( s, __FILE__, __LINE__ ); /* deallocate tor_flag */ for ( i = 0; i < reax->num_atom_types; i++ ) @@ -859,17 +827,17 @@ void Read_Force_Field( const char * const ffield_file, { for ( k = 0; k < reax->num_atom_types; k++ ) { - sfree( tor_flag[i][j][k], "Read_Force_Field::tor_flag[i][j][k]" ); + sfree( tor_flag[i][j][k], __FILE__, __LINE__ ); } - sfree( tor_flag[i][j], "Read_Force_Field::tor_flag[i][j]" ); + sfree( tor_flag[i][j], __FILE__, __LINE__ ); } - sfree( tor_flag[i], "Read_Force_Field::tor_flag[i]" ); + sfree( tor_flag[i], __FILE__, __LINE__ ); } - sfree( tor_flag, "Read_Force_Field::tor_flag" ); + sfree( tor_flag, __FILE__, __LINE__ ); } - sfclose( fp, "Read_Force_Field::fp" ); + sfclose( fp, __FILE__, __LINE__ ); } diff --git a/sPuReMD/src/forces.c b/sPuReMD/src/forces.c index 42f7f9fef1ef03f9a1be5e4de40834e2a80ba6c5..8857fd343dbb91bcbb69c3e9120d99ee8004fbeb 100644 --- a/sPuReMD/src/forces.c +++ b/sPuReMD/src/forces.c @@ -567,8 +567,7 @@ static void Init_Charge_Matrix_Remaining_Entries( reax_system *system, break; case ACKS2_CM: - X_diag = smalloc( sizeof(real) * system->N, - "Init_Charge_Matrix_Remaining_Entries::X_diag" ); + X_diag = smalloc( sizeof(real) * system->N, __FILE__, __LINE__ ); for ( i = 0; i < system->N; ++i ) { @@ -736,7 +735,7 @@ static void Init_Charge_Matrix_Remaining_Entries( reax_system *system, H_sp->val[*H_sp_top] = 0.0; *H_sp_top = *H_sp_top + 1; - sfree( X_diag, "Init_Charge_Matrix_Remaining_Entries::X_diag" ); + sfree( X_diag, __FILE__, __LINE__ ); break; default: @@ -1272,8 +1271,10 @@ static void Init_Forces_Tab( reax_system *system, control_params *control, ++H_sp_top; } } + /* Only non-dummy atoms can form bonds */ - if (system->atoms[i].dummy == FALSE && system->atoms[j].dummy == FALSE) + if ( system->atoms[i].is_dummy == FALSE + && system->atoms[j].is_dummy == FALSE ) { /* hydrogen bond lists */ if ( control->hbond_cut > 0.0 diff --git a/sPuReMD/src/geo_tools.c b/sPuReMD/src/geo_tools.c index e1429630952a9816f84f9f4a472b1ee2048e1fad..dfd2c5b4ed85310298e76589af090d429fd0e7a9 100644 --- a/sPuReMD/src/geo_tools.c +++ b/sPuReMD/src/geo_tools.c @@ -284,6 +284,14 @@ static int Count_Atoms( reax_system *system, FILE *fp, int geo_format ) } +/* Parser for geometry file in free-form custom PuReMD format + * + * geo_file: filename for custom geometry file to parse + * system: struct containing atom-related information + * control: struct containing simulation parameters + * data: struct containing information on active simulations + * workspace: struct containing intermediate structures used for calculations + */ void Read_Geo( const char * const geo_file, reax_system* system, control_params *control, simulation_data *data, static_storage *workspace ) { @@ -293,7 +301,7 @@ void Read_Geo( const char * const geo_file, reax_system* system, control_params char element[3], name[9]; reax_atom *atom; - geo = sfopen( geo_file, "r" ); + geo = sfopen( geo_file, "r", __FILE__, __LINE__ ); if ( Read_Box_Info( system, geo, CUSTOM ) == FAILURE ) { @@ -339,14 +347,32 @@ void Read_Geo( const char * const geo_file, reax_system* system, control_params rvec_MakeZero( atom->v ); rvec_MakeZero( atom->f ); atom->q = 0.0; + + /* check for dummy atom */ + if ( strncmp( element, "X\0", 2 ) == 0 ) + { + atom->is_dummy = TRUE; + } + else + { + atom->is_dummy = FALSE; + } top++; } - sfclose( geo, "Read_Geo::geo" ); + sfclose( geo, __FILE__, __LINE__ ); } +/* Parser for geometry file in fixed-form PDB format + * + * pdb_file: filename for PDB geometry file to parse + * system: struct containing atom-related information + * control: struct containing simulation parameters + * data: struct containing information on active simulations + * workspace: struct containing intermediate structures used for calculations + */ void Read_PDB( const char * const pdb_file, reax_system* system, control_params *control, simulation_data *data, static_storage *workspace ) { @@ -363,7 +389,7 @@ void Read_PDB( const char * const pdb_file, reax_system* system, control_params rvec x; reax_atom *atom; - pdb = sfopen( pdb_file, "r" ); + pdb = sfopen( pdb_file, "r", __FILE__, __LINE__ ); Allocate_Tokenizer_Space( &s, MAX_LINE, &s1, MAX_LINE, &tmp, MAX_TOKENS, MAX_TOKEN_LEN ); @@ -478,28 +504,38 @@ void Read_PDB( const char * const pdb_file, reax_system* system, control_params pdb_serial = (int) sstrtod( serial, __FILE__, __LINE__ ); workspace->orig_id[top] = pdb_serial; + strncpy( atom->name, atom_name, sizeof(atom->name) - 1 ); + atom->name[sizeof(atom->name) - 1] = '\0'; Trim_Spaces( element, sizeof(element) ); for ( i = 0; i < sizeof(element) - 1; ++i ) { element[i] = toupper( element[i] ); } atom->type = Get_Atom_Type( &system->reax_param, element, sizeof(element) ); - strncpy( atom->name, atom_name, sizeof(atom->name) - 1 ); - atom->name[sizeof(atom->name) - 1] = '\0'; + + /* check for dummy atom */ + if ( strncmp( element, "X\0", 2 ) == 0 ) + { + system->atoms[top].is_dummy = TRUE; + } + else + { + system->atoms[top].is_dummy = FALSE; + } rvec_Copy( atom->x, x ); rvec_MakeZero( atom->v ); rvec_MakeZero( atom->f ); atom->q = 0; - top++; - #if defined(DEBUG_FOCUS) fprintf( stderr, "[INFO] atom: id = %d, name = %s, serial = %d, type = %d, ", top, atom->name, pdb_serial, atom->type ); fprintf( stderr, "x = (%7.3f, %7.3f, %7.3f)\n", atom->x[0], atom->x[1], atom->x[2] ); #endif + + top++; } c++; @@ -515,8 +551,7 @@ void Read_PDB( const char * const pdb_file, reax_system* system, control_params if ( control->restrict_bonds ) { /* error check */ -// Check_Input_Range( c1 - 2, 0, MAX_RESTRICT, -// "CONECT line exceeds max num restrictions allowed.\n" ); +// Check_Input_Range( c1 - 2, 0, MAX_RESTRICT, __FILE__, __LINE__ ); /* read bond restrictions */ // pdb_serial = sstrtol( tmp[1], __FILE__, __LINE__ ); @@ -553,7 +588,7 @@ void Read_PDB( const char * const pdb_file, reax_system* system, control_params exit( INVALID_INPUT ); } - sfclose( pdb, "Read_PDB::pdb" ); + sfclose( pdb, __FILE__, __LINE__ ); Deallocate_Tokenizer_Space( &s, &s1, &tmp, MAX_TOKENS ); } @@ -595,7 +630,7 @@ void Write_PDB( reax_system* system, reax_list* bonds, simulation_data *data, sizeof(control->sim_name) ), control->sim_name, snprintf(NULL, 0, "%d", data->step), data->step ); fname[sizeof(fname) - 1] = '\0'; - pdb = sfopen( fname, "w" ); + pdb = sfopen( fname, "w", __FILE__, __LINE__ ); fprintf( pdb, PDB_CRYST1_FORMAT_O, "CRYST1", system->box.box_norms[0], system->box.box_norms[1], @@ -626,12 +661,13 @@ void Write_PDB( reax_system* system, reax_list* bonds, simulation_data *data, exit( INVALID_INPUT ); } - sfclose( pdb, "Write_PDB::pdb" ); + sfclose( pdb, __FILE__, __LINE__ ); } /* Parser for geometry files in BGF format * + * bgf_file: filename for BGF file to parse * system: struct containing atom-related information * control: struct containing simulation parameters * data: struct containing information on active simulations @@ -656,7 +692,7 @@ void Read_BGF( const char * const bgf_file, reax_system* system, control_params ratom = 0; crystx_found = FALSE; - bgf = sfopen( bgf_file, "r" ); + bgf = sfopen( bgf_file, "r", __FILE__, __LINE__ ); Allocate_Tokenizer_Space( &line, MAX_LINE, &backup, MAX_LINE, &tokens, MAX_TOKENS, MAX_TOKEN_LEN ); @@ -696,9 +732,9 @@ void Read_BGF( const char * const bgf_file, reax_system* system, control_params if ( system->prealloc_allocated == FALSE && num_mcc > 0 ) { system->molec_charge_constraints = smalloc( - sizeof(real) * num_mcc, "Read_BGF::molec_charge_constraints" ); + sizeof(real) * num_mcc, __FILE__, __LINE__ ); system->molec_charge_constraint_ranges = smalloc( - sizeof(int) * 2 * num_mcc, "Read_BGF::molec_charge_constraint_ranges" ); + sizeof(int) * 2 * num_mcc, __FILE__, __LINE__ ); system->max_num_molec_charge_constraints = num_mcc; } @@ -706,14 +742,14 @@ void Read_BGF( const char * const bgf_file, reax_system* system, control_params { if ( system->max_num_molec_charge_constraints > 0 ) { - sfree( system->molec_charge_constraints, "Read_BGF::molec_charge_constraints" ); - sfree( system->molec_charge_constraint_ranges, "Read_BGF::molec_charge_constraint_ranges" ); + sfree( system->molec_charge_constraints, __FILE__, __LINE__ ); + sfree( system->molec_charge_constraint_ranges, __FILE__, __LINE__ ); } system->molec_charge_constraints = smalloc( - sizeof(real) * num_mcc, "Read_BGF::molec_charge_constraints" ); + sizeof(real) * num_mcc, __FILE__, __LINE__ ); system->molec_charge_constraint_ranges = smalloc( - sizeof(int) * 2 * num_mcc, "Read_BGF::molec_charge_constraint_ranges" ); + sizeof(int) * 2 * num_mcc, __FILE__, __LINE__ ); system->max_num_molec_charge_constraints = num_mcc; } @@ -819,7 +855,7 @@ void Read_BGF( const char * const bgf_file, reax_system* system, control_params /* add to mapping */ bgf_serial = sstrtod( serial, __FILE__, __LINE__ ); - Check_Input_Range( bgf_serial, 0, MAX_ATOM_ID, "Invalid bgf serial" ); + Check_Input_Range( bgf_serial, 0, MAX_ATOM_ID, __FILE__, __LINE__ ); workspace->map_serials[ bgf_serial ] = atom_cnt; workspace->orig_id[ atom_cnt ] = bgf_serial; @@ -846,15 +882,16 @@ void Read_BGF( const char * const bgf_file, reax_system* system, control_params system->atoms[atom_cnt].type = Get_Atom_Type( &system->reax_param, element, sizeof(element) ); - // TODO: finalize dummy atom name (Amber uses "Du") - if ( strncmp( element, "X\0", 2) == 0 ) + /* check for dummy atom */ + if ( strncmp( element, "X\0", 2 ) == 0 ) { - system->atoms[atom_cnt].dummy = TRUE; + system->atoms[atom_cnt].is_dummy = TRUE; } else { - system->atoms[atom_cnt].dummy = FALSE; + system->atoms[atom_cnt].is_dummy = FALSE; } + #if defined(DEBUG_FOCUS) fprintf( stderr, "[INFO] atom_cnt = %5d, atom_type = %3d, x = (%10.5f,%10.5f,%10.5f), q = %10.5f, occ = %s, temp = %s, res_name = %4s, element = %s\n", @@ -872,8 +909,7 @@ void Read_BGF( const char * const bgf_file, reax_system* system, control_params if ( control->restrict_bonds ) { /* check number of restrictions */ - Check_Input_Range( token_cnt - 2, 0, MAX_RESTRICT, - "CONECT line exceeds max restrictions allowed.\n" ); + Check_Input_Range( token_cnt - 2, 0, MAX_RESTRICT, __FILE__, __LINE__ ); /* read bond restrictions */ bgf_serial = sstrtol( tokens[1], __FILE__, __LINE__ ); @@ -929,5 +965,5 @@ void Read_BGF( const char * const bgf_file, reax_system* system, control_params Deallocate_Tokenizer_Space( &line, &backup, &tokens, MAX_TOKENS ); - sfclose( bgf, "Read_BGF::bgf" ); + sfclose( bgf, __FILE__, __LINE__ ); } diff --git a/sPuReMD/src/grid.c b/sPuReMD/src/grid.c index f5bfde6686432c6d760dea90b34893b6fbe913b6..3c6eb47bdfe8348e4d821364254125e8d82df2d1 100644 --- a/sPuReMD/src/grid.c +++ b/sPuReMD/src/grid.c @@ -89,101 +89,101 @@ static void Allocate_Space_for_Grid( reax_system * const system, int alloc ) if ( alloc == TRUE ) { /* allocate space for the new grid */ - g->atoms = (int****) scalloc( g->ncell_max[0], sizeof( int*** ), - "Allocate_Space_for_Grid::g->atoms" ); + g->atoms = scalloc( g->ncell_max[0], sizeof( int*** ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) - g->atoms[i] = (int***) scalloc( g->ncell_max[1], sizeof( int** ), - "Allocate_Space_for_Grid::g->atoms[i]" ); + g->atoms[i] = scalloc( g->ncell_max[1], sizeof( int** ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) for ( j = 0; j < g->ncell_max[1]; j++ ) - g->atoms[i][j] = (int**) scalloc( g->ncell_max[2], sizeof( int* ), - "Allocate_Space_for_Grid::g->atoms[i][j]" ); + g->atoms[i][j] = scalloc( g->ncell_max[2], sizeof( int* ), + __FILE__, __LINE__ ); - g->top = (int***) scalloc( g->ncell_max[0], sizeof( int** ), - "Allocate_Space_for_Grid::g->top" ); + g->top = scalloc( g->ncell_max[0], sizeof( int** ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) - g->top[i] = (int**) scalloc( g->ncell_max[1], sizeof( int* ), - "Allocate_Space_for_Grid::g->top[i]" ); + g->top[i] = scalloc( g->ncell_max[1], sizeof( int* ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) for ( j = 0; j < g->ncell_max[1]; j++ ) - g->top[i][j] = (int*) scalloc( g->ncell_max[2], sizeof( int ), - "Allocate_Space_for_Grid::g->top[i][j]" ); + g->top[i][j] = scalloc( g->ncell_max[2], sizeof( int ), + __FILE__, __LINE__ ); - g->mark = (int***) scalloc( g->ncell_max[0], sizeof( int** ), - "Allocate_Space_for_Grid::g->mark" ); + g->mark = scalloc( g->ncell_max[0], sizeof( int** ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) - g->mark[i] = (int**) scalloc( g->ncell_max[1], sizeof( int* ), - "Allocate_Space_for_Grid::g->mark[i]" ); + g->mark[i] = scalloc( g->ncell_max[1], sizeof( int* ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) for ( j = 0; j < g->ncell_max[1]; j++ ) - g->mark[i][j] = (int*) scalloc( g->ncell_max[2], sizeof( int ), - "Allocate_Space_for_Grid::g->mark[i][j]" ); + g->mark[i][j] = scalloc( g->ncell_max[2], sizeof( int ), + __FILE__, __LINE__ ); - g->start = (int***) scalloc( g->ncell_max[0], sizeof( int** ), - "Allocate_Space_for_Grid::g->start" ); + g->start = scalloc( g->ncell_max[0], sizeof( int** ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) - g->start[i] = (int**) scalloc( g->ncell_max[1], sizeof( int* ), - "Allocate_Space_for_Grid::g->start[i]" ); + g->start[i] = scalloc( g->ncell_max[1], sizeof( int* ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) for ( j = 0; j < g->ncell_max[1]; j++ ) - g->start[i][j] = (int*) scalloc( g->ncell_max[2], sizeof( int ), - "Allocate_Space_for_Grid::g->start[i][j]" ); + g->start[i][j] = scalloc( g->ncell_max[2], sizeof( int ), + __FILE__, __LINE__ ); - g->end = (int***) scalloc( g->ncell_max[0], sizeof( int** ), - "Allocate_Space_for_Grid::g->end" ); + g->end = scalloc( g->ncell_max[0], sizeof( int** ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) - g->end[i] = (int**) scalloc( g->ncell_max[1], sizeof( int* ), - "Allocate_Space_for_Grid::g->end[i]" ); + g->end[i] = scalloc( g->ncell_max[1], sizeof( int* ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) for ( j = 0; j < g->ncell_max[1]; j++ ) - g->end[i][j] = (int*) scalloc( g->ncell_max[2], sizeof( int ), - "Allocate_Space_for_Grid::g->end[i][j]" ); + g->end[i][j] = scalloc( g->ncell_max[2], sizeof( int ), + __FILE__, __LINE__ ); - g->nbrs = (ivec****) scalloc( g->ncell_max[0], sizeof( ivec*** ), - "Allocate_Space_for_Grid::g->nbrs" ); + g->nbrs = scalloc( g->ncell_max[0], sizeof( ivec*** ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) - g->nbrs[i] = (ivec***) scalloc( g->ncell_max[1], sizeof( ivec** ), - "Allocate_Space_for_Grid::g->nbrs[i]" ); + g->nbrs[i] = scalloc( g->ncell_max[1], sizeof( ivec** ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) for ( j = 0; j < g->ncell_max[1]; j++ ) - g->nbrs[i][j] = (ivec**) scalloc( g->ncell_max[2], sizeof( ivec* ), - "Allocate_Space_for_Grid::g->nbrs[i][j]" ); + g->nbrs[i][j] = scalloc( g->ncell_max[2], sizeof( ivec* ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) for ( j = 0; j < g->ncell_max[1]; j++ ) for ( k = 0; k < g->ncell_max[2]; k++ ) - g->nbrs[i][j][k] = (ivec*) smalloc( g->max_nbrs * sizeof( ivec ), - "Allocate_Space_for_Grid::g->nbrs[i][j][k]" ); + g->nbrs[i][j][k] = smalloc( g->max_nbrs * sizeof( ivec ), + __FILE__, __LINE__ ); - g->nbrs_cp = (rvec****) scalloc( g->ncell_max[0], sizeof( rvec*** ), - "Allocate_Space_for_Grid::g->nbrs_cp" ); + g->nbrs_cp = scalloc( g->ncell_max[0], sizeof( rvec*** ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) - g->nbrs_cp[i] = (rvec***) scalloc( g->ncell_max[1], sizeof( rvec** ), - "Allocate_Space_for_Grid::g->nbrs_cp[i]" ); + g->nbrs_cp[i] = scalloc( g->ncell_max[1], sizeof( rvec** ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) for ( j = 0; j < g->ncell_max[1]; j++ ) - g->nbrs_cp[i][j] = (rvec**) scalloc( g->ncell_max[2], sizeof( rvec* ), - "Allocate_Space_for_Grid::g->nbrs_cp[i][j]" ); + g->nbrs_cp[i][j] = scalloc( g->ncell_max[2], sizeof( rvec* ), + __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) for ( j = 0; j < g->ncell_max[1]; j++ ) for ( k = 0; k < g->ncell_max[2]; k++ ) - g->nbrs_cp[i][j][k] = (rvec*) smalloc( g->max_nbrs * sizeof( rvec ), - "Allocate_Space_for_Grid::g->nbrs_cp[i][j][k]" ); + g->nbrs_cp[i][j][k] = smalloc( g->max_nbrs * sizeof( rvec ), + __FILE__, __LINE__ ); } for ( i = 0; i < g->ncell[0]; i++ ) @@ -235,8 +235,8 @@ static void Allocate_Space_for_Grid( reax_system * const system, int alloc ) for ( i = 0; i < g->ncell_max[0]; i++ ) for ( j = 0; j < g->ncell_max[1]; j++ ) for ( k = 0; k < g->ncell_max[2]; k++ ) - g->atoms[i][j][k] = (int*) smalloc( g->max_atoms * sizeof( int ), - "Allocate_Space_for_Grid::g->atoms[i][j][k]" ); + g->atoms[i][j][k] = smalloc( g->max_atoms * sizeof( int ), + __FILE__, __LINE__ ); } /* case: grid large enough but max. atoms per grid cells insufficient */ else if ( g->max_atoms > 0 && g->max_atoms < max_atoms ) @@ -246,13 +246,13 @@ static void Allocate_Space_for_Grid( reax_system * const system, int alloc ) for ( i = 0; i < g->ncell_max[0]; i++ ) for ( j = 0; j < g->ncell_max[1]; j++ ) for ( k = 0; k < g->ncell_max[2]; k++ ) - sfree( g->atoms[i][j][k], "Allocate_Space_for_Grid::g->atoms[i][j][k]" ); + sfree( g->atoms[i][j][k], __FILE__, __LINE__ ); for ( i = 0; i < g->ncell_max[0]; i++ ) for ( j = 0; j < g->ncell_max[1]; j++ ) for ( k = 0; k < g->ncell_max[2]; k++ ) - g->atoms[i][j][k] = (int*) smalloc( g->max_atoms * sizeof( int ), - "Allocate_Space_for_Grid::g->atoms[i][j][k]" ); + g->atoms[i][j][k] = smalloc( g->max_atoms * sizeof( int ), + __FILE__, __LINE__ ); } for ( i = 0; i < g->ncell[0]; i++ ) @@ -274,41 +274,41 @@ static void Deallocate_Grid_Space( grid * const g ) for ( j = 0; j < g->ncell_max[1]; j++ ) for ( k = 0; k < g->ncell_max[2]; k++ ) { - sfree( g->atoms[i][j][k], "Deallocate_Grid_Space::g->atoms[i][j][k]" ); - sfree( g->nbrs[i][j][k], "Deallocate_Grid_Space::g->nbrs[i][j][k]" ); - sfree( g->nbrs_cp[i][j][k], "Deallocate_Grid_Space::g->nbrs_cp[i][j][k]" ); + sfree( g->atoms[i][j][k], __FILE__, __LINE__ ); + sfree( g->nbrs[i][j][k], __FILE__, __LINE__ ); + sfree( g->nbrs_cp[i][j][k], __FILE__, __LINE__ ); } for ( i = 0; i < g->ncell_max[0]; i++ ) for ( j = 0; j < g->ncell_max[1]; j++ ) { - sfree( g->atoms[i][j], "Deallocate_Grid_Space::g->atoms[i][j]" ); - sfree( g->top[i][j], "Deallocate_Grid_Space::g->top[i][j]" ); - sfree( g->mark[i][j], "Deallocate_Grid_Space::g->mark[i][j]" ); - sfree( g->start[i][j], "Deallocate_Grid_Space::g->start[i][j]" ); - sfree( g->end[i][j], "Deallocate_Grid_Space::g->end[i][j]" ); - sfree( g->nbrs[i][j], "Deallocate_Grid_Space::g->nbrs[i][j]" ); - sfree( g->nbrs_cp[i][j], "Deallocate_Grid_Space::g->nbrs_cp[i][j]" ); + sfree( g->atoms[i][j], __FILE__, __LINE__ ); + sfree( g->top[i][j], __FILE__, __LINE__ ); + sfree( g->mark[i][j], __FILE__, __LINE__ ); + sfree( g->start[i][j], __FILE__, __LINE__ ); + sfree( g->end[i][j], __FILE__, __LINE__ ); + sfree( g->nbrs[i][j], __FILE__, __LINE__ ); + sfree( g->nbrs_cp[i][j], __FILE__, __LINE__ ); } for ( i = 0; i < g->ncell_max[0]; i++ ) { - sfree( g->atoms[i], "Deallocate_Grid_Space::g->atoms[i]" ); - sfree( g->top[i], "Deallocate_Grid_Space::g->top[i]" ); - sfree( g->mark[i], "Deallocate_Grid_Space::g->mark[i]" ); - sfree( g->start[i], "Deallocate_Grid_Space::g->start[i]" ); - sfree( g->end[i], "Deallocate_Grid_Space::g->end[i]" ); - sfree( g->nbrs[i], "Deallocate_Grid_Space::g->nbrs[i]" ); - sfree( g->nbrs_cp[i], "Deallocate_Grid_Space::g->nbrs_cp[i]" ); + sfree( g->atoms[i], __FILE__, __LINE__ ); + sfree( g->top[i], __FILE__, __LINE__ ); + sfree( g->mark[i], __FILE__, __LINE__ ); + sfree( g->start[i], __FILE__, __LINE__ ); + sfree( g->end[i], __FILE__, __LINE__ ); + sfree( g->nbrs[i], __FILE__, __LINE__ ); + sfree( g->nbrs_cp[i], __FILE__, __LINE__ ); } - sfree( g->atoms, "Deallocate_Grid_Space::g->atoms" ); - sfree( g->top, "Deallocate_Grid_Space::g->top" ); - sfree( g->mark, "Deallocate_Grid_Space::g->mark" ); - sfree( g->start, "Deallocate_Grid_Space::g->start" ); - sfree( g->end, "Deallocate_Grid_Space::g->end" ); - sfree( g->nbrs, "Deallocate_Grid_Space::g->nbrs" ); - sfree( g->nbrs_cp, "Deallocate_Grid_Space::g->nbrs_cp" ); + sfree( g->atoms, __FILE__, __LINE__ ); + sfree( g->top, __FILE__, __LINE__ ); + sfree( g->mark, __FILE__, __LINE__ ); + sfree( g->start, __FILE__, __LINE__ ); + sfree( g->end, __FILE__, __LINE__ ); + sfree( g->nbrs, __FILE__, __LINE__ ); + sfree( g->nbrs_cp, __FILE__, __LINE__ ); } @@ -750,19 +750,19 @@ static void Free_Storage( static_storage * const workspace, for ( i = 0; i < control->cm_solver_restart + 1; ++i ) { - sfree( workspace->v[i], "Free_Storage::workspace->v[i]" ); + sfree( workspace->v[i], __FILE__, __LINE__ ); } - sfree( workspace->v, "Free_Storage::workspace->v" ); + sfree( workspace->v, __FILE__, __LINE__ ); for ( i = 0; i < 3; ++i ) { - sfree( workspace->s[i], "Free_Storage::workspace->s[i]" ); - sfree( workspace->t[i], "Free_Storage::workspace->t[i]" ); + sfree( workspace->s[i], __FILE__, __LINE__ ); + sfree( workspace->t[i], __FILE__, __LINE__ ); } - sfree( workspace->s, "Free_Storage::workspace->s" ); - sfree( workspace->t, "Free_Storage::workspace->t" ); + sfree( workspace->s, __FILE__, __LINE__ ); + sfree( workspace->t, __FILE__, __LINE__ ); - sfree( workspace->orig_id, "Free_Storage::workspace->orig_id" ); + sfree( workspace->orig_id, __FILE__, __LINE__ ); } @@ -793,23 +793,23 @@ void Reorder_Atoms( reax_system * const system, static_storage * const workspace top = 0; g = &system->g; - new_atoms = scalloc( system->N, sizeof(reax_atom), "Reorder_Atoms::new_atoms" ); - orig_id = scalloc( system->N, sizeof(int), "Reorder_Atoms::orig_id" ); - f_old = scalloc( system->N, sizeof(rvec), "Reorder_Atoms::f_old" ); + new_atoms = scalloc( system->N, sizeof(reax_atom), __FILE__, __LINE__ ); + orig_id = scalloc( system->N, sizeof(int), __FILE__, __LINE__ ); + f_old = scalloc( system->N, sizeof(rvec), __FILE__, __LINE__ ); - s = scalloc( 5, sizeof(real *), "Reorder_Atoms::s" ); - t = scalloc( 5, sizeof(real *), "Reorder_Atoms::t" ); + s = scalloc( 5, sizeof(real *), __FILE__, __LINE__ ); + t = scalloc( 5, sizeof(real *), __FILE__, __LINE__ ); for ( i = 0; i < 5; ++i ) { - s[i] = scalloc( system->N_cm, sizeof(real), "Reorder_Atoms::s[i]" ); - t[i] = scalloc( system->N_cm, sizeof(real), "Reorder_Atoms::t[i]" ); + s[i] = scalloc( system->N_cm, sizeof(real), __FILE__, __LINE__ ); + t[i] = scalloc( system->N_cm, sizeof(real), __FILE__, __LINE__ ); } v = scalloc( control->cm_solver_restart + 1, sizeof(real *), - "Reorder_Atoms::v" ); + __FILE__, __LINE__ ); for ( i = 0; i < control->cm_solver_restart + 1; ++i ) { - v[i] = scalloc( system->N_cm, sizeof(real), "Reorder_Atoms::v[i]" ); + v[i] = scalloc( system->N_cm, sizeof(real), __FILE__, __LINE__ ); } for ( i = 0; i < g->ncell[0]; i++ ) @@ -837,7 +837,7 @@ void Reorder_Atoms( reax_system * const system, static_storage * const workspace } } - sfree( system->atoms, "Reorder_Atoms::system->atoms" ); + sfree( system->atoms, __FILE__, __LINE__ ); Free_Storage( workspace, control ); system->atoms = new_atoms; diff --git a/sPuReMD/src/init_md.c b/sPuReMD/src/init_md.c index c97368cb6e67a068bbf09184ce6ab26d0f444be0..f57684d7381bcf835b6e8badd5d4408bb0ff7f96 100644 --- a/sPuReMD/src/init_md.c +++ b/sPuReMD/src/init_md.c @@ -167,7 +167,7 @@ static void Init_Simulation_Data( reax_system *system, control_params *control, || control->ensemble == aNPT || control->compute_pressure == TRUE) ) { data->press_local = smalloc( sizeof( rtensor ) * control->num_threads, - "Init_Simulation_Data::data->press_local" ); + __FILE__, __LINE__ ); } #endif @@ -331,42 +331,42 @@ static void Init_Workspace( reax_system *system, control_params *control, { /* hydrogen bond list */ workspace->hbond_index = smalloc( system->N_max * sizeof( int ), - "Init_Workspace::workspace->hbond_index" ); + __FILE__, __LINE__ ); /* bond order related storage */ workspace->total_bond_order = smalloc( system->N_max * sizeof( real ), - "Init_Workspace::workspace->bond_order" ); + __FILE__, __LINE__ ); workspace->Deltap = smalloc( system->N_max * sizeof( real ), - "Init_Workspace::workspace->Deltap" ); + __FILE__, __LINE__ ); workspace->Deltap_boc = smalloc( system->N_max * sizeof( real ), - "Init_Workspace::workspace->Deltap_boc" ); + __FILE__, __LINE__ ); workspace->dDeltap_self = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->dDeltap_self" ); + __FILE__, __LINE__ ); workspace->Delta = smalloc( system->N_max * sizeof( real ), - "Init_Workspace::workspace->Delta" ); + __FILE__, __LINE__ ); workspace->Delta_lp = smalloc( system->N_max * sizeof( real ), - "Init_Workspace::workspace->Delta_lp" ); + __FILE__, __LINE__ ); workspace->Delta_lp_temp = smalloc( system->N_max * sizeof( real ), - "Init_Workspace::workspace->Delta_lp_temp" ); + __FILE__, __LINE__ ); workspace->dDelta_lp = smalloc( system->N_max * sizeof( real ), - "Init_Workspace::workspace->dDelta_lp" ); + __FILE__, __LINE__ ); workspace->dDelta_lp_temp = smalloc( system->N_max * sizeof( real ), - "Init_Workspace::workspace->dDelta_lp_temp" ); + __FILE__, __LINE__ ); workspace->Delta_e = smalloc( system->N_max * sizeof( real ), - "Init_Workspace::workspace->Delta_e" ); + __FILE__, __LINE__ ); workspace->Delta_boc = smalloc( system->N_max * sizeof( real ), - "Init_Workspace::workspace->Delta_boc" ); + __FILE__, __LINE__ ); workspace->nlp = smalloc( system->N_max * sizeof( real ), - "Init_Workspace::workspace->nlp" ); + __FILE__, __LINE__ ); workspace->nlp_temp = smalloc( system->N_max * sizeof( real ), - "Init_Workspace::workspace->nlp_temp" ); + __FILE__, __LINE__ ); workspace->Clp = smalloc( system->N_max * sizeof( real ), - "Init_Workspace::workspace->Clp" ); + __FILE__, __LINE__ ); workspace->CdDelta = smalloc( system->N_max * sizeof( real ), - "Init_Workspace::workspace->CdDelta" ); + __FILE__, __LINE__ ); workspace->vlpex = smalloc( system->N_max * sizeof( real ), - "Init_Workspace::workspace->vlpex" ); + __FILE__, __LINE__ ); } /* charge method storage */ @@ -408,27 +408,27 @@ static void Init_Workspace( reax_system *system, control_params *control, || control->cm_solver_pre_comp_type == FG_ILUT_PC ) { workspace->droptol = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->droptol" ); + __FILE__, __LINE__ ); } workspace->b_s = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->b_s" ); + __FILE__, __LINE__ ); workspace->b_t = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->b_t" ); + __FILE__, __LINE__ ); workspace->b_prc = scalloc( system->N_cm_max * 2, sizeof( real ), - "Init_Workspace::workspace->b_prc" ); + __FILE__, __LINE__ ); workspace->b_prm = scalloc( system->N_cm_max * 2, sizeof( real ), - "Init_Workspace::workspace->b_prm" ); + __FILE__, __LINE__ ); workspace->s = scalloc( 5, sizeof( real* ), - "Init_Workspace::workspace->s" ); + __FILE__, __LINE__ ); workspace->t = scalloc( 5, sizeof( real* ), - "Init_Workspace::workspace->t" ); + __FILE__, __LINE__ ); for ( i = 0; i < 5; ++i ) { workspace->s[i] = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->s[i]" ); + __FILE__, __LINE__ ); workspace->t[i] = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->t[i]" ); + __FILE__, __LINE__ ); } } @@ -494,81 +494,81 @@ static void Init_Workspace( reax_system *system, control_params *control, case GMRES_S: case GMRES_H_S: workspace->y = scalloc( control->cm_solver_restart + 1, sizeof( real ), - "Init_Workspace::workspace->y" ); + __FILE__, __LINE__ ); workspace->z = scalloc( control->cm_solver_restart + 1, sizeof( real ), - "Init_Workspace::workspace->z" ); + __FILE__, __LINE__ ); workspace->g = scalloc( control->cm_solver_restart + 1, sizeof( real ), - "Init_Workspace::workspace->g" ); + __FILE__, __LINE__ ); workspace->h = scalloc( control->cm_solver_restart + 1, sizeof( real*), - "Init_Workspace::workspace->h" ); + __FILE__, __LINE__ ); workspace->hs = scalloc( control->cm_solver_restart + 1, sizeof( real ), - "Init_Workspace::workspace->hs" ); + __FILE__, __LINE__ ); workspace->hc = scalloc( control->cm_solver_restart + 1, sizeof( real ), - "Init_Workspace::workspace->hc" ); + __FILE__, __LINE__ ); workspace->rn = scalloc( control->cm_solver_restart + 1, sizeof( real*), - "Init_Workspace::workspace->rn" ); + __FILE__, __LINE__ ); workspace->v = scalloc( control->cm_solver_restart + 1, sizeof( real*), - "Init_Workspace::workspace->v" ); + __FILE__, __LINE__ ); for ( i = 0; i < control->cm_solver_restart + 1; ++i ) { workspace->h[i] = scalloc( control->cm_solver_restart + 1, sizeof( real ), - "Init_Workspace::workspace->h[i]" ); + __FILE__, __LINE__ ); workspace->rn[i] = scalloc( system->N_cm_max * 2, sizeof( real ), - "Init_Workspace::workspace->rn[i]" ); + __FILE__, __LINE__ ); workspace->v[i] = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->v[i]" ); + __FILE__, __LINE__ ); } workspace->r = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->r" ); + __FILE__, __LINE__ ); workspace->d = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->d" ); + __FILE__, __LINE__ ); workspace->q = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->q" ); + __FILE__, __LINE__ ); workspace->p = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->p" ); + __FILE__, __LINE__ ); break; case CG_S: workspace->r = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->r" ); + __FILE__, __LINE__ ); workspace->d = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->d" ); + __FILE__, __LINE__ ); workspace->q = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->q" ); + __FILE__, __LINE__ ); workspace->p = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->p" ); + __FILE__, __LINE__ ); break; case SDM_S: workspace->r = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->r" ); + __FILE__, __LINE__ ); workspace->d = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->d" ); + __FILE__, __LINE__ ); workspace->q = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->q" ); + __FILE__, __LINE__ ); break; case BiCGStab_S: workspace->r = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->r" ); + __FILE__, __LINE__ ); workspace->r_hat = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->r_hat" ); + __FILE__, __LINE__ ); workspace->d = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->d" ); + __FILE__, __LINE__ ); workspace->q = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->q" ); + __FILE__, __LINE__ ); workspace->q_hat = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->q_hat" ); + __FILE__, __LINE__ ); workspace->p = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->p" ); + __FILE__, __LINE__ ); workspace->y = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->y" ); + __FILE__, __LINE__ ); workspace->z = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->z" ); + __FILE__, __LINE__ ); workspace->g = scalloc( system->N_cm_max, sizeof( real ), - "Init_Workspace::workspace->g" ); + __FILE__, __LINE__ ); break; default: @@ -580,7 +580,7 @@ static void Init_Workspace( reax_system *system, control_params *control, #if defined(_OPENMP) /* SpMV related */ workspace->b_local = smalloc( control->num_threads * system->N_cm_max * sizeof(real), - "Init_Workspace::b_local" ); + __FILE__, __LINE__ ); #endif } @@ -593,19 +593,19 @@ static void Init_Workspace( reax_system *system, control_params *control, control->cm_solver_pre_app_type == TRI_SOLVE_GC_PA ) { workspace->row_levels_L = smalloc( system->N_cm_max * sizeof(unsigned int), - "Init_Workspace::row_levels_L" ); + __FILE__, __LINE__ ); workspace->level_rows_L = smalloc( system->N_cm_max * sizeof(unsigned int), - "Init_Workspace::level_rows_L" ); + __FILE__, __LINE__ ); workspace->level_rows_cnt_L = smalloc( (system->N_cm_max + 1) * sizeof(unsigned int), - "Init_Workspace::level_rows_cnt_L" ); + __FILE__, __LINE__ ); workspace->row_levels_U = smalloc( system->N_cm_max * sizeof(unsigned int), - "Init_Workspace::row_levels_U" ); + __FILE__, __LINE__ ); workspace->level_rows_U = smalloc( system->N_cm_max * sizeof(unsigned int), - "Init_Workspace::level_rows_U" ); + __FILE__, __LINE__ ); workspace->level_rows_cnt_U = smalloc( (system->N_cm_max + 1) * sizeof(unsigned int), - "Init_Workspace::level_rows_cnt_U" ); + __FILE__, __LINE__ ); workspace->top = smalloc( (system->N_cm_max + 1) * sizeof(unsigned int), - "Init_Workspace::top" ); + __FILE__, __LINE__ ); } else { @@ -626,21 +626,21 @@ static void Init_Workspace( reax_system *system, control_params *control, if ( control->cm_solver_pre_app_type == TRI_SOLVE_GC_PA ) { workspace->color = smalloc( sizeof(unsigned int) * system->N_cm_max, - "Init_Workspace::color" ); + __FILE__, __LINE__ ); workspace->to_color = smalloc( sizeof(unsigned int) * system->N_cm_max, - "Init_Workspace::to_color" ); + __FILE__, __LINE__ ); workspace->conflict = smalloc( sizeof(unsigned int) * system->N_cm_max, - "setup_graph_coloring::conflict" ); + __FILE__, __LINE__ ); workspace->conflict_cnt = smalloc( sizeof(unsigned int) * (control->num_threads + 1), - "Init_Workspace::conflict_cnt" ); + __FILE__, __LINE__ ); workspace->recolor = smalloc( sizeof(unsigned int) * system->N_cm_max, - "Init_Workspace::recolor" ); + __FILE__, __LINE__ ); workspace->color_top = smalloc( sizeof(unsigned int) * (system->N_cm_max + 1), - "Init_Workspace::color_top" ); + __FILE__, __LINE__ ); workspace->permuted_row_col = smalloc( sizeof(unsigned int) * system->N_cm_max, - "Init_Workspace::premuted_row_col" ); + __FILE__, __LINE__ ); workspace->permuted_row_col_inv = smalloc( sizeof(unsigned int) * system->N_cm_max, - "Init_Workspace::premuted_row_col_inv" ); + __FILE__, __LINE__ ); } else { @@ -658,8 +658,8 @@ static void Init_Workspace( reax_system *system, control_params *control, if ( control->cm_solver_pre_app_type == TRI_SOLVE_GC_PA || control->cm_solver_pre_comp_type == ILUTP_PC ) { - workspace->y_p = smalloc( sizeof(real) * system->N_cm_max, "Init_Workspace::y_p" ); - workspace->x_p = smalloc( sizeof(real) * system->N_cm_max, "Init_Workspace::x_p" ); + workspace->y_p = smalloc( sizeof(real) * system->N_cm_max, __FILE__, __LINE__ ); + workspace->x_p = smalloc( sizeof(real) * system->N_cm_max, __FILE__, __LINE__ ); } else { @@ -671,15 +671,15 @@ static void Init_Workspace( reax_system *system, control_params *control, if ( control->cm_solver_pre_app_type == JACOBI_ITER_PA ) { workspace->Dinv_L = smalloc( sizeof(real) * system->N_cm_max, - "Init_Workspace::Dinv_L" ); + __FILE__, __LINE__ ); workspace->Dinv_U = smalloc( sizeof(real) * system->N_cm_max, - "Init_Workspace::Dinv_U" ); + __FILE__, __LINE__ ); workspace->Dinv_b = smalloc( sizeof(real) * system->N_cm_max, - "Init_Workspace::Dinv_b" ); + __FILE__, __LINE__ ); workspace->rp = smalloc( sizeof(real) * system->N_cm_max, - "Init_Workspace::rp" ); + __FILE__, __LINE__ ); workspace->rp2 = smalloc( sizeof(real) * system->N_cm_max, - "Init_Workspace::rp2" ); + __FILE__, __LINE__ ); } else { @@ -694,7 +694,7 @@ static void Init_Workspace( reax_system *system, control_params *control, if ( control->cm_solver_pre_comp_type == ILUTP_PC ) { workspace->perm_ilutp = smalloc( sizeof( int ) * system->N_cm_max, - "Init_Workspace::workspace->perm_ilutp" ); + __FILE__, __LINE__ ); } else { @@ -703,29 +703,29 @@ static void Init_Workspace( reax_system *system, control_params *control, #if defined(QMMM) workspace->mask_qmmm = smalloc( system->N_cm_max * sizeof( int ), - "Init_Workspace::workspace->mask_qmmm" ); + __FILE__, __LINE__ ); #endif /* integrator storage */ workspace->a = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->a" ); + __FILE__, __LINE__ ); workspace->f_old = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->f_old" ); + __FILE__, __LINE__ ); workspace->v_const = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->v_const" ); + __FILE__, __LINE__ ); #if defined(_OPENMP) workspace->f_local = smalloc( control->num_threads * system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->f_local" ); + __FILE__, __LINE__ ); #endif /* storage for analysis */ if ( control->molec_anal || control->diffusion_coef ) { workspace->mark = scalloc( system->N_max, sizeof(int), - "Init_Workspace::workspace->mark" ); + __FILE__, __LINE__ ); workspace->old_mark = scalloc( system->N_max, sizeof(int), - "Init_Workspace::workspace->old_mark" ); + __FILE__, __LINE__ ); } else { @@ -735,7 +735,7 @@ static void Init_Workspace( reax_system *system, control_params *control, if ( control->diffusion_coef ) { workspace->x_old = scalloc( system->N_max, sizeof( rvec ), - "Init_Workspace::workspace->x_old" ); + __FILE__, __LINE__ ); } else { @@ -745,31 +745,31 @@ static void Init_Workspace( reax_system *system, control_params *control, #if defined(TEST_FORCES) workspace->dDelta = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->dDelta" ); + __FILE__, __LINE__ ); workspace->f_ele = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->f_ele" ); + __FILE__, __LINE__ ); workspace->f_vdw = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->f_vdw" ); + __FILE__, __LINE__ ); workspace->f_be = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->f_be" ); + __FILE__, __LINE__ ); workspace->f_lp = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->f_lp" ); + __FILE__, __LINE__ ); workspace->f_ov = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->f_ov" ); + __FILE__, __LINE__ ); workspace->f_un = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->f_un" ); + __FILE__, __LINE__ ); workspace->f_ang = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->f_ang" ); + __FILE__, __LINE__ ); workspace->f_coa = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->f_coa" ); + __FILE__, __LINE__ ); workspace->f_pen = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->f_pen" ); + __FILE__, __LINE__ ); workspace->f_hb = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->f_hb" ); + __FILE__, __LINE__ ); workspace->f_tor = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->f_tor" ); + __FILE__, __LINE__ ); workspace->f_con = smalloc( system->N_max * sizeof( rvec ), - "Init_Workspace::workspace->f_con" ); + __FILE__, __LINE__ ); #endif workspace->realloc.num_far = -1; @@ -817,8 +817,8 @@ static void Init_Lists( reax_system *system, control_params *control, Generate_Neighbor_Lists( system, control, data, workspace, lists ); Htop = 0; - hb_top = scalloc( system->N, sizeof(int), "Init_Lists::hb_top" ); - bond_top = scalloc( system->N, sizeof(int), "Init_Lists::bond_top" ); + hb_top = scalloc( system->N, sizeof(int), __FILE__, __LINE__ ); + bond_top = scalloc( system->N, sizeof(int), __FILE__, __LINE__ ); num_3body = 0; Estimate_Storage_Sizes( system, control, lists, &Htop, @@ -1032,8 +1032,8 @@ static void Init_Lists( reax_system *system, control_params *control, } #endif - sfree( hb_top, "Init_Lists::hb_top" ); - sfree( bond_top, "Init_Lists::bond_top" ); + sfree( hb_top, __FILE__, __LINE__ ); + sfree( bond_top, __FILE__, __LINE__ ); } @@ -1048,7 +1048,7 @@ static void Init_Out_Controls( reax_system *system, control_params *control, strncpy( temp, control->sim_name, TEMP_SIZE - 5 ); temp[TEMP_SIZE - 5] = '\0'; strcat( temp, ".trj" ); - out_control->trj = sfopen( temp, "w" ); + out_control->trj = sfopen( temp, "w", __FILE__, __LINE__ ); out_control->write_header( system, control, workspace, out_control ); } else @@ -1061,7 +1061,7 @@ static void Init_Out_Controls( reax_system *system, control_params *control, strncpy( temp, control->sim_name, TEMP_SIZE - 5 ); temp[TEMP_SIZE - 5] = '\0'; strcat( temp, ".out" ); - out_control->out = sfopen( temp, "w" ); + out_control->out = sfopen( temp, "w", __FILE__, __LINE__ ); fprintf( out_control->out, "%-6s%16s%16s%16s%11s%11s%13s%13s%13s\n", "step", "total_energy", "poten_energy", "kin_energy", "temp", "target", "volume", "press", "target" ); @@ -1070,7 +1070,7 @@ static void Init_Out_Controls( reax_system *system, control_params *control, strncpy( temp, control->sim_name, TEMP_SIZE - 5 ); temp[TEMP_SIZE - 5] = '\0'; strcat( temp, ".pot" ); - out_control->pot = sfopen( temp, "w" ); + out_control->pot = sfopen( temp, "w", __FILE__, __LINE__ ); fprintf( out_control->pot, "%-6s%13s%13s%13s%13s%13s%13s%13s%13s%13s%13s%13s\n", "step", "ebond", "eatom", "elp", "eang", "ecoa", "ehb", @@ -1080,7 +1080,7 @@ static void Init_Out_Controls( reax_system *system, control_params *control, strncpy( temp, control->sim_name, TEMP_SIZE - 5 ); temp[TEMP_SIZE - 5] = '\0'; strcat( temp, ".log" ); - out_control->log = sfopen( temp, "w" ); + out_control->log = sfopen( temp, "w", __FILE__, __LINE__ ); fprintf( out_control->log, "%-6s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s\n", "step", "total", "neighbors", "init", "bonded", "nonbonded", "cm", "cm_sort", "s_iters", "pre_comp", "pre_app", @@ -1099,7 +1099,7 @@ static void Init_Out_Controls( reax_system *system, control_params *control, strncpy( temp, control->sim_name, TEMP_SIZE - 5 ); temp[TEMP_SIZE - 5] = '\0'; strcat( temp, ".prs" ); - out_control->prs = sfopen( temp, "w" ); + out_control->prs = sfopen( temp, "w", __FILE__, __LINE__ ); #if defined(DEBUG) || defined(DEBUG_FOCUS) fprintf( out_control->prs, "%-8s %13s %13s %13s %13s %13s %13s\n", "step", "KExx", "KEyy", "KEzz", @@ -1120,11 +1120,11 @@ static void Init_Out_Controls( reax_system *system, control_params *control, if ( output_enabled == TRUE && control->molec_anal ) { snprintf( temp, TEMP_SIZE, "%.*s.mol", TEMP_SIZE - 5, control->sim_name ); - out_control->mol = sfopen( temp, "w" ); + out_control->mol = sfopen( temp, "w", __FILE__, __LINE__ ); if ( control->num_ignored ) { snprintf( temp, TEMP_SIZE, "%.*s.ign", TEMP_SIZE - 5, control->sim_name ); - out_control->ign = sfopen( temp, "w" ); + out_control->ign = sfopen( temp, "w", __FILE__, __LINE__ ); } } else @@ -1138,7 +1138,7 @@ static void Init_Out_Controls( reax_system *system, control_params *control, strncpy( temp, control->sim_name, TEMP_SIZE - 5 ); temp[TEMP_SIZE - 5] = '\0'; strcat( temp, ".dpl" ); - out_control->dpl = sfopen( temp, "w" ); + out_control->dpl = sfopen( temp, "w", __FILE__, __LINE__ ); fprintf( out_control->dpl, "Step Molecule Count Avg. Dipole Moment Norm\n" ); fflush( out_control->dpl ); @@ -1153,7 +1153,7 @@ static void Init_Out_Controls( reax_system *system, control_params *control, strncpy( temp, control->sim_name, TEMP_SIZE - 6 ); temp[TEMP_SIZE - 6] = '\0'; strcat( temp, ".drft" ); - out_control->drft = sfopen( temp, "w" ); + out_control->drft = sfopen( temp, "w", __FILE__, __LINE__ ); fprintf( out_control->drft, "Step Type Count Avg Squared Disp\n" ); fflush( out_control->drft ); } @@ -1167,62 +1167,62 @@ static void Init_Out_Controls( reax_system *system, control_params *control, strncpy( temp, control->sim_name, TEMP_SIZE - 6 ); temp[TEMP_SIZE - 6] = '\0'; strcat( temp, ".ebond" ); - out_control->ebond = sfopen( temp, "w" ); + out_control->ebond = sfopen( temp, "w", __FILE__, __LINE__ ); strncpy( temp, control->sim_name, TEMP_SIZE - 5 ); temp[TEMP_SIZE - 5] = '\0'; strcat( temp, ".elp" ); - out_control->elp = sfopen( temp, "w" ); + out_control->elp = sfopen( temp, "w", __FILE__, __LINE__ ); strncpy( temp, control->sim_name, TEMP_SIZE - 5 ); temp[TEMP_SIZE - 5] = '\0'; strcat( temp, ".eov" ); - out_control->eov = sfopen( temp, "w" ); + out_control->eov = sfopen( temp, "w", __FILE__, __LINE__ ); strncpy( temp, control->sim_name, TEMP_SIZE - 5 ); temp[TEMP_SIZE - 5] = '\0'; strcat( temp, ".eun" ); - out_control->eun = sfopen( temp, "w" ); + out_control->eun = sfopen( temp, "w", __FILE__, __LINE__ ); strncpy( temp, control->sim_name, TEMP_SIZE - 6 ); temp[TEMP_SIZE - 6] = '\0'; strcat( temp, ".eval" ); - out_control->eval = sfopen( temp, "w" ); + out_control->eval = sfopen( temp, "w", __FILE__, __LINE__ ); strncpy( temp, control->sim_name, TEMP_SIZE - 6 ); temp[TEMP_SIZE - 6] = '\0'; strcat( temp, ".epen" ); - out_control->epen = sfopen( temp, "w" ); + out_control->epen = sfopen( temp, "w", __FILE__, __LINE__ ); strncpy( temp, control->sim_name, TEMP_SIZE - 6 ); temp[TEMP_SIZE - 6] = '\0'; strcat( temp, ".ecoa" ); - out_control->ecoa = sfopen( temp, "w" ); + out_control->ecoa = sfopen( temp, "w", __FILE__, __LINE__ ); strncpy( temp, control->sim_name, TEMP_SIZE - 5 ); temp[TEMP_SIZE - 5] = '\0'; strcat( temp, ".ehb" ); - out_control->ehb = sfopen( temp, "w" ); + out_control->ehb = sfopen( temp, "w", __FILE__, __LINE__ ); strncpy( temp, control->sim_name, TEMP_SIZE - 6 ); temp[TEMP_SIZE - 6] = '\0'; strcat( temp, ".etor" ); - out_control->etor = sfopen( temp, "w" ); + out_control->etor = sfopen( temp, "w", __FILE__, __LINE__ ); strncpy( temp, control->sim_name, TEMP_SIZE - 6 ); temp[TEMP_SIZE - 6] = '\0'; strcat( temp, ".econ" ); - out_control->econ = sfopen( temp, "w" ); + out_control->econ = sfopen( temp, "w", __FILE__, __LINE__ ); strncpy( temp, control->sim_name, TEMP_SIZE - 6 ); temp[TEMP_SIZE - 6] = '\0'; strcat( temp, ".evdw" ); - out_control->evdw = sfopen( temp, "w" ); + out_control->evdw = sfopen( temp, "w", __FILE__, __LINE__ ); strncpy( temp, control->sim_name, TEMP_SIZE - 6 ); temp[TEMP_SIZE - 6] = '\0'; strcat( temp, ".ecou" ); - out_control->ecou = sfopen( temp, "w" ); + out_control->ecou = sfopen( temp, "w", __FILE__, __LINE__ ); #endif @@ -1231,67 +1231,67 @@ static void Init_Out_Controls( reax_system *system, control_params *control, strncpy( temp, control->sim_name, TEMP_SIZE - 5 ); temp[TEMP_SIZE - 5] = '\0'; strcat( temp, ".fbo" ); - out_control->fbo = sfopen( temp, "w" ); + out_control->fbo = sfopen( temp, "w", __FILE__, __LINE__ ); /* open bond orders derivatives file */ strncpy( temp, control->sim_name, TEMP_SIZE - 6 ); temp[TEMP_SIZE - 6] = '\0'; strcat( temp, ".fdbo" ); - out_control->fdbo = sfopen( temp, "w" ); + out_control->fdbo = sfopen( temp, "w", __FILE__, __LINE__ ); /* open bond forces file */ strncpy( temp, control->sim_name, TEMP_SIZE - 7 ); temp[TEMP_SIZE - 7] = '\0'; strcat( temp, ".fbond" ); - out_control->fbond = sfopen( temp, "w" ); + out_control->fbond = sfopen( temp, "w", __FILE__, __LINE__ ); /* open lone-pair forces file */ strncpy( temp, control->sim_name, TEMP_SIZE - 6 ); temp[TEMP_SIZE - 6] = '\0'; strcat( temp, ".flp" ); - out_control->flp = sfopen( temp, "w" ); + out_control->flp = sfopen( temp, "w", __FILE__, __LINE__ ); /* open overcoordination forces file */ strncpy( temp, control->sim_name, TEMP_SIZE - 7 ); temp[TEMP_SIZE - 7] = '\0'; strcat( temp, ".fatom" ); - out_control->fatom = sfopen( temp, "w" ); + out_control->fatom = sfopen( temp, "w", __FILE__, __LINE__ ); /* open angle forces file */ strncpy( temp, control->sim_name, TEMP_SIZE - 8 ); temp[TEMP_SIZE - 8] = '\0'; strcat( temp, ".f3body" ); - out_control->f3body = sfopen( temp, "w" ); + out_control->f3body = sfopen( temp, "w", __FILE__, __LINE__ ); /* open hydrogen bond forces file */ strncpy( temp, control->sim_name, TEMP_SIZE - 5 ); temp[TEMP_SIZE - 5] = '\0'; strcat( temp, ".fhb" ); - out_control->fhb = sfopen( temp, "w" ); + out_control->fhb = sfopen( temp, "w", __FILE__, __LINE__ ); /* open torsion forces file */ strncpy( temp, control->sim_name, TEMP_SIZE - 8 ); temp[TEMP_SIZE - 8] = '\0'; strcat( temp, ".f4body" ); - out_control->f4body = sfopen( temp, "w" ); + out_control->f4body = sfopen( temp, "w", __FILE__, __LINE__ ); /* open nonbonded forces file */ strncpy( temp, control->sim_name, TEMP_SIZE - 7 ); temp[TEMP_SIZE - 7] = '\0'; strcat( temp, ".fnonb" ); - out_control->fnonb = sfopen( temp, "w" ); + out_control->fnonb = sfopen( temp, "w", __FILE__, __LINE__ ); /* open total force file */ strncpy( temp, control->sim_name, TEMP_SIZE - 6 ); temp[TEMP_SIZE - 6] = '\0'; strcat( temp, ".ftot" ); - out_control->ftot = sfopen( temp, "w" ); + out_control->ftot = sfopen( temp, "w", __FILE__, __LINE__ ); /* open coulomb forces file */ strncpy( temp, control->sim_name, TEMP_SIZE - 7 ); temp[TEMP_SIZE - 7] = '\0'; strcat( temp, ".ftot2" ); - out_control->ftot2 = sfopen( temp, "w" ); + out_control->ftot2 = sfopen( temp, "w", __FILE__, __LINE__ ); #endif #undef TEMP_SIZE @@ -1359,8 +1359,8 @@ static void Finalize_System( reax_system *system, control_params *control, if ( system->max_num_molec_charge_constraints > 0 ) { - sfree( system->molec_charge_constraints, "Read_BGF::molec_charge_constraints" ); - sfree( system->molec_charge_constraint_ranges, "Read_BGF::molec_charge_constraint_ranges" ); + sfree( system->molec_charge_constraints, __FILE__, __LINE__ ); + sfree( system->molec_charge_constraint_ranges, __FILE__, __LINE__ ); } system->max_num_molec_charge_constraints = 0; @@ -1372,7 +1372,7 @@ static void Finalize_System( reax_system *system, control_params *control, if ( reset == FALSE ) { - sfree( reax->gp.l, "Finalize_System::reax->gp.l" ); + sfree( reax->gp.l, __FILE__, __LINE__ ); for ( i = 0; i < reax->max_num_atom_types; i++ ) { @@ -1380,27 +1380,27 @@ static void Finalize_System( reax_system *system, control_params *control, { for ( k = 0; k < reax->max_num_atom_types; k++ ) { - sfree( reax->fbp[i][j][k], "Finalize_System::reax->fbp[i][j][k]" ); + sfree( reax->fbp[i][j][k], __FILE__, __LINE__ ); } - sfree( reax->thbp[i][j], "Finalize_System::reax->thbp[i][j]" ); - sfree( reax->hbp[i][j], "Finalize_System::reax->hbp[i][j]" ); - sfree( reax->fbp[i][j], "Finalize_System::reax->fbp[i][j]" ); + sfree( reax->thbp[i][j], __FILE__, __LINE__ ); + sfree( reax->hbp[i][j], __FILE__, __LINE__ ); + sfree( reax->fbp[i][j], __FILE__, __LINE__ ); } - sfree( reax->tbp[i], "Finalize_System::reax->tbp[i]" ); - sfree( reax->thbp[i], "Finalize_System::reax->thbp[i]" ); - sfree( reax->hbp[i], "Finalize_System::reax->hbp[i]" ); - sfree( reax->fbp[i], "Finalize_System::reax->fbp[i]" ); + sfree( reax->tbp[i], __FILE__, __LINE__ ); + sfree( reax->thbp[i], __FILE__, __LINE__ ); + sfree( reax->hbp[i], __FILE__, __LINE__ ); + sfree( reax->fbp[i], __FILE__, __LINE__ ); } - sfree( reax->sbp, "Finalize_System::reax->sbp" ); - sfree( reax->tbp, "Finalize_System::reax->tbp" ); - sfree( reax->thbp, "Finalize_System::reax->thbp" ); - sfree( reax->hbp, "Finalize_System::reax->hbp" ); - sfree( reax->fbp, "Finalize_System::reax->fbp" ); + sfree( reax->sbp, __FILE__, __LINE__ ); + sfree( reax->tbp, __FILE__, __LINE__ ); + sfree( reax->thbp, __FILE__, __LINE__ ); + sfree( reax->hbp, __FILE__, __LINE__ ); + sfree( reax->fbp, __FILE__, __LINE__ ); - sfree( system->atoms, "Finalize_System::system->atoms" ); + sfree( system->atoms, __FILE__, __LINE__ ); } } @@ -1412,7 +1412,7 @@ static void Finalize_Simulation_Data( reax_system *system, control_params *contr if ( control->ensemble == sNPT || control->ensemble == iNPT || control->ensemble == aNPT || control->compute_pressure == TRUE ) { - sfree( data->press_local, "Finalize_Simulation_Data::data->press_local" ); + sfree( data->press_local, __FILE__, __LINE__ ); } #endif } @@ -1423,29 +1423,29 @@ static void Finalize_Workspace( reax_system *system, control_params *control, { int i; - sfree( workspace->hbond_index, "Finalize_Workspace::workspace->hbond_index" ); - sfree( workspace->total_bond_order, "Finalize_Workspace::workspace->total_bond_order" ); - sfree( workspace->Deltap, "Finalize_Workspace::workspace->Deltap" ); - sfree( workspace->Deltap_boc, "Finalize_Workspace::workspace->Deltap_boc" ); - sfree( workspace->dDeltap_self, "Finalize_Workspace::workspace->dDeltap_self" ); - sfree( workspace->Delta, "Finalize_Workspace::workspace->Delta" ); - sfree( workspace->Delta_lp, "Finalize_Workspace::workspace->Delta_lp" ); - sfree( workspace->Delta_lp_temp, "Finalize_Workspace::workspace->Delta_lp_temp" ); - sfree( workspace->dDelta_lp, "Finalize_Workspace::workspace->dDelta_lp" ); - sfree( workspace->dDelta_lp_temp, "Finalize_Workspace::workspace->dDelta_lp_temp" ); - sfree( workspace->Delta_e, "Finalize_Workspace::workspace->Delta_e" ); - sfree( workspace->Delta_boc, "Finalize_Workspace::workspace->Delta_boc" ); - sfree( workspace->nlp, "Finalize_Workspace::workspace->nlp" ); - sfree( workspace->nlp_temp, "Finalize_Workspace::workspace->nlp_temp" ); - sfree( workspace->Clp, "Finalize_Workspace::workspace->Clp" ); - sfree( workspace->CdDelta, "Finalize_Workspace::workspace->CdDelta" ); - sfree( workspace->vlpex, "Finalize_Workspace::workspace->vlpex" ); + sfree( workspace->hbond_index, __FILE__, __LINE__ ); + sfree( workspace->total_bond_order, __FILE__, __LINE__ ); + sfree( workspace->Deltap, __FILE__, __LINE__ ); + sfree( workspace->Deltap_boc, __FILE__, __LINE__ ); + sfree( workspace->dDeltap_self, __FILE__, __LINE__ ); + sfree( workspace->Delta, __FILE__, __LINE__ ); + sfree( workspace->Delta_lp, __FILE__, __LINE__ ); + sfree( workspace->Delta_lp_temp, __FILE__, __LINE__ ); + sfree( workspace->dDelta_lp, __FILE__, __LINE__ ); + sfree( workspace->dDelta_lp_temp, __FILE__, __LINE__ ); + sfree( workspace->Delta_e, __FILE__, __LINE__ ); + sfree( workspace->Delta_boc, __FILE__, __LINE__ ); + sfree( workspace->nlp, __FILE__, __LINE__ ); + sfree( workspace->nlp_temp, __FILE__, __LINE__ ); + sfree( workspace->Clp, __FILE__, __LINE__ ); + sfree( workspace->CdDelta, __FILE__, __LINE__ ); + sfree( workspace->vlpex, __FILE__, __LINE__ ); if ( reset == FALSE && (control->geo_format == BGF || control->geo_format == ASCII_RESTART || control->geo_format == BINARY_RESTART) ) { - sfree( workspace->map_serials, "Finalize_Workspace::workspace->map_serials" ); + sfree( workspace->map_serials, __FILE__, __LINE__ ); } if ( workspace->H.allocated == TRUE ) @@ -1487,27 +1487,27 @@ static void Finalize_Workspace( reax_system *system, control_params *control, for ( i = 0; i < 5; ++i ) { - sfree( workspace->s[i], "Finalize_Workspace::workspace->s[i]" ); - sfree( workspace->t[i], "Finalize_Workspace::workspace->t[i]" ); + sfree( workspace->s[i], __FILE__, __LINE__ ); + sfree( workspace->t[i], __FILE__, __LINE__ ); } if ( control->cm_solver_pre_comp_type == JACOBI_PC ) { - sfree( workspace->Hdia_inv, "Finalize_Workspace::workspace->Hdia_inv" ); + sfree( workspace->Hdia_inv, __FILE__, __LINE__ ); } if ( control->cm_solver_pre_comp_type == ICHOLT_PC || (control->cm_solver_pre_comp_type == ILUT_PC && control->cm_solver_pre_comp_droptol > 0.0 ) || control->cm_solver_pre_comp_type == ILUTP_PC || control->cm_solver_pre_comp_type == FG_ILUT_PC ) { - sfree( workspace->droptol, "Finalize_Workspace::workspace->droptol" ); + sfree( workspace->droptol, __FILE__, __LINE__ ); } - sfree( workspace->b_s, "Finalize_Workspace::workspace->b_s" ); - sfree( workspace->b_t, "Finalize_Workspace::workspace->b_t" ); - sfree( workspace->b_prc, "Finalize_Workspace::workspace->b_prc" ); - sfree( workspace->b_prm, "Finalize_Workspace::workspace->b_prm" ); - sfree( workspace->s, "Finalize_Workspace::workspace->s" ); - sfree( workspace->t, "Finalize_Workspace::workspace->t" ); + sfree( workspace->b_s, __FILE__, __LINE__ ); + sfree( workspace->b_t, __FILE__, __LINE__ ); + sfree( workspace->b_prc, __FILE__, __LINE__ ); + sfree( workspace->b_prm, __FILE__, __LINE__ ); + sfree( workspace->s, __FILE__, __LINE__ ); + sfree( workspace->t, __FILE__, __LINE__ ); switch ( control->cm_solver_type ) { @@ -1515,49 +1515,49 @@ static void Finalize_Workspace( reax_system *system, control_params *control, case GMRES_H_S: for ( i = 0; i < control->cm_solver_restart + 1; ++i ) { - sfree( workspace->h[i], "Finalize_Workspace::workspace->h[i]" ); - sfree( workspace->rn[i], "Finalize_Workspace::workspace->rn[i]" ); - sfree( workspace->v[i], "Finalize_Workspace::workspace->v[i]" ); + sfree( workspace->h[i], __FILE__, __LINE__ ); + sfree( workspace->rn[i], __FILE__, __LINE__ ); + sfree( workspace->v[i], __FILE__, __LINE__ ); } - sfree( workspace->y, "Finalize_Workspace::workspace->y" ); - sfree( workspace->z, "Finalize_Workspace::workspace->z" ); - sfree( workspace->g, "Finalize_Workspace::workspace->g" ); - sfree( workspace->h, "Finalize_Workspace::workspace->h" ); - sfree( workspace->hs, "Finalize_Workspace::workspace->hs" ); - sfree( workspace->hc, "Finalize_Workspace::workspace->hc" ); - sfree( workspace->rn, "Finalize_Workspace::workspace->rn" ); - sfree( workspace->v, "Finalize_Workspace::workspace->v" ); - - sfree( workspace->r, "Finalize_Workspace::workspace->r" ); - sfree( workspace->d, "Finalize_Workspace::workspace->d" ); - sfree( workspace->q, "Finalize_Workspace::workspace->q" ); - sfree( workspace->p, "Finalize_Workspace::workspace->p" ); + sfree( workspace->y, __FILE__, __LINE__ ); + sfree( workspace->z, __FILE__, __LINE__ ); + sfree( workspace->g, __FILE__, __LINE__ ); + sfree( workspace->h, __FILE__, __LINE__ ); + sfree( workspace->hs, __FILE__, __LINE__ ); + sfree( workspace->hc, __FILE__, __LINE__ ); + sfree( workspace->rn, __FILE__, __LINE__ ); + sfree( workspace->v, __FILE__, __LINE__ ); + + sfree( workspace->r, __FILE__, __LINE__ ); + sfree( workspace->d, __FILE__, __LINE__ ); + sfree( workspace->q, __FILE__, __LINE__ ); + sfree( workspace->p, __FILE__, __LINE__ ); break; case CG_S: - sfree( workspace->r, "Finalize_Workspace::workspace->r" ); - sfree( workspace->d, "Finalize_Workspace::workspace->d" ); - sfree( workspace->q, "Finalize_Workspace::workspace->q" ); - sfree( workspace->p, "Finalize_Workspace::workspace->p" ); + sfree( workspace->r, __FILE__, __LINE__ ); + sfree( workspace->d, __FILE__, __LINE__ ); + sfree( workspace->q, __FILE__, __LINE__ ); + sfree( workspace->p, __FILE__, __LINE__ ); break; case SDM_S: - sfree( workspace->r, "Finalize_Workspace::workspace->r" ); - sfree( workspace->d, "Finalize_Workspace::workspace->d" ); - sfree( workspace->q, "Finalize_Workspace::workspace->q" ); + sfree( workspace->r, __FILE__, __LINE__ ); + sfree( workspace->d, __FILE__, __LINE__ ); + sfree( workspace->q, __FILE__, __LINE__ ); break; case BiCGStab_S: - sfree( workspace->r, "Finalize_Workspace::workspace->r" ); - sfree( workspace->r_hat, "Finalize_Workspace::workspace->r_hat" ); - sfree( workspace->d, "Finalize_Workspace::workspace->d" ); - sfree( workspace->q, "Finalize_Workspace::workspace->q" ); - sfree( workspace->q_hat, "Finalize_Workspace::workspace->q_hat" ); - sfree( workspace->p, "Finalize_Workspace::workspace->p" ); - sfree( workspace->y, "Finalize_Workspace::workspace->y" ); - sfree( workspace->z, "Finalize_Workspace::workspace->z" ); - sfree( workspace->g, "Finalize_Workspace::workspace->g" ); + sfree( workspace->r, __FILE__, __LINE__ ); + sfree( workspace->r_hat, __FILE__, __LINE__ ); + sfree( workspace->d, __FILE__, __LINE__ ); + sfree( workspace->q, __FILE__, __LINE__ ); + sfree( workspace->q_hat, __FILE__, __LINE__ ); + sfree( workspace->p, __FILE__, __LINE__ ); + sfree( workspace->y, __FILE__, __LINE__ ); + sfree( workspace->z, __FILE__, __LINE__ ); + sfree( workspace->g, __FILE__, __LINE__ ); break; default: @@ -1568,87 +1568,87 @@ static void Finalize_Workspace( reax_system *system, control_params *control, /* SpMV related */ #if defined(_OPENMP) - sfree( workspace->b_local, "Finalize_Workspace::b_local" ); + sfree( workspace->b_local, __FILE__, __LINE__ ); #endif /* level scheduling related */ if ( control->cm_solver_pre_app_type == TRI_SOLVE_LEVEL_SCHED_PA || control->cm_solver_pre_app_type == TRI_SOLVE_GC_PA ) { - sfree( workspace->row_levels_L, "Finalize_Workspace::row_levels_L" ); - sfree( workspace->level_rows_L, "Finalize_Workspace::level_rows_L" ); - sfree( workspace->level_rows_cnt_L, "Finalize_Workspace::level_rows_cnt_L" ); - sfree( workspace->row_levels_U, "Finalize_Workspace::row_levels_U" ); - sfree( workspace->level_rows_U, "Finalize_Workspace::level_rows_U" ); - sfree( workspace->level_rows_cnt_U, "Finalize_Workspace::level_rows_cnt_U" ); - sfree( workspace->top, "Finalize_Workspace::top" ); + sfree( workspace->row_levels_L, __FILE__, __LINE__ ); + sfree( workspace->level_rows_L, __FILE__, __LINE__ ); + sfree( workspace->level_rows_cnt_L, __FILE__, __LINE__ ); + sfree( workspace->row_levels_U, __FILE__, __LINE__ ); + sfree( workspace->level_rows_U, __FILE__, __LINE__ ); + sfree( workspace->level_rows_cnt_U, __FILE__, __LINE__ ); + sfree( workspace->top, __FILE__, __LINE__ ); } /* graph coloring related */ if ( control->cm_solver_pre_app_type == TRI_SOLVE_GC_PA ) { - sfree( workspace->color, "Finalize_Workspace::workspace->color" ); - sfree( workspace->to_color, "Finalize_Workspace::workspace->to_color" ); - sfree( workspace->conflict, "Finalize_Workspace::workspace->conflict" ); - sfree( workspace->conflict_cnt, "Finalize_Workspace::workspace->conflict_cnt" ); - sfree( workspace->recolor, "Finalize_Workspace::workspace->recolor" ); - sfree( workspace->color_top, "Finalize_Workspace::workspace->color_top" ); - sfree( workspace->permuted_row_col, "Finalize_Workspace::workspace->permuted_row_col" ); - sfree( workspace->permuted_row_col_inv, "Finalize_Workspace::workspace->permuted_row_col_inv" ); + sfree( workspace->color, __FILE__, __LINE__ ); + sfree( workspace->to_color, __FILE__, __LINE__ ); + sfree( workspace->conflict, __FILE__, __LINE__ ); + sfree( workspace->conflict_cnt, __FILE__, __LINE__ ); + sfree( workspace->recolor, __FILE__, __LINE__ ); + sfree( workspace->color_top, __FILE__, __LINE__ ); + sfree( workspace->permuted_row_col, __FILE__, __LINE__ ); + sfree( workspace->permuted_row_col_inv, __FILE__, __LINE__ ); } /* graph coloring related OR ILUTP preconditioner */ if ( control->cm_solver_pre_app_type == TRI_SOLVE_GC_PA || control->cm_solver_pre_comp_type == ILUTP_PC ) { - sfree( workspace->y_p, "Finalize_Workspace::workspace->y_p" ); - sfree( workspace->x_p, "Finalize_Workspace::workspace->x_p" ); + sfree( workspace->y_p, __FILE__, __LINE__ ); + sfree( workspace->x_p, __FILE__, __LINE__ ); } /* Jacobi iteration related */ if ( control->cm_solver_pre_app_type == JACOBI_ITER_PA ) { - sfree( workspace->Dinv_L, "Finalize_Workspace::Dinv_L" ); - sfree( workspace->Dinv_U, "Finalize_Workspace::Dinv_U" ); - sfree( workspace->Dinv_b, "Finalize_Workspace::Dinv_b" ); - sfree( workspace->rp, "Finalize_Workspace::rp" ); - sfree( workspace->rp2, "Finalize_Workspace::rp2" ); + sfree( workspace->Dinv_L, __FILE__, __LINE__ ); + sfree( workspace->Dinv_U, __FILE__, __LINE__ ); + sfree( workspace->Dinv_b, __FILE__, __LINE__ ); + sfree( workspace->rp, __FILE__, __LINE__ ); + sfree( workspace->rp2, __FILE__, __LINE__ ); } /* ILUTP preconditioner related */ if ( control->cm_solver_pre_comp_type == ILUTP_PC ) { - sfree( workspace->perm_ilutp, "Finalize_Workspace::workspace->perm_ilutp" ); + sfree( workspace->perm_ilutp, __FILE__, __LINE__ ); } #if defined(QMMM) - sfree( workspace->mask_qmmm, "Init_Workspace::workspace->mask_qmmm" ); + sfree( workspace->mask_qmmm, __FILE__, __LINE__ ); #endif /* integrator storage */ - sfree( workspace->a, "Finalize_Workspace::workspace->a" ); - sfree( workspace->f_old, "Finalize_Workspace::workspace->f_old" ); - sfree( workspace->v_const, "Finalize_Workspace::workspace->v_const" ); + sfree( workspace->a, __FILE__, __LINE__ ); + sfree( workspace->f_old, __FILE__, __LINE__ ); + sfree( workspace->v_const, __FILE__, __LINE__ ); #if defined(_OPENMP) - sfree( workspace->f_local, "Finalize_Workspace::workspace->f_local" ); + sfree( workspace->f_local, __FILE__, __LINE__ ); #endif /* storage for analysis */ if ( control->molec_anal || control->diffusion_coef ) { - sfree( workspace->mark, "Finalize_Workspace::workspace->mark" ); - sfree( workspace->old_mark, "Finalize_Workspace::workspace->old_mark" ); + sfree( workspace->mark, __FILE__, __LINE__ ); + sfree( workspace->old_mark, __FILE__, __LINE__ ); } if ( control->diffusion_coef ) { - sfree( workspace->x_old, "Finalize_Workspace::workspace->x_old" ); + sfree( workspace->x_old, __FILE__, __LINE__ ); } if ( reset == FALSE ) { - sfree( workspace->orig_id, "Finalize_Workspace::workspace->orig_id" ); + sfree( workspace->orig_id, __FILE__, __LINE__ ); /* space for keeping restriction info, if any */ if ( control->restrict_bonds ) @@ -1656,28 +1656,28 @@ static void Finalize_Workspace( reax_system *system, control_params *control, for ( i = 0; i < system->N; ++i ) { sfree( workspace->restricted_list[i], - "Finalize_Workspace::workspace->restricted_list[i]" ); + __FILE__, __LINE__ ); } - sfree( workspace->restricted, "Finalize_Workspace::workspace->restricted" ); - sfree( workspace->restricted_list, "Finalize_Workspace::workspace->restricted_list" ); + sfree( workspace->restricted, __FILE__, __LINE__ ); + sfree( workspace->restricted_list, __FILE__, __LINE__ ); } } #if defined(TEST_FORCES) - sfree( workspace->dDelta, "Finalize_Workspace::workspace->dDelta" ); - sfree( workspace->f_ele, "Finalize_Workspace::workspace->f_ele" ); - sfree( workspace->f_vdw, "Finalize_Workspace::workspace->f_vdw" ); - sfree( workspace->f_be, "Finalize_Workspace::workspace->f_be" ); - sfree( workspace->f_lp, "Finalize_Workspace::workspace->f_lp" ); - sfree( workspace->f_ov, "Finalize_Workspace::workspace->f_ov" ); - sfree( workspace->f_un, "Finalize_Workspace::workspace->f_un" ); - sfree( workspace->f_ang, "Finalize_Workspace::workspace->f_ang" ); - sfree( workspace->f_coa, "Finalize_Workspace::workspace->f_coa" ); - sfree( workspace->f_pen, "Finalize_Workspace::workspace->f_pen" ); - sfree( workspace->f_hb, "Finalize_Workspace::workspace->f_hb" ); - sfree( workspace->f_tor, "Finalize_Workspace::workspace->f_tor" ); - sfree( workspace->f_con, "Finalize_Workspace::workspace->f_con" ); + sfree( workspace->dDelta, __FILE__, __LINE__ ); + sfree( workspace->f_ele, __FILE__, __LINE__ ); + sfree( workspace->f_vdw, __FILE__, __LINE__ ); + sfree( workspace->f_be, __FILE__, __LINE__ ); + sfree( workspace->f_lp, __FILE__, __LINE__ ); + sfree( workspace->f_ov, __FILE__, __LINE__ ); + sfree( workspace->f_un, __FILE__, __LINE__ ); + sfree( workspace->f_ang, __FILE__, __LINE__ ); + sfree( workspace->f_coa, __FILE__, __LINE__ ); + sfree( workspace->f_pen, __FILE__, __LINE__ ); + sfree( workspace->f_hb, __FILE__, __LINE__ ); + sfree( workspace->f_tor, __FILE__, __LINE__ ); + sfree( workspace->f_con, __FILE__, __LINE__ ); #endif } @@ -1696,6 +1696,10 @@ static void Finalize_Lists( reax_list **lists ) { Delete_List( TYP_BOND, lists[BONDS] ); } + if ( lists[OLD_BONDS]->allocated == TRUE ) + { + Delete_List( TYP_BOND, lists[OLD_BONDS] ); + } if ( lists[THREE_BODIES]->allocated == TRUE ) { Delete_List( TYP_THREE_BODY, lists[THREE_BODIES] ); @@ -1719,70 +1723,70 @@ void Finalize_Out_Controls( reax_system *system, control_params *control, { if ( out_control->write_steps > 0 ) { - sfclose( out_control->trj, "Finalize_Out_Controls::out_control->trj" ); + sfclose( out_control->trj, __FILE__, __LINE__ ); } if ( out_control->log_update_freq > 0 ) { - sfclose( out_control->out, "Finalize_Out_Controls::out_control->out" ); - sfclose( out_control->pot, "Finalize_Out_Controls::out_control->pot" ); - sfclose( out_control->log, "Finalize_Out_Controls::out_control->log" ); + sfclose( out_control->out, __FILE__, __LINE__ ); + sfclose( out_control->pot, __FILE__, __LINE__ ); + sfclose( out_control->log, __FILE__, __LINE__ ); } if ( control->ensemble == sNPT || control->ensemble == iNPT || control->ensemble == aNPT || control->compute_pressure == TRUE ) { - sfclose( out_control->prs, "Finalize_Out_Controls::out_control->prs" ); + sfclose( out_control->prs, __FILE__, __LINE__ ); } if ( control->molec_anal ) { - sfclose( out_control->mol, "Finalize_Out_Controls::out_control->mol" ); + sfclose( out_control->mol, __FILE__, __LINE__ ); if ( control->num_ignored ) { - sfclose( out_control->ign, "Finalize_Out_Controls::out_control->ign" ); + sfclose( out_control->ign, __FILE__, __LINE__ ); } } if ( control->dipole_anal ) { - sfclose( out_control->dpl, "Finalize_Out_Controls::out_control->dpl" ); + sfclose( out_control->dpl, __FILE__, __LINE__ ); } if ( control->diffusion_coef ) { - sfclose( out_control->drft, "Finalize_Out_Controls::out_control->drft" ); + sfclose( out_control->drft, __FILE__, __LINE__ ); } #if defined(TEST_ENERGY) - sfclose( out_control->ebond, "Finalize_Out_Controls::out_control->ebond" ); - sfclose( out_control->elp, "Finalize_Out_Controls::out_control->elp" ); - sfclose( out_control->eov, "Finalize_Out_Controls::out_control->eov" ); - sfclose( out_control->eun, "Finalize_Out_Controls::out_control->eun" ); - sfclose( out_control->eval, "Finalize_Out_Controls::out_control->eval" ); - sfclose( out_control->epen, "Finalize_Out_Controls::out_control->epen" ); - sfclose( out_control->ecoa, "Finalize_Out_Controls::out_control->ecoa" ); - sfclose( out_control->ehb, "Finalize_Out_Controls::out_control->ehb" ); - sfclose( out_control->etor, "Finalize_Out_Controls::out_control->etor" ); - sfclose( out_control->econ, "Finalize_Out_Controls::out_control->econ" ); - sfclose( out_control->evdw, "Finalize_Out_Controls::out_control->evdw" ); - sfclose( out_control->ecou, "Finalize_Out_Controls::out_control->ecou" ); + sfclose( out_control->ebond, __FILE__, __LINE__ ); + sfclose( out_control->elp, __FILE__, __LINE__ ); + sfclose( out_control->eov, __FILE__, __LINE__ ); + sfclose( out_control->eun, __FILE__, __LINE__ ); + sfclose( out_control->eval, __FILE__, __LINE__ ); + sfclose( out_control->epen, __FILE__, __LINE__ ); + sfclose( out_control->ecoa, __FILE__, __LINE__ ); + sfclose( out_control->ehb, __FILE__, __LINE__ ); + sfclose( out_control->etor, __FILE__, __LINE__ ); + sfclose( out_control->econ, __FILE__, __LINE__ ); + sfclose( out_control->evdw, __FILE__, __LINE__ ); + sfclose( out_control->ecou, __FILE__, __LINE__ ); #endif #if defined(TEST_FORCES) - sfclose( out_control->fbo, "Finalize_Out_Controls::out_control->fbo" ); - sfclose( out_control->fdbo, "Finalize_Out_Controls::out_control->fdbo" ); - sfclose( out_control->fbond, "Finalize_Out_Controls::out_control->fbond" ); - sfclose( out_control->flp, "Finalize_Out_Controls::out_control->flp" ); - sfclose( out_control->fatom, "Finalize_Out_Controls::out_control->fatom" ); - sfclose( out_control->f3body, "Finalize_Out_Controls::out_control->f3body" ); - sfclose( out_control->fhb, "Finalize_Out_Controls::out_control->fhb" ); - sfclose( out_control->f4body, "Finalize_Out_Controls::out_control->f4body" ); - sfclose( out_control->fnonb, "Finalize_Out_Controls::out_control->fnonb" ); - sfclose( out_control->ftot, "Finalize_Out_Controls::out_control->ftot" ); - sfclose( out_control->ftot2, "Finalize_Out_Controls::out_control->ftot2" ); + sfclose( out_control->fbo, __FILE__, __LINE__ ); + sfclose( out_control->fdbo, __FILE__, __LINE__ ); + sfclose( out_control->fbond, __FILE__, __LINE__ ); + sfclose( out_control->flp, __FILE__, __LINE__ ); + sfclose( out_control->fatom, __FILE__, __LINE__ ); + sfclose( out_control->f3body, __FILE__, __LINE__ ); + sfclose( out_control->fhb, __FILE__, __LINE__ ); + sfclose( out_control->f4body, __FILE__, __LINE__ ); + sfclose( out_control->fnonb, __FILE__, __LINE__ ); + sfclose( out_control->ftot, __FILE__, __LINE__ ); + sfclose( out_control->ftot2, __FILE__, __LINE__ ); #endif } diff --git a/sPuReMD/src/io_tools.c b/sPuReMD/src/io_tools.c index 24fda64895773228647cffb54e4b562eeeb2420b..c0332ccd7e00c61a66a9b08c1b0170b828fe97e0 100644 --- a/sPuReMD/src/io_tools.c +++ b/sPuReMD/src/io_tools.c @@ -400,7 +400,7 @@ void Print_Near_Neighbors( reax_system *system, control_params *control, reax_list *near_nbrs = lists[NEAR_NBRS]; snprintf( fname, MAX_STR, "%.*s.near_nbrs", MAX_STR - 11, control->sim_name ); - fout = sfopen( fname, "w" ); + fout = sfopen( fname, "w", __FILE__, __LINE__ ); for ( i = 0; i < system->N; ++i ) { @@ -420,7 +420,7 @@ void Print_Near_Neighbors( reax_system *system, control_params *control, } } - sfclose( fout, "Print_Near_Neighbors::fout" ); + sfclose( fout, __FILE__, __LINE__ ); } @@ -434,7 +434,7 @@ void Print_Near_Neighbors2( reax_system *system, control_params *control, reax_list *near_nbrs = lists[NEAR_NBRS]; snprintf( fname, MAX_STR, "%.*s.near_nbrs_lgj", MAX_STR - 15, control->sim_name ); - fout = sfopen( fname, "w" ); + fout = sfopen( fname, "w", __FILE__, __LINE__ ); for ( i = 0; i < system->N; ++i ) { @@ -455,7 +455,7 @@ void Print_Near_Neighbors2( reax_system *system, control_params *control, fprintf( fout, "\n"); } - sfclose( fout, "Print_Near_Neighbors2::fout" ); + sfclose( fout, __FILE__, __LINE__ ); } @@ -473,7 +473,7 @@ void Print_Far_Neighbors( reax_system const * const system, far_nbrs = lists[FAR_NBRS]; snprintf( fname, MAX_STR, "%.*s.%010d.far_nbrs", MAX_STR - 21, control->sim_name, data->step ); - fout = sfopen( fname, "w" ); + fout = sfopen( fname, "w", __FILE__, __LINE__ ); for ( i = 0; i < system->N; ++i ) { @@ -506,7 +506,7 @@ void Print_Far_Neighbors( reax_system const * const system, } } - sfclose( fout, "Print_Far_Neighbors::fout" ); + sfclose( fout, __FILE__, __LINE__ ); } @@ -525,7 +525,7 @@ void Print_Far_Neighbors2( reax_system *system, control_params *control, reax_list *far_nbrs = lists[FAR_NBRS]; snprintf( fname, MAX_STR, "%.*s.far_nbrs_lgj", MAX_STR - 14, control->sim_name ); - fout = sfopen( fname, "w" ); + fout = sfopen( fname, "w", __FILE__, __LINE__ ); int num = 0; int temp[500]; @@ -546,7 +546,7 @@ void Print_Far_Neighbors2( reax_system *system, control_params *control, fprintf( fout, "\n"); } - sfclose( fout, "Print_Far_Neighbors2::fout" ); + sfclose( fout, __FILE__, __LINE__ ); } @@ -559,7 +559,7 @@ void Print_Total_Force( reax_system *system, control_params *control, FILE *fout; snprintf( fname, MAX_STR, "%.*s.%d.forces", MAX_STR - 10, control->sim_name, data->step ); - fout = sfopen( fname, "w" ); + fout = sfopen( fname, "w", __FILE__, __LINE__ ); for ( i = 0; i < system->N; ++i ) { @@ -577,7 +577,7 @@ void Print_Total_Force( reax_system *system, control_params *control, // fflush( out_control->ftot ); fflush( fout ); - sfclose( fout, "Print_Total_Force::fout" ); + sfclose( fout, __FILE__, __LINE__ ); } @@ -711,7 +711,7 @@ void Print_Linear_System( reax_system *system, control_params *control, FILE *out; snprintf( fname, 100, "%.*s.state%10d.out", 79, control->sim_name, step ); - out = sfopen( fname, "w" ); + out = sfopen( fname, "w", __FILE__, __LINE__ ); for ( i = 0; i < system->N_cm; i++ ) fprintf( out, "%6d%2d%24.15e%24.15e%24.15e%24.15e%24.15e%24.15e%24.15e\n", @@ -720,16 +720,16 @@ void Print_Linear_System( reax_system *system, control_params *control, system->atoms[i].x[2], workspace->s[0][i], workspace->b_s[i], workspace->t[0][i], workspace->b_t[i] ); - sfclose( out, "Print_Linear_System::out" ); + sfclose( out, __FILE__, __LINE__ ); // snprintf( fname, 100, "x2_%d", step ); - // out = sfopen( fname, "w" ); + // out = sfopen( fname, "w", __FILE__, __LINE__ ); // for( i = 0; i < system->N; i++ ) // fprintf( out, "%g\n", workspace->s_t[i+system->N] ); - // sfclose( out, "Print_Linear_System::out" ); + // sfclose( out, __FILE__, __LINE__ ); snprintf( fname, 100, "%.*s.H%10d.out", 83, control->sim_name, step ); - out = sfopen( fname, "w" ); + out = sfopen( fname, "w", __FILE__, __LINE__ ); H = &workspace->H; for ( i = 0; i < system->N_cm; ++i ) @@ -749,10 +749,10 @@ void Print_Linear_System( reax_system *system, control_params *control, workspace->orig_id[i], workspace->orig_id[i], H->val[j] ); } - sfclose( out, "Print_Linear_System::out" ); + sfclose( out, __FILE__, __LINE__ ); snprintf( fname, 100, "%.*s.H_sp%10d.out", 80, control->sim_name, step ); - out = sfopen( fname, "w" ); + out = sfopen( fname, "w", __FILE__, __LINE__ ); H = &workspace->H_sp; for ( i = 0; i < system->N_cm; ++i ) @@ -772,19 +772,19 @@ void Print_Linear_System( reax_system *system, control_params *control, workspace->orig_id[i], workspace->orig_id[i], H->val[j] ); } - sfclose( out, "Print_Linear_System::out" ); + sfclose( out, __FILE__, __LINE__ ); /*snprintf( fname, 100, "%.*s.b_s%10d", 84, control->sim_name, step ); - out = sfopen( fname, "w" ); + out = sfopen( fname, "w", __FILE__, __LINE__ ); for( i = 0; i < system->N; i++ ) fprintf( out, "%12.7f\n", workspace->b_s[i] ); - sfclose( out, "Print_Linear_System::out" ); + sfclose( out, __FILE__, __LINE__ ); snprintf( fname, 100, "%.*s.b_t%10d", 84, control->sim_name, step ); - out = sfopen( fname, "w" ); + out = sfopen( fname, "w", __FILE__, __LINE__ ); for( i = 0; i < system->N; i++ ) fprintf( out, "%12.7f\n", workspace->b_t[i] ); - sfclose( out, "Print_Linear_System::out" );*/ + sfclose( out, __FILE__, __LINE__ );*/ } @@ -796,7 +796,7 @@ void Print_Charges( reax_system *system, control_params *control, FILE *fout; snprintf( fname, 100, "%.*s.q%010d", 87, control->sim_name, step ); - fout = sfopen( fname, "w" ); + fout = sfopen( fname, "w", __FILE__, __LINE__ ); for ( i = 0; i < system->N; ++i ) { @@ -805,7 +805,7 @@ void Print_Charges( reax_system *system, control_params *control, workspace->s[0][i], workspace->t[0][i], system->atoms[i].q ); } - sfclose( fout, "Print_Charges::fout" ); + sfclose( fout, __FILE__, __LINE__ ); } @@ -849,11 +849,11 @@ void Print_Sparse_Matrix2( sparse_matrix *A, char *fname, char *mode ) if ( mode == NULL ) { - f = sfopen( fname, "w" ); + f = sfopen( fname, "w", __FILE__, __LINE__ ); } else { - f = sfopen( fname, mode ); + f = sfopen( fname, mode, __FILE__, __LINE__ ); } for ( i = 0; i < A->n; ++i ) @@ -871,7 +871,7 @@ void Print_Sparse_Matrix2( sparse_matrix *A, char *fname, char *mode ) fprintf( f, "%6d %6d %24.15f\n", i + 1, A->j[A->start[i + 1] - 1] + 1, A->val[A->start[i + 1] - 1] ); } - sfclose( f, "Print_Sparse_Matrix2::f" ); + sfclose( f, __FILE__, __LINE__ ); } @@ -886,7 +886,7 @@ void Read_Sparse_Matrix2( sparse_matrix *A, char *fname ) real val; FILE *f; - f = sfopen( fname, "r" ); + f = sfopen( fname, "r", __FILE__, __LINE__ ); top = 0; cur_row = 0; @@ -908,7 +908,7 @@ void Read_Sparse_Matrix2( sparse_matrix *A, char *fname ) A->start[A->n] = top; - sfclose( f, "Read_Sparse_Matrix2::f" ); + sfclose( f, __FILE__, __LINE__ ); } @@ -923,14 +923,14 @@ void Read_Permutation_Matrix( unsigned int *v, char *fname ) double val; FILE *f; - f = sfopen( fname, "r" ); + f = sfopen( fname, "r", __FILE__, __LINE__ ); while ( fscanf( f, "%6u %6u %24lf", &row, &col, &val ) == 3 ) { v[row - 1] = col - 1; } - sfclose( f, "Read_Permuation_Matrix::f" ); + sfclose( f, __FILE__, __LINE__ ); } @@ -941,7 +941,7 @@ void Print_Sparse_Matrix_Binary( sparse_matrix *A, char *fname ) int i, j, temp; FILE *f; - f = sfopen( fname, "wb" ); + f = sfopen( fname, "wb", __FILE__, __LINE__ ); /* header: # rows, # nonzeros */ fwrite( &A->n, sizeof(unsigned int), 1, f ); @@ -967,7 +967,7 @@ void Print_Sparse_Matrix_Binary( sparse_matrix *A, char *fname ) } } - sfclose( f, "Print_Sparse_Matrix_Binary::f" ); + sfclose( f, __FILE__, __LINE__ ); } @@ -976,7 +976,7 @@ void Print_Bonds( reax_system *system, reax_list *bonds, char *fname ) int i, pj; bond_data *pbond; bond_order_data *bo_ij; - FILE *f = sfopen( fname, "w" ); + FILE *f = sfopen( fname, "w", __FILE__, __LINE__ ); for ( i = 0; i < system->N; ++i ) { @@ -992,14 +992,14 @@ void Print_Bonds( reax_system *system, reax_list *bonds, char *fname ) } } - sfclose( f, "Print_Bonds::f" ); + sfclose( f, __FILE__, __LINE__ ); } void Print_Bond_List2( reax_system *system, reax_list *bonds, char *fname ) { int i, j, id_i, id_j, nbr, pj; - FILE *f = sfopen( fname, "w" ); + FILE *f = sfopen( fname, "w", __FILE__, __LINE__ ); int temp[500]; int num = 0; diff --git a/sPuReMD/src/lin_alg.c b/sPuReMD/src/lin_alg.c index 5f630a41a296d0f53991d50f6f95ea3feaa978a1..c6abc8347b38295c43c3f086c2de94310764ec18 100644 --- a/sPuReMD/src/lin_alg.c +++ b/sPuReMD/src/lin_alg.c @@ -119,7 +119,7 @@ void Sort_Matrix_Rows( sparse_matrix * const A ) // #pragma omp parallel default(none) private(i, j, si, ei, temp) shared(stderr) #endif { - temp = smalloc( sizeof(sparse_matrix_entry) * (A->n + 1), "Sort_Matrix_Rows::temp" ); + temp = smalloc( sizeof(sparse_matrix_entry) * (A->n + 1), __FILE__, __LINE__ ); /* sort each row of A using column indices */ #if defined(_OPENMP) @@ -146,7 +146,7 @@ void Sort_Matrix_Rows( sparse_matrix * const A ) } } - sfree( temp, "Sort_Matrix_Rows::temp" ); + sfree( temp, __FILE__, __LINE__ ); } } @@ -242,8 +242,7 @@ void setup_sparse_approx_inverse( const sparse_matrix * const A, Allocate_Matrix( A_spar_patt, A->n, A->n_max, A->m ); } - list = smalloc( sizeof(real) * A->start[A->n], - "setup_sparse_approx_inverse::list" ); + list = smalloc( sizeof(real) * A->start[A->n], __FILE__, __LINE__ ); /* quick-select algorithm for finding the k-th greatest element in the matrix, where * list: values from the matrix @@ -366,7 +365,7 @@ void setup_sparse_approx_inverse( const sparse_matrix * const A, A_spar_patt_full->n_max, A_spar_patt_full->m ); } - sfree( list, "setup_sparse_approx_inverse::list" ); + sfree( list, __FILE__, __LINE__ ); } @@ -399,7 +398,7 @@ void Calculate_Droptol( const sparse_matrix * const A, if ( droptol_local == NULL ) { droptol_local = smalloc( omp_get_num_threads() * A->n * sizeof(real), - "Calculate_Droptol::droptol_local" ); + __FILE__, __LINE__ ); } } @@ -476,7 +475,7 @@ void Calculate_Droptol( const sparse_matrix * const A, #if defined(_OPENMP) #pragma omp master { - sfree( droptol_local, "Calculate_Droptol::droptol_local" ); + sfree( droptol_local, __FILE__, __LINE__ ); } #endif } @@ -552,9 +551,9 @@ real ICHOLT( const sparse_matrix * const A, const real * const droptol, start = Get_Time( ); - Utop = smalloc( (A->n + 1) * sizeof(unsigned int), "ICHOLT::Utop" ); - tmp_j = smalloc( A->n * sizeof(int), "ICHOLT::Utop" ); - tmp_val = smalloc( A->n * sizeof(real), "ICHOLT::Utop" ); + Utop = smalloc( (A->n + 1) * sizeof(unsigned int), __FILE__, __LINE__ ); + tmp_j = smalloc( A->n * sizeof(int), __FILE__, __LINE__ ); + tmp_val = smalloc( A->n * sizeof(real), __FILE__, __LINE__ ); Ltop = 0; tmptop = 0; @@ -683,9 +682,9 @@ real ICHOLT( const sparse_matrix * const A, const real * const droptol, // fprintf( stderr, "nnz(U): %d, max: %d\n", Utop[U->n], U->n * 50 ); - sfree( tmp_val, "ICHOLT::tmp_val" ); - sfree( tmp_j, "ICHOLT::tmp_j" ); - sfree( Utop, "ICHOLT::Utop" ); + sfree( tmp_val, __FILE__, __LINE__ ); + sfree( tmp_j, __FILE__, __LINE__ ); + sfree( Utop, __FILE__, __LINE__ ); return Get_Timing_Info( start ); } @@ -824,8 +823,8 @@ real ILUT( const sparse_matrix * const A, const real * const droptol, start = Get_Time( ); /* use a dense vector with masking for the intermediate row w */ - w = smalloc( sizeof(real) * A->n, "ILUT::w" ); - nz_mask = smalloc( sizeof(unsigned int) * A->n, "ILUT::nz_mask" ); + w = smalloc( sizeof(real) * A->n, __FILE__, __LINE__ ); + nz_mask = smalloc( sizeof(unsigned int) * A->n, __FILE__, __LINE__ ); compute_full_sparse_matrix( A, A_full, FALSE ); @@ -900,8 +899,8 @@ real ILUT( const sparse_matrix * const A, const real * const droptol, if ( Ltop + nz_cnt > L->m ) { L->m = MAX( (5 * nz_cnt) + L->m, (unsigned int) (L->m * SAFE_ZONE) ); - L->j = srealloc( L->j, sizeof(unsigned int) * L->m, "ILUT::L->j" ); - L->val = srealloc( L->val, sizeof(real) * L->m, "ILUT::L->val" ); + L->j = srealloc( L->j, sizeof(unsigned int) * L->m, __FILE__, __LINE__ ); + L->val = srealloc( L->val, sizeof(real) * L->m, __FILE__, __LINE__ ); } /* copy w[0:i-1] to row i of L */ @@ -928,8 +927,8 @@ real ILUT( const sparse_matrix * const A, const real * const droptol, if ( Utop + nz_cnt > U->m ) { U->m = MAX( (5 * nz_cnt) + U->m, (unsigned int) (U->m * SAFE_ZONE) ); - U->j = srealloc( U->j, sizeof(unsigned int) * U->m, "ILUT::L->j" ); - U->val = srealloc( U->val, sizeof(real) * U->m, "ILUT::L->val" ); + U->j = srealloc( U->j, sizeof(unsigned int) * U->m, __FILE__, __LINE__ ); + U->val = srealloc( U->val, sizeof(real) * U->m, __FILE__, __LINE__ ); } /* diagonal for U */ @@ -954,8 +953,8 @@ real ILUT( const sparse_matrix * const A, const real * const droptol, U->start[U->n] = Utop; Deallocate_Matrix( A_full ); - sfree( nz_mask, "ILUT::nz_mask" ); - sfree( w, "ILUT::w" ); + sfree( nz_mask, __FILE__, __LINE__ ); + sfree( w, __FILE__, __LINE__ ); return Get_Timing_Info( start ); } @@ -980,10 +979,10 @@ real ILUTP( const sparse_matrix * const A, const real * const droptol, start = Get_Time( ); /* use a dense vector with masking for the intermediate row w */ - w = smalloc( sizeof(real) * A->n, "ILUTP::w" ); - nz_mask = smalloc( sizeof(int) * A->n, "ILUTP::nz_mask" ); - perm = smalloc( sizeof(int) * A->n, "ILUTP::perm" ); - perm_inv = smalloc( sizeof(int) * A->n, "ILUTP::perm_inv" ); + w = smalloc( sizeof(real) * A->n, __FILE__, __LINE__ ); + nz_mask = smalloc( sizeof(int) * A->n, __FILE__, __LINE__ ); + perm = smalloc( sizeof(int) * A->n, __FILE__, __LINE__ ); + perm_inv = smalloc( sizeof(int) * A->n, __FILE__, __LINE__ ); compute_full_sparse_matrix( A, A_full, FALSE ); @@ -1112,10 +1111,10 @@ real ILUTP( const sparse_matrix * const A, const real * const droptol, U->start[U->n] = Utop; Deallocate_Matrix( A_full ); - sfree( perm_inv, "ILUTP::perm_inv" ); - sfree( perm, "ILUTP::perm" ); - sfree( nz_mask, "ILUTP::nz_mask" ); - sfree( w, "ILUTP::w" ); + sfree( perm_inv, __FILE__, __LINE__ ); + sfree( perm, __FILE__, __LINE__ ); + sfree( nz_mask, __FILE__, __LINE__ ); + sfree( w, __FILE__, __LINE__ ); return Get_Timing_Info( start ); } @@ -1144,9 +1143,9 @@ real FG_ICHOLT( const sparse_matrix * const A, const real * droptol, Allocate_Matrix( &DAD, A->n, A->n_max, A->m ); Allocate_Matrix( &U_T_temp, A->n, A->n_max, A->m ); - D = smalloc( sizeof(real) * A->n, "FG_ICHOLT::D" ); - D_inv = smalloc( sizeof(real) * A->n, "FG_ICHOLT::D_inv" ); - gamma = smalloc( sizeof(real) * A->n, "FG_ICHOLT::gamma" ); + D = smalloc( sizeof(real) * A->n, __FILE__, __LINE__ ); + D_inv = smalloc( sizeof(real) * A->n, __FILE__, __LINE__ ); + gamma = smalloc( sizeof(real) * A->n, __FILE__, __LINE__ ); #if defined(_OPENMP) #pragma omp parallel for schedule(dynamic,512) \ @@ -1321,9 +1320,9 @@ real FG_ICHOLT( const sparse_matrix * const A, const real * droptol, Deallocate_Matrix( &U_T_temp ); Deallocate_Matrix( &DAD ); - sfree( gamma, "FG_ICHOLT::gamma" ); - sfree( D_inv, "FG_ICHOLT::D_inv" ); - sfree( D, "FG_ICHOLT::D" ); + sfree( gamma, __FILE__, __LINE__ ); + sfree( D_inv, __FILE__, __LINE__ ); + sfree( D, __FILE__, __LINE__ ); return Get_Timing_Info( start ); } @@ -1353,9 +1352,9 @@ real FG_ILUT( const sparse_matrix * const A, const real * droptol, Allocate_Matrix( &L_temp, A->n, A->n_max, A->m ); Allocate_Matrix( &U_T_temp, A->n, A->n_max, A->m ); - D = smalloc( sizeof(real) * A->n, "FG_ILUT::D" ); - D_inv = smalloc( sizeof(real) * A->n, "FG_ILUT::D_inv" ); - gamma = smalloc( sizeof(real) * A->n, "FG_ILUT::gamma" ); + D = smalloc( sizeof(real) * A->n, __FILE__, __LINE__ ); + D_inv = smalloc( sizeof(real) * A->n, __FILE__, __LINE__ ); + gamma = smalloc( sizeof(real) * A->n, __FILE__, __LINE__ ); #if defined(_OPENMP) #pragma omp parallel for schedule(dynamic,512) \ @@ -1617,9 +1616,9 @@ real FG_ILUT( const sparse_matrix * const A, const real * droptol, Deallocate_Matrix( &U_T_temp ); Deallocate_Matrix( &L_temp ); Deallocate_Matrix( &DAD ); - sfree( gamma, "FG_ILUT::gamma" ); - sfree( D_inv, "FG_ILUT::D_inv" ); - sfree( D, "FG_ILUT::D_inv" ); + sfree( gamma, __FILE__, __LINE__ ); + sfree( D_inv, __FILE__, __LINE__ ); + sfree( D, __FILE__, __LINE__ ); return Get_Timing_Info( start ); } @@ -1677,10 +1676,10 @@ real sparse_approx_inverse( const sparse_matrix * const A, shared(stderr) #endif { - X = smalloc( sizeof(char) * A->n, "sparse_approx_inverse::X" ); - Y = smalloc( sizeof(char) * A->n, "sparse_approx_inverse::Y" ); - pos_x = smalloc( sizeof(int) * A->n, "sparse_approx_inverse::pos_x" ); - pos_y = smalloc( sizeof(int) * A->n, "sparse_approx_inverse::pos_y" ); + X = smalloc( sizeof(char) * A->n, __FILE__, __LINE__ ); + Y = smalloc( sizeof(char) * A->n, __FILE__, __LINE__ ); + pos_x = smalloc( sizeof(int) * A->n, __FILE__, __LINE__ ); + pos_y = smalloc( sizeof(int) * A->n, __FILE__, __LINE__ ); e_j = NULL; dense_matrix = NULL; @@ -1750,15 +1749,13 @@ real sparse_approx_inverse( const sparse_matrix * const A, /* N x M dense matrix */ if ( dense_matrix == NULL ) { - dense_matrix = smalloc( sizeof(real) * N * M, - "sparse_approx_inverse::dense_matrix" ); + dense_matrix = smalloc( sizeof(real) * N * M, __FILE__, __LINE__ ); dense_matrix_size = sizeof(real) * N * M; } else if ( dense_matrix_size < sizeof(real) * N * M ) { - sfree( dense_matrix, "sparse_approx_inverse::dense_matrix" ); - dense_matrix = smalloc( sizeof(real) * N * M, - "sparse_approx_inverse::dense_matrix" ); + sfree( dense_matrix, __FILE__, __LINE__ ); + dense_matrix = smalloc( sizeof(real) * N * M, __FILE__, __LINE__ ); dense_matrix_size = sizeof(real) * N * M; } @@ -1786,13 +1783,13 @@ real sparse_approx_inverse( const sparse_matrix * const A, * that is the full column of the identity matrix */ if ( e_j == NULL ) { - e_j = smalloc( sizeof(real) * M, "sparse_approx_inverse::e_j" ); + e_j = smalloc( sizeof(real) * M, __FILE__, __LINE__ ); e_j_size = sizeof(real) * M; } else if ( e_j_size < sizeof(real) * M ) { - sfree( e_j, "sparse_approx_inverse::e_j" ); - e_j = smalloc( sizeof(real) * M, "sparse_approx_inverse::e_j" ); + sfree( e_j, __FILE__, __LINE__ ); + e_j = smalloc( sizeof(real) * M, __FILE__, __LINE__ ); e_j_size = sizeof(real) * M; } @@ -1833,12 +1830,12 @@ real sparse_approx_inverse( const sparse_matrix * const A, } } - sfree( dense_matrix, "sparse_approx_inverse::dense_matrix" ); - sfree( e_j, "sparse_approx_inverse::e_j" ); - sfree( pos_y, "sparse_approx_inverse::pos_y" ); - sfree( pos_x, "sparse_approx_inverse::pos_x" ); - sfree( Y, "sparse_approx_inverse::Y" ); - sfree( X, "sparse_approx_inverse::X" ); + sfree( dense_matrix, __FILE__, __LINE__ ); + sfree( e_j, __FILE__, __LINE__ ); + sfree( pos_y, __FILE__, __LINE__ ); + sfree( pos_x, __FILE__, __LINE__ ); + sfree( Y, __FILE__, __LINE__ ); + sfree( X, __FILE__, __LINE__ ); } return Get_Timing_Info( start ); @@ -1945,7 +1942,7 @@ void Transpose( const sparse_matrix * const A, sparse_matrix * const A_t ) { unsigned int i, j, pj, *A_t_top; - A_t_top = scalloc( A->n + 1, sizeof(unsigned int), "Transpose::A_t_top" ); + A_t_top = scalloc( A->n + 1, sizeof(unsigned int), __FILE__, __LINE__ ); for ( i = 0; i < A->n + 1; ++i ) { @@ -1980,7 +1977,7 @@ void Transpose( const sparse_matrix * const A, sparse_matrix * const A_t ) } } - sfree( A_t_top, "Transpose::A_t_top" ); + sfree( A_t_top, __FILE__, __LINE__ ); } @@ -2317,8 +2314,8 @@ void graph_coloring( const control_params * const control, } } - fb_color = smalloc( sizeof(int) * A->n, "graph_coloring::fb_color" ); - conflict_local = smalloc( sizeof(unsigned int) * A->n, "graph_coloring::fb_color" ); + fb_color = smalloc( sizeof(int) * A->n, __FILE__, __LINE__ ); + conflict_local = smalloc( sizeof(unsigned int) * A->n, __FILE__, __LINE__ ); while ( workspace->recolor_cnt > 0 ) { @@ -2415,8 +2412,8 @@ void graph_coloring( const control_params * const control, p_conflict = p_temp; } - sfree( conflict_local, "graph_coloring::conflict_local" ); - sfree( fb_color, "graph_coloring::fb_color" ); + sfree( conflict_local, __FILE__, __LINE__ ); + sfree( fb_color, __FILE__, __LINE__ ); } } @@ -3925,7 +3922,7 @@ real condest( const sparse_matrix * const L, const sparse_matrix * const U ) N = L->n; - e = smalloc( sizeof(real) * N, "condest::e" ); + e = smalloc( sizeof(real) * N, __FILE__, __LINE__ ); for ( i = 0; i < N; ++i ) e[i] = 1.0; @@ -3944,7 +3941,7 @@ real condest( const sparse_matrix * const L, const sparse_matrix * const U ) } - sfree( e, "condest::e" ); + sfree( e, __FILE__, __LINE__ ); return c; } diff --git a/sPuReMD/src/list.c b/sPuReMD/src/list.c index 21dd6a69e64ad0e742f939e8d31440c684b1ccd0..fd9087e4f23de79b6a1b1a06ec58d0941fdf2c8b 100644 --- a/sPuReMD/src/list.c +++ b/sPuReMD/src/list.c @@ -44,8 +44,8 @@ void Make_List( int n, int n_max, int total_intrs, int type, reax_list* l ) l->n_max = n_max; l->total_intrs = total_intrs; - l->index = smalloc( n_max * sizeof(int), "Make_List::l->index" ); - l->end_index = smalloc( n_max * sizeof(int), "Make_List::l->end_index" ); + l->index = smalloc( n_max * sizeof(int), __FILE__, __LINE__ ); + l->end_index = smalloc( n_max * sizeof(int), __FILE__, __LINE__ ); switch ( type ) { @@ -53,7 +53,7 @@ void Make_List( int n, int n_max, int total_intrs, int type, reax_list* l ) if ( l->total_intrs > 0 ) { l->three_body_list = smalloc( l->total_intrs * sizeof(three_body_interaction_data), - "Make_List::l->three_body_list" ); + __FILE__, __LINE__ ); } else { @@ -65,7 +65,7 @@ void Make_List( int n, int n_max, int total_intrs, int type, reax_list* l ) if ( l->total_intrs > 0 ) { l->bond_list = smalloc( l->total_intrs * sizeof(bond_data), - "Make_List::l->bond_list" ); + __FILE__, __LINE__ ); } else { @@ -77,7 +77,7 @@ void Make_List( int n, int n_max, int total_intrs, int type, reax_list* l ) if ( l->total_intrs > 0 ) { l->dbo_list = smalloc( l->total_intrs * sizeof(dbond_data), - "Make_List::l->dbo_list" ); + __FILE__, __LINE__ ); } else { @@ -89,7 +89,7 @@ void Make_List( int n, int n_max, int total_intrs, int type, reax_list* l ) if ( l->total_intrs > 0 ) { l->dDelta_list = smalloc( l->total_intrs * sizeof(dDelta_data), - "Make_List::l->dDelta_list" ); + __FILE__, __LINE__ ); } else { @@ -101,7 +101,7 @@ void Make_List( int n, int n_max, int total_intrs, int type, reax_list* l ) if ( l->total_intrs > 0 ) { l->far_nbr_list = smalloc( l->total_intrs * sizeof(far_neighbor_data), - "Make_List::l->far_nbr_list" ); + __FILE__, __LINE__ ); } else { @@ -113,7 +113,7 @@ void Make_List( int n, int n_max, int total_intrs, int type, reax_list* l ) if ( l->total_intrs > 0 ) { l->near_nbr_list = smalloc( l->total_intrs * sizeof(near_neighbor_data), - "Make_List::l->near_nbr_list" ); + __FILE__, __LINE__ ); } else { @@ -125,7 +125,7 @@ void Make_List( int n, int n_max, int total_intrs, int type, reax_list* l ) if ( l->total_intrs > 0 ) { l->hbond_list = smalloc( l->total_intrs * sizeof(hbond_data), - "Make_List::l->hbond_list" ); + __FILE__, __LINE__ ); } else { @@ -157,57 +157,57 @@ void Delete_List( int type, reax_list* l ) l->n_max = 0; l->total_intrs = 0; - sfree( l->index, "Delete_List::l->index" ); - sfree( l->end_index, "Delete_List::l->end_index" ); + sfree( l->index, __FILE__, __LINE__ ); + sfree( l->end_index, __FILE__, __LINE__ ); switch ( type ) { case TYP_THREE_BODY: if ( l->three_body_list != NULL ) { - sfree( l->three_body_list, "Delete_List::l->three_body_list" ); + sfree( l->three_body_list, __FILE__, __LINE__ ); } break; case TYP_BOND: if ( l->bond_list != NULL ) { - sfree( l->bond_list, "Delete_List::l->bond_list" ); + sfree( l->bond_list, __FILE__, __LINE__ ); } break; case TYP_DBO: if ( l->dbo_list != NULL ) { - sfree( l->dbo_list, "Delete_List::l->dbo_list" ); + sfree( l->dbo_list, __FILE__, __LINE__ ); } break; case TYP_DDELTA: if ( l->dDelta_list != NULL ) { - sfree( l->dDelta_list, "Delete_List::l->dDelta_list" ); + sfree( l->dDelta_list, __FILE__, __LINE__ ); } break; case TYP_FAR_NEIGHBOR: if ( l->far_nbr_list != NULL ) { - sfree( l->far_nbr_list, "Delete_List::l->far_nbr_list" ); + sfree( l->far_nbr_list, __FILE__, __LINE__ ); } break; case TYP_NEAR_NEIGHBOR: if ( l->near_nbr_list != NULL ) { - sfree( l->near_nbr_list, "Delete_List::l->near_nbr_list" ); + sfree( l->near_nbr_list, __FILE__, __LINE__ ); } break; case TYP_HBOND: if ( l->hbond_list != NULL ) { - sfree( l->hbond_list, "Delete_List::l->hbond_list" ); + sfree( l->hbond_list, __FILE__, __LINE__ ); } break; diff --git a/sPuReMD/src/lookup.c b/sPuReMD/src/lookup.c index a7b0b99c139e65034ea1591796649becb4a029bf..ec2b4b5441719f5c40563ffb9b3a73a0c67c948a 100644 --- a/sPuReMD/src/lookup.c +++ b/sPuReMD/src/lookup.c @@ -58,11 +58,11 @@ static void Natural_Cubic_Spline( const real *h, const real *f, real *a, *b, *c, *d, *v; /* allocate space for linear system */ - a = smalloc( sizeof(real) * n, "Natural_Cubic_Spline::a" ); - b = smalloc( sizeof(real) * n, "Natural_Cubic_Spline::b" ); - c = smalloc( sizeof(real) * n, "Natural_Cubic_Spline::c" ); - d = smalloc( sizeof(real) * n, "Natural_Cubic_Spline::d" ); - v = smalloc( sizeof(real) * n, "Natural_Cubic_Spline::v" ); + a = smalloc( sizeof(real) * n, __FILE__, __LINE__ ); + b = smalloc( sizeof(real) * n, __FILE__, __LINE__ ); + c = smalloc( sizeof(real) * n, __FILE__, __LINE__ ); + d = smalloc( sizeof(real) * n, __FILE__, __LINE__ ); + v = smalloc( sizeof(real) * n, __FILE__, __LINE__ ); /* build linear system */ a[0] = 0.0; @@ -113,11 +113,11 @@ static void Natural_Cubic_Spline( const real *h, const real *f, coef[i - 1].a = f[i]; } - sfree( a, "Natural_Cubic_Spline::a" ); - sfree( b, "Natural_Cubic_Spline::b" ); - sfree( c, "Natural_Cubic_Spline::c" ); - sfree( d, "Natural_Cubic_Spline::d" ); - sfree( v, "Natural_Cubic_Spline::v" ); + sfree( a, __FILE__, __LINE__ ); + sfree( b, __FILE__, __LINE__ ); + sfree( c, __FILE__, __LINE__ ); + sfree( d, __FILE__, __LINE__ ); + sfree( v, __FILE__, __LINE__ ); } @@ -128,11 +128,11 @@ static void Complete_Cubic_Spline( const real *h, const real *f, real v0, real v real *a, *b, *c, *d, *v; /* allocate space for the linear system */ - a = smalloc( sizeof(real) * n, "Complete_Cubic_Spline::a" ); - b = smalloc( sizeof(real) * n, "Complete_Cubic_Spline::b" ); - c = smalloc( sizeof(real) * n, "Complete_Cubic_Spline::c" ); - d = smalloc( sizeof(real) * n, "Complete_Cubic_Spline::d" ); - v = smalloc( sizeof(real) * n, "Complete_Cubic_Spline::v" ); + a = smalloc( sizeof(real) * n, __FILE__, __LINE__ ); + b = smalloc( sizeof(real) * n, __FILE__, __LINE__ ); + c = smalloc( sizeof(real) * n, __FILE__, __LINE__ ); + d = smalloc( sizeof(real) * n, __FILE__, __LINE__ ); + v = smalloc( sizeof(real) * n, __FILE__, __LINE__ ); /* build the linear system */ a[0] = 0.0; @@ -176,11 +176,11 @@ static void Complete_Cubic_Spline( const real *h, const real *f, real v0, real v coef[i - 1].a = f[i]; } - sfree( a, "Complete_Cubic_Spline::a" ); - sfree( b, "Complete_Cubic_Spline::b" ); - sfree( c, "Complete_Cubic_Spline::c" ); - sfree( d, "Complete_Cubic_Spline::d" ); - sfree( v, "Complete_Cubic_Spline::v" ); + sfree( a, __FILE__, __LINE__ ); + sfree( b, __FILE__, __LINE__ ); + sfree( c, __FILE__, __LINE__ ); + sfree( d, __FILE__, __LINE__ ); + sfree( v, __FILE__, __LINE__ ); } @@ -239,27 +239,21 @@ void Make_LR_Lookup_Table( reax_system *system, control_params *control, num_atom_types = system->reax_param.num_atom_types; dr = control->nonb_cut / control->tabulate; - h = scalloc( control->tabulate + 2, sizeof(real), - "Make_LR_Lookup_Table::h" ); - fh = scalloc( control->tabulate + 2, sizeof(real), - "Make_LR_Lookup_Table::fh" ); - fvdw = scalloc( control->tabulate + 2, sizeof(real), - "Make_LR_Lookup_Table::fvdw" ); - fCEvd = scalloc( control->tabulate + 2, sizeof(real), - "Make_LR_Lookup_Table::fCEvd" ); - fele = scalloc( control->tabulate + 2, sizeof(real), - "Make_LR_Lookup_Table::fele" ); - fCEclmb = scalloc( control->tabulate + 2, sizeof(real), - "Make_LR_Lookup_Table::fCEclmb" ); + h = scalloc( control->tabulate + 2, sizeof(real), __FILE__, __LINE__ ); + fh = scalloc( control->tabulate + 2, sizeof(real), __FILE__, __LINE__ ); + fvdw = scalloc( control->tabulate + 2, sizeof(real), __FILE__, __LINE__ ); + fCEvd = scalloc( control->tabulate + 2, sizeof(real), __FILE__, __LINE__ ); + fele = scalloc( control->tabulate + 2, sizeof(real), __FILE__, __LINE__ ); + fCEclmb = scalloc( control->tabulate + 2, sizeof(real), __FILE__, __LINE__ ); /* allocate Long-Range LookUp Table space based on number of atom types in the ffield file */ - workspace->LR = (LR_lookup_table**) smalloc( num_atom_types * sizeof(LR_lookup_table*), - "Make_LR_Lookup_Table::LR" ); + workspace->LR = smalloc( num_atom_types * sizeof(LR_lookup_table*), + __FILE__, __LINE__ ); for ( i = 0; i < num_atom_types; ++i ) { - workspace->LR[i] = (LR_lookup_table*) smalloc( num_atom_types * sizeof(LR_lookup_table), - "Make_LR_Lookup_Table::LR[i]"); + workspace->LR[i] = smalloc( num_atom_types * sizeof(LR_lookup_table), + __FILE__, __LINE__ ); } /* most atom types in ffield file will not exist in the current @@ -291,22 +285,22 @@ void Make_LR_Lookup_Table( reax_system *system, control_params *control, workspace->LR[i][j].inv_dx = control->tabulate / control->nonb_cut; workspace->LR[i][j].y = smalloc( workspace->LR[i][j].n * sizeof(LR_data), - "Make_LR_Lookup_Table::LR[i][j].y" ); + __FILE__, __LINE__ ); workspace->LR[i][j].H = smalloc( workspace->LR[i][j].n * sizeof(cubic_spline_coef), - "Make_LR_Lookup_Table::LR[i][j].H" ); + __FILE__, __LINE__ ); workspace->LR[i][j].vdW = smalloc( workspace->LR[i][j].n * sizeof(cubic_spline_coef), - "Make_LR_Lookup_Table::LR[i][j].vdW" ); + __FILE__, __LINE__ ); workspace->LR[i][j].CEvd = smalloc( workspace->LR[i][j].n * sizeof(cubic_spline_coef), - "Make_LR_Lookup_Table::LR[i][j].CEvd" ); + __FILE__, __LINE__ ); workspace->LR[i][j].ele = smalloc( workspace->LR[i][j].n * sizeof(cubic_spline_coef), - "Make_LR_Lookup_Table::LR[i][j].ele" ); + __FILE__, __LINE__ ); workspace->LR[i][j].CEclmb = smalloc( workspace->LR[i][j].n * sizeof(cubic_spline_coef), - "Make_LR_Lookup_Table::LR[i][j].CEclmb" ); + __FILE__, __LINE__ ); for ( r = 1; r <= control->tabulate; ++r ) { @@ -417,12 +411,12 @@ void Make_LR_Lookup_Table( reax_system *system, control_params *control, fprintf( stderr, "eele_maxerr: %24.15e\n", eele_maxerr ); *******/ - sfree( h, "Make_LR_Lookup_Table::h" ); - sfree( fh, "Make_LR_Lookup_Table::fh" ); - sfree( fvdw, "Make_LR_Lookup_Table::fvdw" ); - sfree( fCEvd, "Make_LR_Lookup_Table::fCEvd" ); - sfree( fele, "Make_LR_Lookup_Table::fele" ); - sfree( fCEclmb, "Make_LR_Lookup_Table::fCEclmb" ); + sfree( h, __FILE__, __LINE__ ); + sfree( fh, __FILE__, __LINE__ ); + sfree( fvdw, __FILE__, __LINE__ ); + sfree( fCEvd, __FILE__, __LINE__ ); + sfree( fele, __FILE__, __LINE__ ); + sfree( fCEclmb, __FILE__, __LINE__ ); } @@ -452,18 +446,18 @@ void Finalize_LR_Lookup_Table( reax_system *system, control_params *control, { if ( existing_types[j] ) { - sfree( workspace->LR[i][j].y, "Finalize_LR_Lookup_Table::LR[i][j].y" ); - sfree( workspace->LR[i][j].H, "Finalize_LR_Lookup_Table::LR[i][j].H" ); - sfree( workspace->LR[i][j].vdW, "Finalize_LR_Lookup_Table::LR[i][j].vdW" ); - sfree( workspace->LR[i][j].CEvd, "Finalize_LR_Lookup_Table::LR[i][j].CEvd" ); - sfree( workspace->LR[i][j].ele, "Finalize_LR_Lookup_Table::LR[i][j].ele" ); - sfree( workspace->LR[i][j].CEclmb, "Finalize_LR_Lookup_Table::LR[i][j].CEclmb" ); + sfree( workspace->LR[i][j].y, __FILE__, __LINE__ ); + sfree( workspace->LR[i][j].H, __FILE__, __LINE__ ); + sfree( workspace->LR[i][j].vdW, __FILE__, __LINE__ ); + sfree( workspace->LR[i][j].CEvd, __FILE__, __LINE__ ); + sfree( workspace->LR[i][j].ele, __FILE__, __LINE__ ); + sfree( workspace->LR[i][j].CEclmb, __FILE__, __LINE__ ); } } } - sfree( workspace->LR[i], "Finalize_LR_Lookup_Table::LR[i]" ); + sfree( workspace->LR[i], __FILE__, __LINE__ ); } - sfree( workspace->LR, "Finalize_LR_Lookup_Table::LR" ); + sfree( workspace->LR, __FILE__, __LINE__ ); } diff --git a/sPuReMD/src/reax_types.h b/sPuReMD/src/reax_types.h index be9c48fe94c5739625d1d3fcda28ac2ec81b5fea..2179e26a4cc5fb4a93d522d52e9a7347fdec8ab5 100644 --- a/sPuReMD/src/reax_types.h +++ b/sPuReMD/src/reax_types.h @@ -759,8 +759,10 @@ struct reax_atom { /* integer representation of element type of this atom */ int type; - /* TRUE if the atom is a dummy atom, FALSE otherwise */ - int dummy; + /* TRUE if the atom is a dummy atom, FALSE otherwise + * Note: dummy atoms do not form bonds but participate + * in other (non-bonded) interactions */ + int is_dummy; /* relative coordinates in terms of periodic images of the * simulation box which are used to track if this atom moves * between images between simulation steps which regenerate diff --git a/sPuReMD/src/restart.c b/sPuReMD/src/restart.c index 43ef92027138ace8de2199b232732c068fdd23a8..037d2870598d01a7a2ebfe19904f4077eae6d5c6 100644 --- a/sPuReMD/src/restart.c +++ b/sPuReMD/src/restart.c @@ -38,7 +38,7 @@ void Write_Binary_Restart( reax_system *system, control_params *control, restart_atom res_data; snprintf( fname, MAX_STR, "%.*s.res%d", MAX_STR - 12, control->sim_name, data->step ); - fres = sfopen( fname, "wb" ); + fres = sfopen( fname, "wb", __FILE__, __LINE__ ); res_header.step = data->step; res_header.N = system->N; @@ -63,7 +63,7 @@ void Write_Binary_Restart( reax_system *system, control_params *control, fwrite( &res_data, sizeof(restart_atom), 1, fres ); } - sfclose( fres, "Write_Binary_Restart::fres" ); + sfclose( fres, __FILE__, __LINE__ ); #if defined(DEBUG_FOCUS) fprintf( stderr, "write restart - " ); @@ -81,7 +81,7 @@ void Read_Binary_Restart( const char * const fname, reax_system *system, restart_header res_header; restart_atom res_data; - fres = sfopen( fname, "rb" ); + fres = sfopen( fname, "rb", __FILE__, __LINE__ ); /* parse header of restart file */ fread( &res_header, sizeof(restart_header), 1, fres ); @@ -139,7 +139,7 @@ void Read_Binary_Restart( const char * const fname, reax_system *system, fprintf( stderr, "system->N: %d, i: %d\n", system->N, i ); #endif - sfclose( fres, "Read_Binary_Restart::fres" ); + sfclose( fres, __FILE__, __LINE__ ); data->step = data->prev_steps; /* target num. of MD sim. steps (nsteps) @@ -157,7 +157,7 @@ void Write_ASCII_Restart( reax_system *system, control_params *control, reax_atom *p_atom; snprintf( fname, MAX_STR + 8, "%s.res%d", control->sim_name, data->step ); - fres = sfopen( fname, "w" ); + fres = sfopen( fname, "w", __FILE__, __LINE__ ); fprintf( fres, RESTART_HEADER, data->step, system->N, data->therm.T, data->therm.xi, @@ -176,7 +176,7 @@ void Write_ASCII_Restart( reax_system *system, control_params *control, p_atom->v[0], p_atom->v[1], p_atom->v[2] ); } - sfclose( fres, "Write_ASCII_Restart::fres" ); + sfclose( fres, __FILE__, __LINE__ ); #if defined(DEBUG_FOCUS) fprintf( stderr, "write restart - " ); @@ -192,7 +192,7 @@ void Read_ASCII_Restart( const char * const fname, reax_system *system, FILE *fres; reax_atom *p_atom; - fres = sfopen( fname, "r" ); + fres = sfopen( fname, "r", __FILE__, __LINE__ ); /* parse header of restart file */ fscanf( fres, READ_RESTART_HEADER, @@ -238,7 +238,7 @@ void Read_ASCII_Restart( const char * const fname, reax_system *system, workspace->map_serials[workspace->orig_id[i]] = i; } - sfclose( fres, "Read_ASCII_Restart::fres" ); + sfclose( fres, __FILE__, __LINE__ ); data->step = data->prev_steps; /* target num. of MD sim. steps (nsteps) diff --git a/sPuReMD/src/spuremd.c b/sPuReMD/src/spuremd.c index b3f5ebd83cdd329829800735679f779801b80562..564f3312c860d1376b205bb86761e415b1a20b58 100644 --- a/sPuReMD/src/spuremd.c +++ b/sPuReMD/src/spuremd.c @@ -158,30 +158,19 @@ static void Allocate_Top_Level_Structs( spuremd_handle ** handle ) int i; /* top-level allocation */ - *handle = smalloc( sizeof(spuremd_handle), "Allocate_Top_Level_Structs::handle" ); + *handle = smalloc( sizeof(spuremd_handle), __FILE__, __LINE__ ); /* second-level allocations */ - (*handle)->system = smalloc( sizeof(reax_system), - "Allocate_Top_Level_Structs::handle->system" ); - - (*handle)->control = smalloc( sizeof(control_params), - "Allocate_Top_Level_Structs::handle->control" ); - - (*handle)->data = smalloc( sizeof(simulation_data), - "Allocate_Top_Level_Structs::handle->data" ); - - (*handle)->workspace = smalloc( sizeof(static_storage), - "Allocate_Top_Level_Structs::handle->workspace" ); - - (*handle)->lists = smalloc( sizeof(reax_list *) * LIST_N, - "Allocate_Top_Level_Structs::handle->lists" ); + (*handle)->system = smalloc( sizeof(reax_system), __FILE__, __LINE__ ); + (*handle)->control = smalloc( sizeof(control_params), __FILE__, __LINE__ ); + (*handle)->data = smalloc( sizeof(simulation_data), __FILE__, __LINE__ ); + (*handle)->workspace = smalloc( sizeof(static_storage), __FILE__, __LINE__ ); + (*handle)->lists = smalloc( sizeof(reax_list *) * LIST_N, __FILE__, __LINE__ ); for ( i = 0; i < LIST_N; ++i ) { - (*handle)->lists[i] = smalloc( sizeof(reax_list), - "Allocate_Top_Level_Structs::handle->lists[i]" ); + (*handle)->lists[i] = smalloc( sizeof(reax_list), __FILE__, __LINE__ ); } - (*handle)->out_control = smalloc( sizeof(output_controls), - "Allocate_Top_Level_Structs::handle->out_control" ); + (*handle)->out_control = smalloc( sizeof(output_controls), __FILE__, __LINE__ ); } @@ -503,18 +492,18 @@ int cleanup( const void * const handle ) spmd_handle->workspace, spmd_handle->lists, spmd_handle->out_control, spmd_handle->output_enabled, FALSE ); - sfree( spmd_handle->out_control, "cleanup::spmd_handle->out_control" ); + sfree( spmd_handle->out_control, __FILE__, __LINE__ ); for ( i = 0; i < LIST_N; ++i ) { - sfree( spmd_handle->lists[i], "cleanup::spmd_handle->lists[i]" ); + sfree( spmd_handle->lists[i], __FILE__, __LINE__ ); } - sfree( spmd_handle->lists, "cleanup::spmd_handle->lists" ); - sfree( spmd_handle->workspace, "cleanup::spmd_handle->workspace" ); - sfree( spmd_handle->data, "cleanup::spmd_handle->data" ); - sfree( spmd_handle->control, "cleanup::spmd_handle->control" ); - sfree( spmd_handle->system, "cleanup::spmd_handle->system" ); + sfree( spmd_handle->lists, __FILE__, __LINE__ ); + sfree( spmd_handle->workspace, __FILE__, __LINE__ ); + sfree( spmd_handle->data, __FILE__, __LINE__ ); + sfree( spmd_handle->control, __FILE__, __LINE__ ); + sfree( spmd_handle->system, __FILE__, __LINE__ ); - sfree( spmd_handle, "cleanup::spmd_handle" ); + sfree( spmd_handle, __FILE__, __LINE__ ); ret = SPUREMD_SUCCESS; } @@ -997,10 +986,10 @@ void * setup_qmmm( int qm_num_atoms, const char * const qm_symbols, { spmd_handle->system->molec_charge_constraints = smalloc( sizeof(real) * spmd_handle->system->num_molec_charge_constraints, - "setup_qmmm::molec_charge_constraints" ); + __FILE__, __LINE__ ); spmd_handle->system->molec_charge_constraint_ranges = smalloc( sizeof(int) * 2 * spmd_handle->system->num_molec_charge_constraints, - "setup_qmmm::molec_charge_constraint_ranges" ); + __FILE__, __LINE__ ); for ( i = 0; i < spmd_handle->system->num_molec_charge_constraints; ++i ) { @@ -1148,17 +1137,17 @@ int reset_qmmm( const void * const handle, int qm_num_atoms, if ( spmd_handle->system->max_num_molec_charge_constraints > 0 ) { sfree( spmd_handle->system->molec_charge_constraints, - "reset_qmmm::molec_charge_constraints" ); + __FILE__, __LINE__ ); sfree( spmd_handle->system->molec_charge_constraint_ranges, - "reset_qmmm::molec_charge_constraint_ranges" ); + __FILE__, __LINE__ ); } spmd_handle->system->molec_charge_constraints = smalloc( sizeof(real) * spmd_handle->system->num_molec_charge_constraints, - "reset_qmmm::molec_charge_constraints" ); + __FILE__, __LINE__ ); spmd_handle->system->molec_charge_constraint_ranges = smalloc( sizeof(int) * 2 * spmd_handle->system->num_molec_charge_constraints, - "reset_qmmm::molec_charge_constraint_ranges" ); + __FILE__, __LINE__ ); spmd_handle->system->max_num_molec_charge_constraints = spmd_handle->system->num_molec_charge_constraints; diff --git a/sPuReMD/src/tool_box.c b/sPuReMD/src/tool_box.c index 0483e048cec24801e1bf05a1e0f4851818ce11dc..dab56c3393c01ec740274dac33eba96b0b8cd59f 100644 --- a/sPuReMD/src/tool_box.c +++ b/sPuReMD/src/tool_box.c @@ -170,12 +170,24 @@ int is_Valid_Serial( int serial ) } -int Check_Input_Range( int val, int lo, int hi, char *message ) +/* Validate atom serial numbers in BGF geometry file + * + * val: atom serial to validate + * lo: lower limit of valid serial range + * hi: upper limit of valid serial range + * filename: source filename of caller + * line: source line of caller + */ +int Check_Input_Range( int val, int lo, int hi, const char * const filename, + int line ) { if ( val < lo || val > hi ) { - fprintf( stderr, "[ERROR] %s\nInput %d - Out of range %d-%d. Terminating...\n", - message, val, lo, hi ); + fprintf( stderr, "[ERROR] Invalid BGF serial\n" ); + fprintf( stderr, " [INFO] At line %d in file %.*s\n", + line, (int) strlen(filename), filename ); + fprintf( stderr, " [INFO] Input %d - Out of range %d-%d. Terminating...\n", + val, lo, hi ); exit( INVALID_INPUT ); } @@ -290,14 +302,14 @@ void Allocate_Tokenizer_Space( char **line, size_t line_size, { int i; - *line = smalloc( sizeof(char) * line_size, "Allocate_Tokenizer_Space::*line" ); - *backup = smalloc( sizeof(char) * backup_size, "Allocate_Tokenizer_Space::*backup" ); - *tokens = smalloc( sizeof(char*) * num_tokens, "Allocate_Tokenizer_Space::*tokens" ); + *line = smalloc( sizeof(char) * line_size, __FILE__, __LINE__ ); + *backup = smalloc( sizeof(char) * backup_size, __FILE__, __LINE__ ); + *tokens = smalloc( sizeof(char*) * num_tokens, __FILE__, __LINE__ ); for ( i = 0; i < num_tokens; i++ ) { (*tokens)[i] = smalloc( sizeof(char) * token_size, - "Allocate_Tokenizer_Space::(*tokens)[i]" ); + __FILE__, __LINE__ ); } } @@ -309,12 +321,12 @@ void Deallocate_Tokenizer_Space( char **line, char **backup, for ( i = 0; i < num_tokens; i++ ) { - sfree( (*tokens)[i], "Deallocate_Tokenizer_Space::tokens[i]" ); + sfree( (*tokens)[i], __FILE__, __LINE__ ); } - sfree( *line, "Deallocate_Tokenizer_Space::line" ); - sfree( *backup, "Deallocate_Tokenizer_Space::backup" ); - sfree( *tokens, "Deallocate_Tokenizer_Space::tokens" ); + sfree( *line, __FILE__, __LINE__ ); + sfree( *backup, __FILE__, __LINE__ ); + sfree( *tokens, __FILE__, __LINE__ ); } @@ -343,27 +355,30 @@ int Tokenize( char* s, char*** tok, size_t token_len ) } -/***************** taken from lammps ************************/ /* Safe wrapper around libc malloc * * n: num. of bytes to allocated - * name: message with details about pointer, used for warnings/errors + * filename: source filename of caller + * line: source line of caller * * returns: ptr to allocated memory * */ -void * smalloc( size_t n, const char *name ) +void * smalloc( size_t n, const char * const filename, int line ) { void *ptr; if ( n == 0 ) { - fprintf( stderr, "[ERROR] failed to allocate %zu bytes for array %s.\n", - n, name ); + fprintf( stderr, "[ERROR] failed to allocate %zu bytes for array\n", + n ); + fprintf( stderr, " [INFO] At line %d in file %.*s\n", + line, (int) strlen(filename), filename ); exit( INSUFFICIENT_MEMORY ); } #if defined(DEBUG_FOCUS) - fprintf( stderr, "[INFO] requesting memory for %s\n", name ); + fprintf( stderr, "[INFO] requesting allocation of %zu bytes of memory at line %d in file %.*s\n", + n, line, (int) strlen(filename), filename ); fflush( stderr ); #endif @@ -371,8 +386,10 @@ void * smalloc( size_t n, const char *name ) if ( ptr == NULL ) { - fprintf( stderr, "[ERROR] failed to allocate %zu bytes for array %s.\n", - n, name ); + fprintf( stderr, "[ERROR] failed to allocate %zu bytes for array\n", + n ); + fprintf( stderr, " [INFO] At line %d in file %.*s\n", + line, (int) strlen(filename), filename ); exit( INSUFFICIENT_MEMORY ); } @@ -388,29 +405,27 @@ void * smalloc( size_t n, const char *name ) /* Safe wrapper around libc realloc * * n: num. of bytes to reallocated - * name: message with details about pointer, used for warnings/errors + * filename: source filename of caller + * line: source line of caller * * returns: ptr to reallocated memory * */ -void * srealloc( void *ptr, size_t n, const char *name ) +void * srealloc( void *ptr, size_t n, const char * const filename, int line ) { void *new_ptr; if ( n == 0 ) { - fprintf( stderr, "[ERROR] failed to reallocate %zu bytes for array %s.\n", - n, name ); + fprintf( stderr, "[ERROR] failed to reallocate %zu bytes for array\n", + n ); + fprintf( stderr, " [INFO] At line %d in file %.*s\n", + line, (int) strlen(filename), filename ); exit( INSUFFICIENT_MEMORY ); } - if ( ptr == NULL ) - { - fprintf( stderr, "[INFO] trying to allocate %zu NEW bytes for array %s.\n", - n, name ); - } - #if defined(DEBUG_FOCUS) - fprintf( stderr, "[INFO] requesting memory for %s\n", name ); + fprintf( stderr, "[INFO] requesting reallocation of %zu bytes of memory at line %d in file %.*s\n", + n, line, (int) strlen(filename), filename ); fflush( stderr ); #endif @@ -420,8 +435,10 @@ void * srealloc( void *ptr, size_t n, const char *name ) * but we needed more memory, so abort */ if ( new_ptr == NULL ) { - fprintf( stderr, "[ERROR] failed to reallocate %zu bytes for array %s.\n", - n, name ); + fprintf( stderr, "[ERROR] failed to reallocate %zu bytes for array\n", + n ); + fprintf( stderr, " [INFO] At line %d in file %.*s\n", + line, (int) strlen(filename), filename ); exit( INSUFFICIENT_MEMORY ); } @@ -438,23 +455,27 @@ void * srealloc( void *ptr, size_t n, const char *name ) * * n: num. of elements to allocated (each of size bytes) * size: num. of bytes per element - * name: message with details about pointer, used for warnings/errors + * filename: source filename of caller + * line: source line of caller * * returns: ptr to allocated memory, all bits initialized to zeros * */ -void * scalloc( size_t n, size_t size, const char *name ) +void * scalloc( size_t n, size_t size, const char * const filename, int line ) { void *ptr; if ( n == 0 ) { - fprintf( stderr, "[ERROR] failed to allocate %zu bytes for array %s.\n", - n * size, name ); + fprintf( stderr, "[ERROR] failed to allocate %zu bytes for array\n", + n * size ); + fprintf( stderr, " [INFO] At line %d in file %.*s\n", + line, (int) strlen(filename), filename ); exit( INSUFFICIENT_MEMORY ); } #if defined(DEBUG_FOCUS) - fprintf( stderr, "[INFO] requesting memory for %s\n", name ); + fprintf( stderr, "[INFO] requesting allocation of %zu bytes of zeroed memory at line %d in file %.*s\n", + n * size, line, (int) strlen(filename), filename ); fflush( stderr ); #endif @@ -462,8 +483,10 @@ void * scalloc( size_t n, size_t size, const char *name ) if ( ptr == NULL ) { - fprintf( stderr, "[ERROR] failed to allocate %zu bytes for array %s.\n", - n * size, name ); + fprintf( stderr, "[ERROR] failed to allocate %zu bytes for array\n", + n * size ); + fprintf( stderr, " [INFO] At line %d in file %.*s\n", + line, (int) strlen(filename), filename ); exit( INSUFFICIENT_MEMORY ); } @@ -479,19 +502,22 @@ void * scalloc( size_t n, size_t size, const char *name ) /* Safe wrapper around libc free * * ptr: pointer to dynamically allocated memory which will be deallocated - * name: message with details about pointer, used for warnings/errors + * filename: source filename of caller + * line: source line of caller * */ -void sfree( void *ptr, const char *name ) +void sfree( void *ptr, const char * const filename, int line ) { if ( ptr == NULL ) { - fprintf( stderr, "[WARNING] trying to free the already NULL pointer %s!\n", - name ); + fprintf( stderr, "[WARNING] trying to free the already NULL pointer\n" ); + fprintf( stderr, " [INFO] At line %d in file %.*s\n", + line, (int) strlen(filename), filename ); return; } #if defined(DEBUG_FOCUS) - fprintf( stderr, "[INFO] trying to free pointer %s\n", name ); + fprintf( stderr, "[INFO] trying to free pointer at line %d in file %.*s\n", + line, (int) strlen(filename), filename ); fflush( stderr ); fprintf( stderr, "[INFO] address: %p [SFREE]\n", (void *) ptr ); fflush( stderr ); @@ -505,20 +531,27 @@ void sfree( void *ptr, const char *name ) * * fname: name of file to be opened * mode: mode in which to open file + * filename: source filename of caller + * line: source line of caller * */ -FILE * sfopen( const char * fname, const char * mode ) +FILE * sfopen( const char * fname, const char * mode, + const char * const filename, int line ) { FILE * ptr; if ( fname == NULL ) { fprintf( stderr, "[ERROR] trying to open file\n" ); + fprintf( stderr, " [INFO] At line %d in file %.*s\n", + line, (int) strlen(filename), filename ); fprintf( stderr, " [INFO] NULL file name\n" ); exit( INVALID_INPUT ); } if ( mode == NULL ) { fprintf( stderr, "[ERROR] trying to open file\n" ); + fprintf( stderr, " [INFO] At line %d in file %.*s\n", + line, (int) strlen(filename), filename ); fprintf( stderr, " [INFO] NULL mode\n" ); exit( INVALID_INPUT ); } @@ -529,6 +562,8 @@ FILE * sfopen( const char * fname, const char * mode ) { fprintf( stderr, "[ERROR] failed to open file %s with mode %s\n", fname, mode ); + fprintf( stderr, " [INFO] At line %d in file %.*s\n", + line, (int) strlen(filename), filename ); exit( INVALID_INPUT ); } @@ -538,18 +573,19 @@ FILE * sfopen( const char * fname, const char * mode ) /* Safe wrapper around libc fclose * - * fname: name of file to be opened - * mode: mode in which to open file - * msg: message to be printed in case of error + * fp: pointer to file to close + * filename: source filename of caller + * line: source line of caller * */ -void sfclose( FILE * fp, const char * msg ) +void sfclose( FILE * fp, const char * const filename, int line ) { int ret; if ( fp == NULL ) { fprintf( stderr, "[WARNING] trying to close NULL file pointer. Returning...\n" ); - fprintf( stderr, " [INFO] %s\n", msg ); + fprintf( stderr, " [INFO] At line %d in file %.*s\n", + line, (int) strlen(filename), filename ); return; } @@ -558,7 +594,8 @@ void sfclose( FILE * fp, const char * msg ) if ( ret != 0 ) { fprintf( stderr, "[ERROR] error detected when closing file\n" ); - fprintf( stderr, " [INFO] %s\n", msg ); + fprintf( stderr, " [INFO] At line %d in file %.*s\n", + line, (int) strlen(filename), filename ); exit( INVALID_INPUT ); } } diff --git a/sPuReMD/src/tool_box.h b/sPuReMD/src/tool_box.h index 88e333c9a9a6b8d0a0a7a69240e0523177883c67..dbc8028e0b55ebfdce33bed6b6559aeb94912474 100644 --- a/sPuReMD/src/tool_box.h +++ b/sPuReMD/src/tool_box.h @@ -39,7 +39,7 @@ void Make_Point( real, real, real, rvec * ); int is_Valid_Serial( int ); -int Check_Input_Range( int, int, int, char * ); +int Check_Input_Range( int, int, int, const char * const, int ); void Trim_Spaces( char * const, const size_t ); @@ -63,23 +63,20 @@ void Deallocate_Tokenizer_Space( char **, char **, char ***, int Tokenize( char *, char ***, size_t ); -/* from lammps */ -void * smalloc( size_t, const char * ); +void * smalloc( size_t, const char * const, int ); -void * srealloc( void *, size_t, const char * ); +void * srealloc( void *, size_t, const char * const, int ); -void * scalloc( size_t, size_t, const char * ); +void * scalloc( size_t, size_t, const char * const, int ); -void sfree( void *, const char * ); +void sfree( void *, const char * const, int ); -FILE * sfopen( const char *, const char * ); +FILE * sfopen( const char *, const char *, const char * const, int ); -void sfclose( FILE *, const char * ); +void sfclose( FILE *, const char * const, int ); -int sstrtol( const char * const, - const char * const, int ); +int sstrtol( const char * const, const char * const, int ); -double sstrtod( const char * const, - const char * const, int ); +double sstrtod( const char * const, const char * const, int ); #endif