Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26749 Discussions

Module function interface gives syntax error in XE2017

Andrew_Smith
New Contributor III
140 Views
module Fruit
   integer, parameter :: DP = 8
   interface
      real(DP) module function rasberry() result (ripple)
         implicit none
      end
   end interface
end module

Gives: error #6683: A kind type parameter must be a compile-time constant.   [DP]

If we move the declaration of rippple into the function then it compiles OK.

0 Kudos
7 Replies
Steve_Lionel
Black Belt Retired Employee
140 Views

Read this...

Andrew_Smith
New Contributor III
140 Views

Steve, your example is not for a module function, just a plain function.

It achieves nothing and is a syntax error to add "import" to a module function interface.

Steve_Lionel
Black Belt Retired Employee
140 Views

Ok, I missed that. It works when you declare the result separately. I agree that this is a compiler bug, and it is still present in the 18.0 beta.

andrew_4619
Honored Contributor I
140 Views

I hate the layout with the type before the function name which is why I have not had this problem ..... But it is clearly legal.

Mohammed_E_
Beginner
140 Views

hi all programmers
please i need a help
i have a project use 5 files "modules", there is no problem when i compile it , but without good results, and i think the problem is in the exchange of tables with this " modules'. so maybe i need to use the "interface"
the question is : it's necessairy to use the " interface " even if i use the " use" statement in the main program ?
when i use a " module " for interfaces , a number of problem appear

module variable
implicit none
………………………………………………..
all the variables that i need in the main program +
type :: atm_indice
sequence
integer::ind1,ind2,ind3,ind4
end type atm_indice

type (atm_indice), dimension(:), ALLOCATABLE :: cell_atm_indice1
………………………………………………………………………….
end module variable
MODULE position
contains
SUBROUTINE init_fcc(a,ncell_x_min,ncell_x_max,ncell_y_min, ncell_y_max,ncell_z_min, ncell_z_max,irefmin,irefmax,St_Summit,St_centre_f,St_centre_c,atype,rxi, ryi, rzi)
implicit none
integer,INTENT(in) ::ncell_x_min,ncell_x_max,ncell_y_min, ncell_y_max,ncell_z_min,& ncell_z_max,irefmin,irefmax
integer :: ix, iy, iz, iref
double precision,intent(in) :: a
character(len=2), INTENT(in) :: St_Summit,St_centre_f,St_centre_c
double precision , dimension(ncell_x_min:ncell_x_max, ncell_y_min:ncell_y_max, ncell_z_min:ncell_z_max, irefmin:irefmax) , INTENT(out) :: rxi, ryi, rzi
double precision , dimension (irefmin:irefmax) :: rx, ry, rz

character(len=2), dimension(ncell_x_min:ncell_x_max, ncell_y_min:ncell_y_max,& ncell_z_min:ncell_z_max, irefmin:irefmax) ,INTENT(out) :: atype

..... other specification statements .....
......... executable statements ..........
return
end SUBROUTINE init_fcc
SUBROUTINE fcc_spin(atype,ncell_x_min,ncell_x_max,ncell_y_min,ncell_y_max,ncell_z_min,ncell_z_max,irefmin,irefmax,St_Summit,St_centre_f,St_centre_c,S_Summit,S_centre_f,S_centre_c,spin)
implicit none
integer, intent(in) :: ncell_x_min,ncell_x_max,ncell_y_min, ncell_y_max,ncell_z_min, ncell_z_max,irefmin,irefmax
character(len=2), INTENT(in) :: St_centre_f,St_Summit,St_centre_c
double precision,intent(in) :: S_Summit,S_centre_f,S_centre_c
character(len=2), dimension(ncell_x_min:ncell_x_max, ncell_y_min:ncell_y_max,& ncell_z_min:ncell_z_max, irefmin:irefmax) , INTENT(in) :: atype
double precision, dimension(ncell_x_min:ncell_x_max, ncell_y_min:ncell_y_max, ncell_z_min:ncell_z_max, irefmin:irefmax),intent(out):: spin
integer:: i,j,k,ir

..... other specification statements .....
......... executable statements ..........

end SUBROUTINE fcc_spin

end MODULE position

module source1
use variable
contains
subroutine atmcont(atype,type_atm,ncell_x_min,ncell_x_max,ncell_y_min,& ncell_y_max,ncell_z_min, ncell_z_max,irefmin, irefmax,nbre_atm)
implicit none
character(len=2),dimension(ncell_x_min:ncell_x_max,ncell_y_min:ncell_y_max,ncell_z_min:ncell_z_max,irefmin:irefmax) , INTENT(in) :: atype
character(len=2) , INTENT(in) ::type_atm
integer,intent(in):: ncell_x_min, ncell_x_max,ncell_y_min, ncell_y_max,ncell_z_min, ncell_z_max,irefmin, irefmax
integer,intent(out)::nbre_atm
integer:: i,j,k,ir

..... other specification statements .....
......... executable statements ..........

end subroutine atmcont

subroutine atmindice(atype,type_atm,ncell_x_min,ncell_x_max,ncell_y_min,& ncell_y_max,ncell_z_min, ncell_z_max,irefmin, irefmax,cell_atm_indice,nbre_atm)
implicit none
integer,intent(in):: ncell_x_min, ncell_x_max,ncell_y_min, ncell_y_max,ncell_z_min, ncell_z_max,irefmin, irefmax
character(len=2) , INTENT(in) ::type_atm
integer,intent(in)::nbre_atm
character(len=2),dimension(ncell_x_min:ncell_x_max,ncell_y_min:ncell_y_max,ncell_z_min:ncell_z_max,irefmin:irefmax) , INTENT(in) :: atype
integer::erreur

type (atm_indice), dimension(nbre_atm), intent(out) :: cell_atm_indice
integer:: i,j,k,ir,ind

..... other specification statements .....
......... executable statements ..........

end subroutine atmindice
end module source1

module read_type
use variable
contains
subroutine read_file(unit)
implicit none
integer,intent(in) :: unit

..... other specification statements .....
......... executable statements ..........
end subroutine read_file

subroutine read_screen(unit)
implicit none
integer,intent(in) :: unit

..... other specification statements .....
......... executable statements ..........

end subroutine read_screen

subroutine write_file(unit)
implicit none
integer,intent(in) :: unit
end subroutine write_file

end module read_type

module dopage_display
use variable
contains
subroutine dopage(atype,spin,type_atm,percent_dop,type_atm_dop,spin_dop,cell_atm_indice,nbre_atm)
implicit none
character(len=2), dimension(:,:,:,:) , INTENT(inout) :: atype
double precision, dimension(:,:,:,:), INTENT(inout) :: spin
character(len=2),intent(in) :: type_atm_dop,type_atm
double precision, INTENT(in) :: spin_dop,percent_dop
integer,intent(in)::nbre_atm
integer:: cn,natm_D1,i,j,k,ir,ii,erreur
double precision:: qdrn1
type (atm_indice),dimension(nbre_atm), intent(in) :: cell_atm_indice

..... other specification statements .....
......... executable statements ..........

end subroutine dopage
end module dopage_display

module interface_source

interface posi
SUBROUTINE init_fcc(a,ncell_x_min,ncell_x_max,ncell_y_min, ncell_y_max,ncell_z_min, ncell_z_max,irefmin,irefmax,St_Summit,St_centre_f,St_centre_c,atype,rxi, ryi, rzi)
integer,INTENT(in) ::ncell_x_min,ncell_x_max,ncell_y_min, ncell_y_max,ncell_z_min, ncell_z_max,irefmin,irefmax
character(len=2), INTENT(in) :: St_Summit,St_centre_f,St_centre_c
double precision,intent(in) :: a
double precision , dimension(ncell_x_min:ncell_x_max, ncell_y_min:ncell_y_max, ncell_z_min:ncell_z_max, irefmin:irefmax) , INTENT(out) :: rxi, ryi, rzi
character(len=2), dimension(ncell_x_min:ncell_x_max, ncell_y_min:ncell_y_max, ncell_z_min:ncell_z_max, irefmin:irefmax) ,INTENT(out) :: atype
end subroutine
end interface posi

interface count
subroutine atmcont(atype,type_atm,ncell_x_min,ncell_x_max,ncell_y_min, ncell_y_max,ncell_z_min, ncell_z_max,irefmin, irefmax,nbre_atm)
character(len=2), dimension(ncell_x_min:ncell_x_max,ncell_y_min:ncell_y_max,ncell_z_min:ncell_z_max,irefmin:irefmax) , INTENT(in) :: atype
character(len=2) , INTENT(in) ::type_atm
integer,intent(in):: ncell_x_min, ncell_x_max,ncell_y_min, ncell_y_max,ncell_z_min, ncell_z_max,irefmin, irefmax
integer,intent(out)::nbre_atm
interface posi
SUBROUTINE init_fcc(a,ncell_x_min,ncell_x_max,ncell_y_min, ncell_y_max,ncell_z_min, ncell_z_max,irefmin,irefmax,St_Summit,St_centre_f,St_centre_c,atype,rxi, ryi, rzi)
integer,INTENT(in) ::ncell_x_min,ncell_x_max,ncell_y_min, ncell_y_max,ncell_z_min, ncell_z_max,irefmin,irefmax
character(len=2), INTENT(in) :: St_Summit,St_centre_f,St_centre_c
double precision,intent(in) :: a
double precision , dimension(ncell_x_min:ncell_x_max, ncell_y_min:ncell_y_max, ncell_z_min:ncell_z_max, irefmin:irefmax) , INTENT(out) :: rxi, ryi, rzi
character(len=2), dimension(ncell_x_min:ncell_x_max, ncell_y_min:ncell_y_max, ncell_z_min:ncell_z_max, irefmin:irefmax) ,INTENT(out) :: atype
end subroutine
end interface posi
end subroutine
end interface count

interface spincnofig
SUBROUTINE fcc_spin(atype,ncell_x_min,ncell_x_max,ncell_y_min, ncell_y_max,ncell_z_min, ncell_z_max,irefmin,irefmax,St_Summit,St_centre_f,St_centre_c,S_Summit,S_centre_f,S_centre_c,spin)
integer, intent(in) :: ncell_x_min,ncell_x_max,ncell_y_min, ncell_y_max,ncell_z_min, ncell_z_max,irefmin,irefmax
character(len=2), INTENT(in) :: St_centre_f,St_Summit,St_centre_c
double precision,intent(in) :: S_Summit,S_centre_f,S_centre_c
character(len=2), dimension(ncell_x_min:ncell_x_max, ncell_y_min:ncell_y_max, ncell_z_min:ncell_z_max, irefmin:irefmax) , INTENT(in) :: atype
double precision, dimension(ncell_x_min:ncell_x_max, ncell_y_min:ncell_y_max, ncell_z_min:ncell_z_max, irefmin:irefmax),intent(out):: spin
interface posi
SUBROUTINE init_fcc(a,ncell_x_min,ncell_x_max,ncell_y_min, ncell_y_max,ncell_z_min, ncell_z_max,irefmin,irefmax,St_Summit,St_centre_f,St_centre_c,atype,rxi, ryi, rzi)
integer,INTENT(in) ::ncell_x_min,ncell_x_max,ncell_y_min, ncell_y_max,ncell_z_min, ncell_z_max,irefmin,irefmax
character(len=2), INTENT(in) :: St_Summit,St_centre_f,St_centre_c
double precision,intent(in) :: a
double precision , dimension(ncell_x_min:ncell_x_max, ncell_y_min:ncell_y_max, ncell_z_min:ncell_z_max, irefmin:irefmax) , INTENT(out) :: rxi, ryi, rzi
character(len=2), dimension(ncell_x_min:ncell_x_max, ncell_y_min:ncell_y_max, ncell_z_min:ncell_z_max, irefmin:irefmax) ,INTENT(out) :: atype
end subroutine
end interface posi
end subroutine
end interface spincnofig
end module interface_source

the main program :

program simulation
use variable
use read_type
use position
use dopage_display
use source1
use interface_source
implicit none
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!allocation variables!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
allocate ( angle_t1( ncell_x_min1:ncell_x_max1,ncell_y_min1:ncell_y_max1,ncell_z_min1:ncell_z_max1,irefmin1:irefmax1 ) ,&
angle_p1( ncell_x_min1:ncell_x_max1,ncell_y_min1:ncell_y_max1,ncell_z_min1:ncell_z_max1,irefmin1:irefmax1 ), stat=erreur )
IF(erreur /= 0 ) THEN
WRITE(*,*) "erreur allocation angle "
STOP
END IF
allocate ( itype1( ncell_x_min1:ncell_x_max1,ncell_y_min1:ncell_y_max1,ncell_z_min1:ncell_z_max1,irefmin1:irefmax1 ) , stat=erreur )
IF(erreur /= 0 ) THEN
WRITE(*,*) "erreur allocation itype1 "
STOP
END IF

allocate ( spin1( ncell_x_min1:ncell_x_max1,ncell_y_min1:ncell_y_max1,ncell_z_min1:ncell_z_max1,irefmin1:irefmax1 ) , stat=erreur )
IF(erreur /= 0 ) THEN
WRITE(*,*) "erreur allocation spin1"
STOP
END IF

allocate ( spin2( ncell_x_min1:ncell_x_max1,ncell_y_min1:ncell_y_max1,ncell_z_min1:ncell_z_max1,irefmin1:irefmax1 ) , stat=erreur )
IF(erreur /= 0 ) THEN
WRITE(*,*) "erreur allocation spin2"
STOP
END IF
allocate ( rxi1( ncell_x_min1:ncell_x_max1,ncell_y_min1:ncell_y_max1,ncell_z_min1:ncell_z_max1,irefmin1:irefmax1 ),&
ryi1( ncell_x_min1:ncell_x_max1,ncell_y_min1:ncell_y_max1,ncell_z_min1:ncell_z_max1,irefmin1:irefmax1 ),&
rzi1( ncell_x_min1:ncell_x_max1,ncell_y_min1:ncell_y_max1,ncell_z_min1:ncell_z_max1,irefmin1:irefmax1 ) , stat=erreur )
IF(erreur /= 0 ) THEN
WRITE(*,*) "erreur allocation rxi1,ryi1,rzi1"
STOP
END IF
allocate ( atype1( ncell_x_min1:ncell_x_max1,ncell_y_min1:ncell_y_max1,ncell_z_min1:ncell_z_max1,irefmin1:irefmax1 ) , stat=erreur )
IF(erreur /= 0 ) THEN
WRITE(*,*) "erreur allocation atype1 "
STOP
END IF

..... other specification statements .....
......... executable statements ..........

call init_fcc(a1,ncell_x_min1,ncell_x_max1,ncell_y_min1, ncell_y_max1,ncell_z_min1, ncell_z_max1,irefmin1,irefmax1,St_Summit1,St_centre_f1,St_centre_c1,atype1, rxi1, ryi1, rzi1)

call init_fcc(a1,ncell_x_min2,ncell_x_max2,ncell_y_min2, ncell_y_max2,ncell_z_min2, ncell_z_max2,irefmin1,irefmax1,St_Summit1,St_centre_f1,St_centre_c1,atype2, rxi1, ryi1, rzi1)

call fcc_spin(atype1,ncell_x_min1,ncell_x_max1,ncell_y_min1, ncell_y_max1,ncell_z_min1, ncell_z_max1,irefmin1,irefmax1,St_Summit1,St_centre_f1,St_centre_c1,S_Summit1,S_centre_f1,S_centre_c1,spin1)

call fcc_spin(atype2,ncell_x_min2,ncell_x_max2,ncell_y_min2, ncell_y_max2,ncell_z_min2, ncell_z_max2,irefmin1,irefmax1,St_Summit1,St_centre_f1,St_centre_c1,S_Summit1,S_centre_f1,S_centre_c1,spin2)

call atmcont(atype2,type_atm1,ncell_x_min2,ncell_x_max2,ncell_y_min2, ncell_y_max2,ncell_z_min2, ncell_z_max2,irefmin1, irefmax1,nbre_atm_s)
allocate ( cell_atm_indice1(nbre_atm_s) , stat=erreur )
IF(erreur /= 0 ) THEN
WRITE(*,*) "erreur allocation cell_atm_indice 1"
STOP
END IF

call atmindice(atype2,type_atm1,ncell_x_min2,ncell_x_max2,ncell_y_min2, ncell_y_max2,ncell_z_min2, ncell_z_max2,irefmin1, irefmax1,cell_atm_indice1,nbre_atm_s)

call dopage(atype2,spin2,type_atm1,percent_dop1,type_atm_dop1,spin_dop1,cell_atm_indice1,nbre_atm_s)

deallocate(cell_atm_indice1)

..... other specification statements .....
......... executable statements ..........

deallocate(itype1,spin1,teta1,phi1,dEn1,angle_t1,angle_p1,rxi1,ryi1,rzi1,atype1)
end program simulation

andrew_4619
Honored Contributor I
140 Views

when you have a MODULE the interfaces for any CONTAINed subroutines/functions are automatically created and made available in other places by the USE statement. The interfaces will cause and error because it is defining the same thing 2 times. You may be confused with the SUBMODULE feature where you do need to create interfaces. I suggest you read some fortran text book on this. 

Devorah_H_Intel
Moderator
140 Views

Andrew - Thank you for your report! This issue is better to be reported via our Online Service Center at https://supporttickets.intel.com/  
Instructions on how to file a ticket are available here: 
https://software.intel.com/en-us/articles/how-to-create-a-support-request-at-online-service-center  

 

Reply