LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-24-2020, 11:00 AM   #1
chiendarret
Member
 
Registered: Mar 2007
Posts: 255

Rep: Reputation: 16
Fortran error reading line


On trying to read a molecular volumetric (cube) file with MOLDEN, error

Quote:
At line 923 of file rdgaus.f (unit = 21, file = 'mep.cube')
Fortran runtime error: Bad value during floating point read
line 923 is highlighted in the attached screenshot and I don't see any difference with respect to the other lines. Also, as far as I can view, line 923 conforms to the standard of GAUSSIAN CUBE files that are usually read by MOLDEN.

I hope that someone can see better than me.
chiendarret
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2020-05-22_11-10-23.png
Views:	12
Size:	85.8 KB
ID:	33258  
 
Old 05-24-2020, 12:04 PM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 1,126

Rep: Reputation: Disabled
Wait, the error message says it choked on line 923 of fortran file rdgaus.f when trying to read from mep.cube. It doesn't say what line in the input data file is wrong.

Try something silly like
Code:
awk '{for(i=1;i<=NF;i++)printf "%f ",$i;print""}' mep.cube
to see if awk can read the data.

Last edited by shruggy; 05-24-2020 at 12:12 PM.
 
1 members found this post helpful.
Old 05-24-2020, 01:27 PM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,807

Rep: Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867
additionally you may try (for example) od -xc mep.cube to see if there was something illegal (incorrect char) in it.
But first you need to find at least the approximate location (line number?) in that file.
 
1 members found this post helpful.
Old 05-25-2020, 02:45 AM   #4
chiendarret
Member
 
Registered: Mar 2007
Posts: 255

Original Poster
Rep: Reputation: 16
mep.cube could be read and nothing illegal came out. Suspecting a shortage of memory I tried on a linux box with more ram: same error.

I tried a small cube file for water (taken from the web) and MOLDEN showed correctly the map, colored by atomic charges.

therefore, I have now submitted the issue to the author of MOLDEN. probably the python software that I used to generate the cube file from ORCA data (as from my post of a week ago) does not provide a full standard.

it is not rare that we loose more time on visualization tools than on the scientific core problem

chiendarret
 
Old 05-25-2020, 03:23 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,807

Rep: Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867Reputation: 4867
if you could modify rdgaus.f (around line 923) you may have better information on the issue. Add some logs or debug info.
 
Old 05-25-2020, 08:14 AM   #6
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 1,126

Rep: Reputation: Disabled
Quote:
Originally Posted by chiendarret View Post
mep.cube could be read and nothing illegal came out.
After trying it out myself I realized that awk won't catch any badly formatted floating numbers anyway because it's too tolerant to what it gets on input. I tested it with this data:
Code:
-1.22372e-01  -1.21192e-01
-2.04038e-01  -2.03724e-O1  -2.03209e-01  -2.O2502e-01  -2.01616e-01  -2.00565e-01
I changed 0 (zero) to O (capital letter O) in two places marked red. And the awk output was:
Code:
-0.122372 -0.121192
-0.204038 -2.037240 -0.203209 -2.000000 -0.201616 -0.200565
As you can see, it just converted good parts of bad numbers up to an illegal character.

So, then I put my hope into anomaly, or datamash, or miller, or num-utils. As if! All those great tools (and I'm not sarcastic here, they are really great!) are designed according to the robustness principle: they would just silently discard any data that are not properly formatted numbers.

I ended up with the following solutions.

First, my test file:
Code:
$ cat mep.cube
The first comment line
The second comment line
-2 0.1 0.2 0.3 6
7 0.4 0.5 0.6
8 0.7 0.8 0.9
9 0.5 0.4 0.3
1 0.0 0.1 0.2 0.3
2 0.0 0.1 0.2 0.3
4 8 9
1 7 8 9
2 6 7 8
3 5 6 7
4 4 5 6
-1.22372e-01  -1.21192e-01
-2.04038e-01  -2.03724e-O1  -2.03209e-01  -2.O2502e-01  -2.01616e-01  -2.00565e-01
The first solution is quite simple, just check for illegal characters with grep:
Code:
$ tail -n+3 mep.cube|grep --color -Pn '[^-\s\d.e]'
13:-2.04038e-01  -2.03724e-O1  -2.03209e-01  -2.O2502e-01  -2.01616e-01  -2.00565e-01
You can do it in one command with sed, but sed won't colorize the matching parts:
Code:
$ sed -n '1,2d;/[^-\t 0-9.e]/p' mep.cube
-2.04038e-01  -2.03724e-O1  -2.03209e-01  -2.O2502e-01  -2.01616e-01  -2.00565e-01
OTOH, you'll get the exact line numbers that aren't off by two because of tail. Just replace p with = in the sed expression above, or add it like this:
Code:
sed '1,2d;/[^- 0-9.e]/!d;=' mep.cube
The second solution tries to validate the data, adjust it as needed:
Code:
#!/usr/bin/awk
NR==3{
  if ($1 < 0) {
    natoms=-$1; dset=1
  } else {
    natoms=$1;  dset=0
  }
}
NR==(6+natoms+dset) {
  if (dset) ndset=$1
}
NR>(6+natoms+dset+ndset) {
  for (i=1; i<=NF; i++)
    if ($i < -0.3 || $i > -0.1 )
      print "line",NR,"field",i,"value",$i
}

Last edited by shruggy; 05-25-2020 at 08:24 AM.
 
Old 05-27-2020, 01:12 AM   #7
chiendarret
Member
 
Registered: Mar 2007
Posts: 255

Original Poster
Rep: Reputation: 16
I could not follow all the procedure in the last post, however, what I can now say is that MOLDEN does not open the so called .cube file from ORCA because the ".cube" extension is no standard. Each package outputs its own type of .cube file and MOLDEN is not prepared to the ".cube" from ORCA (it opens three other types of .cube). One could say - and I would agree to clear from confusion - that each non standard cube file (which is proprietary) should not have the .cube extension.

I contacted MOLDEN, which perhaps will take into consideration in the future my request to support ORCA (which has become the most used QM package, particularly on large clusters). Because all other visualization free packages that I tried do not attain the quality of MOLDEN (actually - in my hands - they produce plots of the electrostatic potential that could hardly be used for publication), the solution would be to adapt mep.py (the python script that converts ORCA electrostatic potential data into a cube file) to output a cube file type supported by MOLDEN. This could only be done by a software engineer not by a biochemist as I am. And it would greatly serve the scientific community.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Programing Question: Reading file line by line.. then char by char in each line adriumroot Programming 8 05-30-2010 01:55 AM
how to Reading And Writing SAC (Seismic Analysis Code) Data Files in Fortran codes lengyue Linux - Software 2 12-03-2008 12:39 PM
g77 in gcc 4.1.0 not found only gfortran fortran 95 compiler! I need fortran 77. TheBrick Linux - Software 3 07-04-2007 06:39 AM
Gnu Fortran versus Intel Fortran tomatoefish Linux - Software 3 02-20-2006 01:31 PM
does linux fortran compiler in fedora 4 support VAX FORTRAN? terrence Programming 17 08-31-2005 08:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration