- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I expect that whether textblock is declared len=: or len=80 that the following code would produce a successful assignment to textblock; but in one case textblock is unallocated on version 16. Is this still an issue with V 17?
! place in file testit.F90; compile with ifort, then "ifort -DCOLON"
! ifort testit.F90 -o fixedlen;./fixedlen
! ifort -DCOLON testit.F90 -o colon;./colon
program testit
implicit none
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#ifdef COLON
character(len=:),allocatable :: textblock(:)
character(len=*),parameter :: string='LEN=:'
#else
character(len=80),allocatable :: textblock(:)
character(len=*),parameter :: string='LEN=80'
#endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
integer :: i
textblock=[ character(len=40) :: &
'#########',&
'# #',&
'# ###################',&
'# #',&
'# #############',&
'# #',&
'###############']
write(*,*) 'FOR ',string
write(*,*) 'ALLOCATED ',allocated(textblock)
write(*,*) 'SIZE ',size(textblock)
if(size(textblock).gt.0)then
write(*,*)'LEN ',len(textblock(1))
endif
write(*,'(a)')(trim(textblock(i)),i=1,size(textblock))
end program testit
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried your code with 17.0 compiler and found both can work as expected:
$ ifort -fpp test.f90
$ ./a.out
FOR LEN=80
ALLOCATED T
SIZE 7
LEN 80
#########
# #
# ###################
# #
# #############
# #
###############
$ ifort -fpp -DCOLON test.f90
$ ./a.out
FOR LEN=:
ALLOCATED T
SIZE 7
LEN 40
#########
# #
# ###################
# #
# #############
# #
###############
Thanks,
Xiaoping Duan
Intel Customer Support
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page