<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Hi all,<br>
    <br>
    I have a unigrid 256^3 simulation that run on 64 processors. I need
    to copy/modify some data: I want to set the velocity of all cells
    having a density higher than a certain threshold to a fixed value,
    the others to 0.<br>
    I wrote a little script using h5py. I have shortened it below:<br>
    <br>
    ###################################################<br>
    <address>for grid in glob.glob('%s/*.cpu*' %(folderIN+NameIN)):</address>
    <address> </address>
    <address>  file1 = H.File(...,'r')</address>
    <address>  file2 = H.File(..., 'w')</address>
    <address>  for group in file1.keys():</address>
    <address>    mygroup = file1[group]</address>
    <address>    subgroup = file2.create_group(group)</address>
    <address>    <b>density = file1[group]['Density']</b></address>
    <address>    for field in mygroup.keys():</address>
    <address>      print 'Field:', field, ' in ', mygroup</address>
    <address>      mydset = mygroup[field]</address>
    <address>      shape = mydset.shape</address>
    <address>      where = '/'+group+'/'+field</address>
    <address><br>
      # Setting up the gas velocity</address>
    <address>      if (field == 'x-velocity'):</address>
    <address>        tmp = N.zeros(file1[group][field].shape)</address>
    <address>        size = file1[group][field].shape</address>
    <address>        for k1 in range(0,size[0],1):</address>
    <address>          for k2 in range(0,size[1],1):</address>
    <address>            for k3 in range(0,size[2],1):</address>
    <address>             <b> if (density[k1,k2,k3] > Threshold):</b></address>
    <address>                tmp[k1,k2,k3] = SomeValue</address>
    <address>              else:</address>
    <address>                tmp[k1,k2,k3] = 0.0</address>
    <address>        print 'Setting up Vx = ', SomeValue, 'if rho >',
      Threshold</address>
    <address>        dset =
      subgroup.create_dataset(field,shape,data=tmp)</address>
    ###################################################<br>
    <br>
    The issue is that this script needs more than 40 minutes to complete
    !!!! In the meantime, if I replace the test :<br>
    <br>
    ################################<br>
    <b>if (density[k1,k2,k3] > Threshold):</b><br>
    ################################<br>
    <br>
    by a static test like:<br>
    <br>
    ################################<br>
    <b>if (10 > Threshold):</b><br>
    ################################<br>
    <br>
    then the execution lasts only a few seconds ! So the problem comes
    from the test involving the field density. <br>
    <br>
    I don't really understand what is going on since I declared the
    variable density outside every loop. Could it be a memory issue ?<br>
    I would really appreciate if someone could help solve that problem.<br>
    <br>
    Thanks a lot,<br>
    <br>
    <br>
    JC<br>
  </body>
</html>