- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am working on a mixed programming project (C++ and Fortran). I am using MS VC++ 6.0 and CVF 6.6B. I want to share variables, which are defined in Fortran to C++ side.
Could any boday help me, how can I share Fortran's "Logical variables" at C++ side.
Could any boday help me, how can I share Fortran's "Logical variables" at C++ side.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Basically, it's the same as integer/int. In C++, it can be also spelled as a BOOL or bool. What makes it LOGICAL is more context than its contents.
C/C++ treat logical expressions as false if their value is zero, and true otherwise. Fortran standard does not specify contents of a LOGICAL, only behaviour.
The only potential gotcha is CVF default convention where only least-significant byte of a LOGICAL is tested (it is a historic remnant from VAX days) -- if it's zero, it evaluates to .FALSE., otherwise .TRUE. Other bits are not tested. Thus:
Jugoslav
C/C++ treat logical expressions as false if their value is zero, and true otherwise. Fortran standard does not specify contents of a LOGICAL, only behaviour.
The only potential gotcha is CVF default convention where only least-significant byte of a LOGICAL is tested (it is a historic remnant from VAX days) -- if it's zero, it evaluates to .FALSE., otherwise .TRUE. Other bits are not tested. Thus:
logical:: b b = 1 write(*,*) b !Outputs "T" b = 2 write(*,*) b !Outputs "F"/fpscomp:logicals compiler switch changes that behaviour, so that it's the same as C++ (0=.false., /=0 =.true.)
Jugoslav

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page