Changes

Jump to: navigation, search

GPU621/Chapel

1,224 bytes added, 00:12, 30 November 2022
Library Utilities =
A[i] = i;
}
== Library Utilities ===== File I/O === config var n = 9, filename = "Arr.dat"; config const num = 128*1024; config const example = 0; config const testfile = "test.bin"; config const epsilon = 10e-13; use FileSystem; use IO;It initializes an array and writes its size and data to a file. It then opens the file, uses the size in the file to declare a new domain and array, and reads in the array data. if example == 0 || example == 1 { // Create a domain of the specified problem size. const ADom = {1..n, 1..n}; // Create and initialize an array of the specified size. var A: [ADom] real = [(i,j) in ADom] i + j/10.0; // Write the problem size and array out to the specified filename. writeSquareArray(n, A, filename); // Read an array in from the specified filename, storing in a new variable, B. var B = readArray(filename); // Print out B as a debugging step. writeln("B is:\n", B); // Verify that the values in A and B are within tolerance. const numErrors = + reduce [i in ADom] (abs(A(i) - B(i)) > epsilon); if (numErrors > 0) { writeln("FAILURE"); } else { writeln("SUCCESS"); } }
= Reference =
73
edits

Navigation menu