replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Can't ass uint to fortran integer
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can't ass uint to fortran integer

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
alex21



Joined: 20 Apr 2011
Posts: 75
Location: Australia

PostPosted: Wed Jul 06, 2011 4:28 am    Post subject: Can't ass uint to fortran integer Reply with quote

Hello,

Im faced with this problem,
You cannot assign an expression of type OBJECT('System.UInt32') to a variable of type INTEGER(KIND=3)

Is there any way to handle a uint in FORTRAN code?

Thanks,
Alex.
Back to top
View user's profile Send private message MSN Messenger
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Thu Jul 07, 2011 10:19 pm    Post subject: Reply with quote

You can use transfer provided the uint fits in a 32 bit unsigned integer, if not you can use a combination of transfer and iand and a 64 bit integer.

Code:

program anon

   object('System.UInt32') a
   integer b, c
   
   b = 12

   ! Just check size is 4 bytes
   print *, 'Number of bytes in a = ', size(transfer(a,(/'A'/)))
   
   ! Assign b to a, i.e. a=b
   a = transfer(b,a)
   
   ! Assign a to c, i.e. c = a
   c = transfer(a, c)

   print *, 'c = ', c

 end

_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl


Last edited by davidb on Tue Jul 12, 2011 6:39 am; edited 1 time in total
Back to top
View user's profile Send private message
alex21



Joined: 20 Apr 2011
Posts: 75
Location: Australia

PostPosted: Fri Jul 08, 2011 12:02 am    Post subject: Reply with quote

Thank you, Ill give that a whirl.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
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 © 2001, 2005 phpBB Group