From 08063d4f4844b46b9e08694bed9dca85ce2e6bc0 Mon Sep 17 00:00:00 2001 From: Salvatore Filippone Date: Wed, 22 May 2019 09:24:03 +0100 Subject: [PATCH] Deallocate output if needed in indxmap%clone. --- base/modules/desc/psb_desc_mod.F90 | 15 +++------------ base/modules/desc/psb_gen_block_map_mod.F90 | 10 +++++++--- base/modules/desc/psb_glist_map_mod.f90 | 9 +++++++-- base/modules/desc/psb_hash_map_mod.f90 | 9 +++++++-- base/modules/desc/psb_list_map_mod.f90 | 8 ++++++-- base/modules/desc/psb_repl_map_mod.f90 | 8 ++++++-- 6 files changed, 36 insertions(+), 23 deletions(-) diff --git a/base/modules/desc/psb_desc_mod.F90 b/base/modules/desc/psb_desc_mod.F90 index 4a2b7380..7170af96 100644 --- a/base/modules/desc/psb_desc_mod.F90 +++ b/base/modules/desc/psb_desc_mod.F90 @@ -1029,8 +1029,8 @@ contains call psb_erractionsave(err_act) name = 'psb_cdcpy' - if (desc%is_valid()) then - call desc_out%free(info) + call desc_out%free(info) + if ((info == psb_success_).and.desc%is_valid()) then ictxt = desc%get_context() ! check on blacs grid @@ -1061,14 +1061,8 @@ contains & call psb_safe_ab_cpy(desc%lprm,desc_out%lprm,info) if (info == psb_success_)& & call psb_safe_ab_cpy(desc%idx_space,desc_out%idx_space,info) -!!$ if ((info == psb_success_).and.(allocated(desc%indxmap))) & -!!$ & call desc%indxmap%clone(desc_out%indxmap,info) -!!$ associate(indxin => desc%indxmap) -!!$ if ((info == psb_success_).and.(allocated(desc%indxmap))) & -!!$ & call indxin%clone(desc_out%indxmap,info) -!!$ end associate if ((info == psb_success_).and.(allocated(desc%indxmap))) & - & allocate(desc_out%indxmap,source=desc%indxmap,stat=info) + & call desc%indxmap%clone(desc_out%indxmap,info) if (info == psb_success_) & & call desc%v_halo_index%clone(desc_out%v_halo_index,info) if (info == psb_success_) & @@ -1078,9 +1072,6 @@ contains if (info == psb_success_) & & call desc%v_ovr_mst_idx%clone(desc_out%v_ovr_mst_idx,info) - - else - call desc_out%free(info) end if if (info /= psb_success_) then info = psb_err_from_subroutine_ diff --git a/base/modules/desc/psb_gen_block_map_mod.F90 b/base/modules/desc/psb_gen_block_map_mod.F90 index 279ceadd..0032159b 100644 --- a/base/modules/desc/psb_gen_block_map_mod.F90 +++ b/base/modules/desc/psb_gen_block_map_mod.F90 @@ -2075,12 +2075,16 @@ contains info = psb_success_ call psb_get_erraction(err_act) - if (allocated(outmap)) then - write(0,*) 'Error: should not be allocated on input' + if (allocated(outmap)) then + call outmap%free() + deallocate(outmap,stat=info) + end if + if (info /= 0) then + write(0,*) 'Error: could not cleanup output' info = -87 goto 9999 end if - + allocate(psb_gen_block_map :: outmap, stat=info) if (info /= psb_success_) then info = psb_err_alloc_dealloc_ diff --git a/base/modules/desc/psb_glist_map_mod.f90 b/base/modules/desc/psb_glist_map_mod.f90 index 4dc60b51..22ded20d 100644 --- a/base/modules/desc/psb_glist_map_mod.f90 +++ b/base/modules/desc/psb_glist_map_mod.f90 @@ -203,12 +203,17 @@ contains info = psb_success_ call psb_get_erraction(err_act) - if (allocated(outmap)) then - write(0,*) 'Error: should not be allocated on input' + if (allocated(outmap)) then + call outmap%free() + deallocate(outmap,stat=info) + end if + if (info /= 0) then + write(0,*) 'Error: could not cleanup output' info = -87 goto 9999 end if + allocate(psb_glist_map :: outmap, stat=info) if (info /= psb_success_) then info = psb_err_alloc_dealloc_ diff --git a/base/modules/desc/psb_hash_map_mod.f90 b/base/modules/desc/psb_hash_map_mod.f90 index 0e14384e..4289ae50 100644 --- a/base/modules/desc/psb_hash_map_mod.f90 +++ b/base/modules/desc/psb_hash_map_mod.f90 @@ -1445,11 +1445,16 @@ contains info = psb_success_ call psb_get_erraction(err_act) - if (allocated(outmap)) then - write(0,*) 'Error: should not be allocated on input' + if (allocated(outmap)) then + call outmap%free() + deallocate(outmap,stat=info) + end if + if (info /= 0) then + write(0,*) 'Error: could not cleanup output' info = -87 goto 9999 end if + allocate(psb_hash_map :: outmap, stat=info ) if (info /= psb_success_) then diff --git a/base/modules/desc/psb_list_map_mod.f90 b/base/modules/desc/psb_list_map_mod.f90 index 1256d78e..d1e20b9d 100644 --- a/base/modules/desc/psb_list_map_mod.f90 +++ b/base/modules/desc/psb_list_map_mod.f90 @@ -1181,8 +1181,12 @@ contains info = psb_success_ call psb_get_erraction(err_act) - if (allocated(outmap)) then - write(0,*) 'Error: should not be allocated on input' + if (allocated(outmap)) then + call outmap%free() + deallocate(outmap,stat=info) + end if + if (info /= 0) then + write(0,*) 'Error: could not cleanup output' info = -87 goto 9999 end if diff --git a/base/modules/desc/psb_repl_map_mod.f90 b/base/modules/desc/psb_repl_map_mod.f90 index 80887823..37013255 100644 --- a/base/modules/desc/psb_repl_map_mod.f90 +++ b/base/modules/desc/psb_repl_map_mod.f90 @@ -799,8 +799,12 @@ contains info = psb_success_ call psb_get_erraction(err_act) - if (allocated(outmap)) then - write(0,*) 'Error: should not be allocated on input' + if (allocated(outmap)) then + call outmap%free() + deallocate(outmap,stat=info) + end if + if (info /= 0) then + write(0,*) 'Error: could not cleanup output' info = -87 goto 9999 end if