Silverfrost Forums

Welcome to our forums

Problem with PRIVATE and INCLUDE

30 Sep 2006 7:54 #1103

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:\arjen\flibs\tests\datastructures\salford\mem1.f90) 1/0001) ! mem1.f90 -- *** PRIVATE can only appear inside MODULE or TYPE blocks (In include file c:\arjen\flibs\tests\datastructures\salford\mem1.f90) *** Variable name expected 1/0005) public :: printline *** PRINTLINE has already been declared with the PUBLIC attribute (In include file c:\arjen\flibs\tests\datastructures\salford\mem1.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/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] *** Compilation abandoned

Can anyone confirm this?

I also included the code directly in the source file to be compiled and it was accepted without any problems and ran correctly. The point is though that this nullifies the genericity of the code.

Kind regards,

Arjen

30 Sep 2006 1:32 #1104

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.

2 Oct 2006 12:15 #1105

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

Please login to reply.