Passing a dynamic 2D array from C++ to Fortran and back
问题 Passing a fixed 2D array between C++ and Fortran works fine, however not so with the program I have written to pass a 2D dynamic array from C++ to Fortran. C++ side extern "C" {void array2d_(double **, int *, int *); } using namespace std; int main() { double **array; int nx=3; int ny=2; int i,j; cout << "Passing dynamic array from C to Fortran\n"; array = (double **) malloc(nx * sizeof(double *)); if(array == NULL) { fprintf(stderr, "out of memory\n"); exit; } for(i = 0; i < nx; i++) { array