Hi Brian -

I've finally figured out the problem here.

Chapel's current implementation of 'writeln' for stdout
needs to do an 'on' statement back to Locale 0. (I might
like to fix that one day, but I can't imagine that it won't
communicate with Locale 0).

As a result, writeln can't be used from the local block
(unless you are writing to a file).

For your program, doing the following change makes it work:

use IO;


for loc in Locales {
  on loc {
    local {
      var count = 0;
      var infile = open("data.txt", iomode.r);
      var row: string;
      for row in infile.lines() {
        count += 1;
      }
    }
    writeln("count = ", count); // Moved OUT of local block
  }
}



You've uncovered a problem with the 'local' block: it's
not really composable with arbitrary library code...
I believe this is a known issue.

Thanks,

-michael

On 6/1/15, 11:17 AM, "Brian Guarraci" <[email protected]> wrote:

>Hi,
>
>
>I'm curious what's expected for the following sample code.  I
>consistently run into an issue where opening the file on a locale in a
>local block causes a remote data access violation.  Wondering if I'm
>misunderstanding a concept or if it's a bug.
>
>
>Thanks!
>Brian
>
>
>$ ./a.out -nl 2
>file_locale.chpl:7: error: cannot access remote data in local block
>count = 1164970
>
>
>
>-----
>
>
>use IO;
>
>
>for loc in Locales {
>  on loc {
>    local {
>      var count = 0;
>      var infile = open("data.txt", iomode.r);
>      var row: string;
>      for row in infile.lines() {
>        count += 1;
>      }
>      writeln("count = ", count);
>    }
>  }
>}
>
>
>


------------------------------------------------------------------------------
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to