[Swift-devel] Swift hanging on array close?

Justin M Wozniak wozniak at mcs.anl.gov
Fri Jul 9 16:40:08 CDT 2010


Using @filename() should get the job done.

Also, note that you need file i[] as an array at the end there.  And your 
cat call in mktableinput.sh may not work as desired.

On Fri, 9 Jul 2010, Michael Wilde wrote:

> In the following script, two nested foreach stmts fill a sparse array. 
> @filenames(array) is then passed to an ext mapper.
>
> This seems to hang: the ext mapper is never called.
>
> This code in on the mcs net in ~wilde/swift/lab/sgflow.
>
> Mihael and/or Justin, can you take a look? The FL group needs this for a 
> tutorial next week (and has lots more to do, so a quick fix or 
> workaround this afternoon would be very helpful)
>
> Thanks,
>
> Mike
>
> type file;
>
> # <bus> is integer between 1 and 30
> # <power> is in megawatts
>
> app (file o) sgflow (int bus, int power)
> {
>  sgflow bus power stdout=@o;
> }
> app (file o) mkgraph (file i)
> {
>  awk "-f" "/home/turam/tmp/mkgraph.awk" @filename(i) stdout=@o;
> }
>
> app (file o) mktable (file i)
> {
>  awk "-f" "/home/turam/tmp/SGsplitter.awk" stdin=@i;
> }
>
> file ofiles[] <ext;exec="ofiles.map">;
>
> string nbus = @arg("nbus","1");
> string nplevel = @arg("nplevel", "2");
> foreach bus in [1:@toint(nbus)] {
>  foreach plevel in [1:@toint(nplevel)] {
>    # file o<single_file_mapper; file=@strcat("out.","bus.",bus,".pow.",plevel)>;
>    ofiles[bus*@toint(nplevel)+plevel] = sgflow(bus,plevel);
>  }
> }
>
> file i <ext;exec="mktableinput.sh",o="out.csv",i=@filenames(ofiles)>;
>
> # ^^^^ hangs here - mktableinput.sh is never called.
> # trace(@filenames(ofiles)) also hangs.
>
> file otable <"otable.txt">;
> otable = mktable(i);
>
> ----
> ofiles.map is hardcoded to return ofile.3 and ofile.4 - this works, and those files get the expected output.
>
>

-- 
Justin M Wozniak



More information about the Swift-devel mailing list