diff --git a/sources/io.F90 b/sources/io.F90 index bd56e8f..a6578dd 100644 --- a/sources/io.F90 +++ b/sources/io.F90 @@ -1458,9 +1458,25 @@ module io if (nprocs >= lnprocs) then - if (nproc < lnprocs) then +! spread the restart snapshots reading across new processes so we do not +! overload the memory; change the data block process starting from the last +! down to the first process, so we do not change the process number of blocks +! which have already been updated; +! + n = nprocs / lnprocs + do nl = lnprocs - 1, 0, -1 + nu = nl * n + call change_blocks_process(nl, nu) + end do + if (mod(nproc, n) == 0) then + nl = nproc / n + else + nl = -1 + end if - write(fname,sfmt) trim(dname), "datablocks", nproc, "xml" + if (nl >= 0) then + + write(fname,sfmt) trim(dname), "datablocks", nl, "xml" inquire(file=fname, exist=test) if (.not. test) then write(*,*) trim(fname) // " does not exist!" @@ -1538,7 +1554,7 @@ module io if (status == 0) then - write(fname,sfmt) trim(dname), "datablock_ids", nproc, "bin" + write(fname,sfmt) trim(dname), "datablock_ids", nl, "bin" open(newunit=lun, file=fname, form='unformatted', access='stream') read(lun) ids close(lun) @@ -1553,7 +1569,7 @@ module io call link_blocks(block_array(ids(l))%ptr, pdata) write(fname,"(a,'datablock_prim_',i6.6,'_',i6.6,'.bin')") & - trim(dname), nproc, l + trim(dname), nl, l open(newunit=lun, file=fname, form='unformatted', access='stream') read(lun) array(:,:,:,:,1) close(lun) @@ -1575,7 +1591,7 @@ module io end if write(fname,"(a,'datablock_cons_',i6.6,'_',i6.6,'.bin')") & - trim(dname), nproc, l + trim(dname), nl, l open(newunit=lun, file=fname, form='unformatted', access='stream') read(lun) array close(lun) @@ -1610,7 +1626,7 @@ module io if (status == 0) then - write(fname,sfmt) trim(dname), "random_seeds", nproc, "bin" + write(fname,sfmt) trim(dname), "random_seeds", nl, "bin" open(newunit=lun, file=fname, form='unformatted', access='stream') read(lun) seeds close(lun) @@ -1625,7 +1641,7 @@ module io call print_message(loc, "Could not allocate space for seeds!") end if - else ! nproc < lnprocs + else ! nl < 0 write(fname,sfmt) trim(dname), "datablocks", 0, "xml" inquire(file=fname, exist=test) @@ -1683,7 +1699,7 @@ module io end if ! gentype == "same" - end if ! nproc < nprocs + end if ! nl < 0 else ! nprocs < lnprocs