replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - ERROR in Fortran Code(cannot be in logical expressions)
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 

ERROR in Fortran Code(cannot be in logical expressions)

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



Joined: 02 Sep 2008
Posts: 26

PostPosted: Mon Jan 17, 2011 9:49 am    Post subject: ERROR in Fortran Code(cannot be in logical expressions) Reply with quote

Hello, I have a question: In an Fortran code (Visual Studio) I have the following expression:
INTEGER*2 KENN
INTEGER*2 R5
...
KENN = R5 .AND. "HFF00"

after this expression, I get the following error:
"INTEGER(KIND=2) variables, such as R5, cannot be in logical expressions (with '.AND.')." Sad

What is my Problem? Question

Greetings from Germany!
Michael
Back to top
View user's profile Send private message Send e-mail MSN Messenger
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: N�rnberg, Germany

PostPosted: Mon Jan 17, 2011 10:17 am    Post subject: Reply with quote

It seems like a logical expression from the compiler Smile

Spa� bei Seite: What would you like to do? You have a string and an integer in your expression - the result must be an integer (KENN).
Back to top
View user's profile Send private message
m.burkhardt



Joined: 02 Sep 2008
Posts: 26

PostPosted: Tue Jan 18, 2011 9:45 am    Post subject: ERROR in Fortran Code(cannot be in logical expressions) Reply with quote

Thank you for helping me! Very Happy
I want to extract the low byte. A logical AND bit operation
if R5 has the Value in Hex '014F' after the operation KENN is Hex '0100'.
Thats what the expression do in the past.

Greetings an thanks!
Michael
Back to top
View user's profile Send private message Send e-mail MSN Messenger
jjgermis



Joined: 21 Jun 2006
Posts: 404
Location: N�rnberg, Germany

PostPosted: Tue Jan 18, 2011 12:59 pm    Post subject: Reply with quote

I am not familiar with hexadecimal in Fortran and a quick search did not deliver any positive results. An attempt would be to write a little subroutine that uses strings. Here you have an internal write to convert from integer to string:
Code:
program cutandpaste

integer :: i
character(len=4) hex

do i=0,10000
  WRITE(hex,'(Z4.0)') i
  write(*,'(A4)') hex
enddo
end
Back to top
View user's profile Send private message
Sebastian



Joined: 20 Feb 2008
Posts: 177

PostPosted: Tue Jan 18, 2011 2:55 pm    Post subject: Reply with quote

Quote:
I want to extract the low byte. A logical AND bit operation

.AND. is no bit operation, it's a boolean operation (both operands logical values) so I don't have a clue how the code you posted would ever have extracted bits.


Quote:
I want to extract the low byte. if R5 has the Value in Hex '014F' after the operation KENN is Hex '0100'.

If you extract the low byte of 0x014F you'll get 0x004F, so I assume you want to mask out the low byte. This can be done with for example the following code:
Code:
KENN = IAND(R5, Z'FF00')
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2402
Location: Yateley, Hants, UK

PostPosted: Wed Jan 19, 2011 3:22 pm    Post subject: Reply with quote

As the functions are now generic, AND (...) would do as well as IAND (...)

E
Back to top
View user's profile Send private message
Sebastian



Joined: 20 Feb 2008
Posts: 177

PostPosted: Wed Jan 19, 2011 4:15 pm    Post subject: Reply with quote

Yes, AND() should work but not .AND.
Back to top
View user's profile Send private message
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Tue Jan 25, 2011 11:56 pm    Post subject: Re: Reply with quote

LitusSaxonicum wrote:
As the functions are now generic, AND (...) would do as well as IAND (...)


Are you sure?

I don't think there is an AND intrinsic function (unless new in 2003/08)! I always use IAND, IOR etc. when using bitwise operations. Don't these only work with integers (of various KINDs) so don't need to be generic (overloaded)?

Try the following to extract the low byte.

Code:

KENN = IAND(R5, 255)
Back to top
View user's profile Send private message
Sebastian



Joined: 20 Feb 2008
Posts: 177

PostPosted: Wed Jan 26, 2011 8:25 am    Post subject: Reply with quote

Quote:
Try the following to extract the low byte.

He wants to extract the high byte, see my posting+code.
Back to top
View user's profile Send private message
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