 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
alex21
Joined: 20 Apr 2011 Posts: 75 Location: Australia
|
Posted: Wed Jul 06, 2011 4:28 am Post subject: Can't ass uint to fortran integer |
|
|
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 |
|
 |
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Thu Jul 07, 2011 10:19 pm Post subject: |
|
|
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 |
|
 |
alex21
Joined: 20 Apr 2011 Posts: 75 Location: Australia
|
Posted: Fri Jul 08, 2011 12:02 am Post subject: |
|
|
Thank you, Ill give that a whirl. |
|
Back to top |
|
 |
|
|
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
|