diff --git a/Source/Fortran/PSMatrixModule.F90 b/Source/Fortran/PSMatrixModule.F90 index 65f90e20..a9783ffe 100644 --- a/Source/Fortran/PSMatrixModule.F90 +++ b/Source/Fortran/PSMatrixModule.F90 @@ -651,11 +651,12 @@ RECURSIVE SUBROUTINE ConstructMatrixFromBinary_ps(this, file_name, & !! Compute Offset local_triplets = total_values / this%process_grid%total_processors - local_offset = local_triplets * this%process_grid%global_rank + local_offset = INT(local_triplets, KIND=NTLONG) * & + & this%process_grid%global_rank header_size = 3 * bytes_per_int + bytes_per_long IF (this%process_grid%global_rank .EQ. & & this%process_grid%total_processors - 1) THEN - local_triplets = INT(total_values) - INT(local_offset) + local_triplets = INT(total_values - local_offset) END IF local_offset = local_offset*(bytes_per_int*2 + bytes_per_data) + & & header_size diff --git a/Source/Fortran/distributed_includes/WriteMatrixToBinary.f90 b/Source/Fortran/distributed_includes/WriteMatrixToBinary.f90 index c9eb96f9..88db2be3 100644 --- a/Source/Fortran/distributed_includes/WriteMatrixToBinary.f90 +++ b/Source/Fortran/distributed_includes/WriteMatrixToBinary.f90 @@ -25,6 +25,7 @@ CALL MPI_Allgather(SIZE(merged_local_data%values), 1, MPINTINTEGER, & & local_values_buffer, 1, MPINTINTEGER, & & this%process_grid%within_slice_comm, ierr) + total_values = GetMatrixSize(this) write_offset = 0 write_offset = write_offset + header_size @@ -53,7 +54,6 @@ END IF CALL MPI_File_write_at(mpi_file_handler, zero_offset, header_buffer, & & 3, MPINTINTEGER, message_status, ierr) - total_values = SUM(local_values_buffer) CALL MPI_File_write_at(mpi_file_handler, & & zero_offset + bytes_per_int * 3, total_values, & & 1, MPINTLONG, message_status, ierr)