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

intel 2021.3.0 ifx null terminated strings

Frank_R_1
New Contributor I
1,208 Views

Hi,

 

We used Intel parallel studio for many years, especially classic icc/icl, ifort compilers for linux and windows.

We have heard that the classic compilers will not be supported in the future and life cycle ends,

so we want to transit to icx, ifx on both platforms.

After some struggle (at c++17 icx is far more strict than icl) we managed to build our product on windows to test it. But we found out that ifx does not provide null terminated strings like ifort does!

That is a big problem, since we jump between Fortran and C, and with ifort null terminated strings this was no problem (huge fortran 77 legacy code base).

 

Question: Is there a compiler switch to force null terminated strings?

 

Side question: we used fp:consistent on both platforms to get binary identically results on linux and windows regardless of release or debug build. It seems that this is not available in ifx,icx anymore. Is there a workaround for this important compile switch?

Thank you and best regards

Frank

 

0 Kudos
4 Replies
Steve_Lionel
Honored Contributor III
1,163 Views

Please use ifort for production use. ifx is still very much "beta" and is incomplete. It's great to try out and see what does and doesn't work, but it's too soon to transition to ifx for normal use.

Fortran strings are not NUL-terminated and there is no option to make them so. If you want a NUL-terminated string you must do it yourself. Intel Fortran does support a "C string" extension that provides NUL-terminated constants, for example, 'ABCD'C .

As for /fp:consistent, it was never a guarantee of identical results across processors or platforms. See Improving Numerical Reproducibility in C/C++/Fortran for helpful information.

Frank_R_1
New Contributor I
1,023 Views

Hi,

 

I am testing ifx 2021.4.0 now, and its same behavior.

My question is, why ifort on linux and windows zero terminates strings and ifx does not?

From compiler implementation side adding a zero at the end of strings should be no effort.

We are using Intel ifort over decades and now its recommended to transit to ifx in the future because classic compiler will not be maintained anymore.

We have a huge Fortran code base using calls to C functions which rely on zero terminated strings.

In Fortran we just write 'whatecverstringname', if we have to substitute this to 'whatecverstringname'C it would cost some time and it is error prone.

 

So what I would expect is that ifx has the same behavior as ifort, which does the zero termination.

 

Best regards

Frank

0 Kudos
Arjen_Markus
Honored Contributor I
1,013 Views

Can you show a standalone working example of how this works in your code base, because, like Steve said, Intel Fortran does not append a NUL character, unless you use the 'string'C form (compiler extension). And it has never done that, for the simple reason that the Fortran language does not deal with strings in that way.

0 Kudos
Steve_Lionel
Honored Contributor III
999 Views

I'll comment that some older DEC Fortran compilers DID NUL-terminate character constants, but this was never a documented feature. Current Intel compilers don't do this.

0 Kudos
Reply