forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Parameter checking

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: Nürnberg, Germany

PostPosted: Fri Nov 27, 2009 10:11 am    Post subject: Parameter checking Reply with quote

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 Very Happy
Code:
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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group