diff --git a/source/world_builder/utilities.cc b/source/world_builder/utilities.cc index 6e2e7fd4f..85eb25c1f 100644 --- a/source/world_builder/utilities.cc +++ b/source/world_builder/utilities.cc @@ -1183,7 +1183,7 @@ namespace WorldBuilder MPI_Comm_rank(comm, &my_rank); if (my_rank == 0) { - uint64_t filesize; + int filesize; std::ifstream filestream; filestream.open(filename.c_str()); WBAssertThrow (filestream.is_open(), std::string("Could not open file <") + filename + ">."); @@ -1217,9 +1217,9 @@ namespace WorldBuilder } data_string = datastream.str(); - filesize = data_string.size(); - WBAssertThrow(filesize < std::numeric_limits::max(), + WBAssertThrow(data_string.size() < std::numeric_limits::max(), "File to large to be send with MPI."); + filesize = static_cast(data_string.size()); // Distribute data_size and data across processes int ierr = MPI_Bcast(&filesize, 1, MPI_UNSIGNED, 0, comm); @@ -1227,7 +1227,7 @@ namespace WorldBuilder // Receive and store data ierr = MPI_Bcast(&data_string[0], - static_cast(filesize), + filesize, MPI_CHAR, 0, comm); @@ -1510,12 +1510,12 @@ namespace WorldBuilder multiply_3x3_matrices(const std::array,3> mat1, const std::array,3> mat2) { std::array,3> result; - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { result[i][j] = 0; - for (int k = 0; k < 3; k++) + for (size_t k = 0; k < 3; k++) { result[i][j] += mat1[i][k] * mat2[k][j]; } diff --git a/tests/unit_tests/utilities.cc b/tests/unit_tests/utilities.cc index a2ef6a924..670cb86bf 100644 --- a/tests/unit_tests/utilities.cc +++ b/tests/unit_tests/utilities.cc @@ -40,54 +40,54 @@ TEST_CASE("multiply 3x3 matrices") std::array,3> result6 = {{{{39.9,36.8,33.7}},{{60,47.5,35}},{{-94.2,-80.5,-66.8}}}}; //mat3*mat2 std::array,3> result7 = Utilities::multiply_3x3_matrices(mat1, mat2); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { CHECK(result1[i][j] == Approx(result7[i][j])); } } std::array,3> result8 = Utilities::multiply_3x3_matrices(mat2, mat1); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { CHECK(result2[i][j] == Approx(result8[i][j])); } } std::array,3> result9 = Utilities::multiply_3x3_matrices(mat1, mat3); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { CHECK(result3[i][j] == Approx(result9[i][j])); } } std::array,3> result10 = Utilities::multiply_3x3_matrices(mat3, mat1); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { CHECK(result4[i][j] == Approx(result10[i][j])); } } std::array,3> result11 = Utilities::multiply_3x3_matrices(mat2, mat3); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { CHECK(result5[i][j] == Approx(result11[i][j])); } } std::array,3> result12 = Utilities::multiply_3x3_matrices(mat3, mat2); - for (int i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) + for (size_t j = 0; j < 3; j++) { CHECK(result6[i][j] == Approx(result12[i][j])); }