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