Importance of module use order?

Arjen Markus arjen.markus895@gmail.com
Fri Dec 16 12:05:00 GMT 2011


Hi Billy,

I have no answer for you, but I would suggest that you post this on
the comp.lang.fortran
newsgroup as well. It transcends gfortran as such, especially if the
standard is not
clear about it.

Regards,

Arjen

2011/12/16 Billy Backer <billybacker@yahoo.co.uk>:
> Hi,
>
> This may be a silly question, but I have a routine that uses two modules (mod1 & mod2).
> One of the modules (mod2) uses the other module (mod1) - so effectively the main routine
> is doubly using mod1. I was wondering if it is important regarding the order of the use
> statements in the main routine, see below:
>
> -----------------------------------
> module mod1
> integer :: axx=2
> end module mod1
>
> module mod2
> use mod1
> end module mod2
>
> subroutine sub1
> use mod1, oxx=>axx
> use mod2
> implicit none
> print*,axx   !line compiles OK for gfortran, fails for Intel
> end subroutine sub1
>
> subroutine sub2
> use mod2
> use mod1, oxx=>axx
> implicit none
> print*,axx  !line fails to compile for gfortran, OK for Intel
> end subroutine sub2
> -----------------------------------
>
> NOTE: I would expect variable "axx" to be non-visible for both routines.
> Interestingly, the Intel compiler behaves
> in the opposite sense. I can't find anything in the fortran-standard
> that mentions module ordering. Do you think the
> behaviour is compiler specific?
>
> Thanks in advance,
>
> Billy Backer
>



More information about the Fortran mailing list