Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
11 Views

Fortran95: deallocating arrays necessary in Program and DLL?

I understand, that a Fortran 95 program, when ending, gives up all its allocated memory to the system, so no deallocation is necessary and memory leaks cannot occur at that time.

Is this also true for Fortran DLL's called from, f.i., C# at returning to the calling program?

0 Kudos
2 Replies
Highlighted
Black Belt Retired Employee
11 Views

No - that cleanup doesn't happen until image exit. Returning from a procedure, whether it is in a DLL or static library, is not the same.

0 Kudos
Highlighted
New Contributor III
11 Views

Hi Erik,

I have Fortran routines in a DLL called from C#, and I use the "deallocate" command in the Fortran routines to make sure that all local arrays in the Fortran routines have been deallocated before exiting back to the C#.  Deallocating the Fortran arrays allows changes in the C# GUI to the input values so that the Fortran routines can be called again.  Is this what you want to do?  I also avoid using the "stop" command in the Fortran DLL routines as that can freeze the program.  I've found it is better to return an error message or flag from the Fortran DLL to the C# code.

Regards,
Greg T.

0 Kudos