- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The documentation says :
"All entry names within a function subprogram are associated with the name of the function subprogram. Therefore, defining any entry name or the name of the function subprogram defines all the associated names with the same data type. All associated names with different data types become undefined."
Well, in the following code, the function subprogram and the entry have different types, and it compiles and runs smoothly. According to the documentation, I should have some troubles. I did not.
Is anyway advisable avoiding entries of different types ? Is it a violation of the standard ?
Thanks for your attention.
"All entry names within a function subprogram are associated with the name of the function subprogram. Therefore, defining any entry name or the name of the function subprogram defines all the associated names with the same data type. All associated names with different data types become undefined."
Well, in the following code, the function subprogram and the entry have different types, and it compiles and runs smoothly. According to the documentation, I should have some troubles. I did not.
Is anyway advisable avoiding entries of different types ? Is it a violation of the standard ?
Thanks for your attention.
[fxfortran] PROGRAM TFENTRY REAL(8) :: A,B,C,D,E,F EXTERNAL :: MFUN, RFUN A=1.D0 B=2.D0 C=4.D0 D=8.D0 mmfun=mfun(a,b) rrfun=rfun(c,d) write (*,*) a,b,mmfun write (*,*) c,d,rrfun STOP END FUNCTION MFUN(P1,P2) REAL(8) :: P1,P2,P3,P4 REAL(8) :: A,B A = P1 B = P2 MFUN = A+B write (*,*) 'in mfun ',P1,P2,mfun GOTO 10 ENTRY RFUN(P3,P4) A = P3 B = P4 RFUN = A+B write (*,*) 'in rfun ',P3,P4,rfun 10 CONTINUE RETURN END [/fxfortran]
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This code is fine. What the standard says is that when you assign to MFUN, then any value previously assigned to RFUN is undefined, and vice-versa. Your example never uses the value of the "other" entry. For example, if you removed the GOTO in MFUN and, in the WRITE at line 33 you wrote out the value of mfun, it would be "wrong".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot for your really prompt response.
Then, I had misunderstood the meaning of "defines" in the documentation.
I did not get it referred to the behavior at runtime, and not at "declaration" time.
Thanks again.
Then, I had misunderstood the meaning of "defines" in the documentation.
I did not get it referred to the behavior at runtime, and not at "declaration" time.
Thanks again.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page