diff --git a/base/modules/psb_c_linmap_mod.f90 b/base/modules/psb_c_linmap_mod.f90 index 24801dac..501552ee 100644 --- a/base/modules/psb_c_linmap_mod.f90 +++ b/base/modules/psb_c_linmap_mod.f90 @@ -50,6 +50,7 @@ module psb_c_linmap_mod procedure, pass(map) :: is_asb => c_is_asb procedure, pass(map) :: free => c_free procedure, pass(map) :: clone => c_clone + procedure, pass(map) :: cnv => psb_c_map_cscnv end type psb_clinmap_type @@ -163,7 +164,7 @@ contains use psb_i_vect_mod use psb_c_mat_mod implicit none - type(psb_clinmap_type), intent(inout) :: map + class(psb_clinmap_type), intent(inout) :: map integer(psb_ipk_), intent(out) :: info character(len=*), intent(in), optional :: type class(psb_c_base_sparse_mat), intent(in), optional :: mold diff --git a/base/modules/psb_c_vect_mod.F90 b/base/modules/psb_c_vect_mod.F90 index 68da4bc2..00ef3b04 100644 --- a/base/modules/psb_c_vect_mod.F90 +++ b/base/modules/psb_c_vect_mod.F90 @@ -562,20 +562,23 @@ contains subroutine c_vect_cnv(x,mold) class(psb_c_vect_type), intent(inout) :: x - class(psb_c_base_vect_type), intent(in) :: mold + class(psb_c_base_vect_type), intent(in), optional :: mold class(psb_c_base_vect_type), allocatable :: tmp integer(psb_ipk_) :: info + if (present(mold)) then #ifdef HAVE_MOLD allocate(tmp,stat=info,mold=mold) #else call mold%mold(tmp,info) #endif - call x%v%sync() - if (info == psb_success_) call tmp%bld(x%v%v) - call x%v%free(info) - call move_alloc(tmp,x%v) - + if (allocated(x%v)) then + call x%v%sync() + if (info == psb_success_) call tmp%bld(x%v%v) + call x%v%free(info) + end if + call move_alloc(tmp,x%v) + end if end subroutine c_vect_cnv end module psb_c_vect_mod diff --git a/base/modules/psb_d_vect_mod.F90 b/base/modules/psb_d_vect_mod.F90 index 2472b815..3659b8d4 100644 --- a/base/modules/psb_d_vect_mod.F90 +++ b/base/modules/psb_d_vect_mod.F90 @@ -579,7 +579,6 @@ contains end if call move_alloc(tmp,x%v) end if - end subroutine d_vect_cnv end module psb_d_vect_mod diff --git a/base/modules/psb_s_linmap_mod.f90 b/base/modules/psb_s_linmap_mod.f90 index 2c8131c6..0730fc11 100644 --- a/base/modules/psb_s_linmap_mod.f90 +++ b/base/modules/psb_s_linmap_mod.f90 @@ -50,6 +50,7 @@ module psb_s_linmap_mod procedure, pass(map) :: is_asb => s_is_asb procedure, pass(map) :: free => s_free procedure, pass(map) :: clone => s_clone + procedure, pass(map) :: cnv => psb_s_map_cscnv end type psb_slinmap_type @@ -163,7 +164,7 @@ contains use psb_i_vect_mod use psb_s_mat_mod implicit none - type(psb_slinmap_type), intent(inout) :: map + class(psb_slinmap_type), intent(inout) :: map integer(psb_ipk_), intent(out) :: info character(len=*), intent(in), optional :: type class(psb_s_base_sparse_mat), intent(in), optional :: mold diff --git a/base/modules/psb_s_vect_mod.F90 b/base/modules/psb_s_vect_mod.F90 index 1f14558d..493b833b 100644 --- a/base/modules/psb_s_vect_mod.F90 +++ b/base/modules/psb_s_vect_mod.F90 @@ -562,20 +562,23 @@ contains subroutine s_vect_cnv(x,mold) class(psb_s_vect_type), intent(inout) :: x - class(psb_s_base_vect_type), intent(in) :: mold + class(psb_s_base_vect_type), intent(in), optional :: mold class(psb_s_base_vect_type), allocatable :: tmp integer(psb_ipk_) :: info + if (present(mold)) then #ifdef HAVE_MOLD allocate(tmp,stat=info,mold=mold) #else call mold%mold(tmp,info) #endif - call x%v%sync() - if (info == psb_success_) call tmp%bld(x%v%v) - call x%v%free(info) - call move_alloc(tmp,x%v) - + if (allocated(x%v)) then + call x%v%sync() + if (info == psb_success_) call tmp%bld(x%v%v) + call x%v%free(info) + end if + call move_alloc(tmp,x%v) + end if end subroutine s_vect_cnv end module psb_s_vect_mod diff --git a/base/modules/psb_z_linmap_mod.f90 b/base/modules/psb_z_linmap_mod.f90 index eab413fe..150bc99b 100644 --- a/base/modules/psb_z_linmap_mod.f90 +++ b/base/modules/psb_z_linmap_mod.f90 @@ -50,6 +50,7 @@ module psb_z_linmap_mod procedure, pass(map) :: is_asb => z_is_asb procedure, pass(map) :: free => z_free procedure, pass(map) :: clone => z_clone + procedure, pass(map) :: cnv => psb_z_map_cscnv end type psb_zlinmap_type @@ -163,7 +164,7 @@ contains use psb_i_vect_mod use psb_z_mat_mod implicit none - type(psb_zlinmap_type), intent(inout) :: map + class(psb_zlinmap_type), intent(inout) :: map integer(psb_ipk_), intent(out) :: info character(len=*), intent(in), optional :: type class(psb_z_base_sparse_mat), intent(in), optional :: mold diff --git a/base/modules/psb_z_vect_mod.F90 b/base/modules/psb_z_vect_mod.F90 index e448f9ed..dd703928 100644 --- a/base/modules/psb_z_vect_mod.F90 +++ b/base/modules/psb_z_vect_mod.F90 @@ -562,20 +562,23 @@ contains subroutine z_vect_cnv(x,mold) class(psb_z_vect_type), intent(inout) :: x - class(psb_z_base_vect_type), intent(in) :: mold + class(psb_z_base_vect_type), intent(in), optional :: mold class(psb_z_base_vect_type), allocatable :: tmp integer(psb_ipk_) :: info + if (present(mold)) then #ifdef HAVE_MOLD allocate(tmp,stat=info,mold=mold) #else call mold%mold(tmp,info) #endif - call x%v%sync() - if (info == psb_success_) call tmp%bld(x%v%v) - call x%v%free(info) - call move_alloc(tmp,x%v) - + if (allocated(x%v)) then + call x%v%sync() + if (info == psb_success_) call tmp%bld(x%v%v) + call x%v%free(info) + end if + call move_alloc(tmp,x%v) + end if end subroutine z_vect_cnv end module psb_z_vect_mod