Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example 10 fails without mpi4py library #31

Open
mrakitin opened this issue Feb 1, 2017 · 12 comments
Open

Example 10 fails without mpi4py library #31

mrakitin opened this issue Feb 1, 2017 · 12 comments
Assignees

Comments

@mrakitin
Copy link
Owner

mrakitin commented Feb 1, 2017

Example 10 fails on Mac after the 4th step with the error:

Calculation will be sequential (non-parallel), because "mpi4py" module can not be loaded
i= 0 Electron Coord.: x= -2.74452048352e-05 x'= -5.30201947148e-06 y= 3.33399322641e-06 y'= 8.88316322966e-07 E= 3.00238284361
i= 1 Electron Coord.: x= 2.94014986023e-05 x'= -3.43237532114e-06 y= -1.01652414766e-06 y'= -5.38704099806e-06 E= 3.00112419227
i= 2 Electron Coord.: x= 2.30356693789e-05 x'= 1.81178681222e-06 y= 2.70769424073e-06 y'= 1.69800387734e-06 E= 3.00249151578
i= 3 Electron Coord.: x= -4.12356508492e-05 x'= -2.36273974903e-05 y= 2.75360743031e-06 y'= 4.41985214074e-06 E= 2.99916732752
i= 4 Electron Coord.: x= 6.21094516163e-05 x'= -1.07174990888e-05 y= -1.19992938014e-06 y'= -3.97142680411e-06 E= 3.0004317949
Traceback (most recent call last):
  File "SRWLIB_Example10.py", line 217, in <module>
    os.path.join(os.getcwd(), strExDataFolderName, strIntPropME_OutFileName), sampFactNxNyForProp, optBL)
  File "/Users/vagrant/src/mrakitin/SRW/env/work/srw_python/srwlib.py", line 4593, in srwl_wfr_emit_prop_multi_e
    srwl_uti_save_stat_wfr_emit_prop_multi_e(i + 1, total_num_of_particles, filename=log_path)
  File "/Users/vagrant/src/mrakitin/SRW/env/work/srw_python/srwlib.py", line 3839, in srwl_uti_save_stat_wfr_emit_prop_multi_e
    srwl_uti_save_text(text_to_save, status_text_file, mode=mode)
  File "/Users/vagrant/src/mrakitin/SRW/env/work/srw_python/srwlib.py", line 3697, in srwl_uti_save_text
    with open(_file_path, mode) as f:
IOError: [Errno 2] No such file or directory: '/Users/vagrant/src/mrakitin/SRW/env/work/srw_python/__srwl_logs__/srwl_stat_wfr_emit_prop_multi_e_2017-01-30_19-59-32.log'
@robnagler
Copy link
Collaborator

I tested by setting the number of macro electrons down to 2, sorry.

@mrakitin
Copy link
Owner Author

mrakitin commented Feb 1, 2017

That's fine. I'll check what's going wrong there.

@robnagler
Copy link
Collaborator

robnagler commented Feb 1, 2017

I'm not seeing this error:

Calculation will be sequential (non-parallel), because "mpi4py" module can not be loaded
i= 0 Electron Coord.: x= -2.74452048352e-05 x'= -5.30201947148e-06 y= 3.33399322641e-06 y'= 8.88316322966e-07 E= 3.00238284361
i= 1 Electron Coord.: x= 2.94014986023e-05 x'= -3.43237532114e-06 y= -1.01652414766e-06 y'= -5.38704099806e-06 E= 3.00112419227
i= 2 Electron Coord.: x= 2.30356693789e-05 x'= 1.81178681222e-06 y= 2.70769424073e-06 y'= 1.69800387734e-06 E= 3.00249151578
i= 3 Electron Coord.: x= -4.12356508492e-05 x'= -2.36273974903e-05 y= 2.75360743031e-06 y'= 4.41985214074e-06 E= 2.99916732752
i= 4 Electron Coord.: x= 6.21094516163e-05 x'= -1.07174990888e-05 y= -1.19992938014e-06 y'= -3.97142680411e-06 E= 3.0004317949
i= 5 Electron Coord.: x= 7.3260748751e-05 x'= 7.79653887459e-06 y= 2.44371077004e-06 y'= -1.38341144966e-06 E= 2.99982473891
i= 6 Electron Coord.: x= 4.1509977579e-05 x'= -1.04050744888e-05 y= 5.52057700099e-06 y'= 1.56349806772e-06 E= 2.99922713544
i= 7 Electron Coord.: x= 9.59965901195e-06 x'= -1.88606855745e-05 y= 1.24538799667e-06 y'= -2.67208857646e-06 E= 3.00118094599
i= 8 Electron Coord.: x= 2.53495969248e-05 x'= 7.48612653311e-06 y= 5.81342573793e-07 y'= -4.05367374664e-06 E= 3.00299184895
i= 9 Electron Coord.: x= -4.13070513812e-05 x'= 4.35930554132e-06 y= -1.01591946856e-07 y'= 2.91897196637e-06 E= 3.00038364949

I'm running Sierra (10.12.3).

@mrakitin
Copy link
Owner Author

mrakitin commented Feb 1, 2017

Do you see __srwl_logs__ dir? Did it exist before? I would remove it and try to run this calculation again, since it fails create this directory due to the rank=1 instead of 0 in

if rank == 0:
.

@robnagler
Copy link
Collaborator

robnagler commented Feb 1, 2017

No, there is no __srwl_logs__ directory. I ran the example again. Then I ran it after creating __srwl_logs__. It ran fine, but didn't write any output there, but it did write to data_example_10/.

@mrakitin
Copy link
Owner Author

mrakitin commented Feb 2, 2017

That's strange - it's an old behavior and it should not happen in the most recent version. Do you have the latest changes from https://github.com/mrakitin/SRW/tree/master?

@robnagler
Copy link
Collaborator

Just did a clean build of master and still no errors and an empty __srwl_logs__ directory.

@robnagler
Copy link
Collaborator

ah, logs just showed up. :)

i= 3 Electron Coord.: x= -4.12356508492e-05 x'= -2.36273974903e-05 y= 2.75360743031e-06 y'= 4.41985214074e-06 E= 2.99916732752
i= 4 Electron Coord.: x= 6.21094516163e-05 x'= -1.07174990888e-05 y= -1.19992938014e-06 y'= -3.97142680411e-06 E= 3.0004317949
i= 5 Electron Coord.: x= 7.3260748751e-05 x'= 7.79653887459e-06 y= 2.44371077004e-06 y'= -1.38341144966e-06 E= 2.99982473891
i= 6 Electron Coord.: x= 4.1509977579e-05 x'= -1.04050744888e-05 y= 5.52057700099e-06 y'= 1.56349806772e-06 E= 2.99922713544
i= 7 Electron Coord.: x= 9.59965901195e-06 x'= -1.88606855745e-05 y= 1.24538799667e-06 y'= -2.67208857646e-06 E= 3.00118094599
  C-c C-cTraceback (most recent call last):
  File "/Users/nagler/src/mrakitin/SRW/env/work/srw_python/srwlib.py", line 4455, in srwl_wfr_emit_prop_multi_e
    srwl.CalcElecFieldSR(wfr, 0, _mag, arPrecParSR) #calculate Electric Field emitted by current electron
KeyboardInterrupt
i= 8 Electron Coord.: x= 2.53495969248e-05 x'= 7.48612653311e-06 y= 5.81342573793e-07 y'= -4.05367374664e-06 E= 3.00299184895
  C-c C-cTraceback (most recent call last):
  File "/Users/nagler/src/mrakitin/SRW/env/work/srw_python/srwlib.py", line 4471, in srwl_wfr_emit_prop_multi_e
    srwl.PropagElecField(wfr, _opt_bl) #propagate Electric Field emitted by the electron
RuntimeError: External (callback) function falied to modify (/ reallocate memory for) wavefront data.
i= 9 Electron Coord.: x= -4.13070513812e-05 x'= 4.35930554132e-06 y= -1.01591946856e-07 y'= 2.91897196637e-06 E= 3.00038364949
  C-c C-cTraceback (most recent call last):
  File "/Users/nagler/src/mrakitin/SRW/env/work/srw_python/srwlib.py", line 4471, in srwl_wfr_emit_prop_multi_e
    srwl.PropagElecField(wfr, _opt_bl) #propagate Electric Field emitted by the electron
RuntimeError: External (callback) function falied to modify (/ reallocate memory for) wavefront data.
  C-c C-cTraceback (most recent call last):
  File "SRWLIB_Example10.py", line 217, in <module>
    os.path.join(os.getcwd(), strExDataFolderName, strIntPropME_OutFileName), sampFactNxNyForProp, optBL)
  File "/Users/nagler/src/mrakitin/SRW/env/work/srw_python/srwlib.py", line 4509, in srwl_wfr_emit_prop_multi_e
    wfr.calc_stokes(workStokes) #calculate Stokes parameters from Electric Field
  File "/Users/nagler/src/mrakitin/SRW/env/work/srw_python/srwlib.py", line 1610, in calc_stokes
    _stokes.arS[i + nTot3] = 2*(-reEx*reEy + imEx*imEy) #check sign
KeyboardInterrupt
[2.7.9;@ski srw_python]$ ls -al __srwl_logs__/
total 16
drwxr-x---   4 nagler  staff   136 Feb  2 07:55 .
drwxr-x---  67 nagler  staff  2278 Feb  2 07:53 ..
-rw-------   1 nagler  staff   152 Feb  2 07:55 srwl_stat_wfr_emit_prop_multi_e_2017-02-02_07-54-25.json
-rw-r-----   1 nagler  staff    70 Feb  2 07:55 srwl_stat_wfr_emit_prop_multi_e_2017-02-02_07-54-25.log

@mrakitin
Copy link
Owner Author

mrakitin commented Feb 2, 2017

OK, I see. Thanks Rob. Do you use Python 2 or 3?

@robnagler
Copy link
Collaborator

I've been testing with 2.7.9. In general, we use py2.

@mrakitin
Copy link
Owner Author

mrakitin commented Feb 2, 2017

OK, I've reproduced the problem. It's not related to Mac, but rather to the mpi4py library. If it's not installed, the rank is 1, which does not trigger the directory creation. I'll change the name of the ticket and will fix the issue.

@mrakitin mrakitin changed the title Example 10 fails on Mac Example 10 fails without mpi4py library Feb 2, 2017
@mrakitin
Copy link
Owner Author

Too many 1st priorities, reduce priority to 2nd. Will take care of it after other 1st priority issues are solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants