I have a read statement which is like this:
do 150 i = 1, 10
pos = (i-1)*4+1
read(unit=cvar(pos : pos+3), FMT = 210) rvar(i)
150 continue
210 format(A4)
here cvar is a character array
cvar=‘SOMETEXT’
rvar is real array.
pos and i are integers
I intend to group the text in cvar into a word of 4 characters and copy it into rvar(which is of type real). But it is copying only the first byte into rvar.
for eg. if cvar(1) in hexadecimal format is 454D4F53
then I would want rvar(1) also to be the same, but it after the read is executed once rvar(1) is only 53
if I write a separate fortran program just to test the working of the read it works fine. but I am using this code snippet in another application and only in this application read is behaving like this.
Please anybody, tell me why this is happening and why I am not able to reproduce this in a separate program.