Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

One Fortran Code Line Not Understood

Status
Not open for further replies.

kubota

Electrical
Oct 22, 2015
2
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

 
Replies continue below

Recommended for you

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:




Doug Jenkins
Interactive Design Services
 
Actually the Fortran also works in VBA:

Code:
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
 
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.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor