Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

DEFAULT KIND and Strings

dajum
Novice
379 Views
Steve,

I have tried to change my code to use all 64 bit integers and reals by using /integer_size:64 and /real_size:64 in my mixed-language program. It all seems to work fine and IVF seems to treat the string lengths passed via subroutines as 64 bit integers as well. But in my CVF version, I have trouble getting it to run correctly. It almost looks like it treats the lengths still as 32 bit variables. Can you tell me what size does each compiler use to pass the string lengths when the integer size is 64 bits?

Thanks,

Dave
0 Kudos
6 Replies
Steven_L_Intel1
Employee
379 Views
Both compilers use 32-bit lengths for 32-bit code (the only kind CVF is capable of.) The standard on 64-bit systems is 64-bit lengths. The default integer kind has no bearing on this - it is determined solely by architecture.

Why do you want to use 64-bit integers and reals by default?
0 Kudos
dajum
Novice
379 Views

Mostly ease of conversion. There are lots and lots of places where we have equivalenced variables, keeping them the same size eliminates a lot of issues with equivalencing. It also allows us to go ahead and use larger integers for numbering, which is convient in our models.

Where I have some C routines calling Fortran, the CVF compiler is getting an undefined pointer for the second argument of a Fortran function. The first is a character string and the second is an integer.The code works fine on the 64 bit IVF version, but doesn't on the 32 bit CVF version. Passing a 32 bit string size after the string or a 64 bit size seems to do the same thing, the FORTRAN isn't getting the second argument which is a 64 bit integer in both the C and Fortran (based on the /integer_size:64 compiler argument for the FORTRAN).

0 Kudos
Steven_L_Intel1
Employee
379 Views
CVF and Intel Fortran pass string lengths in different places. CVF puts the length immediately after the argument address, whereas Intel Fortran puts all the lengths at the end of the argument list. You can use the !DEC$ ATTRIBUTES keyword NOMIXED_STR_LEN_ARG in both to put the length at the end. What does the C routine expect?
0 Kudos
dajum
Novice
379 Views
Both versions use the compiler option /iface:mixed_str_len_arg to place it after each string. The code has worked fine until I changed the default kind. The strange thing is that small test cases seem to work. But in the giant project, it gets these crashes in CVF. Making the string length an int in the C doesn't seem to fix it for CVF (since it was an __int64 in the 64 bit IVF version which works fine).
0 Kudos
Steven_L_Intel1
Employee
379 Views
String length should be size_t in C.

What exactly doesn't work? Have you made sure to use ATTRIBUTES C in CVF to get the C calling convention? You might be mixing C and STDCALL conventions.
0 Kudos
dajum
Novice
379 Views

Okay, when I went back and changed the C code to pass a 32 bit int, I didn't change the function prototype. Changed that too and now it runs. I'm not much of a C programmer. Thanks for your help.

0 Kudos
Reply