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

character var and blank padding

gelarimer
Beginner
269 Views

Question about proper way to pad a charactersubstring with blanks:

character(5) str

str(1:5) = '12345'

does assigning a single blank ' ' as follow cause position 3 tru5 to be padded with blanks also?

str(2:) = ' ' ! str = '1bbbb' where b stands for blank

Itworks, but just wanted to be sure that this is the proper way tooverwrite existing characters with blanks.

or is this better,

str = str(1:1) ! str = '1bbbb'

Thanks fora reply.

0 Kudos
2 Replies
Steven_L_Intel1
Employee
269 Views
The Fortran language defines character assignment to do padding on the right with blanks as needed, so your str(2:) = '' is just fine. You may want to look at the standard intrinsics ADJUSTL and ADJUSTR to see if they are of interest for your application.
0 Kudos
gelarimer
Beginner
269 Views
Thank you.
0 Kudos
Reply