Skip to content

Commit 01130a0

Browse files
authored
Merge branch 'vijaysm/fix-memleaks' (PR #8495)
Fixes memory leaks when accessing the string from MCT for data models [BFB]
2 parents 6c76669 + e78b627 commit 01130a0

5 files changed

Lines changed: 5 additions & 1 deletion

File tree

components/data_comps/datm/src/datm_comp_mod.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,8 +1351,8 @@ subroutine datm_comp_run(EClock, x2a, a2x, &
13511351
mct_field = mct_string_toChar(mctOStr)
13521352
tagname= trim(mct_field)//C_NULL_CHAR
13531353
call moab_set_tag_from_av(tagname, a2x, index_list, mphaid, datam, lsize) ! loop over all a2x fields, not just a few
1354+
call mct_string_clean(mctOStr) ! mct_list_get allocates a new string each iteration; free it here to avoid a per-timestep leak
13541355
enddo
1355-
call mct_string_clean(mctOStr)
13561356
call mct_list_clean(temp_list)
13571357
deallocate(datam) ! maybe we should keep it around, deallocate at the final only?
13581358

components/data_comps/dice/src/dice_comp_mod.F90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ subroutine dice_comp_run(EClock, x2i, i2x, &
916916
mct_field = mct_string_toChar(mctOStr)
917917
tagname= trim(mct_field)//C_NULL_CHAR
918918
call moab_set_tag_from_av(tagname, i2x, index_list, MPSIID, datam, lsize) ! loop over all a2x fields, not just a few
919+
call mct_string_clean(mctOStr) ! mct_list_get allocates a new string each iteration; free it here to avoid a per-timestep leak
919920
enddo
920921
call mct_list_clean(temp_list)
921922
deallocate(datam) ! maybe we should keep it around, deallocate at the final only?

components/data_comps/dlnd/src/dlnd_comp_mod.F90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ subroutine dlnd_comp_run(EClock, x2l, l2x, &
646646
mct_field = mct_string_toChar(mctOStr)
647647
tagname= trim(mct_field)//C_NULL_CHAR
648648
call moab_set_tag_from_av(tagname, l2x, index_list, mlnid, datam, lsize) ! loop over all a2x fields, not just a few
649+
call mct_string_clean(mctOStr) ! mct_list_get allocates a new string each iteration; free it here to avoid a per-timestep leak
649650
enddo
650651
call mct_list_clean(temp_list)
651652
deallocate(datam) ! maybe we should keep it around, deallocate at the final only?

components/data_comps/docn/src/docn_comp_mod.F90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,7 @@ subroutine docn_comp_run(EClock, x2o, o2x, &
988988
mct_field = mct_string_toChar(mctOStr)
989989
tagname = trim(mct_field)//C_NULL_CHAR
990990
call moab_set_tag_from_av(tagname, o2x, index_list, mpoid, data, lsize)
991+
call mct_string_clean(mctOStr) ! mct_list_get allocates a new string each iteration; free it here to avoid a per-timestep leak
991992
enddo
992993
call mct_list_clean(temp_list)
993994
deallocate(data)

components/data_comps/drof/src/drof_comp_mod.F90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ subroutine drof_comp_run(EClock, x2r, r2x, &
588588
mct_field = mct_string_toChar(mctOStr)
589589
tagname= trim(mct_field)//C_NULL_CHAR
590590
call moab_set_tag_from_av(tagname, r2x, index_list, mrofid, datam, lsize) ! loop over all a2x fields, not just a few
591+
call mct_string_clean(mctOStr) ! mct_list_get allocates a new string each iteration; free it here to avoid a per-timestep leak
591592
enddo
592593
call mct_list_clean(temp_list)
593594
deallocate(datam) ! maybe we should keep it around, deallocate at the final only?

0 commit comments

Comments
 (0)