Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Passing string constants

hweisberg
Beginner
488 Views
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.




0 Kudos
2 Replies
Steven_L_Intel1
Employee
488 Views
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
0 Kudos
hweisberg
Beginner
488 Views
Thanks -- we'll try this.
0 Kudos
Reply