- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need to pass a real number from Fortran to a C library. When I compile it using Intel Fortran 12.1.5.344 build 201206012. It is ok. However, when I compile it using 2021.11.1, build 20231117_000000. The code can be compiled. However, when I ran it, it complains "Number not numeric". Do you know what could be the possible reason? How do I fix it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is not a Fortran message, and since you did not include any code or test case. it's difficult to help you here. I will note that you are using a 12-year-old compiler, not that I think it is related to your issue. I recommend installing and using the free Intel oneAPI compiler.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is not a Fortran message, and since you did not include any code or test case. it's difficult to help you here. I will note that you are using a 12-year-old compiler, not that I think it is related to your issue. I recommend installing and using the free Intel oneAPI compiler.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
Such problems are very often linked to stack corruption especially during subroutine/functions calls or out of bounds array access.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>"Number not numeric"
Without seeing the code (both sides), I/we can only assume "Number not numeric" refers to a value passed as a text string as opposed to int/float/double. I suggest you print out the value seen at the C side, in particular if the incoming argument is text (that is supposedly numeric) that you print it out as text (%s), then show it here. You may find your "oops" and fix it yourself.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please note too, that
character(len=5) :: foo
...
foo = '12.34'
...
call YourCfunc(foo,'56.78')
will pass two non-null terminated values, and which the junk following the text may be found to be non-numeric, or worse, found numeric, but then you have the wrong numbers.
character(len=6) :: foo
...
foo = '12.34'C ! or foo = '12.34' // C_NULL_CHAR
------------ or -----------
use, intrinsic :: iso_c_binding
character(len=5) :: foo
foo = '12.34'
...
call YourCfunc(F_C_STRING(foo),F_C_STRING('56.78'))
or variations of the above.

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