Loaded PSXE2016 start night and today had a first play with the much awaited SUBMODULES. consider the following code:
MODULE BILL implicit none public integer, parameter :: axs6_irk = kind(1.D0) ! real kind for dp integer, parameter, private :: irk = axs6_irk INTERFACE MODULE FUNCTION IS_LEAP_YEAR(IYEAR) INTEGER(KIND=2), INTENT(IN) :: IYEAR LOGICAL(KIND=4) :: IS_LEAP_YEAR END FUNCTION IS_LEAP_YEAR MODULE SUBROUTINE DVECRS(V1XV2,V1,V2) REAL(KIND=IRK) :: V1XV2(3) REAL(KIND=IRK), INTENT(IN) :: V1(3) REAL(KIND=IRK), INTENT(IN) :: V2(3) END SUBROUTINE DVECRS END INTERFACE END MODULE BILL
This compiles OK with no errors or warnings. Then we have.
submodule (BILL) BILL_SUBS1 contains function is_leap_year(iyear) ! returns true if iyear is a leap year and false otherwise implicit none logical(4) :: is_leap_year integer(2), intent (in) :: iyear if (mod(iyear,400_2) == 0) then ! special case for every 4th century is_leap_year=.true. elseif (mod(iyear,100_2) == 0) then ! centuries are not leap years is_leap_year=.false. elseif (mod(iyear,4_2) /= 0 ) then ! not divisible by 4 and not special case so not a leap year is_leap_year=.false. else is_leap_year=.true. ! divisible by 4 and not a special case to leap year endif end function is_leap_year subroutine dvecrs(V1XV2,V1,V2 ) ! THIS FORMS THE CROSS PRODUCT OF V1 AND V2 AS V1XV2 implicit none REAL(irk) :: V1XV2(3) REAL(irk), intent(in) :: V1(3) , V2(3) V1XV2 = [V1(2)*V2(3) - V1(3)*V2(2), -V1(1)*V2(3) + V1(3)*V2(1), V1(1)*V2(2) - V1(2)*V2(1)] end subroutine dvecrs end submodule BILL_SUBS1
This was a simple example using one function and one subroutine. I get the errors>>>>
sample2.f90(3): error #6645: The name of the module procedure conflicts with a name in the encompassing scoping unit. [IS_LEAP_YEAR]
sample2.f90(18): error #6645: The name of the module procedure conflicts with a name in the encompassing scoping unit. [DVECRS]
what have a done wrong? I have read various example etc and I can't see it though I may be suffering that brand of selective blindness that sometime filters out the glaring errors...