void Validate_Lists( reax_system *system, storage *workspace, reax_list **lists, int step, int n, int N, int numH, MPI_Comm comm ) { int i, comp, Hindex; reax_list *bonds, *hbonds; reallocate_data *realloc; realloc = &(workspace->realloc); /* bond list */ if( N > 0 ) { bonds = *lists + BONDS; for( i = 0; i < N; ++i ) { // if( i < n ) - we need to update ghost estimates for delayed nbrings system->my_atoms[i].num_bonds = MAX(Num_Entries(i,bonds)*2, MIN_BONDS); //if( End_Index(i, bonds) >= Start_Index(i+1, bonds)-2 ) //workspace->realloc.bonds = 1; if( i < N-1 ) comp = Start_Index(i+1, bonds); else comp = bonds->num_intrs; if( End_Index(i, bonds) > comp ) { fprintf( stderr, "step%d-bondchk failed: i=%d end(i)=%d str(i+1)=%d\n", step, i, End_Index(i,bonds), comp ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } } } /* hbonds list */ if( numH > 0 ) { hbonds = *lists + HBONDS; for( i = 0; i < n; ++i ) { Hindex = system->my_atoms[i].Hindex; if( Hindex > -1 ) { system->my_atoms[i].num_hbonds = (int)(MAX( Num_Entries(Hindex, hbonds)*SAFER_ZONE, MIN_HBONDS )); //if( Num_Entries(i, hbonds) >= //(Start_Index(i+1,hbonds)-Start_Index(i,hbonds))*0.90/*DANGER_ZONE*/){ // workspace->realloc.hbonds = 1; if( Hindex < numH-1 ) comp = Start_Index(Hindex+1, hbonds); else comp = hbonds->num_intrs; if( End_Index(Hindex, hbonds) > comp ) { fprintf(stderr,"step%d-hbondchk failed: H=%d end(H)=%d str(H+1)=%d\n", step, Hindex, End_Index(Hindex,hbonds), comp ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } } } } }
void Validate_Lists(static_storage *workspace, list **lists, int step, int n, int Hmax, int Htop, int num_bonds, int num_hbonds) { int i, flag; list *bonds, *hbonds; bonds = *lists + BONDS; hbonds = *lists + HBONDS; /* far neighbors */ if (Htop > Hmax * DANGER_ZONE) { workspace->realloc.Htop = Htop; if (Htop > Hmax) { fprintf(stderr, "step%d - ran out of space on H matrix: Htop=%d, max = %d", step, Htop, Hmax); exit(INSUFFICIENT_SPACE); } } /* bond list */ flag = -1; workspace->realloc.num_bonds = num_bonds; for (i = 0; i < n - 1; ++i) if (End_Index(i, bonds) >= Start_Index(i + 1, bonds) - 2) { workspace->realloc.bonds = 1; if (End_Index(i, bonds) > Start_Index(i + 1, bonds)) flag = i; } if (flag > -1) { fprintf(stderr, "step%d-bondchk failed: i=%d end(i)=%d str(i+1)=%d\n", step, flag, End_Index(flag, bonds), Start_Index(flag + 1, bonds)); exit(INSUFFICIENT_SPACE); } if (End_Index(i, bonds) >= bonds->num_intrs - 2) { workspace->realloc.bonds = 1; if (End_Index(i, bonds) > bonds->num_intrs) { fprintf(stderr, "step%d-bondchk failed: i=%d end(i)=%d bond_end=%d\n", step, flag, End_Index(i, bonds), bonds->num_intrs); exit(INSUFFICIENT_SPACE); } } /* hbonds list */ if (workspace->num_H > 0) { flag = -1; workspace->realloc.num_hbonds = num_hbonds; for (i = 0; i < workspace->num_H - 1; ++i) if (Num_Entries(i, hbonds) >= (Start_Index(i + 1, hbonds) - Start_Index(i, hbonds)) * DANGER_ZONE) { workspace->realloc.hbonds = 1; if (End_Index(i, hbonds) > Start_Index(i + 1, hbonds)) flag = i; } if (flag > -1) { fprintf(stderr, "step%d-hbondchk failed: i=%d end(i)=%d str(i+1)=%d\n", step, flag, End_Index(flag, hbonds), Start_Index(flag + 1, hbonds)); exit(INSUFFICIENT_SPACE); } if (Num_Entries(i, hbonds) >= (hbonds->num_intrs - Start_Index(i, hbonds)) * DANGER_ZONE) { workspace->realloc.hbonds = 1; if (End_Index(i, hbonds) > hbonds->num_intrs) { fprintf(stderr, "step%d-hbondchk failed: i=%d end(i)=%d hbondend=%d\n", step, flag, End_Index(i, hbonds), hbonds->num_intrs); exit(INSUFFICIENT_SPACE); } } } }