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

colon :

Ahmad_Falahatpisheh
1,324 Views
Hi my friends,

Could anyone tell me what the following two commands do?

IMAX = SUM(J=1,NB):NG(J)
NF = MAX(J=1,NB):SUM(I=IBEGIN(J),IEND(J)):NFG(I)*NPF(I)

In what FORTRAN version are they available?

Thanks.
0 Kudos
1 Solution
mecej4
Honored Contributor III
1,324 Views
In your first post, you wrote "command" where, if you had written "comment", you would have transferred much less confusion to your readers.

The author of the comments seems to be transcribing standard mathematical notation to ASCII text in a straightforward way. For example,

IMAX = SUM(J=1,NB):NG(J)

should perhaps be read as

nb
IMAX = ngj
j=1

and is by no means to be thought of as Fortran syntax.

Knuth proposed Literate Programming as a solution for such infelicities. The idea was that when you ran the compiler on your source code, there were two output files produced: i) an object file, to be linked with other object files and libraries, as usual, and ii) a document file, such as a Postscript or PDF file, which could be displayed to view mathematical comments in universal notation.

View solution in original post

0 Kudos
6 Replies
TimP
Honored Contributor III
1,324 Views
Are you certain you've quoted this accurately? Colon has been given some non-standard meanings by certain past compilers, and has a standard meaning in syntax somewhat close to what you quoted.
0 Kudos
Ahmad_Falahatpisheh
1,324 Views
Actually I want to modify a code which is previously written by somebody else. It is said as a comment in the code that:
IMAX = SUM(J=1,NB):NG(J)
NF = MAX(J=1,NB):SUM(I=IBEGIN(J),IEND(J)):NFG(I)*NPF(I)

I am kind of confused. I haven't seen such a thing. I would appreciate it if you could let me know what you understand from that.

0 Kudos
mecej4
Honored Contributor III
1,325 Views
In your first post, you wrote "command" where, if you had written "comment", you would have transferred much less confusion to your readers.

The author of the comments seems to be transcribing standard mathematical notation to ASCII text in a straightforward way. For example,

IMAX = SUM(J=1,NB):NG(J)

should perhaps be read as

nb
IMAX = ngj
j=1

and is by no means to be thought of as Fortran syntax.

Knuth proposed Literate Programming as a solution for such infelicities. The idea was that when you ran the compiler on your source code, there were two output files produced: i) an object file, to be linked with other object files and libraries, as usual, and ii) a document file, such as a Postscript or PDF file, which could be displayed to view mathematical comments in universal notation.
0 Kudos
Ahmad_Falahatpisheh
1,324 Views
Thanks a lot. That is a very good explanation. Literate programming is interesting.

Do you know what the MAX(J=1,NB) is in the second comment: NF = MAX(J=1,NB):SUM(I=IBEGIN(J),IEND(J)):NFG(I)*NPF(I) Can it be equivalent to the following?


DO J=1,NB
l.gif
END DO

Then pick NF as the maximum element of NF1 array? Is this what you also understand from it?

I have another question that whether IFORT can make the document file such as a Postscript or PDF?

Thank you.
0 Kudos
mecej4
Honored Contributor III
1,324 Views
Thanks a lot. That is a very good explanation. Literate programming is interesting.

See here for Knuth's ideas. In that paper he make this cynical comment: "..some of us are glad that traditional programming languages have comparatively primitive capabilities for inserted comments, because such difficulties provide a good excuse for not documenting programs well."

Do you know what the MAX(J=1,NB) is in the second comment: NF = MAX(J=1,NB):SUM(I=IBEGIN(J),IEND(J)):NFG(I)*NPF(I) Can it be equivalent to the following?


DO J=1,NB
l.gif
END DO

Then pick NF as the maximum element of NF1 array? Is this what you also understand from it?

That is a reasonable conclusion. Only the author of the comment can confirm. Another, if less likely, interpretation is that NF is to be given the index value of the element in your array NF1 that contains the maximal value.

I have another question that whether IFORT can make the document file such as a Postscript or PDF?

That would make a Swiss Army Knife out of a compiler. There are third party tools to print program text with syntax highlighting, in HTML, PS, PDF, etc., but almost none that can do full-fledged mathematical typesetting. You would need more mark-up information in the source file than that which you have shown to make this possible.

0 Kudos
Arjen_Markus
Honored Contributor II
1,324 Views
A tool like doxygen is well capable of transforming specially formatted comments into mathematical
formulae. Perhaps that isclose enoughto what you want?

Regards,

Arjen
0 Kudos
Reply