Tags
character, f77, fortran, fortran 77, integer to character, integer to string, programming, string
Let’s assume that we have defined two strings as
str1 = 'abc'
str2 = 'pqr'
and an integer
integ = 25
(Make sure str1 and str2, and integ are defined as character strings, and integer, respectively)
1. Concatenate str1 and str2 into str3 (make sure you define str3 first as a character string)
str3 = str1//str2
2. Concatenate str1 and integ into str3 (again make sure str3 is defined as a character string)
step a: convert integer to a string first (make sure str4 is defined as a character string and not initialized, i.e. it’s so far an empty string)
write(str4,'(I5)') integ
step b: concatenate str1 and str4 into str3
str3 = str1//str4
Mubeen said:
Excellent,
I was never aware of this fact that integer data can be written to string via write statement.
Anonymous said:
Thanks, it helped me. I needed change number to character to use it in FORMAT section. But I use fortran 90.
ff='(6(F3.1,X))’ (here is problem when you want use integer variable)
print ff !this is character varyable!, (some array of numbers)
arun mukherjee said:
This was very helpful…….I was not able to create a no of sequential files, now its possible.
Thank you.
Anonymous said:
Thanks, that was helpful. I appreciate your help