PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Character

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
jx8



Joined: 06 May 2005
Posts: 1

PostPosted: Fri May 06, 2005 7:23 am    Post subject: Character Reply with quote

Suppouse I don't know exactly the length of my CHARACTER variable, or that I want to use a different length in different subroutines of the same variable.
Is there any way to work around the fact that you have to define the length of a CHARACTER explicitely?

example: CHARACTER(len=10) dummy

is there a way for me to omit the "len=10" so that my "dummy" variable could be long 10 characters, or 8 characters or 12 characters in the same subroutine or in different subroutines of the same program?

thank you
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 5952
Location: The Portland Group Inc.

PostPosted: Fri May 06, 2005 9:09 am    Post subject: Reply with quote

Hi jx8,


You could use an assumed-size character array as the dummy argument.

Example:

Code:
     program test

       call stringlen('String1')
       call stringlen('A longer string')
       call stringlen('A even longer string')
 
     end program test

     subroutine stringlen (str)
     
       character (*) :: str

       WRITE(*,*), '\'', str, '\' is length ', LEN(str)
       
     end subroutine stringlen


Hope this helps,
Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
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 © phpBB Group