<div dir="ltr"><div>I think the problem is just that the directories the file is in isn't automatically created by write.  It probably would make sense for it to, so I'm checking in a fix to that.<br><br></div>As a workaround you could just do a mkdir before you use the directory:<br><div><br><span style="font-family:monospace,monospace">import io;<br>import sys;<br>import files;<br><br>main<br>{<br>    string upf_file_name = argv("f"); // e.g., -f="upf.txt"<br>    string upf_lines[]  = file_lines(input(upf_file_name));<br>    foreach s,i in upf_lines<br>    {<br>      string instance_dir = strcat(strcat("instance_",fromint(i)),"/");<br><br>      my_mkdir(instance_dir) =><br>      {<br>        file out <strcat(instance_dir,"out.txt")>;<br>        file err <strcat(instance_dir,"err.txt")>;<br>        file tmp <strcat(instance_dir,"upf.txt")> = write(s);<br>      }<br>    }<br>}<br><br>app (void o) my_mkdir(string dirname) {<br>  "mkdir" "-p" dirname;<br>}<br></span><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 15 April 2015 at 20:03, Ozik, Jonathan <span dir="ltr"><<a href="mailto:jozik@anl.gov" target="_blank">jozik@anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello all,<br>
<br>
I’m wondering if I’m seeing an unintended file I/O race condition or if I’m simply doing something wrong but I’m getting errors when trying to execute this script using trunk:<br>
<br>
swift-t -n 4 very_simple.swift -f=upf_small_3.txt<br>
(where upf_small_3.txt is a file with 3 lines)<br>
<br>
##### very_simple.swift #####<br>
import io;<br>
import sys;<br>
import files;<br>
<br>
main<br>
{<br>
    string upf_file_name = argv("f"); // e.g., -f="upf.txt"<br>
    string upf_lines[]  = file_lines(input(upf_file_name));<br>
    foreach s,i in upf_lines<br>
    {<br>
      string instance_dir = strcat(strcat("instance_",fromint(i)),"/");<br>
<br>
      file out <strcat(instance_dir,"out.txt")>;<br>
      file err <strcat(instance_dir,"err.txt")>;<br>
      file tmp <strcat(instance_dir,"upf.txt")> = write(s);<br>
    }<br>
}<br>
##### very_simple.swift #####<br>
<br>
The errors are:<br>
couldn't open "instance_1/upf.txt": no such file or directory<br>
    while executing<br>
"::open [ local_file_path $local_file ] w+ "<br>
    (procedure "turbine::file_write_local" line 3)<br>
    invoked from within<br>
"turbine::file_write_local v:tmp ${v:s}"<br>
    (procedure "__entry-call_foreign-write" line 5)<br>
    invoked from within<br>
"__entry-call_foreign-write {2  randomSeed      1,zombieStep    0.1,humanStep   0.5,human_count 200,zombie_count        2} instance_1/upf.txt {file 7 is_mapped 1}"<br>
Turbine worker task error in: __entry-call_foreign-write {2     randomSeed      1,zombieStep    0.1,humanStep   0.5,human_count 200,zombie_count        2} instance_1/upf.txt {file 7 is_mapped 1}<br>
    invoked from within<br>
"c::worker_loop $WORK_TYPE($mode) $keyword_args"<br>
    (procedure "standard_worker" line 27)<br>
    invoked from within<br>
"standard_worker $rules $startup_cmd "<br>
    (procedure "enter_mode_unchecked" line 5)<br>
    invoked from within<br>
"enter_mode_unchecked $rules $startup_cmd"<br>
    (procedure "enter_mode" line 5)<br>
    invoked from within<br>
"enter_mode $rules $startup_cmd “<br>
<br>
Jonathan<br>
_______________________________________________<br>
ExM-user mailing list<br>
<a href="mailto:ExM-user@lists.mcs.anl.gov">ExM-user@lists.mcs.anl.gov</a><br>
<a href="https://lists.mcs.anl.gov/mailman/listinfo/exm-user" target="_blank">https://lists.mcs.anl.gov/mailman/listinfo/exm-user</a><br>
</blockquote></div><br></div>