You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/allocate/README.md
+10-2Lines changed: 10 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,15 @@
2
2
3
3
Deallocating arrays in a Fortran procedure that were allocated in another Fortran procedure, both called from a C/C++ main program is defined in a compiler vendor-dependent way.
4
4
The Intel oneAPI compiler works with the "fancy_allocate" demo, while GCC Gfortran works with all the allocate examples.
5
-
Cray Fortran ftn compiler currently doesn't work with the allocate in Fortran from C/C++ main program examples.
6
5
7
-
To be more compiler vendor independent, the general recommendation when using a C/C++ main program is to allocate the memory in C/C++ e.g. via `malloc()` or in C++ via `new`, `vector` or `array` and then pass back and forth to Fortran.
6
+
7
+
To be more compiler vendor independent, the general recommendation when using a C/C++ main program is to allocate the memory in:
8
+
9
+
* C `malloc()`
10
+
* C++ `std::vector`
11
+
* C++ `std::array`
12
+
* C++ `std::make_unique`
13
+
14
+
and then pass back and forth to Fortran.
15
+
8
16
This allows memory to be managed fully, particularly with regard to freeing memory when no longer used to avoid memory leaks in long-running programs.
0 commit comments