<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Thanks Tim, this will do the trick.
<div class="">I thought I was seeing that in some situations the necessary folders were being created but not in others. I could be wrong though.</div>
<div class=""><br class="">
</div>
<div class="">Jonathan</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Apr 15, 2015, at 9:05 PM, Tim Armstrong <<a href="mailto:tim.g.armstrong@gmail.com" class="">tim.g.armstrong@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div class="">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 class="">
<br class="">
</div>
As a workaround you could just do a mkdir before you use the directory:<br class="">
<div class=""><br class="">
<span style="font-family:monospace,monospace" class="">import io;<br class="">
import sys;<br class="">
import files;<br class="">
<br class="">
main<br class="">
{<br class="">
string upf_file_name = argv("f"); // e.g., -f="upf.txt"<br class="">
string upf_lines[] = file_lines(input(upf_file_name));<br class="">
foreach s,i in upf_lines<br class="">
{<br class="">
string instance_dir = strcat(strcat("instance_",fromint(i)),"/");<br class="">
<br class="">
my_mkdir(instance_dir) =><br class="">
{<br class="">
file out <strcat(instance_dir,"out.txt")>;<br class="">
file err <strcat(instance_dir,"err.txt")>;<br class="">
file tmp <strcat(instance_dir,"upf.txt")> = write(s);<br class="">
}<br class="">
}<br class="">
}<br class="">
<br class="">
app (void o) my_mkdir(string dirname) {<br class="">
"mkdir" "-p" dirname;<br class="">
}<br class="">
</span><br class="">
</div>
</div>
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On 15 April 2015 at 20:03, Ozik, Jonathan <span dir="ltr" class="">
<<a href="mailto:jozik@anl.gov" target="_blank" class="">jozik@anl.gov</a>></span> wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello all,<br class="">
<br class="">
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 class="">
<br class="">
swift-t -n 4 very_simple.swift -f=upf_small_3.txt<br class="">
(where upf_small_3.txt is a file with 3 lines)<br class="">
<br class="">
##### very_simple.swift #####<br class="">
import io;<br class="">
import sys;<br class="">
import files;<br class="">
<br class="">
main<br class="">
{<br class="">
string upf_file_name = argv("f"); // e.g., -f="upf.txt"<br class="">
string upf_lines[] = file_lines(input(upf_file_name));<br class="">
foreach s,i in upf_lines<br class="">
{<br class="">
string instance_dir = strcat(strcat("instance_",fromint(i)),"/");<br class="">
<br class="">
file out <strcat(instance_dir,"out.txt")>;<br class="">
file err <strcat(instance_dir,"err.txt")>;<br class="">
file tmp <strcat(instance_dir,"upf.txt")> = write(s);<br class="">
}<br class="">
}<br class="">
##### very_simple.swift #####<br class="">
<br class="">
The errors are:<br class="">
couldn't open "instance_1/upf.txt": no such file or directory<br class="">
while executing<br class="">
"::open [ local_file_path $local_file ] w+ "<br class="">
(procedure "turbine::file_write_local" line 3)<br class="">
invoked from within<br class="">
"turbine::file_write_local v:tmp ${v:s}"<br class="">
(procedure "__entry-call_foreign-write" line 5)<br class="">
invoked from within<br class="">
"__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 class="">
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 class="">
invoked from within<br class="">
"c::worker_loop $WORK_TYPE($mode) $keyword_args"<br class="">
(procedure "standard_worker" line 27)<br class="">
invoked from within<br class="">
"standard_worker $rules $startup_cmd "<br class="">
(procedure "enter_mode_unchecked" line 5)<br class="">
invoked from within<br class="">
"enter_mode_unchecked $rules $startup_cmd"<br class="">
(procedure "enter_mode" line 5)<br class="">
invoked from within<br class="">
"enter_mode $rules $startup_cmd “<br class="">
<br class="">
Jonathan<br class="">
_______________________________________________<br class="">
ExM-user mailing list<br class="">
<a href="mailto:ExM-user@lists.mcs.anl.gov" class="">ExM-user@lists.mcs.anl.gov</a><br class="">
<a href="https://lists.mcs.anl.gov/mailman/listinfo/exm-user" target="_blank" class="">https://lists.mcs.anl.gov/mailman/listinfo/exm-user</a><br class="">
</blockquote>
</div>
<br class="">
</div>
_______________________________________________<br class="">
ExM-user mailing list<br class="">
<a href="mailto:ExM-user@lists.mcs.anl.gov" class="">ExM-user@lists.mcs.anl.gov</a><br class="">
https://lists.mcs.anl.gov/mailman/listinfo/exm-user<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>