mjs84
Aerospace
- Aug 20, 2003
- 27
I am having a problem reading a 'character' string into a 'real' variable. The only way I know how to do it is:
character cstr
real realva
read(cstr,'(f8.3)') realva
I think that's what I have employed below, but as you can tell from the 'output', I am not getting what I'm expecting.
If anyone can see a problem with this code, I would surely appreciate it.
Thanks, mjs84
CHARACTER*42 LIDEN
REAL*8 TMPVAR
LIDEN = 'MIN.375/MAX.378_1'
WRITE(7,'(2A)') 'Element ID is: ', LIDEN
WRITE(7,'(2A)') 'chrs 4:7 are: ', LIDEN(4:7)
READ(LIDEN(4:7),'(f8.3)') TMPVAR
WRITE(7,'(A,F8.3)') 'tmp real var: ', TMPVAR
.......................................................
Output:
Element ID is: MIN.375/MAX.378_1
chrs 4:7 are: .375
tmp real var: .000 (I am expecting a ' .375' here.)
character cstr
real realva
read(cstr,'(f8.3)') realva
I think that's what I have employed below, but as you can tell from the 'output', I am not getting what I'm expecting.
If anyone can see a problem with this code, I would surely appreciate it.
Thanks, mjs84
CHARACTER*42 LIDEN
REAL*8 TMPVAR
LIDEN = 'MIN.375/MAX.378_1'
WRITE(7,'(2A)') 'Element ID is: ', LIDEN
WRITE(7,'(2A)') 'chrs 4:7 are: ', LIDEN(4:7)
READ(LIDEN(4:7),'(f8.3)') TMPVAR
WRITE(7,'(A,F8.3)') 'tmp real var: ', TMPVAR
.......................................................
Output:
Element ID is: MIN.375/MAX.378_1
chrs 4:7 are: .375
tmp real var: .000 (I am expecting a ' .375' here.)