EMsoft-org / EMsoft

Public EMsoft repository
Other
61 stars 94 forks source link

Fix f90wrap kind mapping for Python bindings #167

Closed ZacharyVarley closed 1 year ago

ZacharyVarley commented 1 year ago

Removed old names 'real_kind4' and 'real_kind8' from mapping I assume that "c_int" should map to "int"

for float maps I referenced: from /Source/EMsoftLib/local.f90.in:

INTEGER, PARAMETER :: real_kind_7 = SELECTED_REAL_KIND(6,37) !should map to REAL*4 on most modern processors
INTEGER, PARAMETER :: real_kind_15 = SELECTED_REAL_KIND(15,307) !should map to REAL*8 on most modern processors
hakonanes commented 1 year ago

This fixes #145, it seems?

ZacharyVarley commented 1 year ago

This fixes #145, it seems?

Yes. My rough understanding is that the C standard requires at least 16 bits for an "int". It is OS dependent. Most 64 bit OS have 32 bit wide ints even though pointers are 64 bits:

See https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models

Only ILP64 and SILP64 data models (obsolete operating systems HAL and UNICOS use those) have 64 bit ints.

When defining a "c_int" in Fortan, I think the corresponding datatype in C (what is required in kind map), will always have the same number of bits as a C standard int on a given machine by definition.