- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, someone give me any suggestions to find way of transfering real value to character.
My demand is to get character value as using file name, when I get random value with rand function.
How should I do?
I am waiting for any suggestion.
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
use internal write
character(len=10) :: FileName
real :: rv
rv = 3.14159
write(FileName,'(F10.5)') rv
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for message.
Let me explain my needs more detailed.
I want to use real value as string in file name. Therefore it is need to transfer real as like your exsample to character string.
Could you let me know any way to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you mean you want the number as "part" of a file name?
(example abc3.14159.txt )
If so then youyouwillneed to remove leading spaces from the string used in theinternal write.
You will also need touseconcatenation, and possibly "trim"
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HI, Thank you for suggestions and Ireconsidered my issue.
CHARACTER*5filename
REAL randnum
REAL randnum
random(randnum)
10filename = randnum//'.txt'
10filename = randnum//'.txt'
....
open (1,file=filename)
....
close(1)
but probably line 10th is not available. It is actually my issue. Therefore how to
transfer real value to character value.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have already shown you in my first post.
character(len=10) ::aString ! This is a character variable.
real :: rv
rv = 1.234
write(aString,'(F10.5)') rv ! This is internal write. Converts real to character representation.
Then you use aString to build your file name.
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, Thank you for suggestions. I will try to do coding according to yours.
Thank you again.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page