- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We have legacy code (HP 1000 Fortran) that includes many instances of the following:
call sub('abc')
?
subroutine sub(I)
integer*2 I(2)
! I(1) should contain 0x6261 and I(2) should contain 0x0063
end
Is there an elegant way using attributes to make this work in CVF?
The present solution we have is a pre-compiler that converts the above code to
character*3 $c1
integer*2 $t1
equivalence ($c1, $t1)
data $c1 /'abc'/
?
call sub($t1)
etc
This works but I wonder if there is a cleaner way to do it.
call sub('abc')
?
subroutine sub(I)
integer*2 I(2)
! I(1) should contain 0x6261 and I(2) should contain 0x0063
end
Is there an elegant way using attributes to make this work in CVF?
The present solution we have is a pre-compiler that converts the above code to
character*3 $c1
integer*2 $t1
equivalence ($c1, $t1)
data $c1 /'abc'/
?
call sub($t1)
etc
This works but I wonder if there is a cleaner way to do it.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is an easier way, though I'm sure you understand that your current code is incorrect. (Yes, it works on a lot of compilers, but it's still wrong..)
Anyway - there are two CVF options you need to change to accomodate this coding practice. Both can be found under Project..Settings..Fortran..External Procedures.
Change Argument Passing Convention to "C, by Ref".
Change String Length Argument Passing to "After all Args"
If you are using the command line, the switches to add are: /iface:cref /iface:nomixed_str_len_arg
Do a Build..Rebuild All.
Steve
Anyway - there are two CVF options you need to change to accomodate this coding practice. Both can be found under Project..Settings..Fortran..External Procedures.
Change Argument Passing Convention to "C, by Ref".
Change String Length Argument Passing to "After all Args"
If you are using the command line, the switches to add are: /iface:cref /iface:nomixed_str_len_arg
Do a Build..Rebuild All.
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks -- we'll try this.

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