Hi Christine,<br><br>I'm not sure you can use the only_on_root like that.  Someone can correct me if I'm wrong.  However, you can do this:<br><br>@only_on_root<br>def do_something:<br>      do_stuff<br>      more_stuff<br>
      return stuff<br><br>do_something()<br><br>Britton<br><br><div class="gmail_quote">On Tue, Nov 22, 2011 at 11:49 AM, Christine Simpson <span dir="ltr"><<a href="mailto:csimpson@astro.columbia.edu">csimpson@astro.columbia.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<br>
<br>
I'm trying to run a script with parallel yt that does some non-yt io.<br>
I'm a little confused about how to use only_on_root.<br>
<br>
Here is a test script I've tried:<br>
<br>
from yt.mods import *<br>
from yt.visualization.api import PlotCollection<br>
<br>
import matplotlib.colorbar as cb<br>
<br>
path =<br>
"/scratch/01112/tg803911/halo88_therm_feed_3.7e-6_LW_RadiationShield_lmax12/DD0010/"<br>
fn = "output_0010"<br>
pf = load(path+fn)<br>
pc = PlotCollection(pf)<br>
pc.add_projection("Density",0)<br>
pc.set_width(20,'kpc')<br>
pc.save(fn)<br>
<br>
filename = 'hello_world'<br>
<br>
file = only_on_root(open(filename,'w'))<br>
only_on_root(file.write("hello_world \n"))<br>
only_on_root(file.close())<br>
<br>
Pasted below is the error.  I'm uncertain about the syntax of<br>
only_on_root.  Do I just wrap it around normal commands?  Also, it seems<br>
that the write command is trying to execute on all the processors.  That<br>
shouldn't be happening, right?<br>
<br>
P007 yt : [INFO     ] 2011-11-22 09:50:20,558 Saved<br>
output_0010_Projection_x_Density.png<br>
P008 yt : [INFO     ] 2011-11-22 09:50:20,558 Saved<br>
output_0010_Projection_x_Density.png<br>
P009 yt : [INFO     ] 2011-11-22 09:50:20,560 Saved<br>
output_0010_Projection_x_Density.png<br>
Traceback (most recent call last):<br>
Traceback (most recent call last):<br>
  File "test_parallel_yt.py", line 19, in <module><br>
  File "test_parallel_yt.py", line 19, in <module><br>
Traceback (most recent call last):<br>
  File "test_parallel_yt.py", line 19, in <module><br>
    only_on_root(file.write("hello_world \n"))<br>
AttributeError: 'NoneType' object has no attribute 'write'<br>
    only_on_root(file.write("hello_world \n"))<br>
AttributeError    : only_on_root(file.write("hello_world \n"))<br>
'NoneType' object has no attribute 'write'<br>
P010 yt : [INFO     ] 2011-11-22 09:50:20,561 Saved<br>
output_0010_Projection_x_Density.png<br>
AttributeErrorP011 yt : [INFO     ] 2011-11-22 09:50:20,561 Saved<br>
output_0010_Projection_x_Density.png<br>
: 'NoneType' object has no attribute 'write'<br>
Traceback (most recent call last):<br>
  File "test_parallel_yt.py", line 19, in <module><br>
    only_on_root(file.write("hello_world \n"))<br>
Traceback (most recent call last):<br>
AttributeError:   File "test_parallel_yt.py", line 19, in <module><br>
'NoneType' object has no attribute 'write'<br>
P005 yt : [INFO     ] 2011-11-22 09:50:20,562 Saved<br>
output_0010_Projection_x_Density.png<br>
P004 yt : [INFO     ] 2011-11-22 09:50:20,562 Saved<br>
output_0010_Projection_x_Density.png<br>
    only_on_root(file.write("hello_world \n"))<br>
AttributeError: 'NoneType' object has no attribute 'write'<br>
Traceback (most recent call last):<br>
  File "test_parallel_yt.py", line 19, in <module><br>
    only_on_root(file.write("hello_world \n"))<br>
AttributeError: 'NoneType' object has no attribute 'write'<br>
Traceback (most recent call last):<br>
  File "test_parallel_yt.py", line 19, in <module><br>
    only_on_root(file.write("hello_world \n"))<br>
AttributeError: 'NoneType' object has no attribute 'write'<br>
Traceback (most recent call last):<br>
  File "test_parallel_yt.py", line 19, in <module><br>
    only_on_root(file.write("hello_world \n"))<br>
AttributeError: 'NoneType' object has no attribute 'write'<br>
P002 yt : [INFO     ] 2011-11-22 09:50:20,583 Saved<br>
output_0010_Projection_x_Density.png<br>
Traceback (most recent call last):<br>
  File "test_parallel_yt.py", line 19, in <module><br>
    only_on_root(file.write("hello_world \n"))<br>
AttributeError: 'NoneType' object has no attribute 'write'<br>
P001 yt : [INFO     ] 2011-11-22 09:50:20,589 Saved<br>
output_0010_Projection_x_Density.png<br>
P003 yt : [INFO     ] 2011-11-22 09:50:20,589 Saved<br>
output_0010_Projection_x_Density.png<br>
Traceback (most recent call last):<br>
  File "test_parallel_yt.py", line 19, in <module><br>
    only_on_root(file.write("hello_world \n"))<br>
AttributeError: 'NoneType' object has no attribute 'write'<br>
Traceback (most recent call last):<br>
  File "test_parallel_yt.py", line 19, in <module><br>
    only_on_root(file.write("hello_world \n"))<br>
AttributeError: 'NoneType' object has no attribute 'write'<br>
P013 yt : [INFO     ] 2011-11-22 09:50:20,593 Saved<br>
output_0010_Projection_x_Density.png<br>
P014 yt : [INFO     ] 2011-11-22 09:50:20,593 Saved<br>
output_0010_Projection_x_Density.png<br>
Traceback (most recent call last):<br>
  File "test_parallel_yt.py", line 19, in <module><br>
    only_on_root(file.write("hello_world \n"))<br>
AttributeError: 'NoneType' object has no attribute 'write'<br>
Traceback (most recent call last):<br>
  File "test_parallel_yt.py", line 19, in <module><br>
    only_on_root(file.write("hello_world \n"))<br>
AttributeError: 'NoneType' object has no attribute 'write'<br>
P012 yt : [INFO     ] 2011-11-22 09:50:20,596 Saved<br>
output_0010_Projection_x_Density.png<br>
Traceback (most recent call last):<br>
  File "test_parallel_yt.py", line 19, in <module><br>
    only_on_root(file.write("hello_world \n"))<br>
AttributeError: 'NoneType' object has no attribute 'write'<br>
P015 yt : [INFO     ] 2011-11-22 09:50:20,599 Saved<br>
output_0010_Projection_x_Density.png<br>
Traceback (most recent call last):<br>
  File "test_parallel_yt.py", line 19, in <module><br>
    only_on_root(file.write("hello_world \n"))<br>
AttributeError: 'NoneType' object has no attribute 'write'<br>
P000 yt : [INFO     ] 2011-11-22 09:50:21,410 Saved<br>
output_0010_Projection_x_Density.png<br>
Traceback (most recent call last):<br>
  File "test_parallel_yt.py", line 18, in <module><br>
    file = only_on_root(open(filename,'w'))<br>
  File<br>
"/share/home/01112/tg803911/yt_17May2011/yt-x86_64/src/yt-hg/yt/funcs.py", line 357, in only_on_root<br>
    return func(*args, **kwargs)<br>
TypeError: 'file' object is not callable<br>
mpispawn.c:303 Unexpected exit status<br>
<br>
Child exited abnormally!<br>
Killing remote processes...DONE<br>
<br>
<br>
<br>
_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
</blockquote></div><br>