Silverfrost Forums

Welcome to our forums

Parameter checking

27 Nov 2009 9:11 #5453

I recently used a compiler other than Silverfrost. Anyway, the upcase@ function was not available. So I used the following as given below. At first the other compiler did not pick up that I called my subroutine in the wrong way. Then I tested it with FTN95 - which gave me the error! Good old FTN95 😄 program test implicit none character(len=10) :: str str = 'hello'

  call upcase(str)
  write(*,*) str

  call upcase('hello')  ! FTN95 picked this up!!

contains
  
subroutine upcase(str)
! Converts all characters to uppercase
! A-Z corresponds to 65 - 90
! a-z corresponds to 97 - 122
  implicit none
  character(len=*),intent(inout) :: str
  integer :: i,j
  do i=1,len_trim(str)
     do j=97,122
        if (ichar(str(i:i))==j) then
           str(i:i) = char(j-32)
        end if
     end do
  end do
  return
end subroutine upcase

end program test
Please login to reply.