Are there any Open Source Java tools for parsing FORTRAN output? I'd like to be able 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);
Note that it's specifically FORTRAN. Note the fun things like concatenated fields, overflows, blank space=0, etc. There are so many gotchas that I don't want to rediscover them myself!
COMMENT. I don't see why this is a wrong way to go. The format is a concise way of generating the reading code. The alternative would be to hardcode a reader for each format. If I have a file with - say 100 different FORMAT outputs then I have to 100 chunks of code. With the iChemLabs approach I write:
List<Object> fields = FortranFormat.read(s, format);
and get back Double Integer String Double Double Integer String Double
UPDATE: I have tested the iChemLabs on a reasonable number of things. With blanks it returns null Integers and Doubles. With * it thows 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 for blank input (but not asterisks):
public void setReturnZeroForBlanks(boolean returnZeroForBlanks)
Set whether zeros are returned for blanks.
Parameters:
returnZeroForBlanks - the return zero for blanks