After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 523167 - Fortran main program call&caller graphs
Fortran main program call&caller graphs
Status: RESOLVED FIXED
Product: doxygen
Classification: Other
Component: general
1.5.5-SVN
Other Linux
: Normal major
: ---
Assigned To: Dimitri van Heesch
Dimitri van Heesch
Depends on:
Blocks:
 
 
Reported: 2008-03-18 13:43 UTC by Alin M Elena
Modified: 2015-06-17 16:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch to treat PROGRAM statements in Fortran as subroutines and functions (5.34 KB, patch)
2009-06-20 21:26 UTC, AstroFloyd
none Details | Review
Original (alternative) patch to treat PROGRAM statements in Fortran as subroutines and functions (2.52 KB, patch)
2009-06-26 14:58 UTC, Oleg Batrashev
none Details | Review
doxyfile used (8.92 KB, text/plain)
2015-06-17 16:17 UTC, Alin M Elena
  Details

Description Alin M Elena 2008-03-18 13:43:38 UTC
in the case of fortran codes the main program does not get a call graph and is not included in any caller graphs

program test
implicit none

call a

end program test

subroutine a
print *, "Hello world"
end subroutine a
Comment 1 Oleg Batrashev 2008-05-26 11:11:26 UTC
I looked into this problem and it does not seem easy to solve. NamespaceDef entities are not MemberDef entities and it looks like many things has to be changes to solve this problem.

The easiest way (requires almost no changes) is to make Function entities from 'programs' and leave 'modules' as Namespace entities. I've tried it out and it works, the only visible consequence is that they are not listed under modules list anymore. Actually, it may be the correct behaviour, because they have code to run and their local variables are not exposed to others.

I do not know how and where global (not module) variables are declared. This may be important, because once we make Functions out of 'programs' we may get into troubles with their visibility.
Comment 2 xavier perois 2008-07-03 15:28:35 UTC
I found the same problem. The solution was to use a "C like" style with a main subroutine :

program test
call main()
contains
   subroutine main()
      implicit none
      call a
   end subroutine main
end program test

subroutine a
print *, "Hello world"
end subroutine a

Just a workaround with some lines more, but then you have a complete call graph
Comment 3 AstroFloyd 2009-06-20 21:26:54 UTC
Created attachment 137091 [details] [review]
Proposed patch to treat PROGRAM statements in Fortran as subroutines and functions

This patch *seems* to fix the fact that the program statement in Fortran is treated by doxygen as a module rather than a subroutine or function.  However, I don't know doxygen very well, so I may have missed something.
Comment 4 AstroFloyd 2009-06-20 21:30:17 UTC
(Apparently, I lost the body of my message while uploading the attachment in the previous post.  Here it is.)


Comment 5 AstroFloyd 2009-06-20 21:31:05 UTC
(Apparently, I lost the body of my message while uploading the attachment in the previous post.  Here it is.)


(In reply to comment #1)
> The easiest way (requires almost no changes) is to make Function entities from
> 'programs' and leave 'modules' as Namespace entities. I've tried it out and it
> works, the only visible consequence is that they are not listed under modules
> list anymore. Actually, it may be the correct behaviour, because they have code
> to run and their local variables are not exposed to others.

I think this is the correct behaviour.  The Fortran 
program name
  ...
end program name

defines the main routine of a program, just like the 

void main() {
  ...
}

statement in C.  Hence there can only be one such routine in a program, and it 
cannot be called by other routines.  Other than that, the contents of a program
are the same as those of a subroutine or a function.  Hence, a program should
NOT be listed under modules (as it is now) and should be treated as a subroutine
or function, so that it is included in the call graph (which it isn't at the 
moment, which, it being the main routine, has quite an impact on the call graph.


> I do not know how and where global (not module) variables are declared. This
> may be important, because once we make Functions out of 'programs' we may get
> into troubles with their visibility.

I have been programming in Fortran for about eight years now, and I have never 
used a global variable (as they exist in C).  I have tried to look up 'global
variables' in my reference books and google for them, but can't find anything 
else than 'use modules' (or common blocks for Fortran 77).

It would be really useful if this change were made (treat program as subroutine).  
I attach a patch for doxygen 1.5.8 that seems to do the trick, though I'm not 
100% confident that I didn't miss anything.  If someone who knows doxygen better
could check, that would be great, I'd like to push the patch into the Gentoo 
package tree until it's resolved here.

Comment 6 Oleg Batrashev 2009-06-26 14:58:10 UTC
Created attachment 137423 [details] [review]
Original (alternative) patch to treat PROGRAM statements in Fortran as subroutines and functions

This is one mentioned in comment 1. Need to figure out if this fix is better. In the while solving some serious caller/callee issues (local variables are ignored).
Comment 7 Dimitri van Heesch 2009-07-18 21:56:19 UTC
Thanks Oleg, I'll include your patch in the next subversion update.
Comment 8 Dimitri van Heesch 2009-08-20 10:13:22 UTC
This bug was previously marked ASSIGNED, which means it should be fixed in
doxygen version 1.6.0. Please verify if this is indeed the case and reopen the
bug if you think it is not fixed (include any additional information that you
think can be relevant).
Comment 9 Stas 2015-06-16 17:25:23 UTC
For me this bug is still present in the version 1.8.9.

Can some one test it?
Comment 10 AstroFloyd 2015-06-17 15:55:44 UTC
Doxygen 1.8.9 seems to be fine for me.  I just reran it for rochePlot and the program is recognised as such, and shows up in Caller and Callee graphs: http://tinyurl.com/oowsw99
Comment 11 Alin M Elena 2015-06-17 16:17:01 UTC
I tested it with my original example... and with the attached Doxyfle and works!


Regards,
Alin
Comment 12 Alin M Elena 2015-06-17 16:17:39 UTC
Created attachment 305493 [details]
doxyfile used