For Programmers: Free Programming Magazines  


Home > Archive > Fortran > June 2004 > simple F2003 varying string?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author simple F2003 varying string?
David Frank

2004-06-10, 3:58 pm

Will my S2P function below provide varying string support
equivalent to whats in the F2003 standard but with much less
overhead (faster) in its execution?

! ----------------------------
program f2003_simple_varying_string ! using string pointer
character(:),pointer :: string

string => s2p("The quick brown fox ")
write (*,*) trim(string), len(string) ! len dynamically changes

string => s2p("jumps over the lazy dog's back.")
write (*,*) trim(string), len(string) ! len dynamically changes
stop

contains
function s2p(string) result (out)
character(*),intent(in) :: string
character(:),pointer :: out
deallocate (out)
allocate (character(len(string)) :: out)
out = string
end function
end program

Varying string output ???
The quick brown fox 31
jumps over the lazy dog's back. 32


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com