forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with PRIVATE and INCLUDE

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
arjenmarkus



Joined: 30 Sep 2006
Posts: 2

PostPosted: Sat Sep 30, 2006 8:54 am    Post subject: Problem with PRIVATE and INCLUDE Reply with quote

Hello,

I am experimenting a bit with the Salford compiler (personal edition) and I got a few problems. The code below
produces error messages that seem to me incorrect (other compilers, gfortran, g95 and Compaq Visual Fortran
had no such problems - at least with the full program, see below):

! test_mem1.f90 --
! Define a module with included source
!
module mem1
include 'mem1.f90'
end module

program test_mem1
use mem1

call printline( 'Hm' )

end program test_mem1

The include file "mem1.f90" contains the following text:

! mem1.f90 --
! Simply include the source text
!

public :: printline
private

contains

! printline --
! Subroutine to print a line of text
!
subroutine printline( string )
character(len=*) :: string

write(*,*) string

end subroutine printline

The error messages I get are:

[FTN95/Win32 Ver. 4.9.0 Copyright (C) Silverforst Ltd 1993-2005]
PROCESSING MODULE [<MEM1> FTN95/Win32 v4.9.0]
1/0005) public :: printline
*** PRINTLINE has already been declared with the PUBLIC attribute (In include
file c:arjenflibstestsdatastructuressalfordmem1.f90)
1/0001) ! mem1.f90 --
*** PRIVATE can only appear inside MODULE or TYPE blocks (In include file
c:arjenflibstestsdatastructuressalfordmem1.f90)
*** Variable name expected
1/0005) public :: printline
*** PRINTLINE has already been declared with the PUBLIC attribute (In include
file c:arjenflibstestsdatastructuressalfordmem1.f90)
*** PRINTLINE has already been declared with the PUBLIC attribute
*** PRINTLINE has already been declared with the PUBLIC attribute
*** PRINTLINE has already been declared with the PUBLIC attribute
*** PRINTLINE has already been declared with the PUBLIC attribute
*** PRINTLINE has already been declared with the PUBLIC attribute
*** PRINTLINE has already been declared with the PUBLIC attribute
*** PRINTLINE has already been declared with the PUBLIC attribute
*** PRINTLINE has already been declared with the PUBLIC attribute
*** PRINTLINE has already been declared with the PUBLIC attribute
*** Too many errors

14 ERRORS [test_mem1.F90] - Compilation failed.

The above program is an attempt to isolate another problem - as the code is some 300 lines
I hesitate to post it here. This has very much the same structure:
- The actual code for the module is in an INCLUDEd file (so that the definitions of _specific_
derived types can stay outside the generic code)
- The code that includes the file consists of little more than "module -- include file -- end module"

However, with that program the compiler runs into an infinite loop. The first part of
the output is:

[FTN95/Win32 Ver. 4.9.0 Copyright (C) Silverforst Ltd 1993-2005]
PROCESSING MODULE [<MYDATA_MODULE> FTN95/Win32 v4.9.0]
NO ERRORS [<MYDATA_MODULE> FTN95/Win32 v4.9.0]
PROCESSING MODULE [<MYDATA_POOL> FTN95/Win32 v4.9.0]
NO ERRORS [<MYDATA_POOL> FTN95/Win32 v4.9.0]
0015) module MYDATA_POOL
*** This module has already been defined
PROCESSING MODULE [<MYDATA_POOL> FTN95/Win32 v4.9.0]
1 ERROR [<MYDATA_POOL> FTN95/Win32 v4.9.0]
*** This module has already been defined
PROCESSING MODULE [<MYDATA_POOL> FTN95/Win32 v4.9.0]
1 ERROR [<MYDATA_POOL> FTN95/Win32 v4.9.0]
*** This module has already been defined
PROCESSING MODULE [<MYDATA_POOL> FTN95/Win32 v4.9.0]
1 ERROR [<MYDATA_POOL> FTN95/Win32 v4.9.0]
*** This module has already been defined
PROCESSING MODULE [<MYDATA_POOL> FTN95/Win32 v4.9.0]
1 ERROR [<MYDATA_POOL> FTN95/Win32 v4.9.0]

...

*** This module has already been defined
PROCESSING MODULE [<MYDATA_POOL> FTN95/Win32 v4.9.0]
1 ERROR [<MYDATA_POOL> FTN95/Win32 v4.9.0]
*** This module has already been defined
PROCESSING MODULE [<MYDATA_POOL> FTN95/Win32 v4.9.0]
1 ERROR [<MYDATA_POOL> FTN95/Win
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sat Sep 30, 2006 2:32 pm    Post subject: Problem with PRIVATE and INCLUDE Reply with quote

Arjen

Yes FTN95 gets confused by this usage of INCLUDE.
It works OK if you put the whole of the module in the include file, from MODULE to END MODULE.
I will log it as a bug.
Back to top
View user's profile Send private message AIM Address
arjenmarkus



Joined: 30 Sep 2006
Posts: 2

PostPosted: Mon Oct 02, 2006 1:15 am    Post subject: Problem with PRIVATE and INCLUDE Reply with quote

Ah, thanks for the reply.

Like I said: using INCLUDE is important for this code as it is a method to achieve
a certain level of "genericity".

Regards,

Arjen
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group