diff --git a/src/read_restart.cpp b/src/read_restart.cpp index f29a603ef6..331a5d6cda 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -212,7 +212,8 @@ void ReadRestart::command(int narg, char **arg) int perAtomSize = avec->size_restart(); // ...so we can get its size atom->nlocal = 0; // restore nlocal to zero atoms int atomCt = (int) (assignedChunkSize / perAtomSize); -#ifdef DEBUG_ME_NOTNOW +//#define DEBUG_PRE_GROW +#ifdef DEBUG_PRE_GROW fprintf(stdout, "ReadRestart::command %04d: pAS %d, aCt %d, nmax %d, chunckSize %12.0f, %12.0f\n" ,me ,perAtomSize @@ -1026,6 +1027,7 @@ void ReadRestart::file_layout() // if the number of ranks that did the writing is different if (me == 0) { + int ndx; int *all_written_send_sizes; memory->create(all_written_send_sizes,nprocs_file, "write_restart:all_written_send_sizes"); @@ -1035,30 +1037,76 @@ void ReadRestart::file_layout() fread(all_written_send_sizes,sizeof(int),nprocs_file,fp); - int init_chunk_number = nprocs_file/nprocs; - int num_extra_chunks = nprocs_file - (nprocs*init_chunk_number); + if ((nprocs != nprocs_file) && !(atom->nextra_store)) { + // nprocs differ, but atom sizes are fixed length, yeah! + atom->nlocal = 1; // temporarily claim there is one atom... + int perAtomSize = atom->avec->size_restart(); // ...so we can get its size + atom->nlocal = 0; // restore nlocal to zero atoms - for (int i = 0; i < nprocs; i++) { - if (i < num_extra_chunks) - nproc_chunk_number[i] = init_chunk_number+1; - else - nproc_chunk_number[i] = init_chunk_number; - } + bigint total_size = 0; + for (int i = 0; i < nprocs_file; ++i) { + total_size += all_written_send_sizes[i]; + } + bigint total_ct = total_size / perAtomSize; - int all_written_send_sizes_index = 0; - bigint current_offset = 0; - for (int i=0;inatoms + ,(double) base_ct + ,(double) leftover_ct + ,nprocs + ,nprocs_file + ,(total_size == (total_ct * perAtomSize)) ? ' ' : 'E' + ,(total_ct == (base_ct * nprocs + leftover_ct)) ? ' ' : 'F' +); +#endif + } else { // Bummer, we have to read in based on how it was written + int init_chunk_number = nprocs_file/nprocs; + int num_extra_chunks = nprocs_file - (nprocs*init_chunk_number); + + for (int i = 0; i < nprocs; i++) { + if (i < num_extra_chunks) + nproc_chunk_number[i] = init_chunk_number+1; + else + nproc_chunk_number[i] = init_chunk_number; } + int all_written_send_sizes_index = 0; + bigint current_offset = 0; + for (int i=0;idestroy(all_written_send_sizes); memory->destroy(nproc_chunk_number);