Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29276 Discussions

using an integer variable to control a format: is that possible?

johannes
Beginner
789 Views
Hi all.

Well, first of all, I'm sorry but I'm not quite sure if I'm posting it in the proper place. If the moderator thinks there is a best sub-forum for this question, please feel free to move it into there.

I'm trying to compile and run with ifc an code that has an write statement with implicit looping as follows:

write (96,'(F10.4,(X, E14.4))') ((rcut*ic)/nc)-(rcut/(2*nc)),(Rgrid(jrdf,ic,1),jrdf = 1,npares)

Unfortunatelly, it compiles perfectly, BUT when I run the code the program outputs me as a syntax error (a syntax error should not be outputed by the compiler itself, rather than the code running?). I also tried some clues that I could get, for example in this forum, here:

http://softwareforums.intel.com/ids/board/message?board.id=5&message.id=10256

But none of them worked out.

I don't even know if this kind of stuff is possible, But I don't know also where to get even this "yes" or "no". ;) Could anyone please help me with this subject?

Thanks a lot in advance! ;)
0 Kudos
4 Replies
TimP
Honored Contributor III
789 Views
Using an X format without a preceding integer constant was a fairly common extension in the past. Compilers vary in the extent to which they do compile time format checks. You slipped this one past the compiler, but the run time found it unacceptable.
0 Kudos
Steven_L_Intel1
Employee
789 Views
Tim is correct that the X edit descriptor without a count is non-standard. I think you are using ifc 7, which, if I recall coirrectly, did its format processing at run-time. ifort 8 should deal with this ok.
I don't see a connection to the subject of your message, though - perhaps it's due to my not having had any coffee yet?
0 Kudos
johannes
Beginner
789 Views
Hi. Sorry, but it seems that I didn't reviewed the message in an enough carefully way. So, the code line I tried to use were pasted wrongly, and I didn't noticed. What I tried is the following:

write (96,'(F10.4, npares+1 (X, E14.4))') ((rcut*ic)/nc) -(rcut/(2*nc)), (Rgrid(jrdf,ic,1),jrdf=1,npares)

This is a try to not have a defined number of maximum collums per line. Unfortunatelly, compiling doesn't show any problem, But when the program tries to write the file, it complains about the "npares+1" (npares is an integer, and that's how it`s related to the topic title! ;) ) in the write format. Basically, trying to have an "elegant" code or, at least, an "elegant" output. Hope now it's properly posted! ;) And thanks for any help possible. ;)

Message Edited by johannes@iq.ufrgs.br on 09-16-2004 12:23 PM

0 Kudos
Steven_L_Intel1
Employee
789 Views
Oh, I see. You are trying to use a feature called Variable Format Expressions. I don't know if version 7 supports this fully. Try this syntax:

write (96,'(F10.4, (X, E14.4))') ((rcut*ic)/nc) -(rcut/(2*nc)), (Rgrid(jrdf,ic,1),jrdf=1,npares)

Now it's possible you DID use that syntax and this forum didn't display it right... If so, then it is likely that ifc 7 doesn't support it. Version 8 definitely does.
0 Kudos
Reply