void Reallocate_Neighbor_List( reax_list *far_nbrs, int n, int num_intrs, MPI_Comm comm ) { Delete_List( far_nbrs, comm ); if(!Make_List( n, num_intrs, TYP_FAR_NEIGHBOR, far_nbrs, comm )){ fprintf(stderr, "Problem in initializing far nbrs list. Terminating!\n"); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } }
/* * Must be called on the worker that created the bag, no check yet! */ static int p_dbag_dissolve(value vdbag, type tdbag, value vl, type tl) { aport_id_t bag_aport_id; dbag_descr_t *dbag_descr; amsg_t this_msg; amsg_ref_t *this_msg_data_hdr; pword list; register pword *car, *cdr; Check_Integer(tdbag); bag_aport_id = (aport_id_t) vdbag.nint; Check_Output_List(tl); if (aport_get_option(bag_aport_id, APORT_DATA_PTR, (aport_optval_t *) &dbag_descr) != AMSG_OK) { Bip_Error(MPS_ERROR); } this_msg = dbag_descr->first.msg; this_msg_data_hdr = dbag_descr->first.msg_data_hdr; hp_free_size((generic_ptr) dbag_descr, sizeof(dbag_descr_t)); cdr = &list; while (this_msg_data_hdr != &dbag_descr->first) { pword *pw1; amsg_t old_msg; car = TG; Push_List_Frame(); Make_List(cdr, car); cdr = car + 1; pw1 = dbformat_to_term((char*)(this_msg_data_hdr+1), D_UNKNOWN, tdict); if (!pw1) { value va; va.did = d_.abort; Bip_Throw(va, tdict); } car->val.ptr = pw1->val.ptr; car->tag.kernel = pw1->tag.kernel; old_msg = this_msg; this_msg = this_msg_data_hdr->msg; this_msg_data_hdr = this_msg_data_hdr->msg_data_hdr; (void) amsg_free(old_msg); } Make_Nil(cdr); if (aport_deallocate(bag_aport_id) != AMSG_OK) { Bip_Error(MPS_ERROR); } Return_Unify_Pw(vl, tl, list.val, list.tag); }
int Reallocate_Bonds_List( reax_system *system, reax_list *bonds, int *total_bonds, int *est_3body, MPI_Comm comm ) { int i; *total_bonds = 0; *est_3body = 0; for( i = 0; i < system->N; ++i ){ *est_3body += SQR(system->my_atoms[i].num_bonds); // commented out - already updated in validate_lists in forces.c // system->my_atoms[i].num_bonds = MAX( Num_Entries(i,bonds)*2, MIN_BONDS ); *total_bonds += system->my_atoms[i].num_bonds; } *total_bonds = (int)(MAX( *total_bonds * SAFE_ZONE, MIN_CAP*MIN_BONDS )); Delete_List( bonds, comm ); if(!Make_List(system->total_cap, *total_bonds, TYP_BOND, bonds, comm)) { fprintf( stderr, "not enough space for bonds list. terminating!\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } return SUCCESS; }
int Reallocate_HBonds_List( reax_system *system, reax_list *hbonds, MPI_Comm comm ) { int i, id, total_hbonds; total_hbonds = 0; for( i = 0; i < system->n; ++i ) if( (id = system->my_atoms[i].Hindex) >= 0 ) { // commented out - already updated in validate_lists in forces.c // system->my_atoms[i].num_hbonds = MAX(Num_Entries(id,hbonds)*SAFER_ZONE, // MIN_HBONDS); total_hbonds += system->my_atoms[i].num_hbonds; } total_hbonds = (int)(MAX( total_hbonds*SAFER_ZONE, MIN_CAP*MIN_HBONDS )); Delete_List( hbonds, comm ); if( !Make_List( system->Hcap, total_hbonds, TYP_HBOND, hbonds, comm ) ) { fprintf( stderr, "not enough space for hbonds list. terminating!\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } return total_hbonds; }
void ReAllocate( reax_system *system, control_params *control, simulation_data *data, storage *workspace, reax_list **lists, mpi_datatypes *mpi_data ) { int i, j, k, p; int num_bonds, est_3body, nflag, Nflag, Hflag, mpi_flag, ret, total_send; int renbr, newsize; reallocate_data *realloc; reax_list *far_nbrs; sparse_matrix *H; grid *g; neighbor_proc *nbr_pr; mpi_out_data *nbr_data; MPI_Comm comm; char msg[200]; realloc = &(workspace->realloc); g = &(system->my_grid); comm = mpi_data->world; #if defined(DEBUG) fprintf( stderr, "p%d@reallocate: n: %d, N: %d, numH: %d\n", system->my_rank, system->n, system->N, system->numH ); fprintf( stderr, "p%d@reallocate: local_cap: %d, total_cap: %d, Hcap: %d\n", system->my_rank, system->local_cap, system->total_cap, system->Hcap); fprintf( stderr, "p%d: realloc.num_far: %d\n", system->my_rank, realloc->num_far ); fprintf( stderr, "p%d: realloc.H: %d, realloc.Htop: %d\n", system->my_rank, realloc->H, realloc->Htop ); fprintf( stderr, "p%d: realloc.Hbonds: %d, realloc.num_hbonds: %d\n", system->my_rank, realloc->hbonds, realloc->num_hbonds ); fprintf( stderr, "p%d: realloc.bonds: %d, num_bonds: %d\n", system->my_rank, realloc->bonds, realloc->num_bonds ); fprintf( stderr, "p%d: realloc.num_3body: %d\n", system->my_rank, realloc->num_3body ); #endif // IMPORTANT: LOOSE ZONES CHECKS ARE DISABLED FOR NOW BY &&'ing with 0!!! nflag = 0; if( system->n >= DANGER_ZONE * system->local_cap || (0 && system->n <= LOOSE_ZONE * system->local_cap) ) { nflag = 1; system->local_cap = MAX( (int)(system->n * SAFE_ZONE), MIN_CAP ); } Nflag = 0; if( system->N >= DANGER_ZONE * system->total_cap || (0 && system->N <= LOOSE_ZONE * system->total_cap) ) { Nflag = 1; system->total_cap = MAX( (int)(system->N * SAFE_ZONE), MIN_CAP ); } if( Nflag ) { /* system */ #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d: reallocating system and workspace -"\ "n=%d N=%d local_cap=%d total_cap=%d\n", system->my_rank, system->n, system->N, system->local_cap, system->total_cap ); #endif ret = Allocate_System( system, system->local_cap, system->total_cap, msg ); if( ret != SUCCESS ) { fprintf( stderr, "not enough space for atom_list: total_cap=%d", system->total_cap ); fprintf( stderr, "terminating...\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } /* workspace */ DeAllocate_Workspace( control, workspace ); ret = Allocate_Workspace( system, control, workspace, system->local_cap, system->total_cap, comm, msg ); if( ret != SUCCESS ) { fprintf( stderr, "no space for workspace: local_cap=%d total_cap=%d", system->local_cap, system->total_cap ); fprintf( stderr, "terminating...\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } } renbr = (data->step - data->prev_steps) % control->reneighbor == 0; /* far neighbors */ if( renbr ) { far_nbrs = *lists + FAR_NBRS; if( Nflag || realloc->num_far >= far_nbrs->num_intrs * DANGER_ZONE ) { if( realloc->num_far > far_nbrs->num_intrs ) { fprintf( stderr, "step%d-ran out of space on far_nbrs: top=%d, max=%d", data->step, realloc->num_far, far_nbrs->num_intrs ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } newsize = static_cast<int> (MAX( realloc->num_far*SAFE_ZONE, MIN_CAP*MIN_NBRS )); #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d: reallocating far_nbrs: num_fars=%d, space=%dMB\n", system->my_rank, (int)(realloc->num_far*SAFE_ZONE), (newsize*sizeof(far_neighbor_data)/(1024*1024)) ); #endif Reallocate_Neighbor_List( far_nbrs, system->total_cap, newsize, comm ); realloc->num_far = 0; } } #if defined(PURE_REAX) /* qeq coef matrix */ H = workspace->H; if( nflag || realloc->Htop >= H->m * DANGER_ZONE ) { if( realloc->Htop > H->m ) { fprintf( stderr, "step%d - ran out of space on H matrix: Htop=%d, max = %d", data->step, realloc->Htop, H->m ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d: reallocating H matrix: Htop=%d, space=%dMB\n", system->my_rank, (int)(realloc->Htop*SAFE_ZONE), (int)(realloc->Htop * SAFE_ZONE * sizeof(sparse_matrix_entry) / (1024*1024)) ); #endif newsize = static_cast<int> (MAX( realloc->Htop*SAFE_ZONE, MIN_CAP*MIN_NBRS )); Reallocate_Matrix( &(workspace->H), system->local_cap, newsize, "H", comm ); //Deallocate_Matrix( workspace->L ); //Deallocate_Matrix( workspace->U ); workspace->L = NULL; workspace->U = NULL; realloc->Htop = 0; } #endif /*PURE_REAX*/ /* hydrogen bonds list */ if( control->hbond_cut > 0 ) { Hflag = 0; if( system->numH >= DANGER_ZONE * system->Hcap || (0 && system->numH <= LOOSE_ZONE * system->Hcap) ) { Hflag = 1; system->Hcap = MAX( system->numH * SAFER_ZONE, MIN_CAP ); } if( Hflag || realloc->hbonds ) { ret = Reallocate_HBonds_List( system, (*lists)+HBONDS, comm ); realloc->hbonds = 0; #if defined(DEBUG_FOCUS) fprintf(stderr, "p%d: reallocating hbonds: total_hbonds=%d space=%dMB\n", system->my_rank, ret, (int)(ret*sizeof(hbond_data)/(1024*1024))); #endif } } /* bonds list */ num_bonds = est_3body = -1; if( Nflag || realloc->bonds ){ Reallocate_Bonds_List( system, (*lists)+BONDS, &num_bonds, &est_3body, comm ); realloc->bonds = 0; realloc->num_3body = MAX( realloc->num_3body, est_3body ); #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d: reallocating bonds: total_bonds=%d, space=%dMB\n", system->my_rank, num_bonds, (int)(num_bonds*sizeof(bond_data)/(1024*1024)) ); #endif } /* 3-body list */ if( realloc->num_3body > 0 ) { #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d: reallocating 3body list: num_3body=%d, space=%dMB\n", system->my_rank, realloc->num_3body, (int)(realloc->num_3body * sizeof(three_body_interaction_data) / (1024*1024)) ); #endif Delete_List( (*lists)+THREE_BODIES, comm ); if( num_bonds == -1 ) num_bonds = ((*lists)+BONDS)->num_intrs; realloc->num_3body = (int)(MAX(realloc->num_3body*SAFE_ZONE, MIN_3BODIES)); if( !Make_List( num_bonds, realloc->num_3body, TYP_THREE_BODY, (*lists)+THREE_BODIES, comm ) ) { fprintf( stderr, "Problem in initializing angles list. Terminating!\n" ); MPI_Abort( comm, CANNOT_INITIALIZE ); } realloc->num_3body = -1; } #if defined(PURE_REAX) /* grid */ if( renbr && realloc->gcell_atoms > -1 ) { #if defined(DEBUG_FOCUS) fprintf(stderr, "reallocating gcell: g->max_atoms: %d\n", g->max_atoms); #endif for( i = g->native_str[0]; i < g->native_end[0]; i++ ) for( j = g->native_str[1]; j < g->native_end[1]; j++ ) for( k = g->native_str[2]; k < g->native_end[2]; k++ ) { // reallocate g->atoms sfree( g->cells[i][j][k].atoms, "g:atoms" ); g->cells[i][j][k].atoms = (int*) scalloc( realloc->gcell_atoms, sizeof(int), "g:atoms", comm); } realloc->gcell_atoms = -1; } /* mpi buffers */ // we have to be at a renbring step - // to ensure correct values at mpi_buffers for update_boundary_positions if( !renbr ) mpi_flag = 0; // check whether in_buffer capacity is enough else if( system->max_recved >= system->est_recv * 0.90 ) mpi_flag = 1; else { // otherwise check individual outgoing buffers mpi_flag = 0; for( p = 0; p < MAX_NBRS; ++p ) { nbr_pr = &( system->my_nbrs[p] ); nbr_data = &( mpi_data->out_buffers[p] ); if( nbr_data->cnt >= nbr_pr->est_send * 0.90 ) { mpi_flag = 1; break; } } } if( mpi_flag ) { #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d: reallocating mpi_buf: old_recv=%d\n", system->my_rank, system->est_recv ); for( p = 0; p < MAX_NBRS; ++p ) fprintf( stderr, "p%d: nbr%d old_send=%d\n", system->my_rank, p, system->my_nbrs[p].est_send ); #endif /* update mpi buffer estimates based on last comm */ system->est_recv = MAX( system->max_recved*SAFER_ZONE, MIN_SEND ); system->est_trans = (system->est_recv * sizeof(boundary_atom)) / sizeof(mpi_atom); total_send = 0; for( p = 0; p < MAX_NBRS; ++p ) { nbr_pr = &( system->my_nbrs[p] ); nbr_data = &( mpi_data->out_buffers[p] ); nbr_pr->est_send = MAX( nbr_data->cnt*SAFER_ZONE, MIN_SEND ); total_send += nbr_pr->est_send; } #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d: reallocating mpi_buf: recv=%d send=%d total=%dMB\n", system->my_rank, system->est_recv, total_send, (int)((system->est_recv+total_send)*sizeof(boundary_atom)/ (1024*1024))); for( p = 0; p < MAX_NBRS; ++p ) fprintf( stderr, "p%d: nbr%d new_send=%d\n", system->my_rank, p, system->my_nbrs[p].est_send ); #endif /* reallocate mpi buffers */ Deallocate_MPI_Buffers( mpi_data ); ret = Allocate_MPI_Buffers( mpi_data, system->est_recv, system->my_nbrs, msg ); if( ret != SUCCESS ) { fprintf( stderr, "%s", msg ); fprintf( stderr, "terminating...\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } } #endif /*PURE_REAX*/ #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d @ step%d: reallocate done\n", system->my_rank, data->step ); MPI_Barrier( comm ); #endif }
int Init_Lists( reax_system *system, control_params *control, simulation_data *data, storage *workspace, reax_list **lists, mpi_datatypes *mpi_data, char *msg ) { int i, num_nbrs; int total_hbonds, total_bonds, bond_cap, num_3body, cap_3body, Htop; int *hb_top, *bond_top; int nrecv[MAX_NBRS]; MPI_Comm comm; comm = mpi_data->world; bond_top = (int*) calloc( system->total_cap, sizeof(int) ); hb_top = (int*) calloc( system->local_cap, sizeof(int) ); Estimate_Storages( system, control, lists, &Htop, hb_top, bond_top, &num_3body, comm ); if( control->hbond_cut > 0 ) { /* init H indexes */ total_hbonds = 0; for( i = 0; i < system->n; ++i ) { system->my_atoms[i].num_hbonds = hb_top[i]; total_hbonds += hb_top[i]; } total_hbonds = (int)(MAX( total_hbonds*SAFER_ZONE, MIN_CAP*MIN_HBONDS )); if( !Make_List( system->Hcap, total_hbonds, TYP_HBOND, *lists+HBONDS, comm ) ) { fprintf( stderr, "not enough space for hbonds list. terminating!\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d: allocated hbonds: total_hbonds=%d, space=%dMB\n", system->my_rank, total_hbonds, (int)(total_hbonds*sizeof(hbond_data)/(1024*1024)) ); #endif } /* bonds list */ //Allocate_Bond_List( system->N, bond_top, (*lists)+BONDS ); //num_bonds = bond_top[system->N-1]; total_bonds = 0; for( i = 0; i < system->N; ++i ) { system->my_atoms[i].num_bonds = bond_top[i]; total_bonds += bond_top[i]; } bond_cap = (int)(MAX( total_bonds*SAFE_ZONE, MIN_CAP*MIN_BONDS )); if( !Make_List( system->total_cap, bond_cap, TYP_BOND, *lists+BONDS, comm ) ) { fprintf( stderr, "not enough space for bonds list. terminating!\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d: allocated bonds: total_bonds=%d, space=%dMB\n", system->my_rank, bond_cap, (int)(bond_cap*sizeof(bond_data)/(1024*1024)) ); #endif /* 3bodies list */ cap_3body = (int)(MAX( num_3body*SAFE_ZONE, MIN_3BODIES )); if( !Make_List( bond_cap, cap_3body, TYP_THREE_BODY, *lists+THREE_BODIES, comm ) ){ fprintf( stderr, "Problem in initializing angles list. Terminating!\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d: allocated 3-body list: num_3body=%d, space=%dMB\n", system->my_rank, cap_3body, (int)(cap_3body*sizeof(three_body_interaction_data)/(1024*1024)) ); #endif #if defined(TEST_FORCES) if( !Make_List( system->total_cap, bond_cap*8, TYP_DDELTA, *lists+DDELTAS, comm ) ) { fprintf( stderr, "Problem in initializing dDelta list. Terminating!\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } fprintf( stderr, "p%d: allocated dDelta list: num_ddelta=%d space=%ldMB\n", system->my_rank, bond_cap*30, bond_cap*8*sizeof(dDelta_data)/(1024*1024) ); if( !Make_List( bond_cap, bond_cap*50, TYP_DBO, (*lists)+DBOS, comm ) ) { fprintf( stderr, "Problem in initializing dBO list. Terminating!\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } fprintf( stderr, "p%d: allocated dbond list: num_dbonds=%d space=%ldMB\n", system->my_rank, bond_cap*MAX_BONDS*3, bond_cap*MAX_BONDS*3*sizeof(dbond_data)/(1024*1024) ); #endif free( hb_top ); free( bond_top ); return SUCCESS; }
int Init_Lists( reax_system *system, control_params *control, simulation_data *data, storage *workspace, reax_list **lists, mpi_datatypes *mpi_data, char *msg ) { int i, num_nbrs; int total_hbonds, total_bonds, bond_cap, num_3body, cap_3body, Htop; int *hb_top, *bond_top; MPI_Comm comm; comm = mpi_data->world; //for( i = 0; i < MAX_NBRS; ++i ) nrecv[i] = system->my_nbrs[i].est_recv; //system->N = SendRecv( system, mpi_data, mpi_data->boundary_atom_type, nrecv, // Sort_Boundary_Atoms, Unpack_Exchange_Message, 1 ); num_nbrs = Estimate_NumNeighbors( system, lists ); if(!Make_List( system->total_cap, num_nbrs, TYP_FAR_NEIGHBOR, *lists+FAR_NBRS, comm )){ fprintf(stderr, "Problem in initializing far nbrs list. Terminating!\n"); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d: allocated far_nbrs: num_far=%d, space=%dMB\n", system->my_rank, num_nbrs, (int)(num_nbrs*sizeof(far_neighbor_data)/(1024*1024)) ); #endif Generate_Neighbor_Lists( system, data, workspace, lists ); bond_top = (int*) calloc( system->total_cap, sizeof(int) ); hb_top = (int*) calloc( system->local_cap, sizeof(int) ); Estimate_Storages( system, control, lists, &Htop, hb_top, bond_top, &num_3body, comm ); Allocate_Matrix( &(workspace->H), system->local_cap, Htop, comm ); workspace->L = NULL; workspace->U = NULL; #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d: allocated H matrix: Htop=%d, space=%dMB\n", system->my_rank, Htop, (int)(Htop * sizeof(sparse_matrix_entry) / (1024*1024)) ); #endif if( control->hbond_cut > 0 ) { /* init H indexes */ total_hbonds = 0; for( i = 0; i < system->n; ++i ) { system->my_atoms[i].num_hbonds = hb_top[i]; total_hbonds += hb_top[i]; } total_hbonds = MAX( total_hbonds*SAFER_ZONE, MIN_CAP*MIN_HBONDS ); if( !Make_List( system->Hcap, total_hbonds, TYP_HBOND, *lists+HBONDS, comm ) ) { fprintf( stderr, "not enough space for hbonds list. terminating!\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d: allocated hbonds: total_hbonds=%d, space=%dMB\n", system->my_rank, total_hbonds, (int)(total_hbonds*sizeof(hbond_data)/(1024*1024)) ); #endif } /* bonds list */ //Allocate_Bond_List( system->N, bond_top, (*lists)+BONDS ); //num_bonds = bond_top[system->N-1]; total_bonds = 0; for( i = 0; i < system->N; ++i ) { system->my_atoms[i].num_bonds = bond_top[i]; total_bonds += bond_top[i]; } bond_cap = MAX( total_bonds*SAFE_ZONE, MIN_CAP*MIN_BONDS ); if( !Make_List( system->total_cap, bond_cap, TYP_BOND, *lists+BONDS, comm ) ) { fprintf( stderr, "not enough space for bonds list. terminating!\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d: allocated bonds: total_bonds=%d, space=%dMB\n", system->my_rank, bond_cap, (int)(bond_cap*sizeof(bond_data)/(1024*1024)) ); #endif /* 3bodies list */ cap_3body = MAX( num_3body*SAFE_ZONE, MIN_3BODIES ); if( !Make_List( bond_cap, cap_3body, TYP_THREE_BODY, *lists+THREE_BODIES, comm ) ){ fprintf( stderr, "Problem in initializing angles list. Terminating!\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } #if defined(DEBUG_FOCUS) fprintf( stderr, "p%d: allocated 3-body list: num_3body=%d, space=%dMB\n", system->my_rank, cap_3body, (int)(cap_3body*sizeof(three_body_interaction_data)/(1024*1024)) ); #endif #if defined(TEST_FORCES) if( !Make_List( system->total_cap, bond_cap*8, TYP_DDELTA, *lists+DDELTAS, comm ) ) { fprintf( stderr, "Problem in initializing dDelta list. Terminating!\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } fprintf( stderr, "p%d: allocated dDelta list: num_ddelta=%d space=%ldMB\n", system->my_rank, bond_cap*30, bond_cap*8*sizeof(dDelta_data)/(1024*1024) ); if( !Make_List( bond_cap, bond_cap*50, TYP_DBO, *lists+DBOS, comm ) ) { fprintf( stderr, "Problem in initializing dBO list. Terminating!\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } fprintf( stderr, "p%d: allocated dbond list: num_dbonds=%d space=%ldMB\n", system->my_rank, bond_cap*MAX_BONDS*3, bond_cap*MAX_BONDS*3*sizeof(dbond_data)/(1024*1024) ); #endif free( hb_top ); free( bond_top ); return SUCCESS; }
int Init_ListsOMP( reax_system *system, control_params *control, simulation_data * /* data */, storage * /* workspace */, reax_list **lists, mpi_datatypes *mpi_data, char * /* msg */) { int i, total_hbonds, total_bonds, bond_cap, num_3body, cap_3body, Htop; int *hb_top, *bond_top; MPI_Comm comm; int mincap = system->mincap; double safezone = system->safezone; double saferzone = system->saferzone; comm = mpi_data->world; bond_top = (int*) calloc( system->total_cap, sizeof(int) ); hb_top = (int*) calloc( system->local_cap, sizeof(int) ); Estimate_Storages( system, control, lists, &Htop, hb_top, bond_top, &num_3body, comm ); if (control->hbond_cut > 0) { /* init H indexes */ total_hbonds = 0; for( i = 0; i < system->n; ++i ) { system->my_atoms[i].num_hbonds = hb_top[i]; total_hbonds += hb_top[i]; } total_hbonds = (int)(MAX( total_hbonds*saferzone, mincap*MIN_HBONDS )); if( !Make_List( system->Hcap, total_hbonds, TYP_HBOND, *lists+HBONDS, comm ) ) { fprintf( stderr, "not enough space for hbonds list. terminating!\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } } total_bonds = 0; for( i = 0; i < system->N; ++i ) { system->my_atoms[i].num_bonds = bond_top[i]; total_bonds += bond_top[i]; } bond_cap = (int)(MAX( total_bonds*safezone, mincap*MIN_BONDS )); if( !Make_List( system->total_cap, bond_cap, TYP_BOND, *lists+BONDS, comm ) ) { fprintf( stderr, "not enough space for bonds list. terminating!\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } int nthreads = control->nthreads; reax_list *bonds = (*lists)+BONDS; for (i = 0; i < bonds->num_intrs; ++i) bonds->select.bond_list[i].bo_data.CdboReduction = (double*) smalloc(sizeof(double)*nthreads, "CdboReduction", comm); /* 3bodies list */ cap_3body = (int)(MAX( num_3body*safezone, MIN_3BODIES )); if( !Make_List( bond_cap, cap_3body, TYP_THREE_BODY, *lists+THREE_BODIES, comm ) ){ fprintf( stderr, "Problem in initializing angles list. Terminating!\n" ); MPI_Abort( comm, INSUFFICIENT_MEMORY ); } free( hb_top ); free( bond_top ); return SUCCESS; }