Passing a dynamic 2D array from C++ to Fortran and back

五迷三道 提交于 2019-12-06 05:24:06
Vladimir F

The main reason is that your C array is a jagged array, it is an array of pointers to separate 1D arrays while in Fortran you declare ther argument to be a contiguous 2D array. You must use the same in both parts, preferably use a contiguous array in C too.

Just malloc one big nx*ny buffer and set the pointers to the rows instead of alloacating them. You can see an example in https://stackoverflow.com/a/5901671/721644

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!