Append to string in Fortran -


i have simple problem, yet find answer to. there way in can append character, in particular white space character has been initialized in fortran. apparently

character(2000) :: result result = '' result = result//' ' 

does not work. thank time!

what want achieve? of course works, has not use. try approach have been suggested in previous question. in particular, aware strings filled space after last non-space character, important!

'a'//' ' produces  'a ' 

but

result = result//' ' 

produces 2001 character string, truncated on assignment, result ends being same.

you may want

result = trim(result)//' ' 

but useless, because string filled spaces anyway.

if want make variable larger, have use:

character(:),allocatable:: result result = ''  !now contains ' ' , has length 1 result = result//' ' !now contains '  ' , has length 2 

you have enable reallocation on assignment on processors.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -