Is it possible to declare an array with configuration?
No, this is not yet supported in the Chapel, as in Chapel 1.16.
However, there are ways around this while you demonstrate.
As an alternative solution, you can use IO to write an input string to memory and then read it as an array, e.g.
config type arrType = int; config const arrSize = 3, arrString = '1 2 3'; var A : [1..arrSize] arrType; // Create a memory buffer to write in var f = openmem(); // Create a writer on the memory buffer and write the input string var w = f.writer(); w.writeln(arrString); w.close(); // Create a reader on the memory buffer and read the input string as an array var r = f.reader(); r.readln(A); r.close(); writeln(A);
Note that this requires an array size in front. I think you will need to do some line processing, as your original example, in order to calculate this on the fly.
Some resources:
source share