The code below compiles and runs with lfortran, gfortran, and g95
module m
implicit none
contains
pure character(len=len(s)) function to_lower(s)
! pure function to_lower(s)
character(len=*), intent(in) :: s
! character(len=len(s)) :: to_lower
integer :: i, k
do i = 1, len(s)
k = iachar(s(i:i))
if (k >= iachar(“A”) .and. k <= iachar(“Z”)) then
to_lower(i:i) = achar(k + 32)
else
to_lower(i:i) = s(i:i)
end if
end do
end function to_lower
end module m
program main
use m
implicit none
print “(a)”, to_lower("ABcD123/")
end program main
but ifx says
c:\python\fortran>ifx xto_lower.f90
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2025.0.4 Build 20241205
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.
xto_lower.f90(4): error #6362: The data types of the argument(s) are invalid. [LEN]
pure character(len=len(s)) function to_lower(s)
-----------------------------^
xto_lower.f90(6): error #6415: This name cannot be assigned this data type because it conflicts with prior uses of the name. [S]
character(len=), intent(in) :: s
-----------------------------------------^
xto_lower.f90(6): error #9020: Redeclaration of implicitly-declared character string must have a constant length. [S]
character(len=), intent(in) :: s
-----------------------------------------^
xto_lower.f90(21): error #7013: This module file was not generated by any release of this compiler. [M]
use m
----^
xto_lower.f90(23): error #6404: This name does not have a type, and must have an explicit type. [TO_LOWER]
print “(a)”, to_lower("ABcD123/")
-------------^
compilation aborted for xto_lower.f90 (code 1)
ifx compiles it if the commented out lines replace the first line of function to_lower
ping @greenrongreen