fortran-iso-c-binding Questions

4

Solved

The following code compiles in both GNU gfortran and Intel ifort. But only the gfortran compiled version will run successfully. program fort_tst use iso_c_binding INTEGER, POINTER :: a(:) TYP...

1

Solved

The following function is supposed to convert a C string into a Fortran string and works fine in Release builds, but not in Debug: ! Helper function to generate a Fortran string from a C char point...
Succinylsulfathiazole asked 13/8, 2021 at 11:6

1

Solved

Suppose you had created a Fortran array(:) of pointers to memory allocated in C by malloc (as shown in best answer, code repeated below). Is there a way to write an integer value into this allocate...
Tactical asked 11/6, 2020 at 16:53

2

Solved

How would I reference a Fortran function in a C++ header that uses optional arguments? Would I have a prototype in the header for each possible combination of calls? Or is this even possible? For ...
Chessboard asked 17/10, 2016 at 14:51

3

Solved

Does anyone know of an way to sleep for a given number of milliseconds in Fortran? I do not want to use non-portable system calls so anything intrinsic to Fortran or C libraries would be preferred....
Sat asked 3/8, 2011 at 19:4

7

Solved

I've been held up on this for about a week, now, and have searched forum after forum for a clear explanation of how to send a char* from C to FORTRAN. To make the matter more frustrating, sending a...
Irrespective asked 2/4, 2012 at 7:58

1

Solved

Using scientific notation for floating point literals is easy enough in Fortran: 1.5d-10 would mean a double precision (whatever that means under current Fortran compiler settings) floating point...
Metalinguistic asked 21/4, 2018 at 13:25

2

Solved

Is there a tool to automatically generate Fortan bindings from C library header, using intrinsic iso_c_bindings module from Fortran 2003 standard? I am not interested in translating C to Fortran, ...
Lamoree asked 9/12, 2011 at 11:8

2

I want to pass a string from Fortran to C/C++. Here is my Fortran code: subroutine zdplaskinGetSpeciesName(cstring, index) bind(C, name='zdplaskinGetSpeciesName') use iso_c_binding use ZDPlasKin...
Flapjack asked 26/7, 2017 at 14:49

2

Solved

I have the following function call in C++: int strLength = 20; char* name; getName(name, strLength); printf("name: %s\n", name); and in Fortran: subroutine getName(name) bind (c, name='GETNAM...
Unasked asked 7/6, 2017 at 12:32

1

Solved

I'd like to learn the latest improvement in C++/FORTRAN interoperability when it comes to string in particular. The following is my unsuccessful attempt, please help me correct or advise a better s...
Chandelle asked 31/5, 2017 at 15:52

1

Solved

What does it mean when the intrinsic keyword is added to the use statement for a module, as in the following example? use, intrinsic :: iso_c_binding (From 7.1 Overview of Fortran interface, FF...
Executant asked 20/4, 2017 at 14:27

3

Solved

I think title says what I need. I know we can use "asd" function to do this, but for some reasons I need to do the allocation in Fortran (i.e. in subroutine "asd_"). Here is the C code: #include &...
Banderole asked 13/3, 2012 at 3:25

2

Solved

I am trying to pass an array from C/C++ into a Fortran 2003 module and get the calculated values back into C/C++. I've been able to pass and return single values (scalars) just fine, but getting an...
Lampedusa asked 2/1, 2016 at 1:52

1

Solved

I've got some Fortran and C code that need to be combined. I'm using a Fortran interface that looks mostly like this: module bridge use, intrinsic::iso_c_binding, only : c_ptr, c_null_ptr impli...
Karmenkarna asked 24/8, 2015 at 5:13

2

Solved

I have a large existing Fortran95 code. It uses real(dp), dimension(num) :: array to declare arrays. I want to join in some C code and found that I can do this by writing interfaces to the C-f...
Hortensehortensia asked 24/2, 2015 at 14:0

1

I am having a lot of trouble passing Fortran arrays to a C program. From what I have gathered from previous posts is the inclusion of the interface. That got rid of some of my problems. However, I ...
Tessellation asked 17/1, 2015 at 19:51

1

Solved

I would like to link a Fortran program with an arbitrary binary file. I am using gfortran, and I found here that the same task is easy with gcc using objcopy from binutils. However, I can't make i...
Pfister asked 15/12, 2014 at 14:41

1

Solved

I posted a similar question few weeks ago (iso_c_binding calling C routine with pointers from Fortran with arrays) and I found a solution to my problem. Now I modified few things and I am having so...
Spermatogonium asked 31/10, 2014 at 16:9

1

Solved

I digged on the forum looking for a solution but I failed. My main problem is I am too noob with C language and Fortran-C interoperability in order to understand what I am doing wrong exactly. I w...
Weismannism asked 19/9, 2014 at 16:5

2

Solved

I'm a C programmer who has to update a huge Fortran 2003 program by adding a single call to a C function. First, I need to write a minimal Fortran wrapper (in modern, free-form Fortran, no shoutin...
Iolanthe asked 2/9, 2014 at 22:55

2

Solved

How can I pass an array of C strings (char* cstrings[]) to a Fortran subroutine? Question Arrays of strings in fortran-C bridges using iso_c_binding is definitely related, but the answer does not ...
Havana asked 1/9, 2014 at 16:57

2

Solved

I am used to Fortran in which I used the namelist sequential read in to get variables out of a file. This allows me to have a file which looks like this &inputDataList n = 1000.0 ! This is the...
Radiation asked 10/7, 2013 at 21:43

1

Solved

I would like to set up a workflow to reach fortran routines from Python using Cython on a Windows Machine after some searching I found : http://www.fortran90.org/src/best-practices.html#interfaci...
Pastorate asked 14/3, 2014 at 11:44

2

Solved

I'm having to write a subroutine that can be called both by C and by Fortran. This subroutine takes a file name as one of its arguments. I know that to interoperate nicely with C, the ISO C binding...
Estellestella asked 13/3, 2014 at 17:55

© 2022 - 2025 — McMap. All rights reserved.