PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Course

Read/ Write ot/from variable

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Sudeep Mohan



Joined: 16 Feb 2010
Posts: 7

PostPosted: Sat Sep 04, 2010 11:44 am    Post subject: Read/ Write ot/from variable Reply with quote

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.
Back to top
View user's profile
N. Shamsundar



Joined: 20 Apr 2005
Posts: 23

PostPosted: Sat Sep 04, 2010 7:21 pm    Post subject: Reply with quote

If rvar is a real variable, you should read it using an appropriate format -- A4 is not such a format -- and the internal file from which you are reading the value should contain a properly formatted real number: <sign>aaa.bbbE<sign>nnn.

If you want to read from a hexadecimal string, the format to use is Z8 for 32 bit integers and Z16 for 64 bit integers. Standard Fortran does not let you directly use hexadecimal representations for real constants.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group