×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

One Fortran Code Line Not Understood

One Fortran Code Line Not Understood

One Fortran Code Line Not Understood

(OP)
Hi all,
I'm in the process of converting a Fortran maths program of several hundred lines to Excel VBA. All is fine except for one line of the Fortran code. I haven't seen this code form before.

CODE -->

! ...
  logical aa
  real ( kind = 8 ) bb
  real ( kind = 8 ) cc
  real ( kind = 8 ) dd
  real ( kind = 8 ) ee

! ... numerous code lines go here 

Here's the problem line of code, which I presume is intended to set the state of aa

CODE -->

aa = aa .or. ( bb < cc .and. dd < ee ) 

I don't understand why aa is on the right side, separated by the .or. test. For example, it seems that aa could be set to the state of aa, which makes no sense to me. I'm clearly missing something here.
Any clarification would be much appreciated.
Thanks

RE: One Fortran Code Line Not Understood

If aa is true then it stays true
If aa is false but (bb < cc .and. dd < ee ) then it becomes true
If aa is false and ( bb < cc .and. dd < ee ) is also false then it stays false

So I'd say the equivalent VBA would be

If aa = False and ( bb < cc and dd < ee) = True then aa = True

But I haven't checked that.

ps If you are interested in a fairly painless way of running Fortran from Excel, you might like to look at:

https://newtonexcelbach.wordpress.com/2014/09/15/r...

Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/

RE: One Fortran Code Line Not Understood

Actually the Fortran also works in VBA:

CODE --> VB

Function Checkaa(aa As Boolean, bb As Long, cc As Long, dd As Long, ee As Long) As Boolean
aa = aa Or (bb < cc And dd < ee)
Checkaa = aa
End Function 

Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/

RE: One Fortran Code Line Not Understood

(OP)
Thanks for clarifying the code. I now understand the operation of the logic.
Your line:

CODE -->

aa = aa Or (bb < cc And dd < ee) 


works perfectly in VBA.
Thank you also for your fast response. Marvellous assistance.



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close