Parsing FORTRAN Output Files Using Java

Are there any open source Java tools for analyzing FORTRAN output? I would like to write something like

Format format = new Format("(1x, 2(F10.3,I3,' XY ',F7.3))");
String s = " -12345.897    XY 123.456-12345.897*** XY 123.456";
Result result = format.parse(s);   

Please note that this is specially FORTRAN. Pay attention to funny things like concatenated fields, overflows, empty space = 0, etc. There are so many mistakes that I don’t want to open them again!

COMMENT. I do not understand why this is the wrong way. The format is a compressed way to generate read code. An alternative would be hard coding for each format. If I have a file with - say, 100 different FORMAT outputs, then I should have 100 pieces of code. With the iChemLabs approach, I write:

List<Object> fields = FortranFormat.read(s, format);

and return double integer double double integer double

UPDATE: I tested iChemLabs for a reasonable amount of things. With spaces, it returns zero integers and doubles. C * is an exception (not unreasonable). It can manage multiple lines

fields = FortranFormat.read("   1\n    2", "(I4/I4)");

returns 2 integers (1 and 2)

UPDATE: The iChemLabs code specifically allows you to use empty input (but not asterisks):

public void setReturnZeroForBlanks(boolean returnZeroForBlanks)

    Set whether zeros are returned for blanks.

    Parameters:
        returnZeroForBlanks - the return zero for blanks
+3
source share
1 answer

It looks like this (both at the output and at the input). Last update: 1998!

Another one here - looks a little more polished? from iChemLabs

+3
source

Source: https://habr.com/ru/post/1772104/


All Articles