[Swift-user] Externally controlled loop

Mihael Hategan hategan at mcs.anl.gov
Fri Aug 31 14:17:06 CDT 2012


Should work. What's the exact error you are getting?

$ swift b4.swift
no sites file specified, setting to
default: /home/mike/work/cog-svn/cogkit/trunk/current/src/cog/modules/swift/dist/swift-svn/etc/sites.xml
Swift trunk swift-r5739 (swift modified locally) cog-r3088 (cog modified
locally)

RunID: 20120831-1215-i0n6v30e
Progress:  time: Fri, 31 Aug 2012 12:15:09 -0700
Iteration :: 0
Iteration Read :: 0
the value is: 1
Iteration :: 1
the value is: 1
Iteration Read :: 1
Iteration :: 2
the value is: 1
Iteration Read :: 2
Final status: Fri, 31 Aug 2012 12:15:09 -0700

$ cat b4.swift
type file;

iterate passes {
    file passlog <"passes.log">;
    passlog = writeData(passes);

    int value = readData("errorlog");
    int readpasses = readData(passlog);

    tracef("%s: %i\n", "the value is", value);
    tracef("%s: %i\n", "Iteration :", passes);
    tracef("%s: %i\n", "Iteration Read :", readpasses);

} until (readpasses == 2);  # Determine if Done

$


On Fri, 2012-08-31 at 12:02 -0500, Carolyn Phillips wrote:
> Hello,
> 
> So I want to create an externally controlled loop, meaning, the number of times the loop repeats is determined by the output of a executable called within the loop.  That output is written to a file so it can be read and checked.   I am experimenting with getting a very rudimentary set up.   Below you can see that I have two lines that determine if the iteration is done, one based on the variable "passes" and the other based on the variable "read passes" that is read from a file.  The second does not work and throws a execution failed exception.     Any advice on how to make this kind of structure work?
> 
> type file;
> 
> iterate passes {
> 
> 
>     # try writing the iteration to a log file
>     file passlog <"passes.log">;
>     passlog = writeData(passes);
> 
>     # try reading from another log file
>     int value = readData("errorlog");
>     int readpasses = readData(passlog);
>     
>     # Write to the Output Log 
>     int i = 3;
>     tracef("%s: %i\n", "the value is", value); 
>     tracef("%s: %i\n", "Iteration :", passes);
>     tracef("%s: %i\n", "Iteration Read :", readpasses);
> 
> #} until (readpasses == 2);  # Determine if Done
> } until (passes == 2);  # Determine if Done
> _______________________________________________
> Swift-user mailing list
> Swift-user at ci.uchicago.edu
> https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user





More information about the Swift-user mailing list