| misc.c (9e3fb82be6e39ca60257599ff1be2b423bc49429) | misc.c (5d28dccaccae4dbbdfc8aa7c8439b84e1bbb591b) |
|---|---|
| 1// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3// 4// SPDX-License-Identifier: BSD-2-Clause 5// 6// This file is part of CEED: http://github.com/ceed 7 8/// @file --- 343 unchanged lines hidden (view full) --- 352 PetscInt ndims; 353 char line[char_array_len]; 354 char **array; 355 356 PetscFunctionBeginUser; 357 PetscCall(PetscFOpen(comm, path, "r", fp)); 358 PetscCall(PetscSynchronizedFGets(comm, *fp, char_array_len, line)); 359 PetscCall(PetscStrToArray(line, ' ', &ndims, &array)); | 1// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3// 4// SPDX-License-Identifier: BSD-2-Clause 5// 6// This file is part of CEED: http://github.com/ceed 7 8/// @file --- 343 unchanged lines hidden (view full) --- 352 PetscInt ndims; 353 char line[char_array_len]; 354 char **array; 355 356 PetscFunctionBeginUser; 357 PetscCall(PetscFOpen(comm, path, "r", fp)); 358 PetscCall(PetscSynchronizedFGets(comm, *fp, char_array_len, line)); 359 PetscCall(PetscStrToArray(line, ' ', &ndims, &array)); |
| 360 if (ndims != 2) { 361 SETERRQ(comm, -1, "Found %" PetscInt_FMT " dimensions instead of 2 on the first line of %s", ndims, path); 362 } | 360 PetscCheck(ndims == 2, comm, PETSC_ERR_FILE_UNEXPECTED, "Found %" PetscInt_FMT " dimensions instead of 2 on the first line of %s", ndims, path); |
| 363 364 for (PetscInt i = 0; i < ndims; i++) dims[i] = atoi(array[i]); 365 PetscCall(PetscStrToArrayDestroy(ndims, array)); 366 367 PetscFunctionReturn(0); 368} 369 370/* --- 26 unchanged lines hidden (view full) --- 397 char **row_array; 398 PetscFunctionBeginUser; 399 400 PetscCall(PHASTADatFileOpen(comm, path, char_array_len, dims, &fp)); 401 402 for (PetscInt i = 0; i < dims[0]; i++) { 403 PetscCall(PetscSynchronizedFGets(comm, fp, char_array_len, line)); 404 PetscCall(PetscStrToArray(line, ' ', &ndims, &row_array)); | 361 362 for (PetscInt i = 0; i < ndims; i++) dims[i] = atoi(array[i]); 363 PetscCall(PetscStrToArrayDestroy(ndims, array)); 364 365 PetscFunctionReturn(0); 366} 367 368/* --- 26 unchanged lines hidden (view full) --- 395 char **row_array; 396 PetscFunctionBeginUser; 397 398 PetscCall(PHASTADatFileOpen(comm, path, char_array_len, dims, &fp)); 399 400 for (PetscInt i = 0; i < dims[0]; i++) { 401 PetscCall(PetscSynchronizedFGets(comm, fp, char_array_len, line)); 402 PetscCall(PetscStrToArray(line, ' ', &ndims, &row_array)); |
| 405 if (ndims < dims[1]) { 406 SETERRQ(comm, -1, "Line %" PetscInt_FMT " of %s does not contain enough columns (%" PetscInt_FMT " instead of %" PetscInt_FMT ")", i, path, 407 ndims, dims[1]); 408 } | 403 PetscCheck(ndims == dims[1], comm, PETSC_ERR_FILE_UNEXPECTED, 404 "Line %" PetscInt_FMT " of %s does not contain enough columns (%" PetscInt_FMT " instead of %" PetscInt_FMT ")", i, path, ndims, 405 dims[1]); |
| 409 410 for (PetscInt j = 0; j < dims[1]; j++) { 411 array[i * dims[1] + j] = (PetscReal)atof(row_array[j]); 412 } 413 } 414 415 PetscCall(PetscFClose(comm, fp)); 416 417 PetscFunctionReturn(0); 418} | 406 407 for (PetscInt j = 0; j < dims[1]; j++) { 408 array[i * dims[1] + j] = (PetscReal)atof(row_array[j]); 409 } 410 } 411 412 PetscCall(PetscFClose(comm, fp)); 413 414 PetscFunctionReturn(0); 415} |