From 43df0047b399f4655e0931466af52122fcf714b2 Mon Sep 17 00:00:00 2001 From: William Dawson Date: Mon, 16 Oct 2023 14:41:12 +0900 Subject: [PATCH] Fix matrix binary ops for large case where int4 isn't enough --- Source/Fortran/PSMatrixModule.F90 | 2 +- Source/Fortran/distributed_includes/WriteMatrixToBinary.f90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Fortran/PSMatrixModule.F90 b/Source/Fortran/PSMatrixModule.F90 index 65f90e20..eff2a032 100644 --- a/Source/Fortran/PSMatrixModule.F90 +++ b/Source/Fortran/PSMatrixModule.F90 @@ -655,7 +655,7 @@ RECURSIVE SUBROUTINE ConstructMatrixFromBinary_ps(this, file_name, & 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)