- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Are there any pitfalls when using FPP to manipulate non-Fortran text files?
We have some text data files. We want to build multiple versions of the data files from one master copy, using FPP and #ifdef #else #endif. I've tried this and it does work. But I am aware that FPP was not designed to do this, but only to preprocess Fortran code. I am worried that there could be pitfalls: certain text sequences that will cause behaviour that I don't want.
The text files are code-like: they contain lines like these below. They do not contain lines starting with the hash character #. The lines could be any length (I worry that there could be a maximum length.)
Begin Something
Element
' Comment
Property="Value"
OtherProperty=Value2
End Something
We are running FPP like this: fpp /P /undef /DPREPROCVAR=1 inputfile.txt outputfile.txt
Are there any pitfalls with this approach or things I should be aware of?
Thanks in advance
MarkJ
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Don't do this - Intel's fpp will completely mangle your text files as it restructures lines thinking they are Fortran statements.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use the standard Unix/Linux macro processor m4 for this purpose. On Windows, it is available under Cygwin, and other similar utility packages.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh dear! FPP worked very well in my tests, but maybe that's because my text file contents are fairly similar to Fortran statements.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I hate contradicting Steve, so I'm not *exactly* doing that ... however, if it's working for you, then please continue to use it.
it is true that fpp tries to ever-so-briefly parse the syntax, but it is not a complete compiler.
What you will need to worry about, however, is the line length. Fpp will try to re-format lines wider than 132 characters.
--Lorri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Lorri. In my experience you cannot go wrong following Steve's advice, so I have already switched over to using M4 as suggested by mecej4! I used a GNU Windows build rather than cygwin.
It did seem to be working fine with FPP but we feel more confident using M4. We have no long lines at the moment but it could happen in future
--Mark
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page