Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Format Specification

kulachi
Beginner
841 Views
Hi,

I am doing something like this:

-----------------------------------------------
CHARACTER(*) :: MyString
CHARACTER(*) :: Ticker
INTEGER :: TLen

!...
!...

TLen = LEN(Ticker)
WRITE(MyString, "(A)") Ticker

-----------------------------------------------
(Note that I have to mention to avoid spaces in MyString for some later processing.)

Since length of Ticker changes each time (varies from 3 to 10) I have to compute it each time I write it into MyString. Is there a more efficient way of doing this, which could perhaps save me from computing LEN(Ticker) each time.

-Kulachi
0 Kudos
1 Reply
onkelhotte
New Contributor II
841 Views
Quoting - kulachi
Hi,

I am doing something like this:

-----------------------------------------------
CHARACTER(*) :: MyString
CHARACTER(*) :: Ticker
INTEGER :: TLen

!...
!...

TLen = LEN(Ticker)
WRITE(MyString, "(A)") Ticker

-----------------------------------------------
(Note that I have to mention to avoid spaces in MyString for some later processing.)

Since length of Ticker changes each time (varies from 3 to 10) I have to compute it each time I write it into MyString. Is there a more efficient way of doing this, which could perhaps save me from computing LEN(Ticker) each time.

-Kulachi

First of all it would be good if you tell us EXACTLY what you do... "Something like this" is not very helpful ;-)

Second: Why do you want to get rid of LEN? I cant imagine that this will take much CPU time.

Third: You dont have to use LEN to count the spaces. write(mystring,'(a)') trim(Ticker) will do just fine, it removes the trailing blanks. Maybe you want to use write(mystring,'(a)') trim(adjustl(Ticker)) too to get rid of leading blanks as well.

Markus
0 Kudos
Reply