- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
program testit
write(*,'(*(g0))')'[',atleast('',10),']'
write(*,'(*(g0))')'[',atleast('a',10),']'
write(*,'(*(g0))')'[',atleast('ab',10),']'
write(*,'(*(g0))')'[',atleast('abc',10),']'
write(*,'(*(g0))')'[',atleast('abcdefghijklmopqrstuvwxyz',10),']'
write(*,'(*(g0))')'[',atleast('',10,'_'),']'
write(*,'(*(g0))')'[',atleast('a',10,'_'),']'
write(*,'(*(g0))')'[',atleast('ab',10,'_'),']'
write(*,'(*(g0))')'[',atleast('abc',10,'_'),']'
write(*,'(*(g0))')'[',atleast('abcdefghijklmopqrstuvwxyz',10,'_'),']'
contains
function atleast(line,length,pattern) result(strout)
!$@(#) M_strings::atleast(3f): return string padded to at least specified length
character(len=*),intent(in) :: line
integer,intent(in) :: length
character(len=*),intent(in),optional :: pattern
character(len=max(length,len(trim(line)))) :: strout
if(present(pattern))then
!!strout=line//repeat(pattern,strout%len/pattern%len+1)
strout=line//repeat(pattern,len(strout)/len(pattern)+1)
else
strout=line
endif
end function atleast
end program testit
!bug1.f90(20): error #6460: This is not a component name that is defined in the encompassing structure. [LEN]
! strout=line//repeat(pattern,strout%len/pattern%len+1)
! --------------------------------------^
! bug1.f90(20): error #6158: The structure-name is invalid or is missing. [STROUT]
! strout=line//repeat(pattern,strout%len/pattern%len+1)
! -------------------------------^
A little procedure has worked for a long time with at least three compilers. If At line 20 I change "len(pattern)" to "pattern%len" it is fine, but if I change "len(strout)" to "strout%len" I get the errors show from line 27 to 32. It seems to me that line 20 is the equivalent of line 21 and should work.
Should line 20 work, or produce an error?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The problem is escalated to the Intel Fortran compiler development team. Thank you for reporting it.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I haven't studied your issue but an observation len(trim(line)) would seems unnecessary why not use len_trim(line) or indeed just make the return string allocatable and make use of allocate LHS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could do it several ways; but the question for me is really why I get an error message when replacing len(string) with string%len for the returned value, but it works with other compilers. I think it is a compiler bug but not quite sure it might be non-standard usage
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's a compiler bug, Intel team can start with this simple example:
contains
function f( n ) result(r)
character(len=n) :: r
r = ""
print *, r%len
end function
end
C:\temp>ifx /c /standard-semantics p.f90
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2023.0.0 Build 20221201
Copyright (C) 1985-2022 Intel Corporation. All rights reserved.
p.f90(18): error #6460: This is not a component name that is defined in the encompassing structure. [LEN]
print *, r%len
-----------------^
p.f90(18): error #6158: The structure-name is invalid or is missing. [R]
print *, r%len
---------------^
compilation aborted for p.f90 (code 1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The problem is escalated to the Intel Fortran compiler development team. Thank you for reporting it.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page