Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linux->Sun - compiler compatibility - allocatable dummy arg

Status
Not open for further replies.

flav256

Programmer
May 28, 2003
21
0
0
FR
Hi!

I have written a fortran program on a linux machine. I compiled this code with the fortran 6.5 Lahey compiler. It works fine.

Now I m trying to import this code on a sun machine. I don t manage to compile the same code with the fortran workshop for sun.

1- Is there any way to compile this code with a low compatibility option in the sun fortran compiler. I mean, can increase the tolerance of the sun compiler?

2- One of the main issue is the following :

this program aims to load a vector of data with 'num' values as type 'type' ('INTE' for integer or 'DOUB' for real(8))
the file looks like that
1222258 'INTE'
... 1222258 integers follows

#######################
Main MyProgram
implicit none
real(8), dimension:)),allocatable :: tab_doub
integer,dimension:)),allocatable :: tab_inte
integer :: num,fileID
character(4) :: type
...
...
call Read_SizeType(fileID,num,type)
...
call Read_Tab(...,fileID,tab_inte,tab_doub,num)
...
! use of tab_real or tab_doub
...
select case(type)
case('INTE')
deallocate(tab_inte)
case('DOUB')
deallocate(tab_doub)
end select
...
...
end MyProgram

!------------------
module MyModule
implicit none

contains

!!!
subroutine Read_SizeType(fileID,num,type)
integer, intent(out) :: num
character(4) :: type

read(fileID,FMT...) num,type
! read the header: the following data are either integer or real(8), there are num elements.
end subroutine Read_SizeType

!!!
subroutine Read_Tab(...,fileID,type,tab_real,tab_int,num)
real(8),dimension:)),allocatable,intent(out) :: tab_doub
integer,dimension:)),allocatable,intent(out) :: tab_inte
integer,intent(in) :: num,fileID
character(4),intent(in) :: type

select case(type)
case('INTE')
allocate(tab_inte)
read(fileID,FMT...) tab_inte
case('DOUB')
allocate(tab_doub)
read(fileID,FMT...) tab_doub
end select

end subroutine Read_Tab

end module MyModule
####################################
When I compile this piece of code :
"MyProgram.f90", Line = 72, Column = 40: ERROR: Attributes
INTENT and ALLOCATABLE must not appear in the same attribute list.

Regarding the structure of my code, and what I aim to do, Do you have an idea on how to get rid of this error?


Thanks

Flav256
 
I need your help !!!

Thks for your help!!!!!!

 
The error appears for these two lines :
real(8),dimension:)),allocatable,intent(out) :: tab_doub
integer,dimension:)),allocatable,intent(out) :: tab_inte
in the subroutine Read_tab
allocatable and intent or not compatible with the sun compiler, there is not problem with the linux lahey fortran compiler....

????
 
I don't have a Sun compiler so I can't try this out. At a guess, it is moaning about allocatable. Just remove the allocatable in the declaration in the subroutine. As long as you have it where you are passing it in, it should work.
 
hi, thank you.... That was not so tricky...
In fact, I changed the allocation statment... Now, I allocate my tab_ array in the main program... and that s ok!

Now, another error...
In my linux version I declared a type :
-----
module m_extract
use m_general

implicit none
type t_cell
logical :: active = .false.
end type t_cell

type t_grid
integer :: ni,nj,nk
integer :: ncells
type(t_cell), dimension:)),allocatable :: tab_cells
end type t_grid

contains
----
The dimension of tab_cells is ncells
When I read the value of ncells... I allocate tab_cells :
allocate(grid%tab_cells(grid%ncells))
(when grid is of type t_grid)

I have got this error when I compile:
"MyModule.f90", Line = 16, Column = 20: ERROR: Component "TAB_CELLS"
does not have a POINTER attribute so its dimension must be an explicit-shape
array with constant bounds.

We cannot define an allocatable array in a type declaration statement?

How can I define an allocatable array as a pointer in my type declaration?

Thanks

Flav256
 
That is one of the F90/95 things I haven't quite figured out. The way I normally do it is similar to what I would do in C
Code:
   type t_cell
      logical::active = .false.
   end type t_cell

   type t_grid
      integer :: ni, nj
      integer :: ncells
      ! declare as a pointer to an array
      type (t_cell), pointer ::tab_cells(:)
   end type t_grid
   ! must be a target otherwise you cannot point to it
   type (t_cell), allocatable, target, dimension(:)::cells
   type (t_grid)::grid

   !...
   grid%ncells = 42
   !...
   ! allocate a number of cells
   allocate (cells(grid%ncells))
   grid%tab_cells => cells
   !...
   ! accessing the pointer
   grid%tab_cells(20)%active = .true.
 
hey.... thks for your help... I managed to compile this module...

Now another problem...
The sun Workshop compiler !!!

In the Workshop Building windows, I try to build the Entire project or the target

the error is :
----------------------
dmake : Fatal Error in reader :
/users/MyName/projects/MyProject/.make.dependency.5418.0,line3: Unexpected end of line seen
dmake: Temp-file /users/MyName/projects/MyProject/.make.dependency.5418.0 not removed

Failed
------------------

What happend?
Could you help me please!!!!

Flav256
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top