GEOS-ESM / GOCART

GOCART Aerosol model including process library and framework interfaces (MAPL, NUOPC, and CCPP)
Apache License 2.0
13 stars 14 forks source link

memory leak #245

Closed mmanyin closed 1 year ago

mmanyin commented 1 year ago

The arrays dqa and drydepositionfrequency are allocated in the 'run' routines of CA, SS, DU and NI, but never de-allocated. The fix should be zero-diff trivial.

mathomp4 commented 1 year ago

@mmanyin I think this actually isn't a memory leak. Fortran will automatically deallocate allocatable arrays once you get out of scope. Things can get a bit tricky if they are derived data types (I know @tclune has mentioned this), but for this, all is good.

tclune commented 1 year ago

Just some minor clarification, to be safe. Local allocatable variables are deallocated when the code leaves the scope of the procedure. This is not true for allocatable module variables, nor for local pointer variables.

Of course, this is unfortunately somewhat a matter of faith in the compiler, as it is difficult to prove unless you have really good memory tools to monitor the situation. But practice suggests that the major vendors generally get this right unless you do something "really cleaver" (TM).

mmanyin commented 1 year ago

Very good, I stand corrected. Thanks for clarifying-