diag_moldyn.py gets error for MD ouput files of Abinit-8.0.7  [SOLVED]

MULTIBINIT, aTDEP, ANADDB, optics, cut3d, mrg* postprocessors

Moderators: MMNSchmitt, gonze

Locked
thanusit
Posts: 70
Joined: Thu Jan 14, 2010 4:20 am

diag_moldyn.py gets error for MD ouput files of Abinit-8.0.7  [SOLVED]

Post by thanusit » Mon Jun 27, 2016 7:23 am

Dear All

I performed the tutorial lesson on Molecular Dynamics, tmoldyn_01, with Abinit-8.0.7. The calculation was successfully completed but post processing of the MD results with diag_moldyn.py got the following error:
...
[thanusit@physics-clusters tmoldyn_01]$ python diag_moldyn.py
Vous n'avez pas de fichier netcdf pour diagnostics !
...

I wonder if this is due to the script cannot cope with the change of file extension introduced in abinit-8.0.7, i.e. from _HIST to _HIST.nc, or other issues?

(Please note that my Abinit-8.0.7 was built with links against python-2.7.5, netcdf-4.3.1, hdf-5.18.12, openmpi-1.6.5.)


Regards,
Thanusit

User avatar
gmatteo
Posts: 291
Joined: Sun Aug 16, 2009 5:40 pm

Re: diag_moldyn.py gets error for MD ouput files of Abinit-8

Post by gmatteo » Wed Jun 29, 2016 1:25 pm

I wonder if this is due to the script cannot cope with the change of file extension introduced in abinit-8.0.7, i.e. from _HIST to _HIST.nc, or other issues?


Yes, could you try this patch?


=== modified file 'doc/tutorial/lesson_paral_moldyn/diag_moldyn.py'
--- doc/tutorial/lesson_paral_moldyn/diag_moldyn.py 2015-01-24 08:15:18 +0000
+++ doc/tutorial/lesson_paral_moldyn/diag_moldyn.py 2016-06-29 11:22:09 +0000
@@ -43,7 +43,7 @@
ok_OUT=-1;ok_MOLDYN=-1
if len(OUT_list) > 0 :
OUT_list.sort() ; OUT_list.reverse()
- fic_HIST=OUT_list[0][1].replace('_OUT.nc','_HIST')
+ fic_HIST=OUT_list[0][1].replace('_OUT.nc','_HIST.nc')
if os.path.exists(fic_HIST) :
fiche = fic_HIST
ok_OUT=0
@@ -74,7 +74,7 @@
TypeFichier=1
fichier1=file
fichier2=''
- elif file.find('_HIST') == len(file)-5 :
+ elif file.find('_HIST.nc') == len(file)-8 :
TypeFichier=2
fichier1=file
fichier2=file.replace('_HIST','_OUT.nc')

thanusit
Posts: 70
Joined: Thu Jan 14, 2010 4:20 am

Re: diag_moldyn.py gets error for MD ouput files of Abinit-8

Post by thanusit » Thu Jun 30, 2016 7:08 am

Dear Gmatteo

Thank you for your reply.
I tried the patch you suggested. This fixes the above error but a new one came up, as shown below.

Code: Select all

[thanusit@physics-clusters tmoldyn_01]$ python diag_moldyn_patched.py 
Traceback (most recent call last):
  File "diag_moldyn_patched.py", line 213, in <module>
    FDR = lireNetcdf()
  File "diag_moldyn_patched.py", line 60, in lireNetcdf
    ConvNetCdf_Ascii(fiche)
  File "diag_moldyn_patched.py", line 122, in ConvNetCdf_Ascii
    ncfile2 = netcdf.netcdf_file(fichier2, 'r')
  File "/share/apps/python2.7/gcc-4.7.2/lib/python2.7/site-packages/scipy/io/netcdf.py", line 198, in __init__
    self.fp = open(self.filename, '%sb' % mode)
IOError: [Errno 2] No such file or directory: 'tmoldyn_out_OUT.nc.nc'
Exception AttributeError: "'netcdf_file' object has no attribute 'fp'" in <bound method netcdf_file.close of <scipy.io.netcdf.netcdf_file object at 0xfb0610>> ignored



It looks like the '.nc' extension is appended to '_OUT.nc' so that the script is looking for '_OUT.nc.nc' which doesn't exist.

Regards,
Thanusit

User avatar
gmatteo
Posts: 291
Joined: Sun Aug 16, 2009 5:40 pm

Re: diag_moldyn.py gets error for MD ouput files of Abinit-8

Post by gmatteo » Thu Jun 30, 2016 11:01 am

I'm attaching another version of the script that seems to work.
I had to change the file extension by adding a `.log` at the end in order to upload the file.

HTH
M
Attachments
diag_moldyn.py.log
(7.75 KiB) Downloaded 412 times

thanusit
Posts: 70
Joined: Thu Jan 14, 2010 4:20 am

Re: diag_moldyn.py gets error for MD ouput files of Abinit-8

Post by thanusit » Fri Jul 01, 2016 12:27 am

Dear Gmatteo

That works.

Thank you very much.
Thanusit

Locked