I am working on a heat transfer problem in chapel, and while I understand that I'm not going to be able to get a nice GUI I can work with, I would like to have something I can print that allows me to see at least the end result of running my code. So far what I have is hard to read because longer numbers will push out the whole row. I was looking at using formattedIO, but the documentation was confusing to me and seemed to focus more on one line formatting rather than anything table related. What I'm hoping for is some way to ensure that all the columns line up. Here is my code if it is helpful. Thanks in advance!
use Math;
use Time;
var rows = 10;
var cols = 10;
var times = 4;
var x = 5;
var y = 5;
var temps: [0..rows+1, 0..cols+1] real = 0;
var past: [0..rows+1, 0..cols+1] real;
temps[x,y] = 100;
past[x,y] = 100;
var t: Timer;
t.start();
for t in 1..times do {
forall i in 1..rows do {
for j in 1..cols do {
temps[i,j] = floor((past[i-1,j]+past[i+1,j]+past[i,j-1]+past[i,j+1])/4);
//floor was used to cut off extra decimals in an attempt to make the display better
}
}
past = temps;
}
t.stop();
writeln(t.elapsed());
writeln(temps);
Usually the grid is a lot larger (1000 x 1000), but I made it smaller so I could see the values. I would really like to find a way to make it so that a larger grid could be printed in a way that is not awful. Would it maybe be necessary to use file output for larger grid sizes?